TestController.php 44 KB

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