TestController.php 27 KB

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