TestController.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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' => '8227310599200K8', 'wx' => [644771350, 644769766], 'zfb' => '2088440549798194'],
  211. ['name' => '小蔡鲜花批发', 'merchantNo' => '8223050599200BF', 'wx' => [644014296, 643948823], 'zfb' => '2088440255505707'],
  212. //['name' => '扬州花儿很仙', 'merchantNo' => '82231205992001R', 'wx' => [641935836, 641934793], 'zfb' => '2088340698052621'],
  213. //['name' => '福清花好鲜', 'merchantNo' => '82239105992008S', 'wx' => [639783869, 639783652], 'zfb' => '2088340156624896'],
  214. //['name' => '北京花篮子', 'merchantNo' => '8221000599200QM', 'wx' => [639324663, 639322821], 'zfb' => '2088240926611870'],
  215. //['name' => '云南云漫梦金鹏', 'merchantNo' => '8227310599200K0', 'wx' => [638438213, 638437418], 'zfb' => '2088240671151089'],
  216. //['name' => '心悦花艺馆', 'merchantNo' => '82247305992002L', 'wx' => [632850138, 632849309], 'zfb' => '2088140048248384'],
  217. //['name' => '买手很忙', 'merchantNo' => '8227310599200GJ', 'wx' => [601597167, 601595526], 'zfb' => '2088820818930267'],
  218. //['name' => '七彩花都', 'merchantNo' => '8227310599200GF', 'wx' => [601176481, 601148503], 'zfb' => '2088820748594478'],
  219. //['name' => '十年', 'merchantNo' => '82252305992001U', 'wx' => [601285154, 601261795], 'zfb' => '2088820782171763'],
  220. //['name' => '都市花季OK', 'merchantNo' => '82239305992006U', 'wx' => [601174342, 601147649], 'zfb' => '2088820748507346'],
  221. //['name' => '花样年华OK', 'merchantNo' => '82260205992007Q', 'wx' => [601134352, 601091710], 'zfb' => '2088820735043444'],
  222. //['name' => '精茂城OK', 'merchantNo' => '8225840599200TF', 'wx' => [601173752, 601143352], 'zfb' => '2088820746800005'],
  223. //['name' => '莱漫OK', 'merchantNo' => '82239305992007A', 'wx' => [601288494, 601288166], 'zfb' => '2088820783686611'],
  224. //['name' => '莱漫(没用)', 'merchantNo' => '82239305992006T', 'wx' => [601134065, 601125595], 'zfb' => '2088820743859918'],
  225. //['name' => '福州我要花OK', 'merchantNo' => '82239105992007J', 'wx' => [601134030, 601128111], 'zfb' => '2088820745276973'],
  226. //['name' => '泉城OK', 'merchantNo' => '82239705992004F', 'wx' => [601273270, 601272854], 'zfb' => '2088820784658561'],
  227. //['name' => '泉城(没用)', 'merchantNo' => '82239705992004E', 'wx' => [601133056, 601133821], 'zfb' => '2088820746111323'],
  228. //['name' => '美丽花行OK', 'merchantNo' => '82239305992006V', 'wx' => [601155249, 601149712], 'zfb' => '2088820747673312'],
  229. //['name' => '三叶OK', 'merchantNo' => '82236805992001Y', 'wx' => [601152233, 601151024], 'zfb' => '2088820747556725'],
  230. //['name' => '花大苪OK', 'merchantNo' => '8227310599200GG', 'wx' => [601174221, 601165136], 'zfb' => '2088820751181377'],
  231. //['name' => '十堰天天鲜花OK', 'merchantNo' => '82252305992001S', 'wx' => [601171131, 601170642], 'zfb' => '2088820750844626'],
  232. //['name' => '珑松花卉OK', 'merchantNo' => '82260205992007S', 'wx' => [601176093, 601174262], 'zfb' => '2088820754742492'],
  233. //['name' => '惠雅鲜花OK', 'merchantNo' => '82260205992007R', 'wx' => [601173390, 601174002], 'zfb' => '2088820753174540'],
  234. //['name' => '锦绣花卉OK', 'merchantNo' => '82252305992001T', 'wx' => [601176719, 601176660], 'zfb' => '2088820754751663'],
  235. //['name' => '祥瑞鲜花同安店OK', 'merchantNo' => '82239305992006W', 'wx' => [601178350, 601177795], 'zfb' => '2088820755715024'],
  236. //['name' => '祥瑞鲜花翔安店OK', 'merchantNo' => '82239305992006X', 'wx' => [601178260, 601178199], 'zfb' => '2088820754481553'],
  237. //['name' => '初见花季OK', 'merchantNo' => '82239305992006Y', 'wx' => [601178998, 601179605], 'zfb' => '2088820757223312'],
  238. //['name' => '荣发鲜花OK', 'merchantNo' => '82242705992000D', 'wx' => [601179681, 601179180], 'zfb' => '2088820756926593'],
  239. //['name' => '花千朵(多多)OK', 'merchantNo' => '82239305992006Z', 'wx' => [601223474, 601208096], 'zfb' => '2088820766783276'],
  240. //['name' => '花悠星OK', 'merchantNo' => '8225810599200NH', 'wx' => [601228194, 601227691], 'zfb' => '2088820774587446'],
  241. //['name' => '花悠星(没用)', 'merchantNo' => '8225810599200NG', 'wx' => [601223630, 601210952], 'zfb' => '2088820767072874'],
  242. //['name' => '源花汇OK', 'merchantNo' => '82222105992004A', 'wx' => [601221944, 601214269], 'zfb' => '2088820770594246'],
  243. //['name' => '源花汇2(没用)', 'merchantNo' => '8227310599200GD', 'wx' => [601136305, 601067016], 'zfb' => '2088820729832744'],
  244. ];
  245. $new = [];
  246. foreach ($arr as $item) {
  247. $wx = $item['wx'];
  248. $zfb = $item['zfb'];
  249. $merchantNo = $item['merchantNo'];
  250. $name = $item['name'] . ' ' . $merchantNo;
  251. $group = [];
  252. foreach ($wx as $oneWx) {
  253. $params = [
  254. 'appid' => 'OP00002119',
  255. 'serial_no' => '018b08cfddbd',
  256. 'merchant_no' => $merchantNo,
  257. 'term_no' => 'C6337694',
  258. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  259. 'lklCertificatePath' => $lklCertificatePath,
  260. ];
  261. $data = [
  262. 'subMerchantId' => $oneWx,
  263. 'tradeMode' => 'WECHAT',
  264. ];
  265. $laResource = new Lakala($params);
  266. $response = $laResource->openStateQuery($data);
  267. $statusName = '出错了';
  268. if ($response['retCode'] == '000000') {
  269. $checkResult = $response['respData']['checkResult'] ?? '';
  270. $statusName = '未认证';
  271. if ($checkResult == 'AUTHORIZE_STATE_AUTHORIZED') {
  272. $statusName = '已认证';
  273. }
  274. }
  275. $group[] = '微信 ' . $oneWx . ' ' . $statusName;
  276. }
  277. $params = [
  278. 'appid' => 'OP00002119',
  279. 'serial_no' => '018b08cfddbd',
  280. 'merchant_no' => $merchantNo,
  281. 'term_no' => 'C6337694',
  282. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  283. 'lklCertificatePath' => $lklCertificatePath,
  284. ];
  285. $data = [
  286. 'subMerchantId' => $zfb,
  287. 'tradeMode' => 'ALIPAY',
  288. ];
  289. $laResource = new Lakala($params);
  290. $response = $laResource->openStateQuery($data);
  291. $statusName = '出错了';
  292. if ($response['retCode'] == '000000') {
  293. $checkResult = $response['respData']['checkResult'] ?? '';
  294. $statusName = '未认证';
  295. if ($checkResult == 'AUTHORIZED') {
  296. $statusName = '已认证';
  297. }
  298. }
  299. $group[] = '支付宝 ' . $zfb . ' ' . $statusName;
  300. $new[] = ['name' => $name, 'status' => $group];
  301. }
  302. echo '<pre>';
  303. print_r($new);
  304. die;
  305. }
  306. public function actionRefundQuery()
  307. {
  308. $shopId = 520;
  309. $shop = ShopClass::getById($shopId, true);
  310. if (empty($shop)) {
  311. util::stop('没有找到门店');
  312. }
  313. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  314. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  315. $params = [
  316. 'appid' => 'OP00002119',
  317. 'serial_no' => '018b08cfddbd',
  318. 'merchant_no' => $shop->lklSjNo,
  319. 'term_no' => $shop->lklScanTermNo,
  320. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  321. 'lklCertificatePath' => $lklCertificatePath,
  322. ];
  323. $laResource = new Lakala($params);
  324. $orderSn = '20231201110113131266165492618754';
  325. $data = [
  326. 'orderSn' => $orderSn,
  327. ];
  328. $response = $laResource->refundQuery($data);
  329. echo "<pre>";
  330. print_r($response);
  331. }
  332. public function actionBalanceQuery()
  333. {
  334. $shopId = 1212;
  335. $shop = ShopClass::getById($shopId, true);
  336. if (empty($shop)) {
  337. util::stop('没有找到门店');
  338. }
  339. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  340. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  341. $params = [
  342. 'appid' => 'OP00002119',
  343. 'serial_no' => '018b08cfddbd',
  344. 'merchant_no' => $shop->lklSjNo,
  345. 'term_no' => $shop->lklScanTermNo,
  346. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  347. 'lklCertificatePath' => $lklCertificatePath,
  348. ];
  349. $laResource = new Lakala($params);
  350. $response = $laResource->accountBalanceQuery();
  351. echo "<pre>";
  352. print_r($response);
  353. }
  354. //测试环境查线上数据 ssh 20231230
  355. public function actionCsQuery()
  356. {
  357. // $shopId = 1527;
  358. // $shop = ShopClass::getById($shopId, true);
  359. // if (empty($shop)) {
  360. // util::stop('没有找到门店');
  361. // }
  362. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  363. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  364. $params = [
  365. 'appid' => 'OP00002119',
  366. 'serial_no' => '018b08cfddbd',
  367. //'merchant_no' => $shop->lklSjNo,
  368. 'merchant_no' => '82222105992004A',
  369. //'term_no' => $shop->lklScanTermNo,
  370. 'term_no' => 'H3656802',
  371. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  372. 'lklCertificatePath' => $lklCertificatePath,
  373. ];
  374. $laResource = new Lakala($params);
  375. $queryParams = [
  376. //'orderSn' => 'KD26452235',
  377. 'tradeNo' => '20231230110113130266215700775011',
  378. ];
  379. $response = $laResource->query($queryParams, 1);
  380. echo "<pre>";
  381. print_r($response);
  382. }
  383. public function actionQuery()
  384. {
  385. $shopId = 726;
  386. $shop = ShopClass::getById($shopId, true);
  387. if (empty($shop)) {
  388. util::stop('没有找到门店');
  389. }
  390. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  391. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  392. $params = [
  393. 'appid' => 'OP00002119',
  394. 'serial_no' => '018b08cfddbd',
  395. 'merchant_no' => $shop->lklSjNo,
  396. 'term_no' => $shop->lklScanTermNo,
  397. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  398. 'lklCertificatePath' => $lklCertificatePath,
  399. ];
  400. $laResource = new Lakala($params);
  401. $queryParams = [
  402. 'orderSn' => 'KD26481486',
  403. //'tradeNo' => '20231230110113130266215700775011',
  404. ];
  405. $response = $laResource->query($queryParams, 0);
  406. echo "<pre>";
  407. print_r($response);
  408. }
  409. public function actionClearQuery()
  410. {
  411. $shopId = 8249;
  412. $shop = ShopClass::getById($shopId, true);
  413. if (empty($shop)) {
  414. util::stop('没有找到门店');
  415. }
  416. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  417. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  418. $params = [
  419. 'appid' => 'OP00002119',
  420. 'serial_no' => '018b08cfddbd',
  421. 'merchant_no' => $shop->lklSjNo,
  422. 'term_no' => $shop->lklScanTermNo,
  423. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  424. 'lklCertificatePath' => $lklCertificatePath,
  425. ];
  426. $laResource = new Lakala($params);
  427. $queryParams = [
  428. //'orderSn' => 'CL28693295',
  429. 'tradeNo' => '66215417437878',
  430. ];
  431. $response = $laResource->query($queryParams, 1);
  432. echo "<pre>";
  433. print_r($response);
  434. }
  435. //零售订单查询 ssh 20231031
  436. public function actionLsTradeQuery()
  437. {
  438. $shopId = 3969;
  439. $shop = ShopClass::getById($shopId, true);
  440. if (empty($shop)) {
  441. util::stop('没有找到门店');
  442. }
  443. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  444. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  445. $params = [
  446. 'appid' => 'OP00002119',
  447. 'serial_no' => '018b08cfddbd',
  448. 'merchant_no' => $shop->lklSjNo,
  449. 'term_no' => $shop->lklScanTermNo,
  450. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  451. 'lklCertificatePath' => $lklCertificatePath,
  452. ];
  453. $laResource = new Lakala($params);
  454. $queryParams = [
  455. 'orderSn' => 'KD26499746',
  456. //'tradeNo' => '20231029110113130266215259252887',
  457. ];
  458. $response = $laResource->query($queryParams, 0);
  459. print_r($response);
  460. util::stop();
  461. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  462. $connection = Yii::$app->db;
  463. $transaction = $connection->beginTransaction();
  464. try {
  465. $postData = $response['resp_data'] ?? [];
  466. $orderSn = $postData['out_trade_no'] ?? '';
  467. $total_amount = $postData['total_amount'] ?? 0;
  468. $account_type = $postData['account_type'] ?? '';
  469. if (empty($account_type)) {
  470. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  471. util::end();
  472. }
  473. $totalFee = $total_amount / 100;
  474. $transactionId = $postData['trade_no'] ?? 0;
  475. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  476. $currentPayWay = null;
  477. if ($account_type == 'WECHAT') {
  478. $currentPayWay = dict::getDict('payWay', 'wxPay');
  479. } elseif ($account_type == 'ALIPAY') {
  480. $currentPayWay = dict::getDict('payWay', 'alipay');
  481. } else {
  482. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  483. util::end();
  484. }
  485. $attach = '';
  486. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  487. $transaction->commit();
  488. echo 'OK';
  489. } catch (\Exception $e) {
  490. $transaction->rollBack();
  491. Yii::error("失败原因:" . $e->getMessage());
  492. }
  493. }
  494. }
  495. //零售订单查询 ssh 20231031
  496. public function actionClear()
  497. {
  498. $shopId = 10649;
  499. $shop = ShopClass::getById($shopId, true);
  500. if (empty($shop)) {
  501. util::stop('没有找到门店');
  502. }
  503. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  504. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  505. $params = [
  506. 'appid' => 'OP00002119',
  507. 'serial_no' => '018b08cfddbd',
  508. 'merchant_no' => $shop->lklSjNo,
  509. 'term_no' => $shop->lklScanTermNo,
  510. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  511. 'lklCertificatePath' => $lklCertificatePath,
  512. ];
  513. $laResource = new Lakala($params);
  514. $queryParams = [
  515. //'orderSn' => 'KD26461864',
  516. 'tradeNo' => '20231230110113130266215700775011',
  517. ];
  518. $response = $laResource->query($queryParams, 1);
  519. print_r($response);
  520. util::stop();
  521. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  522. $connection = Yii::$app->db;
  523. $transaction = $connection->beginTransaction();
  524. try {
  525. $postData = $response['resp_data'] ?? [];
  526. $orderSn = $postData['out_trade_no'] ?? '';
  527. $total_amount = $postData['total_amount'] ?? 0;
  528. $account_type = $postData['account_type'] ?? '';
  529. if (empty($account_type)) {
  530. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  531. util::end();
  532. }
  533. $totalFee = $total_amount / 100;
  534. $transactionId = $postData['trade_no'] ?? 0;
  535. $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
  536. $currentPayWay = null;
  537. if ($account_type == 'WECHAT') {
  538. $currentPayWay = dict::getDict('payWay', 'wxPay');
  539. } elseif ($account_type == 'ALIPAY') {
  540. $currentPayWay = dict::getDict('payWay', 'alipay');
  541. } else {
  542. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  543. util::end();
  544. }
  545. $attach = '';
  546. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  547. $transaction->commit();
  548. echo 'OK';
  549. } catch (\Exception $e) {
  550. $transaction->rollBack();
  551. Yii::error("失败原因:" . $e->getMessage());
  552. }
  553. }
  554. }
  555. //交易查询 ssh 20231021
  556. public function actionTradeQuery()
  557. {
  558. $shopId = 21486;
  559. $shop = ShopClass::getById($shopId, true);
  560. if (empty($shop)) {
  561. util::stop('没有找到门店');
  562. }
  563. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  564. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  565. $params = [
  566. 'appid' => 'OP00002119',
  567. 'serial_no' => '018b08cfddbd',
  568. 'merchant_no' => $shop->lklSjNo,
  569. 'term_no' => $shop->lklScanTermNo,
  570. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  571. 'lklCertificatePath' => $lklCertificatePath,
  572. ];
  573. $laResource = new Lakala($params);
  574. $queryParams = [
  575. 'orderSn' => 'CG27052211',
  576. //'tradeNo' => '66215960152739',
  577. ];
  578. $response = $laResource->query($queryParams, 0);
  579. print_r($response);
  580. util::stop();
  581. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  582. $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  583. $connection = Yii::$app->db;
  584. $transaction = $connection->beginTransaction();
  585. try {
  586. $account_type = $response['resp_data']['account_type'] ?? 0;
  587. if (empty($account_type)) {
  588. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意', '15280215347');
  589. util::end();
  590. }
  591. $currentPayWay = null;
  592. if ($account_type == 'WECHAT') {
  593. $currentPayWay = dict::getDict('payWay', 'wxPay');
  594. } elseif ($account_type == 'ALIPAY') {
  595. $currentPayWay = dict::getDict('payWay', 'alipay');
  596. } else {
  597. noticeUtil::push('支付回调失败了,没有找到支付类型', '15280215347');
  598. util::end();
  599. }
  600. $attach = '';
  601. $total_amount = $response['resp_data']['total_amount'] ?? 0;
  602. $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
  603. $totalFee = $total_amount / 100;
  604. $transactionId = $response['resp_data']['trade_no'] ?? 0;
  605. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  606. $transaction->commit();
  607. echo 'OK';
  608. } catch (\Exception $e) {
  609. $transaction->rollBack();
  610. Yii::error("失败原因:" . $e->getMessage());
  611. }
  612. }
  613. }
  614. public function actionAliRun2()
  615. {
  616. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  617. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  618. $params = [
  619. 'appid' => 'OP00002119',
  620. 'serial_no' => '018b08cfddbd',
  621. 'merchant_no' => '82240505992000N',
  622. 'term_no' => 'C6337694',
  623. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  624. 'lklCertificatePath' => $lklCertificatePath,
  625. ];
  626. $outTradeNo = orderSn::getPurchaseSn();
  627. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  628. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  629. $aliParams = [
  630. 'orderSn' => $outTradeNo,
  631. 'amount' => 0.16,
  632. 'capitalType' => $currentCapitalType,
  633. 'notifyUrl' => $notifyUrl,
  634. ];
  635. $laResource = new Lakala($params);
  636. $response = $laResource->driveAliPay($aliParams);
  637. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  638. echo '<pre>';
  639. echo "下单成功<br/>";
  640. print_r($response);
  641. } else {
  642. echo '<pre>';
  643. echo "下单失败<br/>";
  644. print_r($response);
  645. }
  646. }
  647. public function actionAliRun3()
  648. {
  649. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  650. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  651. $params = [
  652. 'appid' => 'OP00002119',
  653. 'serial_no' => '018b08cfddbd',
  654. 'merchant_no' => '82240505992000N',
  655. 'term_no' => 'C6337694',
  656. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  657. 'lklCertificatePath' => $lklCertificatePath,
  658. ];
  659. $laResource = new Lakala($params);
  660. $outTradeNo = orderSn::getPurchaseSn();
  661. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  662. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  663. $wxParams = [
  664. 'orderSn' => $outTradeNo,
  665. 'amount' => 0.16,
  666. 'capitalType' => $currentCapitalType,
  667. 'notifyUrl' => $notifyUrl,
  668. ];
  669. $response = $laResource->driveWxPay($wxParams);
  670. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  671. echo '<pre>';
  672. echo "下单成功<br/>";
  673. print_r($response);
  674. } else {
  675. echo '<pre>';
  676. echo "下单失败<br/>";
  677. print_r($response);
  678. }
  679. }
  680. //dada 城市code
  681. public function actionDadaCityCode()
  682. {
  683. $res = dada::getCityCode(0);
  684. util::success($res);
  685. }
  686. //理由
  687. public function actionDadaReasons()
  688. {
  689. $res = dada::getCancelReason(0);
  690. util::success($res);
  691. }
  692. //达达 :下单
  693. public function actionDadaAddOrder()
  694. {
  695. $orderSn = 'XSD_CS26316851';
  696. $orderInfo = OrderClass::getByOrderSn($orderSn);
  697. $res = DadaExpressServices::addOrder($orderInfo);
  698. util::success($res);
  699. }
  700. //重发快递
  701. public function actionDadaReAdd()
  702. {
  703. $orderSn = 'XSD_CS26316851';
  704. $orderInfo = OrderClass::getByOrderSn($orderSn);
  705. $res = DadaExpressServices::reAddOrder($orderInfo);
  706. util::success($res);
  707. }
  708. //达达状态查询
  709. public function actionDadaOrderStatus()
  710. {
  711. $orderSn = 'XSD_CS26316851';
  712. $res = DadaExpressServices::statusOrder($orderSn);
  713. util::success($res);
  714. }
  715. //达达取消下单
  716. public function actionDadaCancelOrder()
  717. {
  718. $orderSn = 'XSD_CS26316851';
  719. $res = DadaExpressServices::cancelOrder($orderSn, 1);
  720. util::success($res);
  721. }
  722. //获取已支持的配送公司列表接口
  723. public function actionGetAllDelivery()
  724. {
  725. $data = MiniExpressService::getAllImmeDelivery();
  726. util::success($data);
  727. }
  728. //即时配送
  729. /*
  730. * Array
  731. (
  732. [resultcode] => 0
  733. [resultmsg] => OK
  734. [shop_list] => Array
  735. (
  736. [0] => Array
  737. (
  738. [shopid] => 1588714266
  739. [delivery_id] => SFTC
  740. [audit_result] => 0
  741. [create_time] => 1612172838
  742. [remark] =>
  743. [delivery_name] => 顺丰同城急送
  744. )
  745. )
  746. )
  747. */
  748. public function actionGetBindAccount()
  749. {
  750. $merchant = WxOpenClass::getGhsWxInfo();
  751. $isOpen = 2;
  752. $r = miniUtil::getBindAccount($merchant, $isOpen);
  753. dd($r);
  754. }
  755. //下单 (沙箱)
  756. /**
  757. * Array
  758. * (
  759. * [resultcode] => 0
  760. * [resultmsg] => ok
  761. * [fee] => 10
  762. * [waybill_id] => test_shop_id1612365974_waybillid
  763. * [order_status] => 101
  764. * [dispatch_duration] => 300
  765. * )
  766. */
  767. public function actionCreateWaybill()
  768. {
  769. $merchant = WxOpenClass::getGhsWxInfo();
  770. $isOpen = 2;
  771. $shopId = 'test_shop_id';
  772. $shopOrderId = 'test_shop_id' . time();
  773. $appSecret = 'test_app_secrect';
  774. $data = [
  775. 'shopid' => $shopId,
  776. 'shop_order_id' => $shopOrderId,
  777. 'shop_no' => '1',
  778. 'delivery_sign' => miniUtil::getDeliverySign($shopId, $shopOrderId, $appSecret), //,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
  779. 'delivery_id' => "TEST",
  780. 'openid' => 'oGKMp45YLxewOTWEbpMFzWoVqdW0',
  781. 'sender' => [
  782. 'name' => 'test',
  783. 'city' => '厦门市',
  784. 'address' => '思明区',
  785. 'address_detail' => '软件园二期',
  786. 'phone' => '19959271111',
  787. 'lng' => 118.134343,
  788. 'lat' => 24.483566,
  789. 'coordinate_type' => 0,
  790. ],
  791. 'receiver' => [
  792. 'name' => 'test',
  793. 'city' => '厦门市',
  794. 'address' => '思明区',
  795. 'address_detail' => '软件园二期',
  796. 'phone' => '19959271111',
  797. 'lng' => 118.134343,
  798. 'lat' => 24.493566,
  799. 'coordinate_type' => 0,
  800. ],
  801. 'cargo' => [
  802. 'goods_value' => 1,
  803. 'goods_weight' => 0.1,
  804. 'cargo_first_class' => '鲜花',
  805. 'cargo_second_class' => '鲜花',
  806. ],
  807. 'order_info' => [
  808. 'order_type' => 0,
  809. ],
  810. 'shop' => [
  811. 'wxa_path' => '/shop',
  812. 'img_url' => 'http://www.baidu.com/test.png',
  813. 'goods_name' => 'test',
  814. 'goods_count' => 1,
  815. ],
  816. ];
  817. $r = miniUtil::addOrder($data, $merchant, $isOpen);
  818. dd($r);
  819. }
  820. //获取运单数据
  821. /**
  822. * Array
  823. * (
  824. * [resultcode] => 0
  825. * [resultmsg] => ok
  826. * [order_status] => 101
  827. * [agent_info] => Array
  828. * (
  829. * )
  830. *
  831. * [waybill_id] => test_shop_id1612365974_waybillid
  832. * [rider_name] =>
  833. * [rider_phone] =>
  834. * [order_token] => NsXweKCKhSyAEIhAdnX3TYZsVDES0-t-tymHDONG0MpRsF31dQvVxiP_JJvLFaKS-kwXuOG3D0hzKkl7o-gzew
  835. * )
  836. */
  837. public function actionGetOrder()
  838. {
  839. $shopId = 'test_shop_id';
  840. $shopOrderId = 'test_shop_id1612365974';
  841. $appSecret = 'test_app_secrect';
  842. $merchant = WxOpenClass::getGhsWxInfo();
  843. $isOpen = 2;
  844. $data = [
  845. 'shopid' => $shopId,
  846. 'shop_order_id' => $shopOrderId,
  847. 'shop_no' => '1',
  848. 'delivery_sign' => MiniExpressService::getDeliverySign($shopId, $shopOrderId, $appSecret),
  849. ];
  850. $r = miniUtil::getOrder($data, $merchant, $isOpen);
  851. dd($r);
  852. }
  853. //沙盒 更新快递状态
  854. public function actionMockUpdateOrder()
  855. {
  856. $merchant = WxOpenClass::getGhsWxInfo();
  857. $isOpen = 2;
  858. /**
  859. * {
  860. * "shopid": "test_shop_id",
  861. * "shop_order_id": "xxxxxxxxxxx",
  862. * "waybill_id": "xxxxxxxxxxxxx",
  863. * "action_time": 12345678,
  864. * "order_status": 101,
  865. * "action_msg": "",
  866. * }
  867. */
  868. $shopId = 'test_shop_id';
  869. $shopOrderId = 'test_shop_id1612365974';
  870. $data = [
  871. 'shop_order_id' => $shopOrderId,
  872. "shopid" => $shopId,
  873. "action_time" => time(),
  874. "order_status" => 302,
  875. 'action_msg' => '状态变更',
  876. ];
  877. $r = miniUtil::mockUpdateOrder($data, $merchant, $isOpen);
  878. dd($r);
  879. }
  880. public function actionTest()
  881. {
  882. }
  883. //新增订单
  884. public function actionAddOrder()
  885. {
  886. $dada = Yii::getAlias("@vendor/dada/");
  887. require_once $dada . 'api/addOrderApi.php';
  888. require_once $dada . 'client/dadaRequestClient.php';
  889. require_once $dada . 'client/dadaResponse.php';
  890. require_once $dada . 'config/config.php';
  891. require_once $dada . 'model/orderModel.php';
  892. // isOnline 判断是否是测试环境,会有不同的域名等
  893. $isOnline = false;
  894. $sourceId = 1000000;
  895. // 初始化一个config
  896. $config = new \Config($sourceId, $isOnline);
  897. $orderModel = new \OrderModel();
  898. $orderModel->setShopNo('11047059');
  899. $orderModel->setOriginId('2018091100000002');
  900. $orderModel->setCityCode('021');
  901. $orderModel->setCargoPrice(10);
  902. $orderModel->setIsPrepay(0);
  903. $orderModel->setReceiverName('测试达达');
  904. $orderModel->setReceiverAddress('上海市崇明岛');
  905. $orderModel->setReceiverLat(31.63);
  906. $orderModel->setReceiverLng(121.41);
  907. $orderModel->setReceiverPhone('18588888888');
  908. $orderModel->setCallback('http://api.b.huaml.com/data/request');
  909. // api主要有2个参数,一个是url, 一个是业务参数
  910. $addOrderApi = new \AddOrderApi(json_encode($orderModel));
  911. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  912. $resp = $dada_client->makeRequest();
  913. echo json_encode($resp);
  914. }
  915. //订单详情查询
  916. public function actionOrderQuery()
  917. {
  918. $dada = Yii::getAlias("@vendor/dada/");
  919. require_once $dada . 'api/OrderQueryApi.php';
  920. require_once $dada . 'client/dadaRequestClient.php';
  921. require_once $dada . 'client/dadaResponse.php';
  922. require_once $dada . 'config/config.php';
  923. require_once $dada . 'model/orderModel.php';
  924. // isOnline 判断是否是测试环境,会有不同的域名等
  925. $isOnline = false;
  926. $sourceId = 1000000;
  927. // 初始化一个config
  928. $config = new \Config($sourceId, $isOnline);
  929. $orderModel = new \OrderModel();
  930. $orderModel->setOrderId('2018091100000002');
  931. // api主要有2个参数,一个是url, 一个是业务参数
  932. $addOrderApi = new \OrderQueryApi(json_encode($orderModel));
  933. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  934. $resp = $dada_client->makeRequest();
  935. echo json_encode($resp);
  936. }
  937. public function actionFocus()
  938. {
  939. $name = '花卉宝';
  940. if (getenv('YII_ENV') == 'dev') {
  941. $name = '花美灵';
  942. }
  943. $merchant = MerchantService::getByCondition(['name' => $name]);
  944. $list = wxUtil::getSubscribeUserList($merchant);
  945. dd($list);
  946. }
  947. //宝贝售出提醒 ssh 2020.1.30
  948. public function actionInform()
  949. {
  950. $merchant = MerchantService::getMerchantById(12362);
  951. $order = OrderService::getById(214810);
  952. InformAdminClass::sendComplete($order);
  953. }
  954. public function actionNotice()
  955. {
  956. $data = ['messageType' => 'inform', 'informWay' => 'wx', 'userType' => 'admin', 'id' => 6, 'mobile' => '15280215347'];
  957. $producer = Yii::$app->rabbitmq->getProducer('informProducer');
  958. echo '<pre>';
  959. print_r($data);
  960. $msg = serialize($data);
  961. $r = $producer->publish($msg, 'informExchange', 'informRoute');
  962. }
  963. }