ThirdPayServices.php 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141
  1. <?php
  2. /**
  3. * 支付宝支付
  4. */
  5. namespace app\api\services;
  6. use app\common\model\PaymentModel;
  7. use app\common\model\ServicesOrderModel;
  8. use app\common\model\ShopGoodsModel;
  9. use app\common\model\ShopOrderGoodsModel as OrderGoods;
  10. use app\common\model\ShopOrderModel;
  11. use app\common\model\ShopOrderModel as Order;
  12. use app\common\model\UserBankSignModel;
  13. use app\common\model\UserModel;
  14. use app\common\model\WithDrawLogModel;
  15. use app\common\service\PaymentService;
  16. use app\common\service\UserBankSignService;
  17. use app\common\service\UserService;
  18. use think\Exception;
  19. use think\facade\Db;
  20. use utils\RedisCache;
  21. class ThirdPayServices extends BasePayServices
  22. {
  23. /**
  24. * 多乐宝支付宝支付
  25. * @param $uid
  26. * @param $params
  27. * @return \think\Response
  28. * @throws Exception
  29. */
  30. public function getPayInfo($uid, $params)
  31. {
  32. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  33. $out_trade_no1 = rand(1000000000, 9999999999) . (string)date('ymdhis', time()) . (int)microtime(true); // 订单号
  34. $params = [
  35. 'appid' => '9d5e3cb9a4946cf28a42b99f4f8bf978',
  36. 'method' => 'payment.wxjsapp',
  37. 'merchant' => '220951176399985946',
  38. 'body' => '购买商品',
  39. 'external_order_no' => $out_trade_no1, // 我们自己的订单号
  40. 'total_amount' => $total_amount,
  41. // 'notify_url'=>'http://api.meikangjw.com/api/aliResult'
  42. 'notify_url' => 'http://zy.suncorex.com:2080/api/aliResultDLB'
  43. ];
  44. $sign = thirdPayGetSign($params, '897d9ea909093173b24dd89c772181e4');
  45. $params['sign'] = $sign;
  46. $res = _curlrequest('http://openpay.duolaibei.com/api/gateway', $params, 'post');
  47. $res = json_decode($res);
  48. if ($res && isset($res->code) && $res->code == 200) {
  49. $out_trade_no = $res->content->order_no;
  50. $this->setPaymentOrder(compact('body', 'out_trade_no', 'out_trade_no1', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 5);
  51. // return api_succ_return(['msg'=>'请求成功', 'data'=>['thirdpaydlbalipay'=>['url'=>$res->content->url]]]);
  52. return api_succ_return(['msg' => '请求成功', 'data' => ['thirdpaydlbwx' => ['url' => $res->content->url, 'jsappid' => $res->content->JSAPPID]]]);
  53. } else {
  54. return api_error_return('获取失败');
  55. }
  56. }
  57. /**
  58. * 多乐宝微信支付
  59. * @param $uid
  60. * @param $params
  61. * @return \think\Response
  62. * @throws Exception
  63. */
  64. public function getWxPayInfo($uid, $params)
  65. {
  66. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  67. $out_trade_no1 = rand(1000000000, 9999999999) . (string)date('ymdhis', time()) . (int)microtime(true); // 订单号
  68. $params = [
  69. 'appid' => '9d5e3cb9a4946cf28a42b99f4f8bf978',
  70. 'method' => 'payment.wxjsapp',
  71. 'merchant' => '220951176399985946',
  72. 'body' => '购买商品',
  73. 'external_order_no' => $out_trade_no1, // 我们自己的订单号
  74. 'total_amount' => $total_amount,
  75. // 'notify_url'=>'http://api.meikangjw.com/api/aliResult'
  76. 'notify_url' => 'http://zy.suncorex.com:2080/api/wechatResultDLB'
  77. ];
  78. $sign = thirdPayGetSign($params, '897d9ea909093173b24dd89c772181e4');
  79. $params['sign'] = $sign;
  80. // return $params;
  81. $res = _curlrequest('http://openpay.duolaibei.com/api/gateway', $params, 'post');
  82. // sr_log(sr_getcurtime(time()).$res);
  83. // {"code":200,"msg":"success","content":{"order_no":"DLB1649853909589099089998901OP","external_order_no":"12365847092204130845091649853909","total_amount":11970,"body":"\u8d2d\u4e70\u5546\u54c1","trans_type":"AL_JSAPP","JSAPPID":"2021002148663267","url":"alipays:\/\/platformapi\/startapp?appId=2021002148663267&page=pages\/open-pay\/open-pay&query=order_no%3DDLB1649853909589099089998901OP","sign":"FA06F884C143DA40E505950918D4AD45"}}
  84. $res = json_decode($res);
  85. if ($res && isset($res->code) && $res->code == 200) {
  86. $out_trade_no = $res->content->order_no;
  87. $this->setPaymentOrder(compact('body', 'out_trade_no', 'out_trade_no1', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 5);
  88. // return api_succ_return(['msg'=>'请求成功', 'data'=>['thirdpaydlbalipay'=>['url'=>$res->content->url]]]);
  89. return api_succ_return(['msg' => '请求成功', 'data' => ['thirdpaydlbwx' => ['url' => $res->content->url, 'jsappid' => $res->content->JSAPPID]]]);
  90. } else {
  91. return api_error_return('获取失败');
  92. }
  93. }
  94. /**
  95. * 畅联微信支付
  96. * @param $uid
  97. * @param $params
  98. * @return \think\Response
  99. * @throws Exception
  100. */
  101. public function getWxPayInfoCL($uid, $params)
  102. {
  103. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  104. $out_trade_no = 'CL' . rand(1000000000, 9999999999) . (string)date('ymdhis', time()) . (int)microtime(true); // 订单号
  105. $success_url = getWebUrl() . '/api/thirdPayClSuccess';
  106. $error_url = getWebUrl() . '/api/thirdPayClError';
  107. $params = [
  108. 'appid' => '1059174',
  109. 'pay_type' => 'partnerJs',
  110. 'amount' => sprintf("%.2f", $total_amount),
  111. 'callback_url' => getWebUrl() . '/api/wechatResultCL',
  112. 'success_url' => $success_url,
  113. 'error_url' => $error_url,
  114. 'extend' => '{"body":"购买商品"}',
  115. 'out_trade_no' => $out_trade_no
  116. ];
  117. // sr_log(json_encode($params));
  118. $sign = thirdPayGetSignCL('XMLfjHMPOGexsSaadIWSVCNG0XJBClZZ', $params);
  119. $params['sign'] = $sign;
  120. // sr_log(json_encode($params));
  121. // return $params;
  122. $res = _curlrequest('https://api.payunk.com/index/unifiedorder?format=json', $params, 'post');
  123. sr_log(sr_getcurtime(time()) . $res);
  124. $res = json_decode($res);
  125. if ($res && isset($res->code) && $res->code == 200) {
  126. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 7);
  127. return api_succ_return(['msg' => '请求成功', 'data' => ['thirdpayclwx' => ['url' => $res->url, 'success_url' => $success_url, 'error_url' => $error_url]]]);
  128. } else {
  129. return api_error_return('获取失败');
  130. }
  131. }
  132. /**
  133. * 畅联支付宝支付 type aban(A版本) h5ban(h5版本) dban(D版本)
  134. * @param $uid
  135. * @param $params
  136. * @param $type
  137. * @return \think\Response
  138. * @throws Exception
  139. */
  140. public function getAliPayInfoCL($uid, $params, $type)
  141. {
  142. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  143. // 这是测试 线要干掉
  144. // $total_amount = floatval('0.'.mt_rand(1, 3).mt_rand(1, 9));
  145. // $total_amount = 0.01;
  146. $out_trade_no = 'CL' . rand(1000000000, 9999999999) . (string)date('ymdhis', time()) . (int)microtime(true); // 订单号
  147. $success_url = getWebUrl() . '/api/thirdPayClSuccess';
  148. $error_url = getWebUrl() . '/api/thirdPayClError';
  149. $type_arr = [
  150. 'aban' => 'alipayApp',
  151. 'h5ban' => 'adapayH5',
  152. 'dban' => 'alipayPrecreate'
  153. ];
  154. $params = [
  155. 'appid' => '1059174',
  156. 'pay_type' => $type_arr[$type],
  157. 'amount' => sprintf("%.2f", $total_amount),
  158. 'callback_url' => getWebUrl() . '/api/AliResultCL',
  159. 'success_url' => $success_url,
  160. 'error_url' => $error_url,
  161. 'extend' => '{"body":"购买商品","subject":"购买商品"}',
  162. 'out_trade_no' => $out_trade_no
  163. ];
  164. // sr_log(json_encode($params));
  165. $sign = thirdPayGetSignCL('XMLfjHMPOGexsSaadIWSVCNG0XJBClZZ', $params);
  166. $params['sign'] = $sign;
  167. // sr_log(json_encode($params));
  168. // return $params;
  169. $res = _curlrequest('https://api2.payunk.com/index/unifiedorder?format=json', $params, 'post');
  170. // sr_log(sr_getcurtime(time()).$res);
  171. $res = json_decode($res);
  172. if ($res && isset($res->code) && $res->code == 200) {
  173. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), ($type == 'aban' ? 10 : 8));
  174. return api_succ_return(['msg' => '请求成功', 'data' => ['thirdpayclali' => ['url' => $res->url, 'success_url' => $success_url, 'error_url' => $error_url]]]);
  175. } else {
  176. return api_error_return('获取失败');
  177. }
  178. }
  179. /**
  180. * mo宝 富有 银联支付
  181. * @param $uid
  182. * @param $paramscon
  183. * @return \think\Response
  184. * @throws Exception
  185. */
  186. public function getBankPayInfoFY($uid, $paramscon)
  187. {
  188. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $paramscon);
  189. // 商户号
  190. $mchnt_cd = env('api.PAY_FUYOU_MCHNT_id');
  191. $time = time();
  192. $time_end = time() + 2 * 60 * 60;
  193. $order_date = sr_getcurtime($time, 'Ymd');
  194. $order_timestart = sr_getcurtime($time, 'YmdHis');
  195. $order_timeend = sr_getcurtime($time_end, 'YmdHis');
  196. $order_id = $paramscon['order_id'];
  197. $out_trade_no = 'FYYL' . $order_id;
  198. $mess_arr = ['mchnt_cd' => $mchnt_cd, 'order_date' => $order_date, 'order_id' => $paramscon['order_id'], 'ver' => '1.0.0'];
  199. // sr_log('message_json'.json_encode($mess_arr));
  200. $params = ['mchnt_cd' => $mchnt_cd, 'message' => RSA_openssl(json_encode($mess_arr))];
  201. // 测试
  202. // $url = 'https://aggapp-test.fuioupay.com/token.fuiou';
  203. // 正式
  204. $url = 'https://aggapp.fuioupay.com/token.fuiou';
  205. $ch = curl_init();
  206. curl_setopt($ch, CURLOPT_URL, $url);
  207. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  208. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  209. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  210. $headers = ['Content-type: application/json'];
  211. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  212. // POST数据
  213. curl_setopt($ch, CURLOPT_POST, 1);
  214. // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  215. // 把post的变量加上
  216. $data = json_encode($params);
  217. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  218. $output = curl_exec($ch);
  219. curl_close($ch);
  220. // sr_log('ccc'.$output);
  221. $rsares = json_decode($output);
  222. $res_decode = json_decode(RSA_openssl($rsares->message, 'decode'));
  223. sr_log('ccc' . json_encode($res_decode));
  224. if (isset($res_decode->order_date) && isset($res_decode->order_token) && isset($res_decode->mchnt_cd) && isset($res_decode->order_id)) {
  225. if ($res_decode->mchnt_cd == $mchnt_cd && $res_decode->order_id == $order_id) {
  226. $bank_params = [
  227. 'mchnt_cd' => $mchnt_cd,
  228. 'order_date' => $order_date,
  229. 'order_amt' => bcmul($total_amount, 100, 0),
  230. 'order_id' => $order_id,
  231. 'page_notifyurl' => ($paramscon['app_sources'] == 'ios' ? getWebUrl() . '/api/thirdPayClSuccess' : AESjiami(getWebUrl() . '/api/thirdPayClSuccess')),
  232. 'back_notifyurl' => ($paramscon['app_sources'] == 'ios' ? getWebUrl() . '/api/BankResultFY' : AESjiami(getWebUrl() . '/api/BankResultFY')),
  233. 'order_timestart' => $order_timestart,
  234. 'order_timeend' => $order_timeend,
  235. 'order_token' => $res_decode->order_token
  236. ];
  237. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 9);
  238. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayflyl' => $bank_params]]);
  239. } else {
  240. return api_error_return('获取失败,订单校验失败1');
  241. }
  242. } else {
  243. return api_error_return('获取失败,订单校验失败');
  244. }
  245. return api_error_return('获取失败');
  246. }
  247. /**
  248. * 易票联 支付宝支付
  249. * @param $uid
  250. * @param $params
  251. * @return \think\Response
  252. * @throws Exception
  253. */
  254. public function getZfbPayInfoYPL($uid, $params)
  255. {
  256. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  257. $order_id = $params['order_id'];
  258. $out_trade_no = 'YPL' . $order_id . mt_rand(1, 10000);
  259. $success_url = getWebUrl() . '/api/thirdPayClSuccess';
  260. $error_url = getWebUrl() . '/api/thirdPayClError';
  261. $notify_url = getWebUrl() . '/api/ZfbResultYPL';
  262. $orderInfo = array();
  263. $orderInfo['Id'] = 'id34535';
  264. $orderInfo['businessType'] = '130001';
  265. $orderInfo['goodsList'] = array(array('name' => 'pay', 'number' => 'one', 'amount' => 1));
  266. $params = [
  267. 'areaInfo' => '440106',
  268. 'attachData' => 'attachData',
  269. 'clientIp' => request()->ip(),
  270. 'customerCode' => '562012003860535',
  271. 'nonceStr' => nonce_str(32),
  272. 'notifyUrl' => $notify_url,
  273. 'orderInfo' => $orderInfo,
  274. 'outTradeNo' => $out_trade_no,
  275. 'payAmount' => bcmul($total_amount, 100, 0),
  276. 'payCurrency' => 'CNY',
  277. 'payMethod' => '7',
  278. 'redirectUrl' => $success_url,
  279. 'transactionStartTime' => date('YmdHis'),
  280. 'version' => '3.0'
  281. ];
  282. sr_log(json_encode($params));
  283. // 测试
  284. // $url = 'http://test-efps.epaylinks.cn';
  285. // 正式
  286. $url = 'https://efps.epaylinks.cn';
  287. $url = $url . '/api/txs/pay/NativePayment';
  288. $sign = $this->YPLsign(json_encode($params));
  289. $headers = [
  290. // 'Content-type: application/json',
  291. 'x-efps-sign-no' => '562012003860535001',
  292. 'x-efps-sign-type' => 'SHA256withRSA',
  293. 'x-efps-sign' => $sign,
  294. 'x-efps-timestamp' => date('YmdHis')
  295. ];
  296. sr_log(json_encode('header' . json_encode($headers)));
  297. // J+08ZMVCkZnMq0roi3JikP//ODGsy9UvYBM09b921RvU0/3Z+4opOwAFQGPBLrKRGhkZzVhHRJwVDZHA9Iu/wWX13SJyowRYkr8zVsYivNQhYKyt3uPScdN/BVfLM3d5OuA9o2ypIqVuoinorYDsrqXixyYg7LEA4pWTDZc9dtuSRWFF+DFvLTW4UODyiwhBCq7bFaa+MOVmWuiahZMM79MhKxiTqsfFQLptsnlc2crlYuok2Bp2TAbEDM7FZhlLIGiidux0kaLhC3dK31tRc6Y72NlukXJc3sN4HVLqj0GAiw+9jzmGf0NwhvxdHvBC6/7uOp2ShCMxSXUA/qPbLmA7Vh/Zv0njHbxJ0j3oylrhjCjUKGPTKf//GD/vgnVQz2m3KXW6+60PBfWRYwQYkSPFRHj2lRALBYe97q4w0kWa9xO/2yRrIW2lNBqt7ZKSmSstsA+NgiOU4u/LCBmIoxMqk9HzygfDPLhQ9oimOuM/7d//qjP0z6mPD4SbhdVKjfgsp9yqN7h9jR3BJJxDGRAtzJJpDA6/YIcTbkDnJIvHwIx4Fkcf22tBYW436W7f +0GeMLxBp5mAr8qlDJt0R3GoPD4hZ5Omh/FxYhOjN9RKG8QcqSykZSQgYgVAKsGeFWVeXes2XNo2AB1F7MlGuZSypOTv73BL5iE75xJVjRupk6qplmOo2YHLKs8USDSX3Y+QprbAC8irxQ5QtK4ayGbLZ8BDHuKnGLLA1/ID++2ccYJsnfA+9cqvSTm8lo19W1btBl9iZQC8Wfv94rfDsIAe2pc3Gd+LJv47i1mwzK03SQ5c6W8LBxgtStinz/f8Rm5oVn6hTgoRfV93F8ZGRVj5K+KYva5qIjBSyweYToPoXCirUO0UdA96PmU7+oVVOVu4pDcqBJjuSxPXIzRLXbSQUlFHecKjedx2DuOlHPdVMhn2XRjpdd+Ka70Grbw0dro76EvaBzHC2x/rN7g8nIe7ReG4LS2ya07bIXrbHyk6b45XfrneBGHnKDpIX6ymlDKZ2NAWyfXkBEPhiQrsT3AVGrokFjMTRVqubXqRW29Q8if2C5MYduen34s3QtmVHaVUZ24N6cX5FIvCwZYIyBvpFrTCfQZztRz3QngjhclbngGGyBv040WFfQ/sqzkWgdO8XP7cIUWlKmD0xANVq9dQqQiwwcvYpWFzMTpQcw9daGYWltwfzKfRveVnXHyfxaq6XVeHlZCboTDv4Fg5/nVW+s4JCmTXNPedU53ZYcDkrrZcHbygFXgPPOM8KMlowq8KnA9lXUYunHATpa2Q9vKnTED8Ro9gn6IGFpGRdZIeuYOJ+vKMA9sy55AIQiJVUMit7iw2M0ZehPwm4k5Dpi6RMzgC/5+OZc1u+Rt13Borvd3/7EuyqaNwhUkITp7Kl0dv75PQkK0Btcsg+PLVs+2h+GadNurWhl3Bvo6y++5HbkcEfymSFV/phDaAZBTYQFyzjAJhwJizMUBp1HFOetOiLEZSs4iMPj/gwps0BSwqCCRFZXJj3ifLo+fi/bE3rU+/nHcTBo9Dhzw/EVE2KLF1QbZw3fGLnhHqCK+PyOv4i7NwEQKqsA==
  298. $response = $this->http_post_json($url, json_encode($params), $sign);
  299. sr_log($response);
  300. if ($response && $response[0] == 200) {
  301. $re_data = json_decode($response[1], true);
  302. if ($re_data['returnCode'] == '0000') {
  303. $payurl = $re_data['codeUrl'];
  304. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 12);
  305. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayYPL' => ['pay_url' => $payurl]]]);
  306. // return api_succ_return(['msg'=>'成功', 'data'=>['thirdpay'=>['url'=>$payurl]]]);
  307. //
  308. }
  309. } else {
  310. return api_error_return('获取失败,请联系客服');
  311. }
  312. return api_error_return('获取失败,请联系客服');
  313. }
  314. /**
  315. * 易票联云闪付
  316. * @param $uid
  317. * @param $params
  318. * @return \think\Response
  319. * @throws Exception
  320. */
  321. public function getYsfPayInfoYPL($uid, $params)
  322. {
  323. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  324. // 商户号
  325. $mchnt_cd = env('api.PAY_FUYOU_MCHNT_id');
  326. $order_id = $params['order_id'];
  327. $out_trade_no = 'YPL' . $order_id . mt_rand(1, 10000);
  328. $success_url = getWebUrl() . '/api/thirdPayClSuccess';
  329. $error_url = getWebUrl() . '/api/thirdPayClError';
  330. $notify_url = getWebUrl() . '/api/ZfbResultYPL';
  331. $orderInfo = array();
  332. $orderInfo['Id'] = 'id34535';
  333. $orderInfo['businessType'] = '130001';
  334. $orderInfo['goodsList'] = array(array('name' => 'pay', 'number' => 'one', 'amount' => 1));
  335. // $order_timestart = sr_getcurtime($time, 'YmdHis');
  336. $params = [
  337. 'areaInfo' => '440106',
  338. 'attachData' => 'attachData',
  339. 'clientIp' => request()->ip(),
  340. 'customerCode' => '562012003860535',
  341. 'nonceStr' => nonce_str(32),
  342. 'notifyUrl' => $notify_url,
  343. 'orderInfo' => $orderInfo,
  344. 'outTradeNo' => $out_trade_no,
  345. 'payAmount' => bcmul($total_amount, 100, 0),
  346. 'payCurrency' => 'CNY',
  347. 'redirectUrl' => $success_url,
  348. 'transactionStartTime' => date('YmdHis'),
  349. 'version' => '3.0'
  350. ];
  351. sr_log('ypl' . json_encode($params));
  352. // 测试
  353. // $url = 'http://test-efps.epaylinks.cn';
  354. // 正式
  355. $url = 'https://efps.epaylinks.cn';
  356. $url = $url . '/api/txs/pay/UnionAppPayment';
  357. sr_log('yplurl:' . $url);
  358. $sign = $this->YPLsign(json_encode($params));
  359. $headers = [
  360. // 'Content-type: application/json',
  361. 'x-efps-sign-no' => '562012003860535001',
  362. 'x-efps-sign-type' => 'SHA256withRSA',
  363. 'x-efps-sign' => $sign,
  364. 'x-efps-timestamp' => date('YmdHis')
  365. ];
  366. sr_log('yplheader' . json_encode($headers));
  367. $response = $this->http_post_json($url, json_encode($params), $sign);
  368. sr_log('yplresponse' . json_encode($response));
  369. if ($response && $response[0] == 200) {
  370. $re_data = json_decode($response[1], true);
  371. if ($re_data['returnCode'] == '0000') {
  372. $tn = $re_data['tn'];
  373. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 13);
  374. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayYPLYsf' => ['tn' => $tn]]]);
  375. //
  376. }
  377. } else {
  378. return api_error_return('获取失败,请联系客服');
  379. }
  380. return api_error_return('获取失败,请联系客服');
  381. }
  382. /**
  383. * 汇付支付宝支付
  384. * @param $uid
  385. * @param $params
  386. * @return \think\Response
  387. * @throws Exception
  388. */
  389. public function getHfPayInfoHF($uid, $params)
  390. {
  391. // 加载基础 adapay 基础类
  392. // SDK 初始化文件加载
  393. include_once "../extend/thirdpay/AdapaySdk/init.php";
  394. // 在文件中设置 DEBUG 为 true 时, 则可以打印日志到指定的日志目录下 LOG_DIR
  395. include_once "../extend/thirdpay/config.php";
  396. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  397. // 这是测试 线要干掉
  398. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  399. // 这是测试 线要干掉
  400. $total_amount = floatval('1.' . mt_rand(1, 3) . mt_rand(1, 9));
  401. }
  402. $time_end = time() + 2 * 60 * 60;
  403. $order_timeend = sr_getcurtime($time_end, 'YmdHis');
  404. $order_id = $params['order_id'];
  405. $out_trade_no = 'HFPAY' . $order_id . mt_rand(1, 10000);
  406. # 初始化支付类
  407. $payment = new \AdaPaySdk\Payment();
  408. # 支付设置
  409. $payment_params = array(
  410. "app_id" => "app_3906a188-adf7-4776-a126-fd1996b178d3",
  411. "order_no" => $out_trade_no,
  412. "pay_channel" => "alipay",
  413. "time_expire" => $order_timeend,
  414. "pay_amt" => strval(intval($total_amount)) . '.00',
  415. "goods_title" => "日用生活用品",
  416. "goods_desc" => "多宝购买商品",
  417. "description" => "购买商品",
  418. "notify_url" => getWebUrl() . '/api/ZfbResultHF'
  419. );
  420. sr_log('汇付支付请求参数:' . json_encode($payment_params));
  421. # 发起支付
  422. $payment->create($payment_params);
  423. # 对支付结果进行处理
  424. if ($payment->isError()) {
  425. //失败处理
  426. $response = $payment->result;
  427. sr_log('hfresponseerror' . json_encode($response));
  428. return api_error_return('获取失败,请联系客服');
  429. } else {
  430. //成功处理
  431. $response = $payment->result;
  432. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 14);
  433. $bank_params = [
  434. 'url' => $response['expend']['pay_info']
  435. ];
  436. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayhf' => $bank_params]]);
  437. }
  438. return api_error_return('获取失败,请联系客服');
  439. }
  440. /**
  441. * 易票联统一支付
  442. * @param $uid
  443. * @param $params
  444. * @return \think\Response
  445. * @throws Exception
  446. */
  447. public function getYsfPayInfoTY($uid, $params)
  448. {
  449. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  450. // 商户号
  451. $order_id = $params['order_id'];
  452. $out_trade_no = 'YPL' . $order_id . mt_rand(1, 10000);
  453. $success_url = getWebUrl() . '/api/thirdPayClSuccess';
  454. $error_url = getWebUrl() . '/api/thirdPayClError';
  455. $notify_url = getWebUrl() . '/api/ZfbResultYPL';
  456. // 商品订单信息
  457. $orderInfo = array();
  458. $orderInfo['Id'] = 'id34535';
  459. $orderInfo['businessType'] = '130001';
  460. $orderInfo['goodsList'] = array(array('name' => 'pay', 'number' => 'one', 'amount' => 1));
  461. $params = [
  462. 'areaInfo' => '440106',
  463. 'attachData' => 'attachData',
  464. 'clientIp' => request()->ip(),
  465. 'customerCode' => '562012003860535',
  466. 'nonceStr' => nonce_str(32),
  467. 'notifyUrl' => $notify_url,
  468. 'orderInfo' => $orderInfo,
  469. 'outTradeNo' => $out_trade_no,
  470. 'payAmount' => bcmul($total_amount, 100, 0),
  471. 'payCurrency' => 'CNY',
  472. 'redirectUrl' => $success_url,
  473. 'transactionStartTime' => date('YmdHis'),
  474. 'version' => '3.0'
  475. ];
  476. sr_log('ypl' . json_encode($params));
  477. // 测试
  478. // $url = 'http://test-efps.epaylinks.cn';
  479. // 正式
  480. $url = 'https://efps.epaylinks.cn';
  481. $url = $url . '/api/txs/pay/UnifiedPayment';
  482. sr_log('yplurl:' . $url);
  483. $sign = '333';
  484. $headers = [
  485. 'x-efps-sign-no' => '562012003860535001',
  486. 'x-efps-sign-type' => 'SHA256withRSA',
  487. 'x-efps-sign' => $sign,
  488. 'x-efps-timestamp' => date('YmdHis')
  489. ];
  490. sr_log('yplheader' . json_encode($headers));
  491. $this->setPaymentOrder(compact('body', 'out_trade_no', 'total_amount', 'remarks', 'uid', 'trade_type', 'order_type', 'pay_way', 'voucher_img'), 13);
  492. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayYPLYsf' => ['tn' => $out_trade_no]]]);
  493. }
  494. /**
  495. * 易票联进件申请
  496. * @param $uid
  497. * @param $params
  498. * @return \think\Response
  499. */
  500. public function getYsfPayJJSubmit($uid, $params)
  501. {
  502. $time = time();
  503. $time_end = time() + 2 * 60 * 60;
  504. $order_date = sr_getcurtime($time, 'Ymd');
  505. $order_timestart = sr_getcurtime($time, 'YmdHis');
  506. $order_timeend = sr_getcurtime($time_end, 'YmdHis');
  507. $success_url = 'https://api.meikangjw.com/api/yplApplyResult';
  508. $error_url = getWebUrl() . '/api/thirdPayClError';
  509. $notify_url = getWebUrl() . '/api/ZfbResultYPL';
  510. $paper = array();
  511. //-------------------------------------------------------
  512. // 经营地址
  513. $paper['businessAddress'] = '重庆市渝北区回兴街道宝圣大道209号西政国际学术交流中心1幢';
  514. // 证件人姓名
  515. $paper['certificateName'] = '胡明冬';
  516. // 证件效期(截止) 无限期填写“长期”
  517. $paper['certificateTo'] = '20270104';
  518. // 省
  519. $paper['province'] = '500000';
  520. // 市
  521. $paper['city'] = '500100';
  522. // 区
  523. $paper['area'] = '500112';
  524. // MCC 码 参考附件商户类别 MCC 码
  525. $paper['mcc'] = '5399';
  526. // 联系人姓名
  527. $paper['contactPerson'] = '胡明冬';
  528. // 联系人手机号码
  529. $paper['contactPhone'] = '13330218461';
  530. // 邮箱地址
  531. $paper['email'] = '845313908@qq.com';
  532. // $paper['isCc']='1';
  533. // 证件号码
  534. $paper['lawyerCertNo'] = '513002199602181213';
  535. //// 证件背面
  536. $paper['lawyerCertPhotoBack'] = 'https://api.meikangjw.com/upload/20220707/42b46e4e6b82c81b9bb3c72d1c630c80.jpg';
  537. /// // 证件正面照
  538. $paper['lawyerCertPhotoFront'] = 'https://api.meikangjw.com/upload/20220707/5fa0ff6cc891e545c1aa423db7613f63.jpg';
  539. // 0:身份证;1:居住证;2:签证;3:护照;4:户口本;5:军人证;6:团员证;7:党员证;8:港澳通行证;9:台胞证;11:临时身份证;12:回乡证;13:营业执照:14:组织机构代码证;15:驾驶证;99:其他目前仅支持 0:身份证
  540. $paper['lawyerCertType'] = '0';
  541. // 开户银行 填写银行名称,参见附件银行
  542. $paper['openBank'] = '中国工商银行';
  543. // 开户行联行号 settleAccountType 为“1:对公账户”时必填,参见附件支行及联行号 查询不到 看链接查询 https://www.lianhanghao.com/
  544. $paper['openBankCode'] = '102290010045';
  545. // 开户支行 settleAccountType 为“1:对公账户”时必填
  546. $paper['openSubBank'] = '中国工商银行股份有限公司上海市闵行支行';
  547. // 客服电话
  548. $paper['serviceTel'] = '13330218461';
  549. // 结算账户名 ①merchantType=1、2 且 settleAccountType=1 时,需与merchantName 一致; ②merchantType=1、2 且 settleAccountType=2 时,需与lawyerName 一致; ③merchantType=3 时,需与 certificateName 一致。
  550. $paper['settleAccount'] = '胡明冬';
  551. // 1:个体工商户;2:企业;3:个人(小微);4:政府 事业单位;9:其他组织
  552. $paper['merchantType'] = '3';
  553. // 结算账户类型 1:对公账户 2:法人账户 3:授权对公 4:授权对私 merchantType=3 时必填 2。
  554. $paper['settleAccountType'] = '2';
  555. // 银行卡正面照
  556. $paper['bankCardPhotoFront'] = 'https://api.meikangjw.com/upload/20220707/1d80b9edb7773c0d1313270a9b39da6c.jpeg';
  557. // 银行卡背面照
  558. $paper['bankCardPhotoBack'] = 'https://api.meikangjw.com/upload/20220707/aff7377fff22225bff320a51cddaa75d.jpeg';
  559. // 结算账户号
  560. $paper['settleAccountNo'] = '6222031001022713072';
  561. // 提现方式 1:自动提现;2:手动提现
  562. $paper['settleTarget'] = '2';
  563. // 商户简称
  564. $paper['shortName'] = 'hmd_xiaowei';
  565. // 门店内景照
  566. $paper['storeHallPhoto'] = 'https://api.meikangjw.com/upload/20220711/a9ed2ef249e919c8432f756bd4b29a0a.jpg';
  567. // 门店门头照
  568. $paper['storeHeadPhoto'] = 'https://api.meikangjw.com/upload/20220711/e3491c28c5096fc20b6c84efff3b003e.jpg';
  569. // 门店外景照
  570. $paper['storeShopPhoto'] = 'https://api.meikangjw.com/upload/20220711/e3491c28c5096fc20b6c84efff3b003e.jpg';
  571. // $paper['unionShortName']='蜀盛锦蓉店铺';
  572. // refundFeeRate 退款手续费费率
  573. // settleCycle 结算周期
  574. // stage 手续费费率
  575. // stage.amountFrom 阶梯起始交易金额
  576. // stage.feePer 单笔收费
  577. // stage.feeRate 按比例收费
  578. // 代付带储蓄卡
  579. $b_withdraw = array('bankStage' => [], 'businessCode' => 'WITHDRAW', 'creditcardsEnabled' => 0, 'refundEnabled' => 1, 'refundFeePer' => 0, 'refundFeeRate' => 0, 'settleCycle' => 'D+0', 'stage' => array(array('amountFrom' => 0, 'feePer' => 200)));
  580. // 支付宝 主扫支付
  581. $b_alinav = array('bankStage' => [], 'businessCode' => 'ALI_NATIVE_PAY', 'creditcardsEnabled' => 0, 'refundEnabled' => 1, 'refundFeePer' => 0, 'refundFeeRate' => 0, 'settleCycle' => 'D+1', 'stage' => array(array('amountFrom' => 0, 'feeRate' => 60)));
  582. // 支付宝生活号支付
  583. $b_alinav1 = array('bankStage' => [], 'businessCode' => 'ALI_JSAPI_PAY', 'creditcardsEnabled' => 0, 'refundEnabled' => 1, 'refundFeePer' => 0, 'refundFeeRate' => 0, 'settleCycle' => 'D+1', 'stage' => array(array('amountFrom' => 0, 'feeRate' => 60)));
  584. $business = array($b_withdraw, $b_alinav, $b_alinav1);
  585. $params = [
  586. // 是否收单 1 是,0 否
  587. 'acceptOrder' => '1',
  588. // 平台商户编号
  589. 'acqSpId' => '562012003860535',
  590. // 审核回调地址
  591. 'backUrl' => $success_url,
  592. 'business' => $business,
  593. // 填写进件的小微名字
  594. 'merchantName' => '重庆闲食有趣',
  595. // 是否开户
  596. 'openAccount' => '1',
  597. 'paper' => json_encode($paper),
  598. // 更换子商户信息必传
  599. 'acqMerId' => 562227003867484
  600. ];
  601. sr_log('yplpaper' . json_encode($paper));
  602. sr_log('ypl' . json_encode($params));
  603. // 正式
  604. $url = 'https://efps.epaylinks.cn';
  605. // 商户进件或者补件
  606. $url = $url . '/api/cust/SP/Merchant/apply';
  607. sr_log('yplurl:' . $url);
  608. $sign = $this->YPLsign(json_encode($params));
  609. $headers = [
  610. 'x-efps-sign-no' => '562012003860535001',
  611. 'x-efps-sign-type' => 'SHA256withRSA',
  612. 'x-efps-sign' => $sign,
  613. 'x-efps-timestamp' => date('YmdHis')
  614. ];
  615. sr_log('yplheader' . json_encode($headers));
  616. $response = $this->http_post_json($url, json_encode($params), $sign);
  617. sr_log('yplresponse' . json_encode($response));
  618. if ($response && $response[0] == 200) {
  619. $re_data = json_decode($response[1], true);
  620. if ($re_data['respCode'] == '0000') {
  621. return api_succ_return('成功');
  622. } else {
  623. return api_error_return($re_data['respMsg']);
  624. }
  625. } else {
  626. return api_error_return('获取失败,请联系客服');
  627. }
  628. return api_error_return('获取失败,请联系客服');
  629. return api_error_return('获取失败');
  630. }
  631. /**
  632. * http请求
  633. * @param $url
  634. * @param $jsonStr
  635. * @param $sign
  636. * @return array
  637. */
  638. protected function http_post_json($url, $jsonStr, $sign)
  639. {
  640. $ch = curl_init();
  641. $headers = array(
  642. 'Content-Type: application/json; charset=utf-8',
  643. 'Content-Length: ' . strlen($jsonStr),
  644. 'x-efps-sign-no:' . '562012003860535001',
  645. 'x-efps-sign-type:SHA256withRSA',
  646. 'x-efps-sign:' . $sign,
  647. 'x-efps-timestamp:' . date('YmdHis'),
  648. );
  649. curl_setopt($ch, CURLOPT_POST, 1);
  650. curl_setopt($ch, CURLOPT_URL, $url);
  651. curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
  652. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  653. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过检查
  654. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 跳过检查
  655. //curl_setopt($ch, CURLOPT_HEADER, true);
  656. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  657. $response = curl_exec($ch);
  658. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  659. return array($httpCode, $response);
  660. }
  661. /**
  662. * 签名
  663. * @param $data
  664. * @return string
  665. */
  666. protected function YPLsign($data)
  667. {
  668. $certs = array();
  669. if (env("app.CUR_SYS_PARAMS") == 1) {
  670. //其中password为你的证书密码
  671. openssl_pkcs12_read(file_get_contents('/Users/sunriseos/Documents/www/wwwroot/cert/ypl/user-rsa.pfx'), $certs, 'zy2033.');
  672. } else {
  673. openssl_pkcs12_read(file_get_contents('/www/wwwroot/cert/ypl/user-rsa.pfx'), $certs, 'zy2033.'); //其中password为你的证书密码
  674. }
  675. ($certs) or die('您使用的私钥格式错误,请检查RSA私钥配置');
  676. openssl_sign($data, $sign, $certs['pkey'], OPENSSL_ALGO_SHA256);
  677. $sign = base64_encode($sign);
  678. return $sign;
  679. }
  680. /**
  681. * 费用配置
  682. * @param int $uid
  683. * @param array $data
  684. * @param int $type
  685. * @return array
  686. */
  687. public function _payConf(int $uid, array $data, int $type = 1)
  688. {
  689. $body = $total_amount = $remarks = '';
  690. switch ($data['order_type']) {
  691. case 1: // 充值
  692. $body = '充值';
  693. $total_amount = $data['money'];
  694. break;
  695. case 2: // 实名认证
  696. $total_amount = Db::name('user_data')->where('uid', $uid)->value('rz_money');
  697. $body = '实名认证费用';
  698. break;
  699. case 3: // 开通会员
  700. $vip_money = env('app.VIP_MONEY', 38);
  701. if (!$vip_money > 0) {
  702. throw new Exception('会员配置不存在');
  703. }
  704. $body = '开通会员';
  705. $total_amount = $vip_money;
  706. $remarks = $data['order_id'];
  707. break;
  708. case 4: //购买商品
  709. $order_sn = $data['order_id'];
  710. $checkingOrder = Order::checkingOrder($order_sn, 0, $uid);
  711. if (!$checkingOrder) {
  712. throw new Exception('校验订单失败');
  713. }
  714. if ($checkingOrder['flag'] !== 200) {
  715. throw new Exception($checkingOrder['msg']);
  716. }
  717. $body = '购买商品';
  718. $total_amount = $checkingOrder['orderPayment'];
  719. $remarks = $order_sn;
  720. //更改订单支付状态为线下支付待审核状态
  721. if ($data['channel'] == 4 && $data['order_type'] == 4) {
  722. Order::where('order_sn', 'in', $order_sn)->save(['pay_type' => 4, 'status' => 4]);
  723. }
  724. break;
  725. case 5: //余额充值
  726. {
  727. if (intval($data['money']) < 0) {
  728. sr_throw('金额填写错误,请填写整数');
  729. }
  730. if (!str_is_int($data['money'])) {
  731. sr_throw('充值金额有误,请输入正整数');
  732. }
  733. if ($data['money'] > 10000 || $data['money'] < 20) {
  734. sr_throw('请输入20到10000之间金额充值');
  735. }
  736. if ($data['channel'] == 19) {
  737. $usdt_price = Db::name('system_config')->where('name', 'usdt_price')->where('group', 'usdt_price')->value('value');
  738. }
  739. $charge_sn = createdRechargeOrderSn();
  740. Db::name('recharge_order')->insertGetId([
  741. 'recharge_sn' => $charge_sn,
  742. 'payment' => $data['money'],
  743. 'total_price' => $data['money'],
  744. 'usdt_money' => ($data['channel'] == 19 ? ceil($data['money'] / $usdt_price * 100) / 100 : 0),
  745. 'user_id' => $uid,
  746. 'pay_type' => $data['channel'],
  747. 'status' => 1,
  748. 'expires_time' => sr_getcurtime(time() + 0.5 * 3600),
  749. 'created_time' => sr_getcurtime(time())
  750. ]);
  751. $count = Db::name('recharge_order')->where('user_id', $uid)->where('pay_type', $data['channel'])->where('status', 1)->whereTime('created_time', '-2 hours')->count('order_id');
  752. if ($count > 20) {
  753. sr_throw('未支付订单过多请2小时后在试');
  754. }
  755. $body = '用户充值';
  756. $total_amount = $data['money'];
  757. $remarks = $charge_sn;
  758. }
  759. break;
  760. case 6:
  761. {
  762. $money = env('boxsetting.SERVICES_STORE_OPEN_PRICE');
  763. $charge_sn = createdRechargeOrderSn();
  764. Db::name('services_order')->insertGetId([
  765. 'recharge_sn' => $charge_sn,
  766. 'payment' => $money,
  767. 'total_price' => $money,
  768. 'usdt_money' => 0,
  769. 'user_id' => $uid,
  770. 'pay_type' => $data['channel'],
  771. 'status' => 1,
  772. 'expires_time' => sr_getcurtime(time() + 0.5 * 3600),
  773. 'created_time' => sr_getcurtime(time())
  774. ]);
  775. $count = Db::name('services_order')->where('user_id', $uid)->where('pay_type', $data['channel'])->where('status', 1)->whereTime('created_time', '-2 hours')->count('order_id');
  776. if ($count > 20) {
  777. sr_throw('未支付订单过多请稍后在试');
  778. }
  779. $body = '用户购买服务商服务';
  780. $total_amount = $money;
  781. $remarks = $charge_sn;
  782. }
  783. break;
  784. }
  785. if (!$body || !$total_amount || $total_amount <= 0){
  786. throw new Exception('配置错误');
  787. }
  788. return [$body, $type == 1 ? $total_amount : bcmul($total_amount, 100, 2), $data['order_type'], $remarks, $data['trade_type'], $data['channel'], isset($data['voucher_img']) ? $data['voucher_img'] : ''];
  789. }
  790. /**
  791. * @param $uid
  792. * @param $params
  793. * @return \think\Response
  794. * @throws Exception
  795. * @throws \think\db\exception\DataNotFoundException
  796. * @throws \think\db\exception\DbException
  797. * @throws \think\db\exception\ModelNotFoundException
  798. */
  799. public function getPayInfoSQZ($uid, $params)
  800. {
  801. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  802. $nowTime = date('Y-m-d H:i:s');
  803. $signId = isset($params['sign_id'])? $params['sign_id'] : 0;
  804. $payCode = PaymentService::make()->getPayCode($pay_way);
  805. $cacheKey = "caches:payment:{$payCode}:signid_{$signId}:";
  806. $signInfo = UserBankSignService::make()->getCacheInfo($signId,$uid);
  807. RedisCache::set($cacheKey.'catch',['params'=> $params, 'sign'=> $signInfo,'date'=> $nowTime], 7200);
  808. if (!$signInfo) {
  809. sr_throw('参数错误');
  810. }
  811. $order_id = '';
  812. if ($order_type == 4) {
  813. $order_id = $params['order_id'];
  814. }
  815. if ($order_type == 5) {
  816. $order_id = $remarks;
  817. }
  818. if ($order_type == 6) {
  819. // 如果是购买服务商订单 order_id 就是 services_order 里面的order_id
  820. $order_id = $remarks;
  821. }
  822. $out_trade_no = 'SY' . $order_id . mt_rand(1, 10000);
  823. // PAYBACK_URL
  824. $pay_success_backurl = env('PAYSQZ.PAYBACK_URL');
  825. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  826. // 这是测试 线要干掉
  827. $total_amount = floatval('0.' . mt_rand(1, 3) . mt_rand(1, 9));
  828. }
  829. $parterid = env('PAYSQZ.PARTER');
  830. $apiData = [
  831. 'parter' => $parterid,
  832. 'type' => 1000,
  833. 'value' => $total_amount,
  834. 'orderid' => $out_trade_no,
  835. // 'hy_auth_uid' => env('PAYSQZ.SXY_PARTER'),
  836. 'callbackurl' => $pay_success_backurl,
  837. 'payerIp' => get_client_ip(),
  838. 'userno' => $signInfo['userno']
  839. ];
  840. $apiUrl = 'http://pay.xindonglife.com/chargebank.aspx';
  841. $apiData['sign'] = md5('parter=' . $parterid . '&type=' . '1000' . '&value=' . $total_amount . '&orderid=' . $out_trade_no . '&callbackurl=' . $pay_success_backurl . env('PAYSQZ.SIGNKEY'));
  842. RedisCache::set($cacheKey.'request',['url'=>urldecode($apiUrl),'params'=> $params,'apiData'=>$apiData, 'sign'=> $signInfo,'date'=> $nowTime], 7200);
  843. $result = _curlrequest($apiUrl, $apiData, 'post');
  844. $res = $result? json_decode($result, true) : [];
  845. RedisCache::set($cacheKey.'request',['url'=>$apiUrl,'params'=> $params,'apiData'=>$apiData, 'result'=>$result, 'sign'=> $signInfo,'date'=> $nowTime], 7200);
  846. if (isset($res->code) && $res->code == 'SUCCESS') {
  847. $insert = [
  848. 'total_fee' => $total_amount,
  849. 'trade_type' => $trade_type,
  850. 'body' => $body,
  851. 'state' => 7,
  852. 'out_trade_no' => $out_trade_no,
  853. 'pay_way' => $pay_way,
  854. 'remarks' => $remarks,
  855. 'order_type' => $order_type,
  856. 'uid' => $uid,
  857. 'voucher_img' => $voucher_img,
  858. 'out_trade_no1' => $res->orderid,
  859. 'hy_token_id' => $res->hy_token_id
  860. ];
  861. if(!PaymentModel::insert($insert)){
  862. sr_throw('调用处理失败');
  863. }
  864. RedisCache::set($cacheKey.'request',['url'=>$apiUrl,'params'=> $params,'apiData'=>$apiData,'result'=>$res,'payment'=>$insert,'sign'=> $signInfo,'date'=> $nowTime], 7200);
  865. return api_succ_return(['msg' => '成功', 'data' => ['thirdpaySYL' => ['orderid' => $res->orderid, 'mobile' => $signInfo['phone']]]]);
  866. }
  867. return api_error_return('调用失败,请确定账号无误后联系客服');
  868. }
  869. /**
  870. * 石区长-支付宝
  871. * @param $uid
  872. * @param $params
  873. * @return \think\Response
  874. * @throws Exception
  875. */
  876. public function getPayInfoSQZAlipay($uid, $params)
  877. {
  878. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  879. $order_id = '';
  880. if ($order_type == 4) {
  881. $order_id = $params['order_id'];
  882. }
  883. if ($order_type == 5) {
  884. $order_id = $remarks;
  885. }
  886. $out_trade_no = 'SA' . $order_id . mt_rand(1, 10000);
  887. // PAYBACK_URL
  888. $pay_success_backurl = env('PAYSQZ.PAYAliBACK_URL');
  889. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  890. // 这是测试 线要干掉
  891. $total_amount = floatval('0.' . mt_rand(1, 3) . mt_rand(1, 9));
  892. }
  893. $parterid = env('PAYSQZ.PARTER');
  894. $params = [
  895. 'parter' => $parterid,
  896. 'type' => 1010,
  897. 'value' => $total_amount,
  898. 'orderid' => $out_trade_no,
  899. 'callbackurl' => $pay_success_backurl,
  900. 'payerIp' => request()->ip()
  901. ];
  902. // 提交确定支付
  903. sr_log('确认支付支付宝:' . json_encode($params));
  904. $params['sign'] = md5('parter=' . $parterid . '&type=' . '1010' . '&value=' . $total_amount . '&orderid=' . $out_trade_no . '&callbackurl=' . $pay_success_backurl . env('PAYSQZ.SIGNKEY'));
  905. $url = 'http://pay.xindonglife.com/chargebank.aspx';
  906. $insert = [
  907. 'total_fee' => $total_amount,
  908. 'trade_type' => $trade_type,
  909. 'body' => $body,
  910. 'state' => 7,
  911. 'out_trade_no' => $out_trade_no,
  912. 'pay_way' => $pay_way,
  913. 'remarks' => $remarks,
  914. 'order_type' => $order_type,
  915. 'uid' => $uid,
  916. 'voucher_img' => $voucher_img,
  917. 'out_trade_no1' => '',
  918. 'hy_token_id' => ''
  919. ];
  920. Db::name('payment')->insert($insert);
  921. $pay_url = $url . '?' . http_build_query($params);
  922. sr_log('支付宝支付链接:' . $pay_url);
  923. return api_succ_return(['msg' => '成功', 'data' => ['thirdpaySQZAlipay' => ['pay_url' => $pay_url]]]);
  924. }
  925. /**
  926. * 石区长-微信支付
  927. * @param $uid
  928. * @param $params
  929. * @return \think\Response
  930. * @throws Exception
  931. */
  932. public function getPayInfoSQZWechat($uid, $params)
  933. {
  934. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  935. $order_id = '';
  936. if ($order_type == 4) {
  937. $order_id = $params['order_id'];
  938. }
  939. if ($order_type == 5) {
  940. $order_id = $remarks;
  941. }
  942. $out_trade_no = 'Sw' . $order_id . mt_rand(1, 10000);
  943. $pay_success_backurl = env('PAYSQZ.PAYWeixinBACK_URL');
  944. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  945. // 这是测试 线要干掉
  946. $total_amount = floatval('0.' . mt_rand(1, 3) . mt_rand(1, 9));
  947. }
  948. $parterid = env('PAYSQZ.PARTER');
  949. $type = 1004;
  950. $params = [
  951. 'parter' => $parterid,
  952. 'type' => $type,
  953. 'value' => $total_amount,
  954. 'orderid' => $out_trade_no,
  955. 'callbackurl' => $pay_success_backurl,
  956. 'payerIp' => request()->ip()
  957. ];
  958. // 提交确定支付
  959. sr_log('确认支付:' . json_encode($params));
  960. $params['sign'] = md5('parter=' . $parterid . '&type=' . $type . '&value=' . $total_amount . '&orderid=' . $out_trade_no . '&callbackurl=' . $pay_success_backurl . env('PAYSQZ.SIGNKEY'));
  961. $url = 'http://pay.xindonglife.com/chargebank.aspx';
  962. $insert = [
  963. 'total_fee' => $total_amount,
  964. 'trade_type' => $trade_type,
  965. 'body' => $body,
  966. 'state' => 7,
  967. 'out_trade_no' => $out_trade_no,
  968. 'pay_way' => $pay_way,
  969. 'remarks' => $remarks,
  970. 'order_type' => $order_type,
  971. 'uid' => $uid,
  972. 'voucher_img' => $voucher_img,
  973. 'out_trade_no1' => '',
  974. 'hy_token_id' => ''
  975. ];
  976. Db::name('payment')->insert($insert);
  977. return api_succ_return(['msg' => '成功', 'data' => ['thirdpaySQZ' => ['pay_url' => $url . '?' . http_build_query($params)]]]);
  978. }
  979. /**
  980. * @param $uid
  981. * @param $params
  982. * @return \think\Response
  983. * @throws Exception
  984. */
  985. public function getPayInfoSQZBankkuai($uid, $params)
  986. {
  987. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  988. $order_id = '';
  989. if ($order_type == 4) {
  990. $order_id = $params['order_id'];
  991. }
  992. if ($order_type == 5) {
  993. $order_id = $remarks;
  994. }
  995. $out_trade_no = 'SK' . $order_id . mt_rand(1, 10000);
  996. $pay_success_backurl = env('PAYSQZ.PAYKUAIJIEBACK_URL');
  997. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  998. // 这是测试 线要干掉
  999. $total_amount = floatval('0.' . mt_rand(1, 3) . mt_rand(1, 9));
  1000. }
  1001. $parterid = env('PAYSQZ.SXY_PARTER');
  1002. $type = 967;
  1003. $params = [
  1004. 'parter' => $parterid,
  1005. 'type' => $type,
  1006. 'value' => $total_amount,
  1007. 'orderid' => $out_trade_no,
  1008. 'callbackurl' => $pay_success_backurl,
  1009. 'payerIp' => request()->ip()
  1010. ];
  1011. // 提交确定支付
  1012. sr_log('确认支付:' . json_encode($params));
  1013. $params['sign'] = md5('parter=' . $parterid . '&type=' . $type . '&value=' . $total_amount . '&orderid=' . $out_trade_no . '&callbackurl=' . $pay_success_backurl . env('PAYSQZ.SXY_SIGNKEY'));
  1014. $url = 'http://pay.xindonglife.com/chargebank.aspx';
  1015. $insert = [
  1016. 'total_fee' => $total_amount,
  1017. 'trade_type' => $trade_type,
  1018. 'body' => $body,
  1019. 'state' => 7,
  1020. 'out_trade_no' => $out_trade_no,
  1021. 'pay_way' => $pay_way,
  1022. 'remarks' => $remarks,
  1023. 'order_type' => $order_type,
  1024. 'uid' => $uid,
  1025. 'voucher_img' => $voucher_img,
  1026. 'out_trade_no1' => '',
  1027. 'hy_token_id' => ''
  1028. ];
  1029. Db::name('payment')->insert($insert);
  1030. return api_succ_return(['msg' => '成功', 'data' => ['thirdpaySQZ' => ['pay_url' => $url . '?' . http_build_query($params)]]]);
  1031. }
  1032. /**
  1033. * 银盛快捷无卡
  1034. * @param $uid
  1035. * @param $params
  1036. * @return \think\Response
  1037. * @throws Exception
  1038. * @throws \think\db\exception\DataNotFoundException
  1039. * @throws \think\db\exception\DbException
  1040. * @throws \think\db\exception\ModelNotFoundException
  1041. */
  1042. public function getPayInfoYSwk($uid, $params)
  1043. {
  1044. if (empty($params['cer_no']) || empty($params['cer_name'] || empty($params['bank_id']) || empty($params['bank_type']) || empty($params['bank_no']) || empty($params['mobile']))) {
  1045. return api_error_return("参数错误");
  1046. }
  1047. if ($params['bank_type'] == 2) {
  1048. if (empty($params['card_expr_time']) || empty($params['security_code'])) {
  1049. return api_error_return('信用卡类型必须填写信用卡上面的三位安全码跟过期时间');
  1050. }
  1051. }
  1052. $bank_info = Db::name('ys_banklist')->where('id', $params['bank_id'])->find();
  1053. if (!$bank_info) {
  1054. return api_error_return('参数错误');
  1055. }
  1056. $buy_mobilee = $params['mobile'];
  1057. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  1058. $interface_url = 'https://openapi.ysepay.com/gateway.do'; //正式
  1059. $order_id = '';
  1060. if ($order_type == 4) {
  1061. $order_id = $params['order_id'];
  1062. }
  1063. if ($order_type == 5) {
  1064. $order_id = $remarks;
  1065. }
  1066. $out_trade_no = $order_id . '_yswk' . mt_rand(1, 10000);
  1067. // PAYBACK_URL
  1068. $pay_success_backurl = env('PAYSQZ.PAYKUAIJIEBACK_URL');
  1069. // $total_amount = 1;
  1070. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  1071. // 这是测试 线要干掉
  1072. $total_amount = floatval('0' . '.' . mt_rand(1, 2) . mt_rand(1, 9));
  1073. }
  1074. $parterid = env('ZLYS.PARTER_ID');
  1075. $cur_time = sr_getcurtime(time());
  1076. $biz_content = array();
  1077. $biz_content['out_trade_no'] = $out_trade_no;
  1078. $biz_content['shopdate'] = sr_getcurtime(time(), 'Ymd');
  1079. $biz_content['subject'] = '购买商品';
  1080. // $biz_content['total_amount'] = $total_amount;
  1081. $biz_content['total_amount'] = $total_amount;
  1082. $biz_content['timeout_express'] = '1h';
  1083. $biz_content['currency'] = 'CNY';
  1084. $biz_content['business_code'] = '3010002';
  1085. $biz_content['seller_id'] = $parterid;
  1086. $biz_content['bank_type'] = $bank_info['bank_value'];
  1087. $biz_content['buyer_name'] = $params['cer_name'];
  1088. $biz_content['buyer_card_number'] = $params['bank_no'];
  1089. $biz_content['buyer_mobile'] = $params['mobile'];
  1090. $number = trim($this->ECBEncrypt($params['cer_no'], 'Scf10981'));
  1091. // 银行卡类型 debit 借记卡 credit信用卡
  1092. $biz_content['support_card_type'] = intval($params['bank_type']) == 1 ? 'debit' : 'credit';
  1093. if ($params['bank_type'] == 2) {
  1094. $biz_content['cardCvn2'] = $this->ECBEncrypt($params['security_code'], 'Scf10981');
  1095. $biz_content['cardExprDt'] = $this->ECBEncrypt($params['card_expr_time'], 'Scf10981');
  1096. }
  1097. $biz_content['bank_name'] = $bank_info['bank_name'];
  1098. $biz_content['pyerIDNo'] = $number;
  1099. $biz_content['pyerIDTp'] = $this->ECBEncrypt('01', 'Scf10981');;
  1100. $biz_content['bank_account_type'] = 'personal';
  1101. $params = [
  1102. 'method' => 'ysepay.online.fastpay',
  1103. 'partner_id' => $parterid,
  1104. 'timestamp' => $cur_time,
  1105. 'charset' => 'UTF-8',
  1106. 'sign_type' => 'RSA',
  1107. 'notify_url' => env('ZLYS.PAYBACK_URL'),
  1108. 'version' => '3.4',
  1109. 'biz_content' => json_encode($biz_content, JSON_UNESCAPED_UNICODE)
  1110. ];
  1111. ksort($params);
  1112. $params['sign'] = $this->sign($params);
  1113. // 提交确定支付
  1114. sr_log('确认支付:' . json_encode($params));
  1115. $result = curlPost($interface_url, $params);
  1116. sr_log('result:' . $result);
  1117. $res = json_decode($result);
  1118. if (isset($res->ysepay_online_fastpay_response->code) && intval($res->ysepay_online_fastpay_response->code) == 10000 && isset($res->ysepay_online_fastpay_response->msg) && intval($res->ysepay_online_fastpay_response->msg) == 'Success') {
  1119. $trade_no = $res->ysepay_online_fastpay_response->trade_no;
  1120. $insert = [
  1121. 'total_fee' => $total_amount,
  1122. 'trade_type' => $trade_type,
  1123. 'body' => $body,
  1124. 'state' => 7,
  1125. 'out_trade_no' => $out_trade_no,
  1126. 'pay_way' => $pay_way,
  1127. 'remarks' => $remarks,
  1128. 'order_type' => $order_type,
  1129. 'uid' => $uid,
  1130. 'voucher_img' => $voucher_img,
  1131. 'out_trade_no1' => '',
  1132. 'hy_token_id' => '',
  1133. 'buyer_mobile' => $buy_mobilee,
  1134. 'trade_no' => $trade_no
  1135. ];
  1136. Db::name('payment')->insert($insert);
  1137. return api_succ_return(['msg' => '成功', 'data' => ['thirdpayYS' => ['trade_no' => $trade_no]]]);
  1138. } else {
  1139. if (isset($res->ysepay_online_fastpay_response->sub_msg)) {
  1140. return api_error_return($res->ysepay_online_fastpay_response->sub_msg);
  1141. } else {
  1142. return api_error_return('支付错误,请联系客服');
  1143. }
  1144. }
  1145. return api_error_return('支付错误,请联系客服1');
  1146. }
  1147. /**
  1148. * 电科支付宝支付信息
  1149. * @param $uid
  1150. * @param $params
  1151. * @return \think\Response
  1152. * @throws Exception
  1153. */
  1154. public function getPayInfoDiankeZfb($uid, $payData)
  1155. {
  1156. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $payData);
  1157. // 接口地址
  1158. $apiUrl = env('PAYDK.DKPAY_API_URL','http://1.14.197.47/proxy/pay/unifiedorder');
  1159. $date = date('Y-m-d H:i:s');
  1160. $out_trade_no = createdOrderSn();
  1161. $cacheKey = "caches:payment:dkpay:otn_{$out_trade_no}:{$uid}_{$remarks}_";
  1162. RedisCache::set($cacheKey.'payData', ['payData'=> $payData, 'date'=>$date], 2*86400);
  1163. // 测试金额
  1164. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])) {
  1165. $total_amount = floatval('0' . '.' . mt_rand(1, 2) . mt_rand(1, 9));
  1166. }
  1167. if ($total_amount > 15000) {
  1168. $loData = ['payData'=> $payData,'error'=>'大额不能使用支付宝支付', 'date'=>$date];
  1169. RedisCache::set($cacheKey.'error', $loData, 2*86400);
  1170. sr_throw('大额不能使用支付宝支付');
  1171. }
  1172. $params = [
  1173. 'appId' => 'dianke',
  1174. 'version' => '1.0',
  1175. 'nonceStr' => nonce_str(15),
  1176. 'orderId' => $out_trade_no,
  1177. 'amount' => intval($total_amount * 100),
  1178. 'payChannel' => 'ALP',
  1179. 'goodsName' => $body? $body : '牛仔裤',
  1180. 'goodsDesc' => $body? $body : '牛仔裤',
  1181. 'clientIp' => get_client_ip(),
  1182. 'asyncNotifyUrl' => env('PAYSQZ.PAYBACK_ZFB_NEWURL'),
  1183. 'tradeType' => 'QRCODE'
  1184. ];
  1185. ksort($params);
  1186. $params['sign'] = $this->diankesign($params);
  1187. // 提交确定支付请求接口
  1188. $loData = ['url'=>$apiUrl,'payData'=> $payData,'params'=> $params, 'date'=>$date];
  1189. RedisCache::set($cacheKey.'request', $loData, 2*86400);
  1190. $result = curlPost($apiUrl, $params);
  1191. $result = $result? json_decode($result, true) : [];
  1192. $payUrl = isset($result['data'])? $result['data'] : '';
  1193. $loData['result'] = $result;
  1194. RedisCache::set($cacheKey.'result', $loData, 2*86400);
  1195. if ($payUrl) {
  1196. $payment = [
  1197. 'total_fee' => $total_amount,
  1198. 'trade_type' => $trade_type,
  1199. 'body' => $body,
  1200. 'state' => 7,
  1201. 'out_trade_no' => $out_trade_no,
  1202. 'pay_way' => $pay_way,
  1203. 'remarks' => $remarks,
  1204. 'order_type' => $order_type,
  1205. 'uid' => $uid,
  1206. 'voucher_img' => $voucher_img,
  1207. 'out_trade_no1' => '',
  1208. 'hy_token_id' => ''
  1209. ];
  1210. Db::name('payment')->insert($payment);
  1211. return api_succ_return(['msg' => '成功', 'data' => ['pay_url' => $payUrl]]);
  1212. } else {
  1213. return api_error_return('支付错误,请联系客服');
  1214. }
  1215. }
  1216. /**
  1217. * 银盛-第三方快捷支付
  1218. * @param $trade_no
  1219. * @param $sms_code
  1220. * @return \think\Response
  1221. * @throws Exception
  1222. * @throws \think\db\exception\DataNotFoundException
  1223. * @throws \think\db\exception\DbException
  1224. * @throws \think\db\exception\ModelNotFoundException
  1225. */
  1226. public function kjPayWithCode($trade_no, $sms_code)
  1227. {
  1228. $field = 'id,out_trade_no,total_fee,user_id,buyer_mobile';
  1229. $paymentInfo = PaymentService::make()->getCacheInfo($trade_no, 0, $field,false);
  1230. if (!$paymentInfo) {
  1231. sr_throw('支付订单错误');
  1232. }
  1233. $out_trade_no = isset($paymentInfo['out_trade_no'])? $paymentInfo['out_trade_no'] : '';
  1234. $interface_url = 'https://openapi.ysepay.com/gateway.do'; //正式
  1235. $parterid = env('ZLYS.PARTER_ID');
  1236. $cur_time = sr_getcurtime(time());
  1237. $biz_content = array();
  1238. $biz_content['out_trade_no'] = $out_trade_no;
  1239. $biz_content['buyer_mobile'] = isset($paymentInfo['buyer_mobile'])? $paymentInfo['buyer_mobile'] : '';
  1240. $biz_content['mobile_verify_code'] = $sms_code;
  1241. $params = [
  1242. 'method' => 'ysepay.online.fastpay.authorize',
  1243. 'partner_id' => $parterid,
  1244. 'timestamp' => $cur_time,
  1245. 'charset' => 'UTF-8',
  1246. 'sign_type' => 'RSA',
  1247. 'notify_url' => env('ZLYS.PAYBACK_URL'),
  1248. 'version' => '3.0',
  1249. 'biz_content' => json_encode($biz_content, JSON_UNESCAPED_UNICODE)
  1250. ];
  1251. ksort($params);
  1252. $params['sign'] = $this->sign($params);
  1253. // 提交确定支付
  1254. $cacheKey = "caches:payment:yskjPay:otn_{$out_trade_no}:";
  1255. RedisCache::set($cacheKey.'params', $params, 3600);
  1256. $result = curlPost($interface_url, $params);
  1257. RedisCache::set($cacheKey.'result', ['params'=> $params,'result'=> $result], 3600);
  1258. $res = json_decode($result);
  1259. $code = isset($res->ysepay_online_fastpay_authorize_response->code)? intval($res->ysepay_online_fastpay_authorize_response->code) : 0;
  1260. $msg = isset($res->ysepay_online_fastpay_authorize_response->msg)? trim($res->ysepay_online_fastpay_authorize_response->msg) : '';
  1261. $sub_msg = isset($res->ysepay_online_fastpay_authorize_response->sub_msg)? trim($res->ysepay_online_fastpay_authorize_response->sub_msg) : '';
  1262. if ($code == 10000 && $msg == 'Success') {
  1263. return api_succ_return('成功');
  1264. } else {
  1265. if ($sub_msg) {
  1266. return api_error_return($sub_msg);
  1267. } else {
  1268. return api_error_return('支付错误,请联系客服');
  1269. }
  1270. }
  1271. }
  1272. /**
  1273. * DES加密方法
  1274. * @param $data 传入需要加密的证件号码
  1275. * @param $key key为商户号前八位.不足八位的需在商户号前补空格
  1276. * @return string 返回加密后的字符串
  1277. */
  1278. function ECBEncrypt($data, $key)
  1279. {
  1280. $encrypted = openssl_encrypt($data, 'DES-ECB', $key, 1);
  1281. return base64_encode($encrypted);
  1282. }
  1283. /**
  1284. * DES解密方法
  1285. * @param $data 传入需要解密的字符串
  1286. * @param $key key为商户号前八位.不足八位的需在商户号前补空格
  1287. * @return string 返回解密后的证件号码
  1288. */
  1289. function doECBDecrypt($data, $key)
  1290. {
  1291. $encrypted = base64_decode($data);
  1292. $decrypted = openssl_decrypt($encrypted, 'DES-ECB', $key, 1);
  1293. return $decrypted;
  1294. }
  1295. /**
  1296. * 签名加密
  1297. * @param input data
  1298. * @return success
  1299. * @return check
  1300. * @return msg
  1301. */
  1302. public function sign_encrypt($input)
  1303. {
  1304. $return = [
  1305. 'success' => 0,
  1306. 'msg' => '',
  1307. 'check' => ''
  1308. ];
  1309. $pkcs12 = file_get_contents(env('ZLYS.PFX_PATH')); //私钥
  1310. if (openssl_pkcs12_read($pkcs12, $certs, env('ZLYS.PSSSWORD'))) {
  1311. $privateKey = $certs['pkey'];
  1312. $publicKey = $certs['cert'];
  1313. $signedMsg = "";
  1314. if (openssl_sign($input['data'], $signedMsg, $privateKey, OPENSSL_ALGO_SHA1)) {
  1315. $return['success'] = 1;
  1316. $return['check'] = base64_encode($signedMsg);
  1317. $return['msg'] = base64_encode($input['data']);
  1318. }
  1319. }
  1320. return $return;
  1321. }
  1322. /**
  1323. * 签名
  1324. * @param $data
  1325. * @return string
  1326. */
  1327. public function sign($data)
  1328. {
  1329. ksort($data);
  1330. $signStr = "";
  1331. foreach ($data as $key => $val) {
  1332. $signStr .= $key . '=' . $val . '&';
  1333. }
  1334. $signStr = trim($signStr, '&');
  1335. $sign = $this->sign_encrypt(array('data' => $signStr));
  1336. return trim($sign['check']);
  1337. }
  1338. /**
  1339. * 签名
  1340. * @param $data
  1341. * @return string
  1342. */
  1343. public function diankesign($data)
  1344. {
  1345. ksort($data);
  1346. $signStr = "";
  1347. foreach ($data as $key => $val) {
  1348. $signStr .= $key . '=' . $val . '&';
  1349. }
  1350. $stringSignTemp = $signStr . 'key=a05fd6fc1f924b74b83dfd519ce93c28';
  1351. $signtemp = \md5($stringSignTemp);
  1352. return strtoupper($signtemp);
  1353. }
  1354. /**
  1355. * thirdPaySqzBack支付三方sqz签名
  1356. * @param $params
  1357. * @return string
  1358. */
  1359. public function sqzSign($params){
  1360. $orderId = isset($params['orderid'])? $params['orderid'] : '';
  1361. return md5('orderid=' . $orderId . '&opstate=' . $params['opstate'] . '&ovalue=' . $params['ovalue'] . env('PAYSQZ.SIGNKEY'));
  1362. }
  1363. /**
  1364. * 签名
  1365. * @param $data
  1366. * @return string
  1367. */
  1368. public function diankesigndf($data)
  1369. {
  1370. ksort($data);
  1371. $signStr = "";
  1372. foreach ($data as $key => $val) {
  1373. $signStr .= $key . '=' . $val . '&';
  1374. }
  1375. $stringSignTemp = $signStr . 'key=b91f3a72fe074e39a6add7382de813bc';
  1376. $signtemp = \md5($stringSignTemp);
  1377. return strtoupper($signtemp);
  1378. }
  1379. /**
  1380. * USDT
  1381. * @param $uid
  1382. * @param $params
  1383. * @return \think\Response
  1384. * @throws Exception
  1385. */
  1386. public function getPayInfoUsdt($uid, $params)
  1387. {
  1388. list($body, $total_amount, $order_type, $remarks, $trade_type, $pay_way, $voucher_img) = $this->_payConf($uid, $params);
  1389. return api_succ_return('成功');
  1390. }
  1391. /**
  1392. * 签约银行卡
  1393. * @param $uid
  1394. * @param $post
  1395. * @return mixed
  1396. * @throws Exception
  1397. * @throws \think\db\exception\DataNotFoundException
  1398. * @throws \think\db\exception\DbException
  1399. * @throws \think\db\exception\ModelNotFoundException
  1400. */
  1401. public function userBankSign($uid, $post)
  1402. {
  1403. $pay_success_backurl = env('PAYSQZ.USER_SIGN_BANK');
  1404. $parterid = env('PAYSQZ.PARTER');
  1405. $phone = $post['phone'];
  1406. $bankCard = $post['bank_card'];
  1407. $name = $post['name'];
  1408. $idCard = $post['id_card'];
  1409. $orderId = creatBankSignOrderSn($uid);
  1410. if ($info = UserBankSignService::make()->checkHasSign($uid, $bankCard, 4)) {
  1411. UserBankSignModel::where('id', $info['id'])->save([
  1412. 'status' => 1,
  1413. 'signorder_id' => $orderId
  1414. ]);
  1415. } else {
  1416. UserBankSignModel::insert([
  1417. 'uid' => $uid,
  1418. 'phone' => $phone,
  1419. 'bank_card' => $bankCard,
  1420. 'name' => $name,
  1421. 'id_card' => $idCard,
  1422. 'create_time' => sr_getcurtime(time()),
  1423. 'signorder_id' => $orderId
  1424. ]);
  1425. }
  1426. // 签约参数
  1427. $param = [
  1428. 'parter' => $parterid,
  1429. 'userid' => $uid,
  1430. 'phone' => $phone,
  1431. 'bankCard' => $bankCard,
  1432. 'name' => $name,
  1433. 'idCard' => $idCard,
  1434. 'orderid' => $orderId,
  1435. 'callBack' => $pay_success_backurl
  1436. ];
  1437. $keystring = 'parter=' . $parterid . '&userid=' . $uid . '&phone=' . $phone . '&bankCard=' . $bankCard . '&name=' . $name . '&idCard=' . $idCard . '&orderid=' . $orderId . env('PAYSQZ.SIGNKEY');
  1438. $param['sign'] = md5($keystring);
  1439. $cacheKey = "caches:userBankSign:user_{$uid}:{$bankCard}_";
  1440. RedisCache::set($cacheKey.'param', $param, 7200);
  1441. $res = _curlrequest('http://pay.xindonglife.com/PageSign.aspx', $param, 'post');
  1442. RedisCache::set($cacheKey.'result', ['param'=> $param,'result'=>$res,'date'=>date('Y-m-d H:i:s')], 7200);
  1443. $result = json_decode($res);
  1444. if (isset($result->code) && $result->code == 'SUCCESS') {
  1445. return $result->sign_url;
  1446. } else {
  1447. if (is_string($res)) {
  1448. sr_throw($res);
  1449. } else {
  1450. sr_throw('请求失败,请稍后再试');
  1451. }
  1452. }
  1453. }
  1454. /**
  1455. * 解绑银行卡
  1456. * @param $uid
  1457. * @param $post
  1458. * @throws Exception
  1459. * @throws \think\db\exception\DataNotFoundException
  1460. * @throws \think\db\exception\DbException
  1461. * @throws \think\db\exception\ModelNotFoundException
  1462. */
  1463. public function userUnBankSign($uid, $post)
  1464. {
  1465. $parterid = env('PAYSQZ.PARTER');
  1466. $orderId = creatBankSignOrderSn($uid);
  1467. $recordId = isset($post['record_id'])? intval($post['record_id']) : 0;
  1468. if (!$recordId || !$bankInfo = UserBankSignService::make()->getCacheInfo($recordId, $uid)) {
  1469. sr_throw('参数错误');
  1470. }
  1471. $param = [
  1472. 'parter' => $parterid,
  1473. 'hy_auth_uid' => $bankInfo['userno'],
  1474. 'orderId' => $orderId
  1475. ];
  1476. $keystring = 'parter=' . $parterid . '&hy_auth_uid=' . $bankInfo['userno'] . env('PAYSQZ.SIGNKEY');
  1477. $param['sign'] = md5($keystring);
  1478. $cacheKey = "caches:userBankSign:{$uid}_{$recordId}_{$parterid}:";
  1479. RedisCache::set($cacheKey.'param', $param, 7200);
  1480. $res = _curlrequest('http://pay.xindonglife.com/CardUnbinding.aspx', $param, 'post');
  1481. RedisCache::set($cacheKey.'result', ['param'=> $param,'result'=> $res,'date'=>date('Y-m-d H:i:s')], 7200);
  1482. $res = json_decode($res);
  1483. if (isset($res->code) && $res->code == 'SUCCESS') {
  1484. RedisCache::keyDel("caches:userBankSign*");
  1485. UserBankSignModel::where('id', $post['record_id'])->save(['signorder_u_id' => $orderId, 'status' => 4]);
  1486. } else {
  1487. RedisCache::set($cacheKey.'back', ['error'=>'解绑失败','param'=> $param,'result'=> $res,'date'=>date('Y-m-d H:i:s')], 7200);
  1488. sr_throw('解绑失败');
  1489. }
  1490. }
  1491. /**
  1492. * 石学长 银联支付
  1493. * @param $uid
  1494. * @param $params
  1495. * @throws Exception
  1496. * @throws \think\db\exception\DataNotFoundException
  1497. * @throws \think\db\exception\DbException
  1498. * @throws \think\db\exception\ModelNotFoundException
  1499. */
  1500. public function sylSurePay($uid, $params)
  1501. {
  1502. if (empty($params['sms_code'])) {
  1503. sr_throw('参数错误');
  1504. }
  1505. $payment_info = Db::name('payment')->where('out_trade_no1', $params['order_id'])->where('state', 7)->where('uid', $uid)->find();
  1506. if (!$payment_info) {
  1507. sr_throw('参数错误或者订单错误');
  1508. }
  1509. $parterid = env('PAYSQZ.PARTER');
  1510. $order_id = creatBankSignOrderSn($uid);
  1511. $out_trade_no1 = rand(1000000000, 9999999999) . (string)date('ymdhis', time()) . (int)microtime(true); // 订单号
  1512. $param = [
  1513. 'parter' => $parterid,
  1514. 'hy_token_id' => $payment_info['hy_token_id'],
  1515. 'verify_code' => $params['sms_code'],
  1516. 'orderId' => $out_trade_no1
  1517. ];
  1518. $keystring = 'parter=' . $parterid . '&hy_token_id=' . $payment_info['hy_token_id'] . '&verify_code=' . $params['sms_code'] . env('PAYSQZ.SIGNKEY');
  1519. $param['sign'] = md5($keystring);
  1520. $res = _curlrequest('http://pay.xindonglife.com/payMentConfirm.aspx', $param, 'post');
  1521. $res = json_decode($res);
  1522. if (isset($res->code) && $res->code == 'SUCCESS') {
  1523. Db::name('payment')->where('id', $payment_info['id'])->save(['hy_bill_no' => $res->hy_bill_no, 'syl_sureorderid' => $out_trade_no1]);
  1524. } else {
  1525. if (isset($res->message)) {
  1526. sr_throw($res->message);
  1527. }
  1528. // {"id":1,"code":"Fail","message":"\u77ed\u4fe1\u9a8c\u8bc1\u7801\u5df2\u8fc7\u671f"}
  1529. // sr_log('确认失败:'.json_encode($res));
  1530. }
  1531. }
  1532. /**
  1533. * pay_money 支付订单的金额
  1534. * @param $out_trade_no
  1535. * @param $pay_money
  1536. * @param $pay_type
  1537. * @param $content
  1538. * @throws Exception
  1539. * @throws \think\db\exception\DataNotFoundException
  1540. * @throws \think\db\exception\DbException
  1541. * @throws \think\db\exception\ModelNotFoundException
  1542. */
  1543. public function payBack($out_trade_no, $pay_money, $pay_type, $content, $cacheKey='')
  1544. {
  1545. $date = date('Y-m-d H:i:s');
  1546. $shopordermodel = new ShopOrderModel();
  1547. $services_ordermodel = new ServicesOrderModel();
  1548. $params = $content? json_encode($content, true):[];
  1549. $cacheKey = $cacheKey? $cacheKey : "caches:payment:callBack:{$out_trade_no}";
  1550. RedisCache::set($cacheKey.'_catch', ['params'=>$params,'date'=> $date], 7200);
  1551. // 验证支付请求信息
  1552. $payInfo = PaymentModel::where('out_trade_no', $out_trade_no)->where('state', 7)->find();
  1553. $payUid = isset($payInfo['uid'])? $payInfo['uid']:0;
  1554. if (!$payInfo || $payUid<=0) {
  1555. $logData = ['params'=>$params,'msg'=>"单号{$out_trade_no}已经回调支付,或支付信息不存在",'date'=> $date];
  1556. RedisCache::set($cacheKey.'_error', $logData, 7200);
  1557. sr_throw('outtradeno已经回调支付:' . $out_trade_no);
  1558. }
  1559. $nowTime = date('Y-m-d H:i:s', time());
  1560. $userInfo = UserService::make()->getCacheInfo($payUid);
  1561. if ($payInfo['order_type'] == 6) {
  1562. $date = sr_getcurtime(time(), 'Y-m-d');
  1563. $expire_day = date('Y-m-d', strtotime("$date +1 month"));
  1564. $payInfo->save(['state' => 6, 'pay_at' => $nowTime]);
  1565. $services_orderinfo = $services_ordermodel->where('recharge_sn', $payInfo['remarks'])->find();
  1566. if ($services_orderinfo) {
  1567. $services_orderinfo->save(['status' => 2, 'pay_type' => $pay_type, 'updated_time' => $nowTime]);
  1568. }
  1569. Db::name('user')->where('id', $services_orderinfo['user_id'])->save([
  1570. 'store_type' => 1,
  1571. 'store_expire_time' => $expire_day
  1572. ]);
  1573. } elseif ($payInfo['order_type'] == 4) {
  1574. $nowTime = date('Y-m-d H:i:s', time());
  1575. $payInfo->save(['state' => 6, 'pay_at' => $nowTime]);
  1576. $order_info = $shopordermodel->where('order_sn', $payInfo['remarks'])->find();
  1577. Db::name('user')->whereIn('id', $userInfo['path'])->inc('total_team_income', $payInfo['total_fee'])->update();
  1578. Db::name('user')->whereIn('id', $userInfo['id'])->inc('total_team_income', $payInfo['total_fee'])->update();
  1579. Db::name('user')->where('id', $userInfo['id'])->inc('total_income', $payInfo['total_fee'])->update();
  1580. $order_info->save(['status' => 1, 'pay_type' => $pay_type, 'updated_time' => $nowTime]);
  1581. // 增加销量
  1582. $orderGoods = OrderGoods::where(['order_id' => $order_info['order_id']])->select()->toArray();
  1583. foreach ($orderGoods as $k => $v) {
  1584. ShopGoodsModel::where(['goods_id' => $v['goods_id']])->inc('sales_volume', $v['num'])->inc('real_sales_volume', $v['num'])->update();
  1585. }
  1586. $uid = $payInfo['uid'];
  1587. Db::name('thirdpay_back')->insert([
  1588. 'out_order_no' => $out_trade_no,
  1589. 'content' => $content,
  1590. 'create_time' => sr_getcurtime(time()),
  1591. 'type' => $pay_type,
  1592. 'uid' => $uid,
  1593. 'money' => $pay_money
  1594. ]);
  1595. // 赠送积分
  1596. edit_user_score(3, $uid, $order_info['rebate_score'], 0, $payInfo['id']);
  1597. }
  1598. }
  1599. /**
  1600. * ay_money 代付回调金额
  1601. * @param $out_trade_no
  1602. * @param $pay_money
  1603. * @param $params
  1604. * @param $content
  1605. * @throws \think\db\exception\DataNotFoundException
  1606. * @throws \think\db\exception\DbException
  1607. * @throws \think\db\exception\ModelNotFoundException
  1608. */
  1609. public function payDfBack($out_trade_no, $pay_money, $params, $content)
  1610. {
  1611. if (isset($params['status'])) {
  1612. $model = new WithDrawLogModel();
  1613. $info = $model->where('out_biz_no', $out_trade_no)->find();
  1614. if (!$info) {
  1615. return;
  1616. }
  1617. if ($info && $info['status'] == 4) {
  1618. if ($params['status'] == 1) {
  1619. // 代付成功
  1620. $info->save(['status' => 1]);
  1621. } else {
  1622. Db::startTrans();
  1623. try {
  1624. Db::startTrans();//开启事务
  1625. $info = $model->where('out_biz_no', $out_trade_no)->find();
  1626. $user_info = Db::name('user')->where('id', $info['uid'])->lock(true)->find();
  1627. $res = edit_user_money(10, $info['uid'], $info['apply_money']);
  1628. Db::name('action_liangb')->insert([
  1629. 'create_time' => sr_getcurtime(time()),
  1630. 'wd_id' => $out_trade_no
  1631. ]);
  1632. // 代付失败
  1633. $info->save(['zfb_error' => $content, 'status' => 3]);
  1634. Db::commit();
  1635. } catch (\Exception $e) {
  1636. Db::rollback();
  1637. sr_log('代付回调报错');
  1638. }
  1639. }
  1640. }
  1641. }
  1642. }
  1643. /**
  1644. * @param $uid
  1645. * @param $pay_info
  1646. * @param $yeji
  1647. * @throws \think\db\exception\DataNotFoundException
  1648. * @throws \think\db\exception\DbException
  1649. * @throws \think\db\exception\ModelNotFoundException
  1650. */
  1651. public function scaleAgentMoney($uid, $pay_info, $yeji)
  1652. {
  1653. $is_privince_get = false;
  1654. $is_city_get = false;
  1655. $money = intval($pay_info['total_fee'] / 100) * 100;
  1656. $user_info = Db::name('user')->where('id', $uid)->find();
  1657. $path = $user_info['path'];
  1658. // sr_log('path:'.$path);
  1659. $arr = explode(',', $path);
  1660. $arr = array_reverse($arr);
  1661. $ids = $arr;
  1662. $ids = implode(',', $ids);
  1663. $order = 'field(id,' . $ids . ')';
  1664. $users = Db::name('user')->where('id', 'in', $arr)->field('id,level,agent_type')->order(Db::raw($order))->select()->toArray();
  1665. foreach ($users as $key => $val) {
  1666. if ($val['agent_type'] == 1) {
  1667. if (!$is_privince_get) {
  1668. if ($is_city_get) {
  1669. edit_user_money(17, $val['id'], $money * 0.5 / 100, 0, $pay_info['remarks']);
  1670. } else {
  1671. edit_user_money(17, $val['id'], $money / 100, 0, $pay_info['remarks']);
  1672. }
  1673. $is_privince_get = true;
  1674. }
  1675. }
  1676. if ($val['agent_type'] == 2) {
  1677. if (!$is_privince_get) {
  1678. edit_user_money(18, $val['id'], $money * 0.5 / 100, 0, $pay_info['remarks']);
  1679. }
  1680. $is_city_get = true;
  1681. }
  1682. }
  1683. }
  1684. /**
  1685. * pay_money 余额支付订单的金额
  1686. * @param $order_sn
  1687. * @param $pay_type
  1688. * @param $content
  1689. * @throws \think\db\exception\DataNotFoundException
  1690. * @throws \think\db\exception\DbException
  1691. * @throws \think\db\exception\ModelNotFoundException
  1692. */
  1693. public function payBalanceDown($order_sn, $pay_type, $content)
  1694. {
  1695. $paymodel = new PaymentModel();
  1696. $shopordermodel = new ShopOrderModel();
  1697. $usermodel = new UserModel();
  1698. $order_info = $shopordermodel->where('order_sn', $order_sn)->find();
  1699. $nowTime = date('Y-m-d H:i:s', time());
  1700. $user_info = $usermodel->where('id', $order_info['user_id'])->find();
  1701. $order_info->save(['status' => 1, 'pay_type' => $pay_type, 'updated_time' => $nowTime]);
  1702. // 增加销量
  1703. $orderGoods = OrderGoods::where(['order_id' => $order_info['order_id']])->select()->toArray();
  1704. foreach ($orderGoods as $k => $v) {
  1705. ShopGoodsModel::where(['goods_id' => $v['goods_id']])->inc('sales_volume', $v['num'])->inc('real_sales_volume', $v['num'])->update();
  1706. }
  1707. $uid = $order_info['user_id'];
  1708. Db::name('thirdpay_back')->insert([
  1709. 'out_order_no' => '',
  1710. 'content' => $content,
  1711. 'create_time' => sr_getcurtime(time()),
  1712. 'type' => $pay_type,
  1713. 'uid' => $uid,
  1714. 'money' => $order_info['payment']
  1715. ]);
  1716. // 给用户添加业绩
  1717. $pay_info = $paymodel->where('remarks', $order_sn)->where('state', 6)->find();
  1718. // 赠送积分
  1719. edit_user_score(1, $uid, $order_info['rebate_score']);
  1720. $this->update_user_yeji($uid, $user_info, $order_info, $pay_info);
  1721. }
  1722. /**
  1723. * @param $uid
  1724. * @param $user_info
  1725. * @param $order_info
  1726. * @param $pay_info
  1727. * @throws \think\db\exception\DataNotFoundException
  1728. * @throws \think\db\exception\DbException
  1729. * @throws \think\db\exception\ModelNotFoundException
  1730. */
  1731. public function update_user_yeji($uid, $user_info, $order_info, $pay_info)
  1732. {
  1733. // 计算用户的yeji
  1734. $yeji = 0;
  1735. // 根据所送的积分算业绩
  1736. if ($user_info['performance_me'] < 10000) {
  1737. if (($user_info['performance_me'] + $order_info['rebate_score']) > 10000) {
  1738. $yeji = 10000 - $user_info['performance_me'];
  1739. incUserPerformance($uid, $yeji);
  1740. } else {
  1741. $yeji = $order_info['rebate_score'];
  1742. incUserPerformance($uid, $yeji);
  1743. }
  1744. }
  1745. if ($yeji > 0) {
  1746. // 如果增加的业绩大于0 计算省代跟市代
  1747. //
  1748. $this->scaleAgentMoney($order_info['user_id'], $pay_info, $yeji);
  1749. }
  1750. }
  1751. /**
  1752. * 手续费
  1753. * @param $uid
  1754. * @param $pay_info
  1755. * @param $nowTime
  1756. * @param int $type
  1757. * @return false
  1758. */
  1759. public function update_user_free($uid, $pay_info, $nowTime, $type = 1){
  1760. // return false;
  1761. }
  1762. }