TestController.php 23 KB

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