TestController.php 43 KB

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