TestController.php 45 KB

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