TestController.php 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\shop\classes\ShopClass;
  5. use biz\sj\services\MerchantService;
  6. use biz\wx\classes\WxMessageClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\custom\classes\CustomDebtChangeClass;
  9. use bizGhs\express\services\DadaExpressServices;
  10. use bizGhs\order\classes\OrderClass;
  11. use bizGhs\order\classes\OrderItemClass;
  12. use bizGhs\order\classes\RefundOrderClass;
  13. use bizHd\message\classes\InformAdminClass;
  14. use bizHd\order\services\OrderService;
  15. use bizHd\purchase\classes\PurchaseClass;
  16. use bizHd\purchase\classes\PurchaseClearClass;
  17. use bizHd\wx\classes\WxOpenClass;
  18. use bizGhs\express\services\MiniExpressService;
  19. use common\components\arrayUtil;
  20. use common\components\dateUtil;
  21. use common\components\dict;
  22. use common\components\lakala\Lakala;
  23. use common\components\miniUtil;
  24. use common\components\noticeUtil;
  25. use common\components\orderSn;
  26. use common\components\wxUtil;
  27. use common\components\payUtil;
  28. use Yii;
  29. use common\components\util;
  30. use wkhtmltox\Image\Converter;
  31. class TestController extends BaseController
  32. {
  33. public $guestAccess = ['in', 'clear-query', 'ip', 'html', 'debt', 'apply', 'clear', 'ls-trade-query', 'refund-query', 'inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query', 'query', 'balance-query', 'refund'];
  34. public function actionIn()
  35. {
  36. $searchTime = 'custom';
  37. $startTime = '2024-05-04';
  38. $endTime = '2024-05-04';
  39. $mainId = 23390;
  40. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  41. $start = $period['startTime'];
  42. $end = $period['endTime'];
  43. $where['time'] = ['between', [$start, $end]];
  44. $currentStartDate = date('Y-m-d', strtotime($start));
  45. $currentEndDate = date('Y-m-d', strtotime($end));
  46. $currentStartTime = $currentStartDate . ' 00:00:00';
  47. $currentEndTime = $currentEndDate . ' 23:59:59';
  48. $totalAmount = 0;
  49. $itemTotalAmount = 0;
  50. $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
  51. $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  52. $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
  53. if (!empty($ghsOrderList)) {
  54. foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
  55. $book = $ghsOrder['book'] ?? 0;
  56. $status = $ghsOrder['status'] ?? 0;
  57. $orderSn = $ghsOrder['orderSn'] ?? '';
  58. $actPrice = $ghsOrder['actPrice'] ?? 0;
  59. $discountAmount = $ghsOrder['discountAmount'] ?? 0;
  60. $labourCost = $ghsOrder['labourCost'] ?? 0;
  61. $tkPrice = $ghsOrder['tkPrice'] ?? 0;
  62. if ($book == 1 && $status == 2) {
  63. //预订单待发货的不算收入
  64. continue;
  65. }
  66. if ($status == 0 || $status == 5) {
  67. continue;
  68. }
  69. $totalAmount = bcadd($totalAmount, $actPrice, 2);
  70. $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  71. $currentAmount = 0;
  72. if (!empty($orderItemList)) {
  73. foreach ($orderItemList as $orderItem) {
  74. $refundNum = $orderItem->refundNum ?? 0;
  75. $name = $orderItem->name ?? '';
  76. $productId = $orderItem->productId ?? 0;
  77. $num = $orderItem->xhNum ?? 0;
  78. $xhUnitPrice = $orderItem->xhUnitPrice ?? 0;
  79. $now = bcmul($num, $xhUnitPrice);
  80. $currentAmount = bcadd($currentAmount, $now, 2);
  81. $remainNum = bcsub($num, $refundNum);
  82. $classId = $orderItem->classId ?? 0;
  83. $className = $classList[$classId]['name'] ?? '已删除';
  84. $amount = bcmul($remainNum, $xhUnitPrice, 2);
  85. $arr[$classId]['className'] = $className;
  86. $arr[$classId]['classId'] = $classId;
  87. if (isset($arr[$classId]['income'])) {
  88. $arr[$classId]['income'] = bcadd($amount, $arr[$classId]['income'], 2);
  89. } else {
  90. $arr[$classId]['expend'] = 0;
  91. $arr[$classId]['income'] = $amount;
  92. }
  93. }
  94. if (floatval($currentAmount) != floatval($actPrice) && $discountAmount <= 0 && $labourCost <= 0 && $tkPrice <= 0) {
  95. echo $orderSn . ' ' . $currentAmount . ' ' . $actPrice . ' ' . $discountAmount . ' ' . $labourCost . ' ' . $tkPrice;
  96. die;
  97. }
  98. if ($tkPrice > 0) {
  99. $refundList = RefundOrderClass::getAllByCondition(['relateOrderSn' => $orderSn], null, '*', null, true);
  100. if (!empty($refundList)) {
  101. foreach ($refundList as $refund) {
  102. if ($refund->refundType == 1) {
  103. //退货退款前面已经考虑,这里不再处理 OK
  104. } else {
  105. //$refund->refundPrice
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. echo $totalAmount . ' ' . $itemTotalAmount;
  114. die;
  115. }
  116. public function actionIp()
  117. {
  118. $ip = $_SERVER['SERVER_ADDR'] ?? '';
  119. echo $ip;
  120. }
  121. public function actionHtml()
  122. {
  123. $c = new Converter(null, [
  124. "fmt" => "png",
  125. "in" => "/tmp/a.html",
  126. "out" => "/tmp/test.png"
  127. ]);
  128. $c->convert();
  129. }
  130. //欠款的查询与跟踪 ssh 20240103
  131. public function actionDebt()
  132. {
  133. $customId = 17081;
  134. $custom = CustomClass::getById($customId, true);
  135. if (empty($custom)) {
  136. echo '没有找到客户';
  137. die;
  138. }
  139. $flag = [];
  140. $changeList = CustomDebtChangeClass::getAllByCondition(['customId' => $customId], null, '*');
  141. if (!empty($changeList)) {
  142. foreach ($changeList as $change) {
  143. $event = $change['evnet'] ?? '';
  144. $relateId = $change['relateId'] ?? 0;
  145. $amount = $change['amount'] ?? 0;
  146. if (strpos($event, '购买花材') >= 0) {
  147. $flag['40-' . $relateId] = $amount;
  148. }
  149. if (strpos($event, '退款') >= 0) {
  150. $flag['33-' . $relateId] = $amount;
  151. }
  152. if (strpos($event, '结账') >= 0) {
  153. $flag['20-' . $relateId] = $amount;
  154. }
  155. }
  156. }
  157. print_r($flag);
  158. $orderList = OrderClass::getAllByCondition(['customId' => $customId, 'debtPrice>' => 0], null, 'id,actPrice,payTime', null);
  159. $arr = [];
  160. if (!empty($orderList)) {
  161. foreach ($orderList as $order) {
  162. $payTime = $order['payTime'] ?? '';
  163. $id = $order['id'] ?? 0;
  164. $arr[$payTime] = $order;
  165. if (isset($flag['40-' . $id]) == false) {
  166. echo '40-' . $id . "订单有问题\n";
  167. }
  168. }
  169. }
  170. //20
  171. $clearList = PurchaseClearClass::getAllByCondition(['customId' => $customId, 'status' => 2], null, 'id,actPrice,payTime', null);
  172. if (!empty($clearList)) {
  173. foreach ($clearList as $clear) {
  174. $payTime = $clear['payTime'] ?? '';
  175. $id = $clear['id'] ?? 0;
  176. $arr[$payTime] = $clear;
  177. if (isset($flag['20-' . $id]) == false) {
  178. echo '20-' . $id . "结账有问题\n";
  179. }
  180. }
  181. }
  182. //33
  183. $refundList = RefundOrderClass::getAllByCondition(['customId' => $customId], null, 'id,refundPrice,updateTime', null);
  184. if (!empty($refundList)) {
  185. foreach ($refundList as $refund) {
  186. $id = $refund['id'] ?? 0;
  187. $updateTime = $refund['updateTime'] ?? '';
  188. $arr[$updateTime] = $refund;
  189. if (isset($flag['33-' . $id]) == false) {
  190. echo '33-' . $id . "退款单有问题\n";
  191. }
  192. }
  193. }
  194. echo "<pre>";
  195. ksort($arr);
  196. print_r($arr);
  197. die;
  198. }
  199. //退款操作 ssh 20231029
  200. public function actionRefund()
  201. {
  202. $shopId = 36524;
  203. $shop = ShopClass::getById($shopId, true);
  204. if (empty($shop)) {
  205. util::fail('没有找到门店');
  206. }
  207. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  208. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  209. $params = [
  210. 'appid' => 'OP00002119',
  211. 'serial_no' => '018b08cfddbd',
  212. 'merchant_no' => $shop->lklSjNo,
  213. 'term_no' => $shop->lklB2BTermNo,
  214. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  215. 'lklCertificatePath' => $lklCertificatePath,
  216. ];
  217. $laResource = new Lakala($params);
  218. $refundReason = '暂无';
  219. $refundOrderSn = orderSn::getCgRefundSn();
  220. $refundPrice = 0.01;
  221. $refundFee = bcmul($refundPrice, 100);
  222. $orderSn = 'KD_CS61235203';
  223. $originTradeNo = '20231030110113230266215266468756';
  224. //$originLogNo = '66215266025626';
  225. $aliParams = [
  226. 'refundSn' => $refundOrderSn,
  227. 'orderSn' => $orderSn,
  228. 'refundAmount' => $refundFee,
  229. 'refundReason' => $refundReason,
  230. 'originTradeNo' => $originTradeNo,
  231. //'originLogNo' => $originLogNo,
  232. ];
  233. $response = $laResource->refund($aliParams);
  234. echo '<pre>';
  235. print_r($response);
  236. }
  237. public function actionApply()
  238. {
  239. $id = 2888;
  240. $shopId = 36524;
  241. $cg = PurchaseClass::getById($id, true);
  242. $shop = ShopClass::getById($shopId, true);
  243. WxMessageClass::hdNewCgOrderInform($shop, $cg);
  244. }
  245. public function actionGet()
  246. {
  247. ini_set('memory_limit', '2045M');
  248. set_time_limit(0);
  249. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  250. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  251. $arr = [
  252. //['name' => '国兰花尚OK', 'merchantNo' => '82239305992006L', 'wx' => [600913569, 600907053], 'zfb' => '2088820709029782'],
  253. //['name' => '花掌柜OK', 'merchantNo' => '82240505992000P', 'wx' => [600466131, 600465187], 'zfb' => '2088820656569304'],
  254. //['name' => '纯彩花艺OK', 'merchantNo' => '82239305992006M', 'wx' => [600922790, 600915407], 'zfb' => '2088820710146836'],
  255. //['name' => '集美天天鲜花OK', 'merchantNo' => '82239305992006P', 'wx' => [601036538, 601036322], 'zfb' => '2088820726763339'],
  256. //['name' => '丰行花行OK', 'merchantNo' => '82260205992007P', 'wx' => [601053759, 601052157], 'zfb' => '2088820725885465'],
  257. //['name' => '独家花行OK', 'merchantNo' => '82239305992006Q', 'wx' => [601049483, 601048223], 'zfb' => '2088820725546555'],
  258. //['name' => '好多花海沧OK', 'merchantNo' => '82239305992006R', 'wx' => [601052177, 601053735], 'zfb' => '2088820725549695'],
  259. //['name' => '美天鲜花OK', 'merchantNo' => '82259505992003F', 'wx' => [601062064, 601138175], 'zfb' => '2088820729400990'],
  260. //['name' => '天天陈江店OK', 'merchantNo' => '82259505992003E', 'wx' => [601060616, 601059382], 'zfb' => '2088820725555368'],
  261. //['name' => '叶上花OK', 'merchantNo' => '82231805992002G', 'wx' => [601062892, 601062589], 'zfb' => '2088820728763546'],
  262. //['name' => '好又多(小明)OK', 'merchantNo' => '82239305992006S', 'wx' => [601135715, 601067347], 'zfb' => '2088820729698012'],
  263. //['name' => '我卖花OK', 'merchantNo' => '82227505992000R', 'wx' => [601177139, 601148755], 'zfb' => '2088820746424032'],
  264. //['name' => '问境OK', 'merchantNo' => '8226900599200KX', 'wx' => [601299388, 601299453], 'zfb' => '2088820787661843'],
  265. //['name' => '昱成OK', 'merchantNo' => '8226900599200KY', 'wx' => [601312993, 601325844], 'zfb' => '2088820788900240'],
  266. //['name' => '杭州斗南', 'merchantNo' => '杭州斗南', 'wx' => [601405963, 601405929], 'zfb' => '2088820793601705'],
  267. //['name' => '杭州斗南(没用)', 'merchantNo' => '8223310599200AD', 'wx' => [601254682, 601250805], 'zfb' => '2088820782666872'],
  268. //['name' => '珑松花卉长安店', 'merchantNo' => '82260205992007U', 'wx' => [602499045, 602497558], 'zfb' => '2088820959620797'],
  269. //['name' => '福州花福(个人)', 'merchantNo' => '82239105992007P', 'wx' => [603301197, 603302321], 'zfb' => '2088920058098261'],
  270. //['name' => '福州花福', 'merchantNo' => '82239105992007N', 'wx' => [602796807, 602774796], 'zfb' => '2088820996010582'],
  271. //['name' => '昆明新宏源', 'merchantNo' => '82239305992007H', 'wx' => [606098318, 606100317], 'zfb' => '2088920878302843'],
  272. //['name' => '昆明纯彩', 'merchantNo' => '82239905992003L', 'wx' => [604923629, 604922175], 'zfb' => '2088920533160795'],
  273. //['name' => '花优田(军兴旺)', 'merchantNo' => '8227310599200GX', 'wx' => [605191281, 605190492], 'zfb' => '2088920588715249'],
  274. //['name' => '肇庆兄弟鲜花', 'merchantNo' => '82259305992001V', 'wx' => [628299301, 628297384], 'zfb' => '2088930936937722'],
  275. //['name' => '郑州唯一鲜花', 'merchantNo' => '8224910599200NB', 'wx' => [624877731, 624877902], 'zfb' => '2088830970964611'],
  276. //['name' => '昆明期待鲜花', 'merchantNo' => '8227310599200J6', 'wx' => [615582300, 615582180], 'zfb' => '2088530113958388'],
  277. //['name' => '厦门遇见你', 'merchantNo' => '82239305992008D', 'wx' => [614782373, 614783346], 'zfb' => '2088430828233036'],
  278. //['name' => '淄博花超鲜花批发', 'merchantNo' => '82245305992001R', 'wx' => [614685779, 614682986], 'zfb' => '2088430805221810'],
  279. //['name' => '广州国恋', 'merchantNo' => '8225810599200Q7', 'wx' => [612321716, 612320978], 'zfb' => '2088330479975012'],
  280. //['name' => '欣研鲜花', 'merchantNo' => '82260305992001Y', 'wx' => [612181234, 612181615], 'zfb' => '2088330365608286'],
  281. //['name' => '村长冷链', 'merchantNo' => '82260205992008G', 'wx' => [612168406, 612168000], 'zfb' => '2088330360870932'],
  282. //['name' => '惠州惠雅鲜花批发', 'merchantNo' => '82259505992003S', 'wx' => [611676975, 611677314], 'zfb' => '2088330136601427'],
  283. //['name' => '杭州斗南鲜花', 'merchantNo' => '8223310599200AR', 'wx' => [608955814, 608955082], 'zfb' => '2088130449323603'],
  284. //['name' => '营口简约花卉', 'merchantNo' => '8227310599200HJ', 'wx' => [608439898, 608440994], 'zfb' => '2088130112725929'],
  285. //['name' => '惠雅鲜花惠州店', 'merchantNo' => '82260205992007Z', 'wx' => [608406948, 608403207], 'zfb' => '2088130098167302'],
  286. //['name' => '云南珑松花卉珠海店', 'merchantNo' => '82258505992002U', 'wx' => [608062727, 608056474], 'zfb' => '2088030873238576'],
  287. //['name' => '昆明鹏诚花卉', 'merchantNo' => '8227310599200JK', 'wx' => [630710385, 630711403], 'zfb' => '2088040532857091'],
  288. //['name' => '云南昆明鲜花导航', 'merchantNo' => '8227310599200K7', 'wx' => [644628542, 644625621], 'zfb' => '2088440522565852'],
  289. //['name' => '兄弟花业', 'merchantNo' => '82260205992009C', 'wx' => [644547729, 644547591], 'zfb' => '2088440499878526'],
  290. //['name' => '花小苪', 'merchantNo' => '8227310599200K5', 'wx' => [644457809, 644457051], 'zfb' => '2088440462746403'],
  291. //['name' => '昆明君花阁', 'merchantNo' => '82239905992004Z', 'wx' => [644889761, 644889492], 'zfb' => '2088440579676361'],
  292. //['name' => '天雨花卉', 'merchantNo' => '82270705992000V', 'wx' => [644883152, 644883508], 'zfb' => '2088440575173671'],
  293. //['name' => '惠雅物流广州线', 'merchantNo' => '82259505992004N', 'wx' => [646083092, 646078226], 'zfb' => '2088440854131130'],
  294. //['name' => '小向花卉', 'merchantNo' => '8227310599200K8', 'wx' => [644771350, 644769766], 'zfb' => '2088440549798194'],
  295. //['name' => '小蔡鲜花批发', 'merchantNo' => '8223050599200BF', 'wx' => [644014296, 643948823], 'zfb' => '2088440255505707'],
  296. //['name' => '花千禧鲜花批发', 'merchantNo' => '8224510599200B2', 'wx' => [651543674, 651544159], 'zfb' => '2088640601421088'],
  297. //['name' => '九江云朵鲜花', 'merchantNo' => '82242405992001G', 'wx' => [653862657, 653862178], 'zfb' => '2088740712634499'],
  298. //['name' => '阿魏鲜花批发', 'merchantNo' => '82237405992001D', 'wx' => [655133268, 655133420], 'zfb' => '2088840200937795'],
  299. ['name' => '木合生花卉', 'merchantNo' => '8227310599200KP', 'wx' => [656152589, 656153824], 'zfb' => '2088840636484902'],
  300. ['name' => '珑松花卉广州店', 'merchantNo' => '8225810599200T4', 'wx' => [656366815, 656367359], 'zfb' => '2088840687638415'],
  301. //['name' => '扬州花儿很仙', 'merchantNo' => '82231205992001R', 'wx' => [641935836, 641934793], 'zfb' => '2088340698052621'],
  302. //['name' => '福清花好鲜', 'merchantNo' => '82239105992008S', 'wx' => [639783869, 639783652], 'zfb' => '2088340156624896'],
  303. //['name' => '北京花篮子', 'merchantNo' => '8221000599200QM', 'wx' => [639324663, 639322821], 'zfb' => '2088240926611870'],
  304. //['name' => '云南云漫梦金鹏', 'merchantNo' => '8227310599200K0', 'wx' => [638438213, 638437418], 'zfb' => '2088240671151089'],
  305. //['name' => '心悦花艺馆', 'merchantNo' => '82247305992002L', 'wx' => [632850138, 632849309], 'zfb' => '2088140048248384'],
  306. //['name' => '买手很忙', 'merchantNo' => '8227310599200GJ', 'wx' => [601597167, 601595526], 'zfb' => '2088820818930267'],
  307. //['name' => '七彩花都', 'merchantNo' => '8227310599200GF', 'wx' => [601176481, 601148503], 'zfb' => '2088820748594478'],
  308. //['name' => '十年', 'merchantNo' => '82252305992001U', 'wx' => [601285154, 601261795], 'zfb' => '2088820782171763'],
  309. //['name' => '都市花季OK', 'merchantNo' => '82239305992006U', 'wx' => [601174342, 601147649], 'zfb' => '2088820748507346'],
  310. //['name' => '花样年华OK', 'merchantNo' => '82260205992007Q', 'wx' => [601134352, 601091710], 'zfb' => '2088820735043444'],
  311. //['name' => '精茂城OK', 'merchantNo' => '8225840599200TF', 'wx' => [601173752, 601143352], 'zfb' => '2088820746800005'],
  312. //['name' => '莱漫OK', 'merchantNo' => '82239305992007A', 'wx' => [601288494, 601288166], 'zfb' => '2088820783686611'],
  313. //['name' => '莱漫(没用)', 'merchantNo' => '82239305992006T', 'wx' => [601134065, 601125595], 'zfb' => '2088820743859918'],
  314. //['name' => '福州我要花OK', 'merchantNo' => '82239105992007J', 'wx' => [601134030, 601128111], 'zfb' => '2088820745276973'],
  315. //['name' => '泉城OK', 'merchantNo' => '82239705992004F', 'wx' => [601273270, 601272854], 'zfb' => '2088820784658561'],
  316. //['name' => '泉城(没用)', 'merchantNo' => '82239705992004E', 'wx' => [601133056, 601133821], 'zfb' => '2088820746111323'],
  317. //['name' => '美丽花行OK', 'merchantNo' => '82239305992006V', 'wx' => [601155249, 601149712], 'zfb' => '2088820747673312'],
  318. //['name' => '三叶OK', 'merchantNo' => '82236805992001Y', 'wx' => [601152233, 601151024], 'zfb' => '2088820747556725'],
  319. //['name' => '花大苪OK', 'merchantNo' => '8227310599200GG', 'wx' => [601174221, 601165136], 'zfb' => '2088820751181377'],
  320. //['name' => '十堰天天鲜花OK', 'merchantNo' => '82252305992001S', 'wx' => [601171131, 601170642], 'zfb' => '2088820750844626'],
  321. //['name' => '珑松花卉OK', 'merchantNo' => '82260205992007S', 'wx' => [601176093, 601174262], 'zfb' => '2088820754742492'],
  322. //['name' => '惠雅鲜花OK', 'merchantNo' => '82260205992007R', 'wx' => [601173390, 601174002], 'zfb' => '2088820753174540'],
  323. //['name' => '锦绣花卉OK', 'merchantNo' => '82252305992001T', 'wx' => [601176719, 601176660], 'zfb' => '2088820754751663'],
  324. //['name' => '祥瑞鲜花同安店OK', 'merchantNo' => '82239305992006W', 'wx' => [601178350, 601177795], 'zfb' => '2088820755715024'],
  325. //['name' => '祥瑞鲜花翔安店OK', 'merchantNo' => '82239305992006X', 'wx' => [601178260, 601178199], 'zfb' => '2088820754481553'],
  326. //['name' => '初见花季OK', 'merchantNo' => '82239305992006Y', 'wx' => [601178998, 601179605], 'zfb' => '2088820757223312'],
  327. //['name' => '荣发鲜花OK', 'merchantNo' => '82242705992000D', 'wx' => [601179681, 601179180], 'zfb' => '2088820756926593'],
  328. //['name' => '花千朵(多多)OK', 'merchantNo' => '82239305992006Z', 'wx' => [601223474, 601208096], 'zfb' => '2088820766783276'],
  329. //['name' => '花悠星OK', 'merchantNo' => '8225810599200NH', 'wx' => [601228194, 601227691], 'zfb' => '2088820774587446'],
  330. //['name' => '花悠星(没用)', 'merchantNo' => '8225810599200NG', 'wx' => [601223630, 601210952], 'zfb' => '2088820767072874'],
  331. //['name' => '源花汇OK', 'merchantNo' => '82222105992004A', 'wx' => [601221944, 601214269], 'zfb' => '2088820770594246'],
  332. //['name' => '源花汇2(没用)', 'merchantNo' => '8227310599200GD', 'wx' => [601136305, 601067016], 'zfb' => '2088820729832744'],
  333. ];
  334. $new = [];
  335. foreach ($arr as $item) {
  336. $wx = $item['wx'];
  337. $zfb = $item['zfb'];
  338. $merchantNo = $item['merchantNo'];
  339. $name = $item['name'] . ' ' . $merchantNo;
  340. $group = [];
  341. foreach ($wx as $oneWx) {
  342. $params = [
  343. 'appid' => 'OP00002119',
  344. 'serial_no' => '018b08cfddbd',
  345. 'merchant_no' => $merchantNo,
  346. 'term_no' => 'C6337694',
  347. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  348. 'lklCertificatePath' => $lklCertificatePath,
  349. ];
  350. $data = [
  351. 'subMerchantId' => $oneWx,
  352. 'tradeMode' => 'WECHAT',
  353. ];
  354. $laResource = new Lakala($params);
  355. $response = $laResource->openStateQuery($data);
  356. $statusName = '出错了';
  357. if ($response['retCode'] == '000000') {
  358. $checkResult = $response['respData']['checkResult'] ?? '';
  359. $statusName = '未认证';
  360. if ($checkResult == 'AUTHORIZE_STATE_AUTHORIZED') {
  361. $statusName = '已认证';
  362. }
  363. }
  364. $group[] = '微信 ' . $oneWx . ' ' . $statusName;
  365. }
  366. $params = [
  367. 'appid' => 'OP00002119',
  368. 'serial_no' => '018b08cfddbd',
  369. 'merchant_no' => $merchantNo,
  370. 'term_no' => 'C6337694',
  371. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  372. 'lklCertificatePath' => $lklCertificatePath,
  373. ];
  374. $data = [
  375. 'subMerchantId' => $zfb,
  376. 'tradeMode' => 'ALIPAY',
  377. ];
  378. $laResource = new Lakala($params);
  379. $response = $laResource->openStateQuery($data);
  380. $statusName = '出错了';
  381. if ($response['retCode'] == '000000') {
  382. $checkResult = $response['respData']['checkResult'] ?? '';
  383. $statusName = '未认证';
  384. if ($checkResult == 'AUTHORIZED') {
  385. $statusName = '已认证';
  386. }
  387. }
  388. $group[] = '支付宝 ' . $zfb . ' ' . $statusName;
  389. $new[] = ['name' => $name, 'status' => $group];
  390. }
  391. echo '<pre>';
  392. print_r($new);
  393. die;
  394. }
  395. public function actionRefundQuery()
  396. {
  397. $shopId = 520;
  398. $shop = ShopClass::getById($shopId, true);
  399. if (empty($shop)) {
  400. util::stop('没有找到门店');
  401. }
  402. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  403. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  404. $params = [
  405. 'appid' => 'OP00002119',
  406. 'serial_no' => '018b08cfddbd',
  407. 'merchant_no' => $shop->lklSjNo,
  408. 'term_no' => $shop->lklScanTermNo,
  409. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  410. 'lklCertificatePath' => $lklCertificatePath,
  411. ];
  412. $laResource = new Lakala($params);
  413. $orderSn = '20231201110113131266165492618754';
  414. $data = [
  415. 'orderSn' => $orderSn,
  416. ];
  417. $response = $laResource->refundQuery($data);
  418. echo "<pre>";
  419. print_r($response);
  420. }
  421. public function actionBalanceQuery()
  422. {
  423. $shopId = 1212;
  424. $shop = ShopClass::getById($shopId, true);
  425. if (empty($shop)) {
  426. util::stop('没有找到门店');
  427. }
  428. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  429. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  430. $params = [
  431. 'appid' => 'OP00002119',
  432. 'serial_no' => '018b08cfddbd',
  433. 'merchant_no' => $shop->lklSjNo,
  434. 'term_no' => $shop->lklScanTermNo,
  435. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  436. 'lklCertificatePath' => $lklCertificatePath,
  437. ];
  438. $laResource = new Lakala($params);
  439. $response = $laResource->accountBalanceQuery();
  440. echo "<pre>";
  441. print_r($response);
  442. }
  443. //测试环境查线上数据 ssh 20231230
  444. public function actionCsQuery()
  445. {
  446. // $shopId = 1527;
  447. // $shop = ShopClass::getById($shopId, true);
  448. // if (empty($shop)) {
  449. // util::stop('没有找到门店');
  450. // }
  451. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  452. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  453. $params = [
  454. 'appid' => 'OP00002119',
  455. 'serial_no' => '018b08cfddbd',
  456. //'merchant_no' => $shop->lklSjNo,
  457. 'merchant_no' => '82222105992004A',
  458. //'term_no' => $shop->lklScanTermNo,
  459. 'term_no' => 'H3656802',
  460. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  461. 'lklCertificatePath' => $lklCertificatePath,
  462. ];
  463. $laResource = new Lakala($params);
  464. $queryParams = [
  465. //'orderSn' => 'KD26452235',
  466. 'tradeNo' => '20231230110113130266215700775011',
  467. ];
  468. $response = $laResource->query($queryParams, 1);
  469. echo "<pre>";
  470. print_r($response);
  471. }
  472. public function actionQuery()
  473. {
  474. $shopId = 726;
  475. $shop = ShopClass::getById($shopId, true);
  476. if (empty($shop)) {
  477. util::stop('没有找到门店');
  478. }
  479. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  480. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  481. $params = [
  482. 'appid' => 'OP00002119',
  483. 'serial_no' => '018b08cfddbd',
  484. 'merchant_no' => $shop->lklSjNo,
  485. 'term_no' => $shop->lklScanTermNo,
  486. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  487. 'lklCertificatePath' => $lklCertificatePath,
  488. ];
  489. $laResource = new Lakala($params);
  490. $queryParams = [
  491. 'orderSn' => 'KD26481486',
  492. //'tradeNo' => '20231230110113130266215700775011',
  493. ];
  494. $response = $laResource->query($queryParams, 0);
  495. echo "<pre>";
  496. print_r($response);
  497. }
  498. public function actionClearQuery()
  499. {
  500. $shopId = 8249;
  501. $shop = ShopClass::getById($shopId, true);
  502. if (empty($shop)) {
  503. util::stop('没有找到门店');
  504. }
  505. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  506. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  507. $params = [
  508. 'appid' => 'OP00002119',
  509. 'serial_no' => '018b08cfddbd',
  510. 'merchant_no' => $shop->lklSjNo,
  511. 'term_no' => $shop->lklScanTermNo,
  512. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  513. 'lklCertificatePath' => $lklCertificatePath,
  514. ];
  515. $laResource = new Lakala($params);
  516. $queryParams = [
  517. //'orderSn' => 'CL28693295',
  518. 'tradeNo' => '66215417437878',
  519. ];
  520. $response = $laResource->query($queryParams, 1);
  521. echo "<pre>";
  522. print_r($response);
  523. }
  524. //零售订单查询 ssh 20231031
  525. public function actionLsTradeQuery()
  526. {
  527. $shopId = 3969;
  528. $shop = ShopClass::getById($shopId, true);
  529. if (empty($shop)) {
  530. util::stop('没有找到门店');
  531. }
  532. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  533. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  534. $params = [
  535. 'appid' => 'OP00002119',
  536. 'serial_no' => '018b08cfddbd',
  537. 'merchant_no' => $shop->lklSjNo,
  538. 'term_no' => $shop->lklScanTermNo,
  539. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  540. 'lklCertificatePath' => $lklCertificatePath,
  541. ];
  542. $laResource = new Lakala($params);
  543. $queryParams = [
  544. 'orderSn' => 'KD26499746',
  545. //'tradeNo' => '20231029110113130266215259252887',
  546. ];
  547. $response = $laResource->query($queryParams, 0);
  548. print_r($response);
  549. util::stop();
  550. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  551. $connection = Yii::$app->db;
  552. $transaction = $connection->beginTransaction();
  553. try {
  554. $postData = $response['resp_data'] ?? [];
  555. $orderSn = $postData['out_trade_no'] ?? '';
  556. $total_amount = $postData['total_amount'] ?? 0;
  557. $account_type = $postData['account_type'] ?? '';
  558. if (empty($account_type)) {
  559. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  560. util::end();
  561. }
  562. $totalFee = $total_amount / 100;
  563. $transactionId = $postData['trade_no'] ?? 0;
  564. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  565. $currentPayWay = null;
  566. if ($account_type == 'WECHAT') {
  567. $currentPayWay = dict::getDict('payWay', 'wxPay');
  568. } elseif ($account_type == 'ALIPAY') {
  569. $currentPayWay = dict::getDict('payWay', 'alipay');
  570. } else {
  571. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  572. util::end();
  573. }
  574. $attach = '';
  575. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  576. $transaction->commit();
  577. echo 'OK';
  578. } catch (\Exception $e) {
  579. $transaction->rollBack();
  580. Yii::error("失败原因:" . $e->getMessage());
  581. }
  582. }
  583. }
  584. //零售订单查询 ssh 20231031
  585. public function actionClear()
  586. {
  587. $shopId = 10649;
  588. $shop = ShopClass::getById($shopId, true);
  589. if (empty($shop)) {
  590. util::stop('没有找到门店');
  591. }
  592. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  593. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  594. $params = [
  595. 'appid' => 'OP00002119',
  596. 'serial_no' => '018b08cfddbd',
  597. 'merchant_no' => $shop->lklSjNo,
  598. 'term_no' => $shop->lklScanTermNo,
  599. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  600. 'lklCertificatePath' => $lklCertificatePath,
  601. ];
  602. $laResource = new Lakala($params);
  603. $queryParams = [
  604. //'orderSn' => 'KD26461864',
  605. 'tradeNo' => '20231230110113130266215700775011',
  606. ];
  607. $response = $laResource->query($queryParams, 1);
  608. print_r($response);
  609. util::stop();
  610. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  611. $connection = Yii::$app->db;
  612. $transaction = $connection->beginTransaction();
  613. try {
  614. $postData = $response['resp_data'] ?? [];
  615. $orderSn = $postData['out_trade_no'] ?? '';
  616. $total_amount = $postData['total_amount'] ?? 0;
  617. $account_type = $postData['account_type'] ?? '';
  618. if (empty($account_type)) {
  619. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  620. util::end();
  621. }
  622. $totalFee = $total_amount / 100;
  623. $transactionId = $postData['trade_no'] ?? 0;
  624. $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
  625. $currentPayWay = null;
  626. if ($account_type == 'WECHAT') {
  627. $currentPayWay = dict::getDict('payWay', 'wxPay');
  628. } elseif ($account_type == 'ALIPAY') {
  629. $currentPayWay = dict::getDict('payWay', 'alipay');
  630. } else {
  631. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  632. util::end();
  633. }
  634. $attach = '';
  635. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  636. $transaction->commit();
  637. echo 'OK';
  638. } catch (\Exception $e) {
  639. $transaction->rollBack();
  640. Yii::error("失败原因:" . $e->getMessage());
  641. }
  642. }
  643. }
  644. //交易查询 ssh 20231021
  645. public function actionTradeQuery()
  646. {
  647. $shopId = 21486;
  648. $shop = ShopClass::getById($shopId, true);
  649. if (empty($shop)) {
  650. util::stop('没有找到门店');
  651. }
  652. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  653. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  654. $params = [
  655. 'appid' => 'OP00002119',
  656. 'serial_no' => '018b08cfddbd',
  657. 'merchant_no' => $shop->lklSjNo,
  658. 'term_no' => $shop->lklScanTermNo,
  659. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  660. 'lklCertificatePath' => $lklCertificatePath,
  661. ];
  662. $laResource = new Lakala($params);
  663. $queryParams = [
  664. 'orderSn' => 'CG27052211',
  665. //'tradeNo' => '66215960152739',
  666. ];
  667. $response = $laResource->query($queryParams, 0);
  668. print_r($response);
  669. util::stop();
  670. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  671. $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  672. $connection = Yii::$app->db;
  673. $transaction = $connection->beginTransaction();
  674. try {
  675. $account_type = $response['resp_data']['account_type'] ?? 0;
  676. if (empty($account_type)) {
  677. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意', '15280215347');
  678. util::end();
  679. }
  680. $currentPayWay = null;
  681. if ($account_type == 'WECHAT') {
  682. $currentPayWay = dict::getDict('payWay', 'wxPay');
  683. } elseif ($account_type == 'ALIPAY') {
  684. $currentPayWay = dict::getDict('payWay', 'alipay');
  685. } else {
  686. noticeUtil::push('支付回调失败了,没有找到支付类型', '15280215347');
  687. util::end();
  688. }
  689. $attach = '';
  690. $total_amount = $response['resp_data']['total_amount'] ?? 0;
  691. $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
  692. $totalFee = $total_amount / 100;
  693. $transactionId = $response['resp_data']['trade_no'] ?? 0;
  694. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  695. $transaction->commit();
  696. echo 'OK';
  697. } catch (\Exception $e) {
  698. $transaction->rollBack();
  699. Yii::error("失败原因:" . $e->getMessage());
  700. }
  701. }
  702. }
  703. public function actionAliRun2()
  704. {
  705. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  706. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  707. $params = [
  708. 'appid' => 'OP00002119',
  709. 'serial_no' => '018b08cfddbd',
  710. 'merchant_no' => '82240505992000N',
  711. 'term_no' => 'C6337694',
  712. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  713. 'lklCertificatePath' => $lklCertificatePath,
  714. ];
  715. $outTradeNo = orderSn::getPurchaseSn();
  716. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  717. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  718. $aliParams = [
  719. 'orderSn' => $outTradeNo,
  720. 'amount' => 0.16,
  721. 'capitalType' => $currentCapitalType,
  722. 'notifyUrl' => $notifyUrl,
  723. ];
  724. $laResource = new Lakala($params);
  725. $response = $laResource->driveAliPay($aliParams);
  726. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  727. echo '<pre>';
  728. echo "下单成功<br/>";
  729. print_r($response);
  730. } else {
  731. echo '<pre>';
  732. echo "下单失败<br/>";
  733. print_r($response);
  734. }
  735. }
  736. public function actionAliRun3()
  737. {
  738. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  739. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  740. $params = [
  741. 'appid' => 'OP00002119',
  742. 'serial_no' => '018b08cfddbd',
  743. 'merchant_no' => '82240505992000N',
  744. 'term_no' => 'C6337694',
  745. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  746. 'lklCertificatePath' => $lklCertificatePath,
  747. ];
  748. $laResource = new Lakala($params);
  749. $outTradeNo = orderSn::getPurchaseSn();
  750. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  751. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  752. $wxParams = [
  753. 'orderSn' => $outTradeNo,
  754. 'amount' => 0.16,
  755. 'capitalType' => $currentCapitalType,
  756. 'notifyUrl' => $notifyUrl,
  757. ];
  758. $response = $laResource->driveWxPay($wxParams);
  759. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  760. echo '<pre>';
  761. echo "下单成功<br/>";
  762. print_r($response);
  763. } else {
  764. echo '<pre>';
  765. echo "下单失败<br/>";
  766. print_r($response);
  767. }
  768. }
  769. //dada 城市code
  770. public function actionDadaCityCode()
  771. {
  772. $res = dada::getCityCode(0);
  773. util::success($res);
  774. }
  775. //理由
  776. public function actionDadaReasons()
  777. {
  778. $res = dada::getCancelReason(0);
  779. util::success($res);
  780. }
  781. //达达 :下单
  782. public function actionDadaAddOrder()
  783. {
  784. $orderSn = 'XSD_CS26316851';
  785. $orderInfo = OrderClass::getByOrderSn($orderSn);
  786. $res = DadaExpressServices::addOrder($orderInfo);
  787. util::success($res);
  788. }
  789. //重发快递
  790. public function actionDadaReAdd()
  791. {
  792. $orderSn = 'XSD_CS26316851';
  793. $orderInfo = OrderClass::getByOrderSn($orderSn);
  794. $res = DadaExpressServices::reAddOrder($orderInfo);
  795. util::success($res);
  796. }
  797. //达达状态查询
  798. public function actionDadaOrderStatus()
  799. {
  800. $orderSn = 'XSD_CS26316851';
  801. $res = DadaExpressServices::statusOrder($orderSn);
  802. util::success($res);
  803. }
  804. //达达取消下单
  805. public function actionDadaCancelOrder()
  806. {
  807. $orderSn = 'XSD_CS26316851';
  808. $res = DadaExpressServices::cancelOrder($orderSn, 1);
  809. util::success($res);
  810. }
  811. //获取已支持的配送公司列表接口
  812. public function actionGetAllDelivery()
  813. {
  814. $data = MiniExpressService::getAllImmeDelivery();
  815. util::success($data);
  816. }
  817. //即时配送
  818. /*
  819. * Array
  820. (
  821. [resultcode] => 0
  822. [resultmsg] => OK
  823. [shop_list] => Array
  824. (
  825. [0] => Array
  826. (
  827. [shopid] => 1588714266
  828. [delivery_id] => SFTC
  829. [audit_result] => 0
  830. [create_time] => 1612172838
  831. [remark] =>
  832. [delivery_name] => 顺丰同城急送
  833. )
  834. )
  835. )
  836. */
  837. public function actionGetBindAccount()
  838. {
  839. $merchant = WxOpenClass::getGhsWxInfo();
  840. $isOpen = 2;
  841. $r = miniUtil::getBindAccount($merchant, $isOpen);
  842. dd($r);
  843. }
  844. //下单 (沙箱)
  845. /**
  846. * Array
  847. * (
  848. * [resultcode] => 0
  849. * [resultmsg] => ok
  850. * [fee] => 10
  851. * [waybill_id] => test_shop_id1612365974_waybillid
  852. * [order_status] => 101
  853. * [dispatch_duration] => 300
  854. * )
  855. */
  856. public function actionCreateWaybill()
  857. {
  858. $merchant = WxOpenClass::getGhsWxInfo();
  859. $isOpen = 2;
  860. $shopId = 'test_shop_id';
  861. $shopOrderId = 'test_shop_id' . time();
  862. $appSecret = 'test_app_secrect';
  863. $data = [
  864. 'shopid' => $shopId,
  865. 'shop_order_id' => $shopOrderId,
  866. 'shop_no' => '1',
  867. 'delivery_sign' => miniUtil::getDeliverySign($shopId, $shopOrderId, $appSecret), //,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
  868. 'delivery_id' => "TEST",
  869. 'openid' => 'oGKMp45YLxewOTWEbpMFzWoVqdW0',
  870. 'sender' => [
  871. 'name' => 'test',
  872. 'city' => '厦门市',
  873. 'address' => '思明区',
  874. 'address_detail' => '软件园二期',
  875. 'phone' => '19959271111',
  876. 'lng' => 118.134343,
  877. 'lat' => 24.483566,
  878. 'coordinate_type' => 0,
  879. ],
  880. 'receiver' => [
  881. 'name' => 'test',
  882. 'city' => '厦门市',
  883. 'address' => '思明区',
  884. 'address_detail' => '软件园二期',
  885. 'phone' => '19959271111',
  886. 'lng' => 118.134343,
  887. 'lat' => 24.493566,
  888. 'coordinate_type' => 0,
  889. ],
  890. 'cargo' => [
  891. 'goods_value' => 1,
  892. 'goods_weight' => 0.1,
  893. 'cargo_first_class' => '鲜花',
  894. 'cargo_second_class' => '鲜花',
  895. ],
  896. 'order_info' => [
  897. 'order_type' => 0,
  898. ],
  899. 'shop' => [
  900. 'wxa_path' => '/shop',
  901. 'img_url' => 'http://www.baidu.com/test.png',
  902. 'goods_name' => 'test',
  903. 'goods_count' => 1,
  904. ],
  905. ];
  906. $r = miniUtil::addOrder($data, $merchant, $isOpen);
  907. dd($r);
  908. }
  909. //获取运单数据
  910. /**
  911. * Array
  912. * (
  913. * [resultcode] => 0
  914. * [resultmsg] => ok
  915. * [order_status] => 101
  916. * [agent_info] => Array
  917. * (
  918. * )
  919. *
  920. * [waybill_id] => test_shop_id1612365974_waybillid
  921. * [rider_name] =>
  922. * [rider_phone] =>
  923. * [order_token] => NsXweKCKhSyAEIhAdnX3TYZsVDES0-t-tymHDONG0MpRsF31dQvVxiP_JJvLFaKS-kwXuOG3D0hzKkl7o-gzew
  924. * )
  925. */
  926. public function actionGetOrder()
  927. {
  928. $shopId = 'test_shop_id';
  929. $shopOrderId = 'test_shop_id1612365974';
  930. $appSecret = 'test_app_secrect';
  931. $merchant = WxOpenClass::getGhsWxInfo();
  932. $isOpen = 2;
  933. $data = [
  934. 'shopid' => $shopId,
  935. 'shop_order_id' => $shopOrderId,
  936. 'shop_no' => '1',
  937. 'delivery_sign' => MiniExpressService::getDeliverySign($shopId, $shopOrderId, $appSecret),
  938. ];
  939. $r = miniUtil::getOrder($data, $merchant, $isOpen);
  940. dd($r);
  941. }
  942. //沙盒 更新快递状态
  943. public function actionMockUpdateOrder()
  944. {
  945. $merchant = WxOpenClass::getGhsWxInfo();
  946. $isOpen = 2;
  947. /**
  948. * {
  949. * "shopid": "test_shop_id",
  950. * "shop_order_id": "xxxxxxxxxxx",
  951. * "waybill_id": "xxxxxxxxxxxxx",
  952. * "action_time": 12345678,
  953. * "order_status": 101,
  954. * "action_msg": "",
  955. * }
  956. */
  957. $shopId = 'test_shop_id';
  958. $shopOrderId = 'test_shop_id1612365974';
  959. $data = [
  960. 'shop_order_id' => $shopOrderId,
  961. "shopid" => $shopId,
  962. "action_time" => time(),
  963. "order_status" => 302,
  964. 'action_msg' => '状态变更',
  965. ];
  966. $r = miniUtil::mockUpdateOrder($data, $merchant, $isOpen);
  967. dd($r);
  968. }
  969. public function actionTest()
  970. {
  971. }
  972. //新增订单
  973. public function actionAddOrder()
  974. {
  975. $dada = Yii::getAlias("@vendor/dada/");
  976. require_once $dada . 'api/addOrderApi.php';
  977. require_once $dada . 'client/dadaRequestClient.php';
  978. require_once $dada . 'client/dadaResponse.php';
  979. require_once $dada . 'config/config.php';
  980. require_once $dada . 'model/orderModel.php';
  981. // isOnline 判断是否是测试环境,会有不同的域名等
  982. $isOnline = false;
  983. $sourceId = 1000000;
  984. // 初始化一个config
  985. $config = new \Config($sourceId, $isOnline);
  986. $orderModel = new \OrderModel();
  987. $orderModel->setShopNo('11047059');
  988. $orderModel->setOriginId('2018091100000002');
  989. $orderModel->setCityCode('021');
  990. $orderModel->setCargoPrice(10);
  991. $orderModel->setIsPrepay(0);
  992. $orderModel->setReceiverName('测试达达');
  993. $orderModel->setReceiverAddress('上海市崇明岛');
  994. $orderModel->setReceiverLat(31.63);
  995. $orderModel->setReceiverLng(121.41);
  996. $orderModel->setReceiverPhone('18588888888');
  997. $orderModel->setCallback('http://api.b.huaml.com/data/request');
  998. // api主要有2个参数,一个是url, 一个是业务参数
  999. $addOrderApi = new \AddOrderApi(json_encode($orderModel));
  1000. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  1001. $resp = $dada_client->makeRequest();
  1002. echo json_encode($resp);
  1003. }
  1004. //订单详情查询
  1005. public function actionOrderQuery()
  1006. {
  1007. $dada = Yii::getAlias("@vendor/dada/");
  1008. require_once $dada . 'api/OrderQueryApi.php';
  1009. require_once $dada . 'client/dadaRequestClient.php';
  1010. require_once $dada . 'client/dadaResponse.php';
  1011. require_once $dada . 'config/config.php';
  1012. require_once $dada . 'model/orderModel.php';
  1013. // isOnline 判断是否是测试环境,会有不同的域名等
  1014. $isOnline = false;
  1015. $sourceId = 1000000;
  1016. // 初始化一个config
  1017. $config = new \Config($sourceId, $isOnline);
  1018. $orderModel = new \OrderModel();
  1019. $orderModel->setOrderId('2018091100000002');
  1020. // api主要有2个参数,一个是url, 一个是业务参数
  1021. $addOrderApi = new \OrderQueryApi(json_encode($orderModel));
  1022. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  1023. $resp = $dada_client->makeRequest();
  1024. echo json_encode($resp);
  1025. }
  1026. public function actionFocus()
  1027. {
  1028. $name = '花卉宝';
  1029. if (getenv('YII_ENV') == 'dev') {
  1030. $name = '花美灵';
  1031. }
  1032. $merchant = MerchantService::getByCondition(['name' => $name]);
  1033. $list = wxUtil::getSubscribeUserList($merchant);
  1034. dd($list);
  1035. }
  1036. //宝贝售出提醒 ssh 2020.1.30
  1037. public function actionInform()
  1038. {
  1039. $merchant = MerchantService::getMerchantById(12362);
  1040. $order = OrderService::getById(214810);
  1041. InformAdminClass::sendComplete($order);
  1042. }
  1043. public function actionNotice()
  1044. {
  1045. $data = ['messageType' => 'inform', 'informWay' => 'wx', 'userType' => 'admin', 'id' => 6, 'mobile' => '15280215347'];
  1046. $producer = Yii::$app->rabbitmq->getProducer('informProducer');
  1047. echo '<pre>';
  1048. print_r($data);
  1049. $msg = serialize($data);
  1050. $r = $producer->publish($msg, 'informExchange', 'informRoute');
  1051. }
  1052. }