TestController.php 27 KB

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