TestController.php 29 KB

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