TestController.php 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\shop\classes\ShopClass;
  5. use biz\sj\services\MerchantService;
  6. use biz\wx\classes\WxMessageClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\custom\classes\CustomDebtChangeClass;
  9. use bizGhs\express\services\DadaExpressServices;
  10. use bizGhs\order\classes\OrderClass;
  11. use bizGhs\order\classes\OrderItemClass;
  12. use bizGhs\order\classes\RefundOrderClass;
  13. use bizHd\message\classes\InformAdminClass;
  14. use bizHd\order\services\OrderService;
  15. use bizHd\purchase\classes\PurchaseClass;
  16. use bizHd\purchase\classes\PurchaseClearClass;
  17. use bizHd\wx\classes\WxOpenClass;
  18. use bizGhs\express\services\MiniExpressService;
  19. use common\components\arrayUtil;
  20. use common\components\dateUtil;
  21. use common\components\dict;
  22. use common\components\lakala\Lakala;
  23. use common\components\miniUtil;
  24. use common\components\noticeUtil;
  25. use common\components\orderSn;
  26. use common\components\wxUtil;
  27. use common\components\payUtil;
  28. use Yii;
  29. use common\components\util;
  30. use wkhtmltox\Image\Converter;
  31. class TestController extends BaseController
  32. {
  33. public $guestAccess = ['on', 'in', 'clear-query', 'ip', 'html', 'debt', 'apply', 'clear', 'ls-trade-query', 'refund-query', 'inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query', 'query', 'balance-query', 'refund'];
  34. public function actionOn()
  35. {
  36. $cacheKey = 'test';
  37. Yii::$app->redis->executeCommand('HSET', [$cacheKey, 'shish', 1]);
  38. echo Yii::$app->redis->executeCommand('HGET', [$cacheKey,'shish']);
  39. Yii::$app->redis->executeCommand('HSET', [$cacheKey, 'sofashi', 2]);
  40. Yii::$app->redis->executeCommand('HSET', [$cacheKey, 'lgl', 3]);
  41. $arr = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]);
  42. print_r($arr);
  43. }
  44. public function actionIn()
  45. {
  46. $searchTime = 'custom';
  47. $startTime = '2024-05-04';
  48. $endTime = '2024-05-04';
  49. $mainId = 23390;
  50. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  51. $start = $period['startTime'];
  52. $end = $period['endTime'];
  53. $where['time'] = ['between', [$start, $end]];
  54. $currentStartDate = date('Y-m-d', strtotime($start));
  55. $currentEndDate = date('Y-m-d', strtotime($end));
  56. $currentStartTime = $currentStartDate . ' 00:00:00';
  57. $currentEndTime = $currentEndDate . ' 23:59:59';
  58. $totalAmount = 0;
  59. $itemTotalAmount = 0;
  60. $where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
  61. $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
  62. $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
  63. if (!empty($ghsOrderList)) {
  64. foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
  65. $book = $ghsOrder['book'] ?? 0;
  66. $status = $ghsOrder['status'] ?? 0;
  67. $orderSn = $ghsOrder['orderSn'] ?? '';
  68. $actPrice = $ghsOrder['actPrice'] ?? 0;
  69. $discountAmount = $ghsOrder['discountAmount'] ?? 0;
  70. $labourCost = $ghsOrder['labourCost'] ?? 0;
  71. $tkPrice = $ghsOrder['tkPrice'] ?? 0;
  72. if ($book == 1 && $status == 2) {
  73. //预订单待发货的不算收入
  74. continue;
  75. }
  76. if ($status == 0 || $status == 5) {
  77. continue;
  78. }
  79. $totalAmount = bcadd($totalAmount, $actPrice, 2);
  80. $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  81. $currentAmount = 0;
  82. if (!empty($orderItemList)) {
  83. foreach ($orderItemList as $orderItem) {
  84. $refundNum = $orderItem->refundNum ?? 0;
  85. $name = $orderItem->name ?? '';
  86. $productId = $orderItem->productId ?? 0;
  87. $num = $orderItem->xhNum ?? 0;
  88. $xhUnitPrice = $orderItem->xhUnitPrice ?? 0;
  89. $remainNum = bcsub($num, $refundNum);
  90. $classId = $orderItem->classId ?? 0;
  91. $className = $classList[$classId]['name'] ?? '已删除';
  92. $amount = bcmul($remainNum, $xhUnitPrice, 2);
  93. $currentAmount = bcadd($currentAmount, $amount, 2);
  94. $arr[$classId]['className'] = $className;
  95. $arr[$classId]['classId'] = $classId;
  96. if (isset($arr[$classId]['income'])) {
  97. $arr[$classId]['income'] = bcadd($amount, $arr[$classId]['income'], 2);
  98. } else {
  99. $arr[$classId]['expend'] = 0;
  100. $arr[$classId]['income'] = $amount;
  101. }
  102. }
  103. if (floatval($currentAmount) != floatval($actPrice) && $discountAmount <= 0 && $labourCost <= 0 && $tkPrice <= 0) {
  104. echo $orderSn . ' ' . $currentAmount . ' ' . $actPrice . ' ' . $discountAmount . ' ' . $labourCost . ' ' . $tkPrice;
  105. die;
  106. }
  107. if (floatval($actPrice) != floatval($currentAmount)) {
  108. echo $actPrice . ' ' . $currentAmount . ' ' . $orderSn . ' ====' . abs(bcsub($actPrice, $currentAmount, 2)) . "\n";
  109. } else {
  110. echo $actPrice . ' ' . $currentAmount . ' ' . $orderSn . "\n";
  111. }
  112. $itemTotalAmount = bcadd($itemTotalAmount, $currentAmount, 2);
  113. if ($tkPrice > 0) {
  114. $refundList = RefundOrderClass::getAllByCondition(['relateOrderSn' => $orderSn], null, '*', null, true);
  115. if (!empty($refundList)) {
  116. foreach ($refundList as $refund) {
  117. if ($refund->refundType == 1) {
  118. //退货退款前面已经考虑,这里不再处理 OK
  119. } else {
  120. //$refund->refundPrice
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. echo $totalAmount . ' ' . $itemTotalAmount;
  129. die;
  130. }
  131. public function actionIp()
  132. {
  133. $ip = $_SERVER['SERVER_ADDR'] ?? '';
  134. echo $ip;
  135. }
  136. public function actionHtml()
  137. {
  138. $c = new Converter(null, [
  139. "fmt" => "png",
  140. "in" => "/tmp/a.html",
  141. "out" => "/tmp/test.png"
  142. ]);
  143. $c->convert();
  144. }
  145. //欠款的查询与跟踪 ssh 20240103
  146. public function actionDebt()
  147. {
  148. $customId = 17081;
  149. $custom = CustomClass::getById($customId, true);
  150. if (empty($custom)) {
  151. echo '没有找到客户';
  152. die;
  153. }
  154. $flag = [];
  155. $changeList = CustomDebtChangeClass::getAllByCondition(['customId' => $customId], null, '*');
  156. if (!empty($changeList)) {
  157. foreach ($changeList as $change) {
  158. $event = $change['evnet'] ?? '';
  159. $relateId = $change['relateId'] ?? 0;
  160. $amount = $change['amount'] ?? 0;
  161. if (strpos($event, '购买花材') >= 0) {
  162. $flag['40-' . $relateId] = $amount;
  163. }
  164. if (strpos($event, '退款') >= 0) {
  165. $flag['33-' . $relateId] = $amount;
  166. }
  167. if (strpos($event, '结账') >= 0) {
  168. $flag['20-' . $relateId] = $amount;
  169. }
  170. }
  171. }
  172. print_r($flag);
  173. $orderList = OrderClass::getAllByCondition(['customId' => $customId, 'debtPrice>' => 0], null, 'id,actPrice,payTime', null);
  174. $arr = [];
  175. if (!empty($orderList)) {
  176. foreach ($orderList as $order) {
  177. $payTime = $order['payTime'] ?? '';
  178. $id = $order['id'] ?? 0;
  179. $arr[$payTime] = $order;
  180. if (isset($flag['40-' . $id]) == false) {
  181. echo '40-' . $id . "订单有问题\n";
  182. }
  183. }
  184. }
  185. //20
  186. $clearList = PurchaseClearClass::getAllByCondition(['customId' => $customId, 'status' => 2], null, 'id,actPrice,payTime', null);
  187. if (!empty($clearList)) {
  188. foreach ($clearList as $clear) {
  189. $payTime = $clear['payTime'] ?? '';
  190. $id = $clear['id'] ?? 0;
  191. $arr[$payTime] = $clear;
  192. if (isset($flag['20-' . $id]) == false) {
  193. echo '20-' . $id . "结账有问题\n";
  194. }
  195. }
  196. }
  197. //33
  198. $refundList = RefundOrderClass::getAllByCondition(['customId' => $customId], null, 'id,refundPrice,updateTime', null);
  199. if (!empty($refundList)) {
  200. foreach ($refundList as $refund) {
  201. $id = $refund['id'] ?? 0;
  202. $updateTime = $refund['updateTime'] ?? '';
  203. $arr[$updateTime] = $refund;
  204. if (isset($flag['33-' . $id]) == false) {
  205. echo '33-' . $id . "退款单有问题\n";
  206. }
  207. }
  208. }
  209. echo "<pre>";
  210. ksort($arr);
  211. print_r($arr);
  212. die;
  213. }
  214. //退款操作 ssh 20231029
  215. public function actionRefund()
  216. {
  217. $shopId = 36524;
  218. $shop = ShopClass::getById($shopId, true);
  219. if (empty($shop)) {
  220. util::fail('没有找到门店');
  221. }
  222. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  223. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  224. $params = [
  225. 'appid' => 'OP00002119',
  226. 'serial_no' => '018b08cfddbd',
  227. 'merchant_no' => $shop->lklSjNo,
  228. 'term_no' => $shop->lklB2BTermNo,
  229. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  230. 'lklCertificatePath' => $lklCertificatePath,
  231. ];
  232. $laResource = new Lakala($params);
  233. $refundReason = '暂无';
  234. $refundOrderSn = orderSn::getCgRefundSn();
  235. $refundPrice = 0.01;
  236. $refundFee = bcmul($refundPrice, 100);
  237. $orderSn = 'KD_CS61235203';
  238. $originTradeNo = '20231030110113230266215266468756';
  239. //$originLogNo = '66215266025626';
  240. $aliParams = [
  241. 'refundSn' => $refundOrderSn,
  242. 'orderSn' => $orderSn,
  243. 'refundAmount' => $refundFee,
  244. 'refundReason' => $refundReason,
  245. 'originTradeNo' => $originTradeNo,
  246. //'originLogNo' => $originLogNo,
  247. ];
  248. $response = $laResource->refund($aliParams);
  249. echo '<pre>';
  250. print_r($response);
  251. }
  252. public function actionApply()
  253. {
  254. $id = 2888;
  255. $shopId = 36524;
  256. $cg = PurchaseClass::getById($id, true);
  257. $shop = ShopClass::getById($shopId, true);
  258. WxMessageClass::hdNewCgOrderInform($shop, $cg);
  259. }
  260. public function actionGet()
  261. {
  262. ini_set('memory_limit', '2045M');
  263. set_time_limit(0);
  264. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  265. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  266. $arr = [
  267. //['name' => '国兰花尚OK', 'merchantNo' => '82239305992006L', 'wx' => [600913569, 600907053], 'zfb' => '2088820709029782'],
  268. //['name' => '花掌柜OK', 'merchantNo' => '82240505992000P', 'wx' => [600466131, 600465187], 'zfb' => '2088820656569304'],
  269. //['name' => '纯彩花艺OK', 'merchantNo' => '82239305992006M', 'wx' => [600922790, 600915407], 'zfb' => '2088820710146836'],
  270. //['name' => '集美天天鲜花OK', 'merchantNo' => '82239305992006P', 'wx' => [601036538, 601036322], 'zfb' => '2088820726763339'],
  271. //['name' => '丰行花行OK', 'merchantNo' => '82260205992007P', 'wx' => [601053759, 601052157], 'zfb' => '2088820725885465'],
  272. //['name' => '独家花行OK', 'merchantNo' => '82239305992006Q', 'wx' => [601049483, 601048223], 'zfb' => '2088820725546555'],
  273. //['name' => '好多花海沧OK', 'merchantNo' => '82239305992006R', 'wx' => [601052177, 601053735], 'zfb' => '2088820725549695'],
  274. //['name' => '美天鲜花OK', 'merchantNo' => '82259505992003F', 'wx' => [601062064, 601138175], 'zfb' => '2088820729400990'],
  275. //['name' => '天天陈江店OK', 'merchantNo' => '82259505992003E', 'wx' => [601060616, 601059382], 'zfb' => '2088820725555368'],
  276. //['name' => '叶上花OK', 'merchantNo' => '82231805992002G', 'wx' => [601062892, 601062589], 'zfb' => '2088820728763546'],
  277. //['name' => '好又多(小明)OK', 'merchantNo' => '82239305992006S', 'wx' => [601135715, 601067347], 'zfb' => '2088820729698012'],
  278. //['name' => '我卖花OK', 'merchantNo' => '82227505992000R', 'wx' => [601177139, 601148755], 'zfb' => '2088820746424032'],
  279. //['name' => '问境OK', 'merchantNo' => '8226900599200KX', 'wx' => [601299388, 601299453], 'zfb' => '2088820787661843'],
  280. //['name' => '昱成OK', 'merchantNo' => '8226900599200KY', 'wx' => [601312993, 601325844], 'zfb' => '2088820788900240'],
  281. //['name' => '杭州斗南', 'merchantNo' => '杭州斗南', 'wx' => [601405963, 601405929], 'zfb' => '2088820793601705'],
  282. //['name' => '杭州斗南(没用)', 'merchantNo' => '8223310599200AD', 'wx' => [601254682, 601250805], 'zfb' => '2088820782666872'],
  283. //['name' => '珑松花卉长安店', 'merchantNo' => '82260205992007U', 'wx' => [602499045, 602497558], 'zfb' => '2088820959620797'],
  284. //['name' => '福州花福(个人)', 'merchantNo' => '82239105992007P', 'wx' => [603301197, 603302321], 'zfb' => '2088920058098261'],
  285. //['name' => '福州花福', 'merchantNo' => '82239105992007N', 'wx' => [602796807, 602774796], 'zfb' => '2088820996010582'],
  286. //['name' => '昆明新宏源', 'merchantNo' => '82239305992007H', 'wx' => [606098318, 606100317], 'zfb' => '2088920878302843'],
  287. //['name' => '昆明纯彩', 'merchantNo' => '82239905992003L', 'wx' => [604923629, 604922175], 'zfb' => '2088920533160795'],
  288. //['name' => '花优田(军兴旺)', 'merchantNo' => '8227310599200GX', 'wx' => [605191281, 605190492], 'zfb' => '2088920588715249'],
  289. //['name' => '肇庆兄弟鲜花', 'merchantNo' => '82259305992001V', 'wx' => [628299301, 628297384], 'zfb' => '2088930936937722'],
  290. //['name' => '郑州唯一鲜花', 'merchantNo' => '8224910599200NB', 'wx' => [624877731, 624877902], 'zfb' => '2088830970964611'],
  291. //['name' => '昆明期待鲜花', 'merchantNo' => '8227310599200J6', 'wx' => [615582300, 615582180], 'zfb' => '2088530113958388'],
  292. //['name' => '厦门遇见你', 'merchantNo' => '82239305992008D', 'wx' => [614782373, 614783346], 'zfb' => '2088430828233036'],
  293. //['name' => '淄博花超鲜花批发', 'merchantNo' => '82245305992001R', 'wx' => [614685779, 614682986], 'zfb' => '2088430805221810'],
  294. //['name' => '广州国恋', 'merchantNo' => '8225810599200Q7', 'wx' => [612321716, 612320978], 'zfb' => '2088330479975012'],
  295. //['name' => '欣研鲜花', 'merchantNo' => '82260305992001Y', 'wx' => [612181234, 612181615], 'zfb' => '2088330365608286'],
  296. //['name' => '村长冷链', 'merchantNo' => '82260205992008G', 'wx' => [612168406, 612168000], 'zfb' => '2088330360870932'],
  297. //['name' => '惠州惠雅鲜花批发', 'merchantNo' => '82259505992003S', 'wx' => [611676975, 611677314], 'zfb' => '2088330136601427'],
  298. //['name' => '杭州斗南鲜花', 'merchantNo' => '8223310599200AR', 'wx' => [608955814, 608955082], 'zfb' => '2088130449323603'],
  299. //['name' => '营口简约花卉', 'merchantNo' => '8227310599200HJ', 'wx' => [608439898, 608440994], 'zfb' => '2088130112725929'],
  300. //['name' => '惠雅鲜花惠州店', 'merchantNo' => '82260205992007Z', 'wx' => [608406948, 608403207], 'zfb' => '2088130098167302'],
  301. //['name' => '云南珑松花卉珠海店', 'merchantNo' => '82258505992002U', 'wx' => [608062727, 608056474], 'zfb' => '2088030873238576'],
  302. //['name' => '昆明鹏诚花卉', 'merchantNo' => '8227310599200JK', 'wx' => [630710385, 630711403], 'zfb' => '2088040532857091'],
  303. //['name' => '云南昆明鲜花导航', 'merchantNo' => '8227310599200K7', 'wx' => [644628542, 644625621], 'zfb' => '2088440522565852'],
  304. //['name' => '兄弟花业', 'merchantNo' => '82260205992009C', 'wx' => [644547729, 644547591], 'zfb' => '2088440499878526'],
  305. //['name' => '花小苪', 'merchantNo' => '8227310599200K5', 'wx' => [644457809, 644457051], 'zfb' => '2088440462746403'],
  306. //['name' => '昆明君花阁', 'merchantNo' => '82239905992004Z', 'wx' => [644889761, 644889492], 'zfb' => '2088440579676361'],
  307. //['name' => '天雨花卉', 'merchantNo' => '82270705992000V', 'wx' => [644883152, 644883508], 'zfb' => '2088440575173671'],
  308. //['name' => '惠雅物流广州线', 'merchantNo' => '82259505992004N', 'wx' => [646083092, 646078226], 'zfb' => '2088440854131130'],
  309. //['name' => '小向花卉', 'merchantNo' => '8227310599200K8', 'wx' => [644771350, 644769766], 'zfb' => '2088440549798194'],
  310. //['name' => '小蔡鲜花批发', 'merchantNo' => '8223050599200BF', 'wx' => [644014296, 643948823], 'zfb' => '2088440255505707'],
  311. //['name' => '花千禧鲜花批发', 'merchantNo' => '8224510599200B2', 'wx' => [651543674, 651544159], 'zfb' => '2088640601421088'],
  312. //['name' => '九江云朵鲜花', 'merchantNo' => '82242405992001G', 'wx' => [653862657, 653862178], 'zfb' => '2088740712634499'],
  313. //['name' => '阿魏鲜花批发', 'merchantNo' => '82237405992001D', 'wx' => [655133268, 655133420], 'zfb' => '2088840200937795'],
  314. //['name' => '木合生花卉', 'merchantNo' => '8227310599200KP', 'wx' => [656152589, 656153824], 'zfb' => '2088840636484902'],
  315. //['name' => '珑松花卉广州店', 'merchantNo' => '8225810599200T4', 'wx' => [656366815, 656367359], 'zfb' => '2088840687638415'],
  316. ['name' => '珑松花卉老香洲店', 'merchantNo' => '82258505992003E', 'wx' => [658185273, 658185986], 'zfb' => '2088940386892391'],
  317. //['name' => '扬州花儿很仙', 'merchantNo' => '82231205992001R', 'wx' => [641935836, 641934793], 'zfb' => '2088340698052621'],
  318. //['name' => '福清花好鲜', 'merchantNo' => '82239105992008S', 'wx' => [639783869, 639783652], 'zfb' => '2088340156624896'],
  319. //['name' => '北京花篮子', 'merchantNo' => '8221000599200QM', 'wx' => [639324663, 639322821], 'zfb' => '2088240926611870'],
  320. //['name' => '云南云漫梦金鹏', 'merchantNo' => '8227310599200K0', 'wx' => [638438213, 638437418], 'zfb' => '2088240671151089'],
  321. //['name' => '心悦花艺馆', 'merchantNo' => '82247305992002L', 'wx' => [632850138, 632849309], 'zfb' => '2088140048248384'],
  322. //['name' => '买手很忙', 'merchantNo' => '8227310599200GJ', 'wx' => [601597167, 601595526], 'zfb' => '2088820818930267'],
  323. //['name' => '七彩花都', 'merchantNo' => '8227310599200GF', 'wx' => [601176481, 601148503], 'zfb' => '2088820748594478'],
  324. //['name' => '十年', 'merchantNo' => '82252305992001U', 'wx' => [601285154, 601261795], 'zfb' => '2088820782171763'],
  325. //['name' => '都市花季OK', 'merchantNo' => '82239305992006U', 'wx' => [601174342, 601147649], 'zfb' => '2088820748507346'],
  326. //['name' => '花样年华OK', 'merchantNo' => '82260205992007Q', 'wx' => [601134352, 601091710], 'zfb' => '2088820735043444'],
  327. //['name' => '精茂城OK', 'merchantNo' => '8225840599200TF', 'wx' => [601173752, 601143352], 'zfb' => '2088820746800005'],
  328. //['name' => '莱漫OK', 'merchantNo' => '82239305992007A', 'wx' => [601288494, 601288166], 'zfb' => '2088820783686611'],
  329. //['name' => '莱漫(没用)', 'merchantNo' => '82239305992006T', 'wx' => [601134065, 601125595], 'zfb' => '2088820743859918'],
  330. //['name' => '福州我要花OK', 'merchantNo' => '82239105992007J', 'wx' => [601134030, 601128111], 'zfb' => '2088820745276973'],
  331. //['name' => '泉城OK', 'merchantNo' => '82239705992004F', 'wx' => [601273270, 601272854], 'zfb' => '2088820784658561'],
  332. //['name' => '泉城(没用)', 'merchantNo' => '82239705992004E', 'wx' => [601133056, 601133821], 'zfb' => '2088820746111323'],
  333. //['name' => '美丽花行OK', 'merchantNo' => '82239305992006V', 'wx' => [601155249, 601149712], 'zfb' => '2088820747673312'],
  334. //['name' => '三叶OK', 'merchantNo' => '82236805992001Y', 'wx' => [601152233, 601151024], 'zfb' => '2088820747556725'],
  335. //['name' => '花大苪OK', 'merchantNo' => '8227310599200GG', 'wx' => [601174221, 601165136], 'zfb' => '2088820751181377'],
  336. //['name' => '十堰天天鲜花OK', 'merchantNo' => '82252305992001S', 'wx' => [601171131, 601170642], 'zfb' => '2088820750844626'],
  337. //['name' => '珑松花卉OK', 'merchantNo' => '82260205992007S', 'wx' => [601176093, 601174262], 'zfb' => '2088820754742492'],
  338. //['name' => '惠雅鲜花OK', 'merchantNo' => '82260205992007R', 'wx' => [601173390, 601174002], 'zfb' => '2088820753174540'],
  339. //['name' => '锦绣花卉OK', 'merchantNo' => '82252305992001T', 'wx' => [601176719, 601176660], 'zfb' => '2088820754751663'],
  340. //['name' => '祥瑞鲜花同安店OK', 'merchantNo' => '82239305992006W', 'wx' => [601178350, 601177795], 'zfb' => '2088820755715024'],
  341. //['name' => '祥瑞鲜花翔安店OK', 'merchantNo' => '82239305992006X', 'wx' => [601178260, 601178199], 'zfb' => '2088820754481553'],
  342. //['name' => '初见花季OK', 'merchantNo' => '82239305992006Y', 'wx' => [601178998, 601179605], 'zfb' => '2088820757223312'],
  343. //['name' => '荣发鲜花OK', 'merchantNo' => '82242705992000D', 'wx' => [601179681, 601179180], 'zfb' => '2088820756926593'],
  344. //['name' => '花千朵(多多)OK', 'merchantNo' => '82239305992006Z', 'wx' => [601223474, 601208096], 'zfb' => '2088820766783276'],
  345. //['name' => '花悠星OK', 'merchantNo' => '8225810599200NH', 'wx' => [601228194, 601227691], 'zfb' => '2088820774587446'],
  346. //['name' => '花悠星(没用)', 'merchantNo' => '8225810599200NG', 'wx' => [601223630, 601210952], 'zfb' => '2088820767072874'],
  347. //['name' => '源花汇OK', 'merchantNo' => '82222105992004A', 'wx' => [601221944, 601214269], 'zfb' => '2088820770594246'],
  348. //['name' => '源花汇2(没用)', 'merchantNo' => '8227310599200GD', 'wx' => [601136305, 601067016], 'zfb' => '2088820729832744'],
  349. ];
  350. $new = [];
  351. foreach ($arr as $item) {
  352. $wx = $item['wx'];
  353. $zfb = $item['zfb'];
  354. $merchantNo = $item['merchantNo'];
  355. $name = $item['name'] . ' ' . $merchantNo;
  356. $group = [];
  357. foreach ($wx as $oneWx) {
  358. $params = [
  359. 'appid' => 'OP00002119',
  360. 'serial_no' => '018b08cfddbd',
  361. 'merchant_no' => $merchantNo,
  362. 'term_no' => 'C6337694',
  363. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  364. 'lklCertificatePath' => $lklCertificatePath,
  365. ];
  366. $data = [
  367. 'subMerchantId' => $oneWx,
  368. 'tradeMode' => 'WECHAT',
  369. ];
  370. $laResource = new Lakala($params);
  371. $response = $laResource->openStateQuery($data);
  372. $statusName = '出错了';
  373. if ($response['retCode'] == '000000') {
  374. $checkResult = $response['respData']['checkResult'] ?? '';
  375. $statusName = '未认证';
  376. if ($checkResult == 'AUTHORIZE_STATE_AUTHORIZED') {
  377. $statusName = '已认证';
  378. }
  379. }
  380. $group[] = '微信 ' . $oneWx . ' ' . $statusName;
  381. }
  382. $params = [
  383. 'appid' => 'OP00002119',
  384. 'serial_no' => '018b08cfddbd',
  385. 'merchant_no' => $merchantNo,
  386. 'term_no' => 'C6337694',
  387. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  388. 'lklCertificatePath' => $lklCertificatePath,
  389. ];
  390. $data = [
  391. 'subMerchantId' => $zfb,
  392. 'tradeMode' => 'ALIPAY',
  393. ];
  394. $laResource = new Lakala($params);
  395. $response = $laResource->openStateQuery($data);
  396. $statusName = '出错了';
  397. if ($response['retCode'] == '000000') {
  398. $checkResult = $response['respData']['checkResult'] ?? '';
  399. $statusName = '未认证';
  400. if ($checkResult == 'AUTHORIZED') {
  401. $statusName = '已认证';
  402. }
  403. }
  404. $group[] = '支付宝 ' . $zfb . ' ' . $statusName;
  405. $new[] = ['name' => $name, 'status' => $group];
  406. }
  407. if (!empty($new)) {
  408. foreach ($new as $info) {
  409. echo "<table style='font-size:40px;margin-bottom:10px;'>";
  410. echo "<tr><td>{$info['name']}</td></tr>";
  411. if (!empty($info['status'])) {
  412. foreach ($info['status'] as $item) {
  413. echo "<tr><td>{$item}</td></tr>";
  414. }
  415. }
  416. echo "</table>";
  417. }
  418. }
  419. }
  420. public function actionRefundQuery()
  421. {
  422. $shopId = 520;
  423. $shop = ShopClass::getById($shopId, true);
  424. if (empty($shop)) {
  425. util::stop('没有找到门店');
  426. }
  427. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  428. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  429. $params = [
  430. 'appid' => 'OP00002119',
  431. 'serial_no' => '018b08cfddbd',
  432. 'merchant_no' => $shop->lklSjNo,
  433. 'term_no' => $shop->lklScanTermNo,
  434. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  435. 'lklCertificatePath' => $lklCertificatePath,
  436. ];
  437. $laResource = new Lakala($params);
  438. $orderSn = '20231201110113131266165492618754';
  439. $data = [
  440. 'orderSn' => $orderSn,
  441. ];
  442. $response = $laResource->refundQuery($data);
  443. echo "<pre>";
  444. print_r($response);
  445. }
  446. public function actionBalanceQuery()
  447. {
  448. $shopId = 1212;
  449. $shop = ShopClass::getById($shopId, true);
  450. if (empty($shop)) {
  451. util::stop('没有找到门店');
  452. }
  453. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  454. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  455. $params = [
  456. 'appid' => 'OP00002119',
  457. 'serial_no' => '018b08cfddbd',
  458. 'merchant_no' => $shop->lklSjNo,
  459. 'term_no' => $shop->lklScanTermNo,
  460. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  461. 'lklCertificatePath' => $lklCertificatePath,
  462. ];
  463. $laResource = new Lakala($params);
  464. $response = $laResource->accountBalanceQuery();
  465. echo "<pre>";
  466. print_r($response);
  467. }
  468. //测试环境查线上数据 ssh 20231230
  469. public function actionCsQuery()
  470. {
  471. // $shopId = 1527;
  472. // $shop = ShopClass::getById($shopId, true);
  473. // if (empty($shop)) {
  474. // util::stop('没有找到门店');
  475. // }
  476. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  477. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  478. $params = [
  479. 'appid' => 'OP00002119',
  480. 'serial_no' => '018b08cfddbd',
  481. //'merchant_no' => $shop->lklSjNo,
  482. 'merchant_no' => '82222105992004A',
  483. //'term_no' => $shop->lklScanTermNo,
  484. 'term_no' => 'H3656802',
  485. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  486. 'lklCertificatePath' => $lklCertificatePath,
  487. ];
  488. $laResource = new Lakala($params);
  489. $queryParams = [
  490. //'orderSn' => 'KD26452235',
  491. 'tradeNo' => '20231230110113130266215700775011',
  492. ];
  493. $response = $laResource->query($queryParams, 1);
  494. echo "<pre>";
  495. print_r($response);
  496. }
  497. public function actionQuery()
  498. {
  499. $shopId = 726;
  500. $shop = ShopClass::getById($shopId, true);
  501. if (empty($shop)) {
  502. util::stop('没有找到门店');
  503. }
  504. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  505. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  506. $params = [
  507. 'appid' => 'OP00002119',
  508. 'serial_no' => '018b08cfddbd',
  509. 'merchant_no' => $shop->lklSjNo,
  510. 'term_no' => $shop->lklScanTermNo,
  511. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  512. 'lklCertificatePath' => $lklCertificatePath,
  513. ];
  514. $laResource = new Lakala($params);
  515. $queryParams = [
  516. 'orderSn' => 'KD26481486',
  517. //'tradeNo' => '20231230110113130266215700775011',
  518. ];
  519. $response = $laResource->query($queryParams, 0);
  520. echo "<pre>";
  521. print_r($response);
  522. }
  523. public function actionClearQuery()
  524. {
  525. $shopId = 8249;
  526. $shop = ShopClass::getById($shopId, true);
  527. if (empty($shop)) {
  528. util::stop('没有找到门店');
  529. }
  530. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  531. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  532. $params = [
  533. 'appid' => 'OP00002119',
  534. 'serial_no' => '018b08cfddbd',
  535. 'merchant_no' => $shop->lklSjNo,
  536. 'term_no' => $shop->lklScanTermNo,
  537. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  538. 'lklCertificatePath' => $lklCertificatePath,
  539. ];
  540. $laResource = new Lakala($params);
  541. $queryParams = [
  542. //'orderSn' => 'CL28693295',
  543. 'tradeNo' => '66215417437878',
  544. ];
  545. $response = $laResource->query($queryParams, 1);
  546. echo "<pre>";
  547. print_r($response);
  548. }
  549. //零售订单查询 ssh 20231031
  550. public function actionLsTradeQuery()
  551. {
  552. $shopId = 3969;
  553. $shop = ShopClass::getById($shopId, true);
  554. if (empty($shop)) {
  555. util::stop('没有找到门店');
  556. }
  557. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  558. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  559. $params = [
  560. 'appid' => 'OP00002119',
  561. 'serial_no' => '018b08cfddbd',
  562. 'merchant_no' => $shop->lklSjNo,
  563. 'term_no' => $shop->lklScanTermNo,
  564. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  565. 'lklCertificatePath' => $lklCertificatePath,
  566. ];
  567. $laResource = new Lakala($params);
  568. $queryParams = [
  569. 'orderSn' => 'KD26499746',
  570. //'tradeNo' => '20231029110113130266215259252887',
  571. ];
  572. $response = $laResource->query($queryParams, 0);
  573. print_r($response);
  574. util::stop();
  575. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  576. $connection = Yii::$app->db;
  577. $transaction = $connection->beginTransaction();
  578. try {
  579. $postData = $response['resp_data'] ?? [];
  580. $orderSn = $postData['out_trade_no'] ?? '';
  581. $total_amount = $postData['total_amount'] ?? 0;
  582. $account_type = $postData['account_type'] ?? '';
  583. if (empty($account_type)) {
  584. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  585. util::end();
  586. }
  587. $totalFee = $total_amount / 100;
  588. $transactionId = $postData['trade_no'] ?? 0;
  589. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  590. $currentPayWay = null;
  591. if ($account_type == 'WECHAT') {
  592. $currentPayWay = dict::getDict('payWay', 'wxPay');
  593. } elseif ($account_type == 'ALIPAY') {
  594. $currentPayWay = dict::getDict('payWay', 'alipay');
  595. } else {
  596. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  597. util::end();
  598. }
  599. $attach = '';
  600. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  601. $transaction->commit();
  602. echo 'OK';
  603. } catch (\Exception $e) {
  604. $transaction->rollBack();
  605. Yii::error("失败原因:" . $e->getMessage());
  606. }
  607. }
  608. }
  609. //零售订单查询 ssh 20231031
  610. public function actionClear()
  611. {
  612. $shopId = 10649;
  613. $shop = ShopClass::getById($shopId, true);
  614. if (empty($shop)) {
  615. util::stop('没有找到门店');
  616. }
  617. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  618. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  619. $params = [
  620. 'appid' => 'OP00002119',
  621. 'serial_no' => '018b08cfddbd',
  622. 'merchant_no' => $shop->lklSjNo,
  623. 'term_no' => $shop->lklScanTermNo,
  624. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  625. 'lklCertificatePath' => $lklCertificatePath,
  626. ];
  627. $laResource = new Lakala($params);
  628. $queryParams = [
  629. //'orderSn' => 'KD26461864',
  630. 'tradeNo' => '20231230110113130266215700775011',
  631. ];
  632. $response = $laResource->query($queryParams, 1);
  633. print_r($response);
  634. util::stop();
  635. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  636. $connection = Yii::$app->db;
  637. $transaction = $connection->beginTransaction();
  638. try {
  639. $postData = $response['resp_data'] ?? [];
  640. $orderSn = $postData['out_trade_no'] ?? '';
  641. $total_amount = $postData['total_amount'] ?? 0;
  642. $account_type = $postData['account_type'] ?? '';
  643. if (empty($account_type)) {
  644. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意,orderSn:' . $orderSn, '15280215347');
  645. util::end();
  646. }
  647. $totalFee = $total_amount / 100;
  648. $transactionId = $postData['trade_no'] ?? 0;
  649. $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
  650. $currentPayWay = null;
  651. if ($account_type == 'WECHAT') {
  652. $currentPayWay = dict::getDict('payWay', 'wxPay');
  653. } elseif ($account_type == 'ALIPAY') {
  654. $currentPayWay = dict::getDict('payWay', 'alipay');
  655. } else {
  656. noticeUtil::push('支付回调失败了,没有找到支付类型,orderSn:' . $orderSn, '15280215347');
  657. util::end();
  658. }
  659. $attach = '';
  660. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  661. $transaction->commit();
  662. echo 'OK';
  663. } catch (\Exception $e) {
  664. $transaction->rollBack();
  665. Yii::error("失败原因:" . $e->getMessage());
  666. }
  667. }
  668. }
  669. //交易查询 ssh 20231021
  670. public function actionTradeQuery()
  671. {
  672. $shopId = 21486;
  673. $shop = ShopClass::getById($shopId, true);
  674. if (empty($shop)) {
  675. util::stop('没有找到门店');
  676. }
  677. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  678. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  679. $params = [
  680. 'appid' => 'OP00002119',
  681. 'serial_no' => '018b08cfddbd',
  682. 'merchant_no' => $shop->lklSjNo,
  683. 'term_no' => $shop->lklScanTermNo,
  684. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  685. 'lklCertificatePath' => $lklCertificatePath,
  686. ];
  687. $laResource = new Lakala($params);
  688. $queryParams = [
  689. 'orderSn' => 'CG27052211',
  690. //'tradeNo' => '66215960152739',
  691. ];
  692. $response = $laResource->query($queryParams, 0);
  693. print_r($response);
  694. util::stop();
  695. if (isset($response['code']) && $response['code'] == 'BBS00000') {
  696. $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  697. $connection = Yii::$app->db;
  698. $transaction = $connection->beginTransaction();
  699. try {
  700. $account_type = $response['resp_data']['account_type'] ?? 0;
  701. if (empty($account_type)) {
  702. noticeUtil::push('支付回调失败了,没有找到钱包类型,请注意', '15280215347');
  703. util::end();
  704. }
  705. $currentPayWay = null;
  706. if ($account_type == 'WECHAT') {
  707. $currentPayWay = dict::getDict('payWay', 'wxPay');
  708. } elseif ($account_type == 'ALIPAY') {
  709. $currentPayWay = dict::getDict('payWay', 'alipay');
  710. } else {
  711. noticeUtil::push('支付回调失败了,没有找到支付类型', '15280215347');
  712. util::end();
  713. }
  714. $attach = '';
  715. $total_amount = $response['resp_data']['total_amount'] ?? 0;
  716. $orderSn = $response['resp_data']['out_trade_no'] ?? 0;
  717. $totalFee = $total_amount / 100;
  718. $transactionId = $response['resp_data']['trade_no'] ?? 0;
  719. payUtil::thirdPay($currentPayWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
  720. $transaction->commit();
  721. echo 'OK';
  722. } catch (\Exception $e) {
  723. $transaction->rollBack();
  724. Yii::error("失败原因:" . $e->getMessage());
  725. }
  726. }
  727. }
  728. public function actionAliRun2()
  729. {
  730. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  731. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  732. $params = [
  733. 'appid' => 'OP00002119',
  734. 'serial_no' => '018b08cfddbd',
  735. 'merchant_no' => '82240505992000N',
  736. 'term_no' => 'C6337694',
  737. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  738. 'lklCertificatePath' => $lklCertificatePath,
  739. ];
  740. $outTradeNo = orderSn::getPurchaseSn();
  741. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  742. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  743. $aliParams = [
  744. 'orderSn' => $outTradeNo,
  745. 'amount' => 0.16,
  746. 'capitalType' => $currentCapitalType,
  747. 'notifyUrl' => $notifyUrl,
  748. ];
  749. $laResource = new Lakala($params);
  750. $response = $laResource->driveAliPay($aliParams);
  751. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  752. echo '<pre>';
  753. echo "下单成功<br/>";
  754. print_r($response);
  755. } else {
  756. echo '<pre>';
  757. echo "下单失败<br/>";
  758. print_r($response);
  759. }
  760. }
  761. public function actionAliRun3()
  762. {
  763. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  764. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  765. $params = [
  766. 'appid' => 'OP00002119',
  767. 'serial_no' => '018b08cfddbd',
  768. 'merchant_no' => '82240505992000N',
  769. 'term_no' => 'C6337694',
  770. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  771. 'lklCertificatePath' => $lklCertificatePath,
  772. ];
  773. $laResource = new Lakala($params);
  774. $outTradeNo = orderSn::getPurchaseSn();
  775. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  776. $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  777. $wxParams = [
  778. 'orderSn' => $outTradeNo,
  779. 'amount' => 0.16,
  780. 'capitalType' => $currentCapitalType,
  781. 'notifyUrl' => $notifyUrl,
  782. ];
  783. $response = $laResource->driveWxPay($wxParams);
  784. if ($response && isset($response['cmdRetCode']) && $response['cmdRetCode'] == 'GLOBAL_SUCCESS') {
  785. echo '<pre>';
  786. echo "下单成功<br/>";
  787. print_r($response);
  788. } else {
  789. echo '<pre>';
  790. echo "下单失败<br/>";
  791. print_r($response);
  792. }
  793. }
  794. //dada 城市code
  795. public function actionDadaCityCode()
  796. {
  797. $res = dada::getCityCode(0);
  798. util::success($res);
  799. }
  800. //理由
  801. public function actionDadaReasons()
  802. {
  803. $res = dada::getCancelReason(0);
  804. util::success($res);
  805. }
  806. //达达 :下单
  807. public function actionDadaAddOrder()
  808. {
  809. $orderSn = 'XSD_CS26316851';
  810. $orderInfo = OrderClass::getByOrderSn($orderSn);
  811. $res = DadaExpressServices::addOrder($orderInfo);
  812. util::success($res);
  813. }
  814. //重发快递
  815. public function actionDadaReAdd()
  816. {
  817. $orderSn = 'XSD_CS26316851';
  818. $orderInfo = OrderClass::getByOrderSn($orderSn);
  819. $res = DadaExpressServices::reAddOrder($orderInfo);
  820. util::success($res);
  821. }
  822. //达达状态查询
  823. public function actionDadaOrderStatus()
  824. {
  825. $orderSn = 'XSD_CS26316851';
  826. $res = DadaExpressServices::statusOrder($orderSn);
  827. util::success($res);
  828. }
  829. //达达取消下单
  830. public function actionDadaCancelOrder()
  831. {
  832. $orderSn = 'XSD_CS26316851';
  833. $res = DadaExpressServices::cancelOrder($orderSn, 1);
  834. util::success($res);
  835. }
  836. //获取已支持的配送公司列表接口
  837. public function actionGetAllDelivery()
  838. {
  839. $data = MiniExpressService::getAllImmeDelivery();
  840. util::success($data);
  841. }
  842. //即时配送
  843. /*
  844. * Array
  845. (
  846. [resultcode] => 0
  847. [resultmsg] => OK
  848. [shop_list] => Array
  849. (
  850. [0] => Array
  851. (
  852. [shopid] => 1588714266
  853. [delivery_id] => SFTC
  854. [audit_result] => 0
  855. [create_time] => 1612172838
  856. [remark] =>
  857. [delivery_name] => 顺丰同城急送
  858. )
  859. )
  860. )
  861. */
  862. public function actionGetBindAccount()
  863. {
  864. $merchant = WxOpenClass::getGhsWxInfo();
  865. $isOpen = 2;
  866. $r = miniUtil::getBindAccount($merchant, $isOpen);
  867. dd($r);
  868. }
  869. //下单 (沙箱)
  870. /**
  871. * Array
  872. * (
  873. * [resultcode] => 0
  874. * [resultmsg] => ok
  875. * [fee] => 10
  876. * [waybill_id] => test_shop_id1612365974_waybillid
  877. * [order_status] => 101
  878. * [dispatch_duration] => 300
  879. * )
  880. */
  881. public function actionCreateWaybill()
  882. {
  883. $merchant = WxOpenClass::getGhsWxInfo();
  884. $isOpen = 2;
  885. $shopId = 'test_shop_id';
  886. $shopOrderId = 'test_shop_id' . time();
  887. $appSecret = 'test_app_secrect';
  888. $data = [
  889. 'shopid' => $shopId,
  890. 'shop_order_id' => $shopOrderId,
  891. 'shop_no' => '1',
  892. 'delivery_sign' => miniUtil::getDeliverySign($shopId, $shopOrderId, $appSecret), //,则delivery_sign=SHA1(shopid + shop_order_id + AppSecret)
  893. 'delivery_id' => "TEST",
  894. 'openid' => 'oGKMp45YLxewOTWEbpMFzWoVqdW0',
  895. 'sender' => [
  896. 'name' => 'test',
  897. 'city' => '厦门市',
  898. 'address' => '思明区',
  899. 'address_detail' => '软件园二期',
  900. 'phone' => '19959271111',
  901. 'lng' => 118.134343,
  902. 'lat' => 24.483566,
  903. 'coordinate_type' => 0,
  904. ],
  905. 'receiver' => [
  906. 'name' => 'test',
  907. 'city' => '厦门市',
  908. 'address' => '思明区',
  909. 'address_detail' => '软件园二期',
  910. 'phone' => '19959271111',
  911. 'lng' => 118.134343,
  912. 'lat' => 24.493566,
  913. 'coordinate_type' => 0,
  914. ],
  915. 'cargo' => [
  916. 'goods_value' => 1,
  917. 'goods_weight' => 0.1,
  918. 'cargo_first_class' => '鲜花',
  919. 'cargo_second_class' => '鲜花',
  920. ],
  921. 'order_info' => [
  922. 'order_type' => 0,
  923. ],
  924. 'shop' => [
  925. 'wxa_path' => '/shop',
  926. 'img_url' => 'http://www.baidu.com/test.png',
  927. 'goods_name' => 'test',
  928. 'goods_count' => 1,
  929. ],
  930. ];
  931. $r = miniUtil::addOrder($data, $merchant, $isOpen);
  932. dd($r);
  933. }
  934. //获取运单数据
  935. /**
  936. * Array
  937. * (
  938. * [resultcode] => 0
  939. * [resultmsg] => ok
  940. * [order_status] => 101
  941. * [agent_info] => Array
  942. * (
  943. * )
  944. *
  945. * [waybill_id] => test_shop_id1612365974_waybillid
  946. * [rider_name] =>
  947. * [rider_phone] =>
  948. * [order_token] => NsXweKCKhSyAEIhAdnX3TYZsVDES0-t-tymHDONG0MpRsF31dQvVxiP_JJvLFaKS-kwXuOG3D0hzKkl7o-gzew
  949. * )
  950. */
  951. public function actionGetOrder()
  952. {
  953. $shopId = 'test_shop_id';
  954. $shopOrderId = 'test_shop_id1612365974';
  955. $appSecret = 'test_app_secrect';
  956. $merchant = WxOpenClass::getGhsWxInfo();
  957. $isOpen = 2;
  958. $data = [
  959. 'shopid' => $shopId,
  960. 'shop_order_id' => $shopOrderId,
  961. 'shop_no' => '1',
  962. 'delivery_sign' => MiniExpressService::getDeliverySign($shopId, $shopOrderId, $appSecret),
  963. ];
  964. $r = miniUtil::getOrder($data, $merchant, $isOpen);
  965. dd($r);
  966. }
  967. //沙盒 更新快递状态
  968. public function actionMockUpdateOrder()
  969. {
  970. $merchant = WxOpenClass::getGhsWxInfo();
  971. $isOpen = 2;
  972. /**
  973. * {
  974. * "shopid": "test_shop_id",
  975. * "shop_order_id": "xxxxxxxxxxx",
  976. * "waybill_id": "xxxxxxxxxxxxx",
  977. * "action_time": 12345678,
  978. * "order_status": 101,
  979. * "action_msg": "",
  980. * }
  981. */
  982. $shopId = 'test_shop_id';
  983. $shopOrderId = 'test_shop_id1612365974';
  984. $data = [
  985. 'shop_order_id' => $shopOrderId,
  986. "shopid" => $shopId,
  987. "action_time" => time(),
  988. "order_status" => 302,
  989. 'action_msg' => '状态变更',
  990. ];
  991. $r = miniUtil::mockUpdateOrder($data, $merchant, $isOpen);
  992. dd($r);
  993. }
  994. public function actionTest()
  995. {
  996. }
  997. //新增订单
  998. public function actionAddOrder()
  999. {
  1000. $dada = Yii::getAlias("@vendor/dada/");
  1001. require_once $dada . 'api/addOrderApi.php';
  1002. require_once $dada . 'client/dadaRequestClient.php';
  1003. require_once $dada . 'client/dadaResponse.php';
  1004. require_once $dada . 'config/config.php';
  1005. require_once $dada . 'model/orderModel.php';
  1006. // isOnline 判断是否是测试环境,会有不同的域名等
  1007. $isOnline = false;
  1008. $sourceId = 1000000;
  1009. // 初始化一个config
  1010. $config = new \Config($sourceId, $isOnline);
  1011. $orderModel = new \OrderModel();
  1012. $orderModel->setShopNo('11047059');
  1013. $orderModel->setOriginId('2018091100000002');
  1014. $orderModel->setCityCode('021');
  1015. $orderModel->setCargoPrice(10);
  1016. $orderModel->setIsPrepay(0);
  1017. $orderModel->setReceiverName('测试达达');
  1018. $orderModel->setReceiverAddress('上海市崇明岛');
  1019. $orderModel->setReceiverLat(31.63);
  1020. $orderModel->setReceiverLng(121.41);
  1021. $orderModel->setReceiverPhone('18588888888');
  1022. $orderModel->setCallback('http://api.b.huaml.com/data/request');
  1023. // api主要有2个参数,一个是url, 一个是业务参数
  1024. $addOrderApi = new \AddOrderApi(json_encode($orderModel));
  1025. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  1026. $resp = $dada_client->makeRequest();
  1027. echo json_encode($resp);
  1028. }
  1029. //订单详情查询
  1030. public function actionOrderQuery()
  1031. {
  1032. $dada = Yii::getAlias("@vendor/dada/");
  1033. require_once $dada . 'api/OrderQueryApi.php';
  1034. require_once $dada . 'client/dadaRequestClient.php';
  1035. require_once $dada . 'client/dadaResponse.php';
  1036. require_once $dada . 'config/config.php';
  1037. require_once $dada . 'model/orderModel.php';
  1038. // isOnline 判断是否是测试环境,会有不同的域名等
  1039. $isOnline = false;
  1040. $sourceId = 1000000;
  1041. // 初始化一个config
  1042. $config = new \Config($sourceId, $isOnline);
  1043. $orderModel = new \OrderModel();
  1044. $orderModel->setOrderId('2018091100000002');
  1045. // api主要有2个参数,一个是url, 一个是业务参数
  1046. $addOrderApi = new \OrderQueryApi(json_encode($orderModel));
  1047. $dada_client = new \DadaRequestClient($config, $addOrderApi);
  1048. $resp = $dada_client->makeRequest();
  1049. echo json_encode($resp);
  1050. }
  1051. public function actionFocus()
  1052. {
  1053. $name = '花卉宝';
  1054. if (getenv('YII_ENV') == 'dev') {
  1055. $name = '花美灵';
  1056. }
  1057. $merchant = MerchantService::getByCondition(['name' => $name]);
  1058. $list = wxUtil::getSubscribeUserList($merchant);
  1059. dd($list);
  1060. }
  1061. //宝贝售出提醒 ssh 2020.1.30
  1062. public function actionInform()
  1063. {
  1064. $merchant = MerchantService::getMerchantById(12362);
  1065. $order = OrderService::getById(214810);
  1066. InformAdminClass::sendComplete($order);
  1067. }
  1068. public function actionNotice()
  1069. {
  1070. $data = ['messageType' => 'inform', 'informWay' => 'wx', 'userType' => 'admin', 'id' => 6, 'mobile' => '15280215347'];
  1071. $producer = Yii::$app->rabbitmq->getProducer('informProducer');
  1072. echo '<pre>';
  1073. print_r($data);
  1074. $msg = serialize($data);
  1075. $r = $producer->publish($msg, 'informExchange', 'informRoute');
  1076. }
  1077. }