TestController.php 26 KB

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