TestController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\sj\services\MerchantService;
  4. use bizGhs\express\services\DadaExpressServices;
  5. use bizGhs\order\classes\OrderClass;
  6. use bizHd\message\classes\InformAdminClass;
  7. use bizHd\order\services\OrderService;
  8. use bizHd\wx\classes\WxOpenClass;
  9. use bizGhs\express\services\MiniExpressService;
  10. use common\components\dict;
  11. use common\components\lakala\Lakala;
  12. use common\components\miniUtil;
  13. use common\components\orderSn;
  14. use common\components\wxUtil;
  15. use Yii;
  16. use common\components\util;
  17. class TestController extends BaseController
  18. {
  19. public $guestAccess = ['inform', 'notice', 'order-query', 'add-order', 'index', 'get'];
  20. public function actionApply()
  21. {
  22. $sjNo ='';
  23. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  24. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  25. $params = [
  26. 'appid' => 'OP00002119',
  27. 'serial_no' => '018b08cfddbd',
  28. 'merchant_no' => $sjNo,
  29. 'term_no' => 'C6337694',
  30. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  31. 'lklCertificatePath' => $lklCertificatePath,
  32. ];
  33. $data = [
  34. ];
  35. $laResource = new Lakala($params);
  36. $response = $laResource->applyInviteClear($data);
  37. }
  38. public function actionGet()
  39. {
  40. ini_set('memory_limit', '2045M');
  41. set_time_limit(0);
  42. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  43. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  44. $arr = [
  45. //['name' => '国兰花尚OK', 'merchantNo' => '82239305992006L', 'wx' => [600913569, 600907053], 'zfb' => '2088820709029782'],
  46. //['name' => '花掌柜OK', 'merchantNo' => '82240505992000P', 'wx' => [600466131, 600465187], 'zfb' => '2088820656569304'],
  47. //['name' => '纯彩花艺OK', 'merchantNo' => '82239305992006M', 'wx' => [600922790, 600915407], 'zfb' => '2088820710146836'],
  48. //['name' => '集美天天鲜花OK', 'merchantNo' => '82239305992006P', 'wx' => [601036538, 601036322], 'zfb' => '2088820726763339'],
  49. //['name' => '丰行花行OK', 'merchantNo' => '82260205992007P', 'wx' => [601053759, 601052157], 'zfb' => '2088820725885465'],
  50. //['name' => '独家花行OK', 'merchantNo' => '82239305992006Q', 'wx' => [601049483, 601048223], 'zfb' => '2088820725546555'],
  51. //['name' => '好多花海沧OK', 'merchantNo' => '82239305992006R', 'wx' => [601052177, 601053735], 'zfb' => '2088820725549695'],
  52. //['name' => '美天鲜花OK', 'merchantNo' => '82259505992003F', 'wx' => [601062064, 601138175], 'zfb' => '2088820729400990'],
  53. //['name' => '天天陈江店OK', 'merchantNo' => '82259505992003E', 'wx' => [601060616, 601059382], 'zfb' => '2088820725555368'],
  54. //['name' => '叶上花OK', 'merchantNo' => '82231805992002G', 'wx' => [601062892, 601062589], 'zfb' => '2088820728763546'],
  55. //['name' => '好又多(小明)OK', 'merchantNo' => '82239305992006S', 'wx' => [601135715, 601067347], 'zfb' => '2088820729698012'],
  56. //['name' => '我卖花OK', 'merchantNo' => '82227505992000R', 'wx' => [601177139, 601148755], 'zfb' => '2088820746424032'],
  57. //['name' => '问境OK', 'merchantNo' => '8226900599200KX', 'wx' => [601299388, 601299453], 'zfb' => '2088820787661843'],
  58. //['name' => '昱成OK', 'merchantNo' => '8226900599200KY', 'wx' => [601312993, 601325844], 'zfb' => '2088820788900240'],
  59. //['name' => '杭州斗南', 'merchantNo' => '杭州斗南', 'wx' => [601405963, 601405929], 'zfb' => '2088820793601705'],
  60. //['name' => '杭州斗南(没用)', 'merchantNo' => '8223310599200AD', 'wx' => [601254682, 601250805], 'zfb' => '2088820782666872'],
  61. ['name' => '买手很忙', 'merchantNo' => '8227310599200GJ', 'wx' => [601597167, 601595526], 'zfb' => '2088820818930267'],
  62. ['name' => '七彩花都OK', 'merchantNo' => '8227310599200GF', 'wx' => [601176481, 601148503], 'zfb' => '2088820748594478'],
  63. //['name' => '十年OK', 'merchantNo' => '82252305992001U', 'wx' => [601285154, 601261795], 'zfb' => '2088820782171763'],
  64. //['name' => '都市花季OK', 'merchantNo' => '82239305992006U', 'wx' => [601174342, 601147649], 'zfb' => '2088820748507346'],
  65. //['name' => '花样年华OK', 'merchantNo' => '82260205992007Q', 'wx' => [601134352, 601091710], 'zfb' => '2088820735043444'],
  66. //['name' => '精茂城OK', 'merchantNo' => '8225840599200TF', 'wx' => [601173752, 601143352], 'zfb' => '2088820746800005'],
  67. //['name' => '莱漫OK', 'merchantNo' => '82239305992007A', 'wx' => [601288494, 601288166], 'zfb' => '2088820783686611'],
  68. //['name' => '莱漫(没用)', 'merchantNo' => '82239305992006T', 'wx' => [601134065, 601125595], 'zfb' => '2088820743859918'],
  69. //['name' => '福州我要花OK', 'merchantNo' => '82239105992007J', 'wx' => [601134030, 601128111], 'zfb' => '2088820745276973'],
  70. //['name' => '泉城OK', 'merchantNo' => '82239705992004F', 'wx' => [601273270, 601272854], 'zfb' => '2088820784658561'],
  71. //['name' => '泉城(没用)', 'merchantNo' => '82239705992004E', 'wx' => [601133056, 601133821], 'zfb' => '2088820746111323'],
  72. //['name' => '美丽花行OK', 'merchantNo' => '82239305992006V', 'wx' => [601155249, 601149712], 'zfb' => '2088820747673312'],
  73. //['name' => '三叶OK', 'merchantNo' => '82236805992001Y', 'wx' => [601152233, 601151024], 'zfb' => '2088820747556725'],
  74. //['name' => '花大苪OK', 'merchantNo' => '8227310599200GG', 'wx' => [601174221, 601165136], 'zfb' => '2088820751181377'],
  75. //['name' => '十堰天天鲜花OK', 'merchantNo' => '82252305992001S', 'wx' => [601171131, 601170642], 'zfb' => '2088820750844626'],
  76. //['name' => '珑松花卉OK', 'merchantNo' => '82260205992007S', 'wx' => [601176093, 601174262], 'zfb' => '2088820754742492'],
  77. //['name' => '惠雅鲜花OK', 'merchantNo' => '82260205992007R', 'wx' => [601173390, 601174002], 'zfb' => '2088820753174540'],
  78. //['name' => '锦绣花卉OK', 'merchantNo' => '82252305992001T', 'wx' => [601176719, 601176660], 'zfb' => '2088820754751663'],
  79. //['name' => '祥瑞鲜花同安店OK', 'merchantNo' => '82239305992006W', 'wx' => [601178350, 601177795], 'zfb' => '2088820755715024'],
  80. //['name' => '祥瑞鲜花翔安店OK', 'merchantNo' => '82239305992006X', 'wx' => [601178260, 601178199], 'zfb' => '2088820754481553'],
  81. //['name' => '初见花季OK', 'merchantNo' => '82239305992006Y', 'wx' => [601178998, 601179605], 'zfb' => '2088820757223312'],
  82. //['name' => '荣发鲜花OK', 'merchantNo' => '82242705992000D', 'wx' => [601179681, 601179180], 'zfb' => '2088820756926593'],
  83. //['name' => '花千朵(多多)OK', 'merchantNo' => '82239305992006Z', 'wx' => [601223474, 601208096], 'zfb' => '2088820766783276'],
  84. //['name' => '花悠星OK', 'merchantNo' => '8225810599200NH', 'wx' => [601228194, 601227691], 'zfb' => '2088820774587446'],
  85. //['name' => '花悠星(没用)', 'merchantNo' => '8225810599200NG', 'wx' => [601223630, 601210952], 'zfb' => '2088820767072874'],
  86. //['name' => '源花汇OK', 'merchantNo' => '82222105992004A', 'wx' => [601221944, 601214269], 'zfb' => '2088820770594246'],
  87. //['name' => '源花汇2(没用)', 'merchantNo' => '8227310599200GD', 'wx' => [601136305, 601067016], 'zfb' => '2088820729832744'],
  88. ];
  89. $new = [];
  90. foreach ($arr as $item) {
  91. $wx = $item['wx'];
  92. $zfb = $item['zfb'];
  93. $merchantNo = $item['merchantNo'];
  94. $name = $item['name'] . ' ' . $merchantNo;
  95. $group = [];
  96. foreach ($wx as $oneWx) {
  97. $params = [
  98. 'appid' => 'OP00002119',
  99. 'serial_no' => '018b08cfddbd',
  100. 'merchant_no' => $merchantNo,
  101. 'term_no' => 'C6337694',
  102. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  103. 'lklCertificatePath' => $lklCertificatePath,
  104. ];
  105. $data = [
  106. 'subMerchantId' => $oneWx,
  107. 'tradeMode' => 'WECHAT',
  108. ];
  109. $laResource = new Lakala($params);
  110. $response = $laResource->openStateQuery($data);
  111. $statusName = '出错了';
  112. if ($response['retCode'] == '000000') {
  113. $checkResult = $response['respData']['checkResult'] ?? '';
  114. $statusName = '未确认';
  115. if ($checkResult == 'AUTHORIZE_STATE_AUTHORIZED') {
  116. $statusName = '已确认';
  117. }
  118. }
  119. $group[] = '微信 ' . $oneWx . ' ' . $statusName;
  120. }
  121. $params = [
  122. 'appid' => 'OP00002119',
  123. 'serial_no' => '018b08cfddbd',
  124. 'merchant_no' => $merchantNo,
  125. 'term_no' => 'C6337694',
  126. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  127. 'lklCertificatePath' => $lklCertificatePath,
  128. ];
  129. $data = [
  130. 'subMerchantId' => $zfb,
  131. 'tradeMode' => 'ALIPAY',
  132. ];
  133. $laResource = new Lakala($params);
  134. $response = $laResource->openStateQuery($data);
  135. $statusName = '出错了';
  136. if ($response['retCode'] == '000000') {
  137. $checkResult = $response['respData']['checkResult'] ?? '';
  138. $statusName = '未确认';
  139. if ($checkResult == 'AUTHORIZED') {
  140. $statusName = '已确认';
  141. }
  142. }
  143. $group[] = '支付宝 ' . $zfb . ' ' . $statusName;
  144. $new[] = ['name' => $name, 'status' => $group];
  145. }
  146. echo '<pre>';
  147. print_r($new);
  148. die;
  149. }
  150. public function actionAliRun2()
  151. {
  152. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  153. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  154. $params = [
  155. 'appid' => 'OP00002119',
  156. 'serial_no' => '018b08cfddbd',
  157. 'merchant_no' => '82240505992000N',
  158. 'term_no' => 'C6337694',
  159. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  160. 'lklCertificatePath' => $lklCertificatePath,
  161. ];
  162. $outTradeNo = orderSn::getPurchaseSn();
  163. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  164. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  165. $aliParams = [
  166. 'orderSn' => $outTradeNo,
  167. 'amount' => 0.16,
  168. 'capitalType' => $currentCapitalType,
  169. 'notifyUrl' => $notifyUrl,
  170. ];
  171. $laResource = new Lakala($params);
  172. $response = $laResource->driveAliPay($aliParams);
  173. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  174. echo '<pre>';
  175. echo "下单成功<br/>";
  176. print_r($response);
  177. } else {
  178. echo '<pre>';
  179. echo "下单失败<br/>";
  180. print_r($response);
  181. }
  182. }
  183. public function actionAliRun3()
  184. {
  185. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  186. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  187. $params = [
  188. 'appid' => 'OP00002119',
  189. 'serial_no' => '018b08cfddbd',
  190. 'merchant_no' => '82240505992000N',
  191. 'term_no' => 'C6337694',
  192. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  193. 'lklCertificatePath' => $lklCertificatePath,
  194. ];
  195. $laResource = new Lakala($params);
  196. $outTradeNo = orderSn::getPurchaseSn();
  197. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  198. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  199. $wxParams = [
  200. 'orderSn' => $outTradeNo,
  201. 'amount' => 0.16,
  202. 'capitalType' => $currentCapitalType,
  203. 'notifyUrl' => $notifyUrl,
  204. ];
  205. $response = $laResource->driveWxPay($wxParams);
  206. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  207. echo '<pre>';
  208. echo "下单成功<br/>";
  209. print_r($response);
  210. } else {
  211. echo '<pre>';
  212. echo "下单失败<br/>";
  213. print_r($response);
  214. }
  215. }
  216. //dada 城市code
  217. public function actionDadaCityCode()
  218. {
  219. $res = dada::getCityCode(0);
  220. util::success($res);
  221. }
  222. //理由
  223. public function actionDadaReasons()
  224. {
  225. $res = dada::getCancelReason(0);
  226. util::success($res);
  227. }
  228. //达达 :下单
  229. public function actionDadaAddOrder()
  230. {
  231. $orderSn = 'XSD_CS26316851';
  232. $orderInfo = OrderClass::getByOrderSn($orderSn);
  233. $res = DadaExpressServices::addOrder($orderInfo);
  234. util::success($res);
  235. }
  236. //重发快递
  237. public function actionDadaReAdd()
  238. {
  239. $orderSn = 'XSD_CS26316851';
  240. $orderInfo = OrderClass::getByOrderSn($orderSn);
  241. $res = DadaExpressServices::reAddOrder($orderInfo);
  242. util::success($res);
  243. }
  244. //达达状态查询
  245. public function actionDadaOrderStatus()
  246. {
  247. $orderSn = 'XSD_CS26316851';
  248. $res = DadaExpressServices::statusOrder($orderSn);
  249. util::success($res);
  250. }
  251. //达达取消下单
  252. public function actionDadaCancelOrder()
  253. {
  254. $orderSn = 'XSD_CS26316851';
  255. $res = DadaExpressServices::cancelOrder($orderSn, 1);
  256. util::success($res);
  257. }
  258. //获取已支持的配送公司列表接口
  259. public function actionGetAllDelivery()
  260. {
  261. $data = MiniExpressService::getAllImmeDelivery();
  262. util::success($data);
  263. }
  264. //即时配送
  265. /*
  266. * Array
  267. (
  268. [resultcode] => 0
  269. [resultmsg] => OK
  270. [shop_list] => Array
  271. (
  272. [0] => Array
  273. (
  274. [shopid] => 1588714266
  275. [delivery_id] => SFTC
  276. [audit_result] => 0
  277. [create_time] => 1612172838
  278. [remark] =>
  279. [delivery_name] => 顺丰同城急送
  280. )
  281. )
  282. )
  283. */
  284. public function actionGetBindAccount()
  285. {
  286. $merchant = WxOpenClass::getGhsWxInfo();
  287. $isOpen = 2;
  288. $r = miniUtil::getBindAccount($merchant, $isOpen);
  289. dd($r);
  290. }
  291. //下单 (沙箱)
  292. /**
  293. * Array
  294. * (
  295. * [resultcode] => 0
  296. * [resultmsg] => ok
  297. * [fee] => 10
  298. * [waybill_id] => test_shop_id1612365974_waybillid
  299. * [order_status] => 101
  300. * [dispatch_duration] => 300
  301. * )
  302. */
  303. public function actionCreateWaybill()
  304. {
  305. $merchant = WxOpenClass::getGhsWxInfo();
  306. $isOpen = 2;
  307. $shopId = 'test_shop_id';
  308. $shopOrderId = 'test_shop_id' . time();
  309. $appSecret = 'test_app_secrect';
  310. $data = [
  311. 'shopid' => $shopId,
  312. 'shop_order_id' => $shopOrderId,
  313. 'shop_no' => '1',
  314. 'delivery_sign' => miniUtil::getDeliverySign($shopId, $shopOrderId, $appSecret), //,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
  315. 'delivery_id' => "TEST",
  316. 'openid' => 'oGKMp45YLxewOTWEbpMFzWoVqdW0',
  317. 'sender' => [
  318. 'name' => 'test',
  319. 'city' => '厦门市',
  320. 'address' => '思明区',
  321. 'address_detail' => '软件园二期',
  322. 'phone' => '19959271111',
  323. 'lng' => 118.134343,
  324. 'lat' => 24.483566,
  325. 'coordinate_type' => 0,
  326. ],
  327. 'receiver' => [
  328. 'name' => 'test',
  329. 'city' => '厦门市',
  330. 'address' => '思明区',
  331. 'address_detail' => '软件园二期',
  332. 'phone' => '19959271111',
  333. 'lng' => 118.134343,
  334. 'lat' => 24.493566,
  335. 'coordinate_type' => 0,
  336. ],
  337. 'cargo' => [
  338. 'goods_value' => 1,
  339. 'goods_weight' => 0.1,
  340. 'cargo_first_class' => '鲜花',
  341. 'cargo_second_class' => '鲜花',
  342. ],
  343. 'order_info' => [
  344. 'order_type' => 0,
  345. ],
  346. 'shop' => [
  347. 'wxa_path' => '/shop',
  348. 'img_url' => 'http://www.baidu.com/test.png',
  349. 'goods_name' => 'test',
  350. 'goods_count' => 1,
  351. ],
  352. ];
  353. $r = miniUtil::addOrder($data, $merchant, $isOpen);
  354. dd($r);
  355. }
  356. //获取运单数据
  357. /**
  358. * Array
  359. * (
  360. * [resultcode] => 0
  361. * [resultmsg] => ok
  362. * [order_status] => 101
  363. * [agent_info] => Array
  364. * (
  365. * )
  366. *
  367. * [waybill_id] => test_shop_id1612365974_waybillid
  368. * [rider_name] =>
  369. * [rider_phone] =>
  370. * [order_token] => NsXweKCKhSyAEIhAdnX3TYZsVDES0-t-tymHDONG0MpRsF31dQvVxiP_JJvLFaKS-kwXuOG3D0hzKkl7o-gzew
  371. * )
  372. */
  373. public function actionGetOrder()
  374. {
  375. $shopId = 'test_shop_id';
  376. $shopOrderId = 'test_shop_id1612365974';
  377. $appSecret = 'test_app_secrect';
  378. $merchant = WxOpenClass::getGhsWxInfo();
  379. $isOpen = 2;
  380. $data = [
  381. 'shopid' => $shopId,
  382. 'shop_order_id' => $shopOrderId,
  383. 'shop_no' => '1',
  384. 'delivery_sign' => MiniExpressService::getDeliverySign($shopId, $shopOrderId, $appSecret),
  385. ];
  386. $r = miniUtil::getOrder($data, $merchant, $isOpen);
  387. dd($r);
  388. }
  389. //沙盒 更新快递状态
  390. public function actionMockUpdateOrder()
  391. {
  392. $merchant = WxOpenClass::getGhsWxInfo();
  393. $isOpen = 2;
  394. /**
  395. * {
  396. * "shopid": "test_shop_id",
  397. * "shop_order_id": "xxxxxxxxxxx",
  398. * "waybill_id": "xxxxxxxxxxxxx",
  399. * "action_time": 12345678,
  400. * "order_status": 101,
  401. * "action_msg": "",
  402. * }
  403. */
  404. $shopId = 'test_shop_id';
  405. $shopOrderId = 'test_shop_id1612365974';
  406. $data = [
  407. 'shop_order_id' => $shopOrderId,
  408. "shopid" => $shopId,
  409. "action_time" => time(),
  410. "order_status" => 302,
  411. 'action_msg' => '状态变更',
  412. ];
  413. $r = miniUtil::mockUpdateOrder($data, $merchant, $isOpen);
  414. dd($r);
  415. }
  416. public function actionTest()
  417. {
  418. }
  419. //新增订单
  420. public function actionAddOrder()
  421. {
  422. $dada = Yii::getAlias("@vendor/dada/");
  423. require_once $dada . 'api/addOrderApi.php';
  424. require_once $dada . 'client/dadaRequestClient.php';
  425. require_once $dada . 'client/dadaResponse.php';
  426. require_once $dada . 'config/config.php';
  427. require_once $dada . 'model/orderModel.php';
  428. // isOnline 判断是否是测试环境,会有不同的域名等
  429. $isOnline = false;
  430. $sourceId = 1000000;
  431. // 初始化一个config
  432. $config = new \Config($sourceId, $isOnline);
  433. $orderModel = new \OrderModel();
  434. $orderModel->setShopNo('11047059');
  435. $orderModel->setOriginId('2018091100000002');
  436. $orderModel->setCityCode('021');
  437. $orderModel->setCargoPrice(10);
  438. $orderModel->setIsPrepay(0);
  439. $orderModel->setReceiverName('测试达达');
  440. $orderModel->setReceiverAddress('上海市崇明岛');
  441. $orderModel->setReceiverLat(31.63);
  442. $orderModel->setReceiverLng(121.41);
  443. $orderModel->setReceiverPhone('18588888888');
  444. $orderModel->setCallback('http://api.b.huaml.com/data/request');
  445. // api主要有2个参数,一个是url, 一个是业务参数
  446. $addOrderApi = new \AddOrderApi(json_encode($orderModel));
  447. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  448. $resp = $dada_client->makeRequest();
  449. echo json_encode($resp);
  450. }
  451. //订单详情查询
  452. public function actionOrderQuery()
  453. {
  454. $dada = Yii::getAlias("@vendor/dada/");
  455. require_once $dada . 'api/OrderQueryApi.php';
  456. require_once $dada . 'client/dadaRequestClient.php';
  457. require_once $dada . 'client/dadaResponse.php';
  458. require_once $dada . 'config/config.php';
  459. require_once $dada . 'model/orderModel.php';
  460. // isOnline 判断是否是测试环境,会有不同的域名等
  461. $isOnline = false;
  462. $sourceId = 1000000;
  463. // 初始化一个config
  464. $config = new \Config($sourceId, $isOnline);
  465. $orderModel = new \OrderModel();
  466. $orderModel->setOrderId('2018091100000002');
  467. // api主要有2个参数,一个是url, 一个是业务参数
  468. $addOrderApi = new \OrderQueryApi(json_encode($orderModel));
  469. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  470. $resp = $dada_client->makeRequest();
  471. echo json_encode($resp);
  472. }
  473. public function actionFocus()
  474. {
  475. $name = '花卉宝';
  476. if (getenv('YII_ENV') == 'dev') {
  477. $name = '花美灵';
  478. }
  479. $merchant = MerchantService::getByCondition(['name' => $name]);
  480. $list = wxUtil::getSubscribeUserList($merchant);
  481. dd($list);
  482. }
  483. //宝贝售出提醒 ssh 2020.1.30
  484. public function actionInform()
  485. {
  486. $merchant = MerchantService::getMerchantById(12362);
  487. $order = OrderService::getById(214810);
  488. InformAdminClass::sendComplete($order);
  489. }
  490. public function actionNotice()
  491. {
  492. $data = ['messageType' => 'inform', 'informWay' => 'wx', 'userType' => 'admin', 'id' => 6, 'mobile' => '15280215347'];
  493. $producer = Yii::$app->rabbitmq->getProducer('informProducer');
  494. echo '<pre>';
  495. print_r($data);
  496. $msg = serialize($data);
  497. $r = $producer->publish($msg, 'informExchange', 'informRoute');
  498. }
  499. }