TestController.php 47 KB

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