ThirdOrderLogic.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <?php
  2. namespace app\common\logic;
  3. use app\api\logic\LoginLogic;
  4. use app\common\{enum\GoodsEnum,
  5. enum\PayEnum,
  6. enum\WorkEnum,
  7. model\goods\Goods,
  8. model\orders\RechargeOrder,
  9. model\recharge\OrderGoods,
  10. model\setting\PostageRegion,
  11. model\third\ThirdGoods,
  12. model\third\ThirdOrders,
  13. model\user\User,
  14. model\works\ServiceWork,
  15. model\works\ServiceWorkLog};
  16. use think\facade\Db;
  17. use app\common\model\service_area\ServiceArea;
  18. /**
  19. * 第三方平台下单逻辑层
  20. * Class UserLogic
  21. * @package app\shopapi\logic
  22. */
  23. class ThirdOrderLogic extends BaseLogic
  24. {
  25. protected const user_token = [
  26. "accessToken"=>"V2-29d801e316e9ec4eb88b3b9abd8dbda490367af539d97d754420056dc5c1329a2c1aff7d4d54729ff622d96ff7c9910aa930f7b7ad27910d199c15029ffc71aa4a84142d75b60f4a34b71a8390a89d8c01a4dd385232e4e9c9204fb5934eda89",
  27. "expireIn"=> 2592000,
  28. "opBizCode"=> "AG5MALO18KG6I5DL8LVONRSRF5G",
  29. "opBizName"=> "武汉开源节流科技有限公司",
  30. "refreshToken"=> "ab8d15b4028b7bd6aca383d230b87450436d301a2996b6bb3151d668dd2d015d68d8393e66fb2a59aa10146c70dd30728b473358ec0d156dc0bc5cc5e574a109a5680ab49c393fa9d2693ef5519ff41a16115b81259b58c71a54d79e23f26381",
  31. "scope"=> "dingdan,generalreserve,merchantreceipt,shangpin"
  32. ];
  33. protected const shop_token1 = [
  34. "accessToken"=> "V2-9667b1ce4ffaabe453d4ce847888c788c9c61762df9230ab342caf33e2b4a735a384288379641f64bb2f4272c88d44db42b080ef237cb0c5e3ae49466d72f5c1b17e8a34991e131e91a24e9947f046027af6bbbbc24e0155f6cd4d738e19b5c0",
  35. "expireIn"=> 2592000,
  36. "opBizCode"=> "AH14KGRJ76O8PFH4GCO67F0CUKC",
  37. "opBizName"=> "众盾闪修 家电清洗 武汉",
  38. "refreshToken"=> "fd3da11174eed4c3d6b4d117f87ab7b62a72603627d2d597bed82dddb1036943b8e76e2959c0c4b3cf7b33ec4664bedbca3ef14dd070f662582a1b6695077577e2268c6a42ca519fda331c7e1cdbc0919af8052151ce9ae0a658d346307ca0c1",
  39. "scope"=> "merchantdata,poiqrcode,tuangou,ugc,yuding"
  40. ];
  41. protected const shop_token2 = [
  42. "accessToken"=> "V2-26f91ef8b515c59b97b9b4404e77dc2b2fc14b9715e3be7edb9f3f86178e193ec380e1ef5a9ab7a877120a94bcae4586707c51ab5e56cfeb4cd91d4fb2983babbbfd2fda0f77353eb21b105fd14299aea392a706589a422baec961b6cc255191",
  43. "expireIn"=> 2592000,
  44. "opBizCode"=> "AE7MKOJAV67338LIC3UD0K5TGIO",
  45. "opBizName"=> "众盾闪修 家电维修 武汉",
  46. "refreshToken"=> "bd57846c8817125f8ad7f4eb4ccad4af80c808f30c8b22e38476fc78c008b568ca8bcd8a027740023f2bcab5c0f6f062fb8a6e8f588cff53512a057c2e97a7b1789fb9fe9dc4b3fc2abf42dd753341c455e6eacb7a5e19dd4894bf1d93db9abf",
  47. "scope"=> "merchantdata,poiqrcode,tuangou,ugc,yuding"
  48. ];
  49. protected const developerId = 114657;
  50. protected const assessKey = '8471lgvnv0qcjpx6';
  51. /**
  52. * 处理订单
  53. * @param array $order
  54. * @return bool
  55. * @throws \think\db\exception\DataNotFoundException
  56. * @throws \think\db\exception\DbException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. */
  59. public static function orderhandle(array $order)
  60. {
  61. $message = json_decode($order['message'], true);
  62. //查询用户是否存在
  63. $userName = $message['userName'];
  64. $mobile = $message['mobile'];
  65. $userAddress = json_decode($message['userAddress']);
  66. $user = User::where(['mobile' =>$mobile])->findOrEmpty();
  67. $product_message = json_decode($message['products'],true);
  68. if($user->isEmpty()){
  69. $user = LoginLogic::register([
  70. 'password'=>'123456',
  71. 'account'=>$userName,
  72. 'mobile'=>$mobile,
  73. 'channel'=>1,
  74. 'user_type'=>0
  75. ]);
  76. }
  77. //查询美团商品和平台商品的对应关系
  78. $productId = $message['productId'];
  79. $product = ThirdGoods::where(['third_type'=>1,'product_id'=>$productId])->findOrEmpty();
  80. //生成第三方订单信息
  81. $orderData = [
  82. 'orderId'=>$message['orderId'],
  83. 'uni_order_id'=>$product_message[0]['uni_order_id'],
  84. 'productId'=>$message['productId'],
  85. 'productName'=>$message['productName'],
  86. 'request_msg'=>json_encode($order,JSON_UNESCAPED_UNICODE),
  87. 'bookStatus'=>1,
  88. 'third_type'=>1,//美团
  89. ];
  90. //判断美团的预约订单是否生成
  91. if(!$product->isEmpty()){
  92. //查询美团预约订单是否生成
  93. $thirdOrder = ThirdOrders::where(['uni_order_id'=>$product_message[0]['uni_order_id']])->findOrEmpty();
  94. if(!$thirdOrder->isEmpty() and $thirdOrder['work_id'] != 0){
  95. //生成第三方订单信息
  96. $orderData['sync_status'] = 1;
  97. $orderData['work_id'] = $thirdOrder['work_id'];
  98. }
  99. }
  100. $thirdOrders = ThirdOrders::where('orderId',$message['orderId'])->findOrEmpty();
  101. //生成未同步预约订单信息
  102. if($thirdOrders->isEmpty()){
  103. $thirdOrders = ThirdOrders::create($orderData);
  104. }
  105. if(!$thirdOrders->isEmpty()){
  106. $orderData['work_id'] = $thirdOrders->work_id;
  107. }
  108. if(empty($orderData['work_id']) and !$product->isEmpty() and !empty($product['goods_id'])){
  109. $goods = Goods::findOrEmpty($product['goods_id']);
  110. $pattern = '/(?:省|市)([\w\s]+市)/u';
  111. Db::startTrans();
  112. try {
  113. if (preg_match($pattern, $userAddress->receiver_address, $matches)) {
  114. $city = $matches[1];
  115. }
  116. $area_city = PostageRegion::where(['level'=>2,'name'=>$city])->value('id');
  117. //生成服务工单
  118. $work_data = [
  119. 'work_sn' => generate_sn(ServiceWork::class, 'work_sn'),
  120. 'real_name' => $userName,
  121. 'mobile' => $mobile,
  122. 'address' => $userAddress->receiver_address,
  123. 'province' => 0,
  124. 'city' => $area_city??0,
  125. 'area_name' => $userAddress->receiver_address,
  126. 'title' => $goods->goods_name,
  127. 'category_type' => $goods['category_type'],
  128. 'goods_category_ids' => $goods['goods_category_ids'],
  129. 'goods_category_id' => $goods['goods_category_id'],
  130. 'base_service_fee' => $goods['base_service_fee'],
  131. 'service_fee' => $product['product_price'],
  132. 'work_pay_status'=>WorkEnum::IS_PAY_STATUS,
  133. 'appointment_time' => strtotime($message['begintime']),
  134. 'user_id'=>$user['id'],
  135. 'lon'=>!empty($userAddress->longitude)?$userAddress->longitude:0,
  136. 'lat'=>!empty($userAddress->latitude)?$userAddress->latitude:0,
  137. 'property_activity_id'=>0,
  138. 'user_equity_id'=>0,
  139. 'third_type'=>1,
  140. 'work_total'=>$product['product_price'],
  141. 'work_amount'=>$product['product_price']
  142. ];
  143. $service_area_id = ServiceArea::serviceAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
  144. $work_data['service_area_id'] = $service_area_id;
  145. $service_work = ServiceWork::create($work_data);
  146. //生成服务订单
  147. $data = [
  148. 'work_id'=> $service_work['id'],
  149. 'sn' => generate_sn(RechargeOrder::class, 'sn'),
  150. 'order_type'=>0,//服务订单
  151. 'order_terminal' => 1,
  152. 'payment_type'=>$goods['goods_payment_type']==GoodsEnum::ISGOODS_PAYMENT_TYPE?0:1,
  153. 'user_id' => $user['id'],
  154. 'pay_status' => PayEnum::ISPAID,
  155. 'coupon_id'=>0,
  156. 'coupon_price'=>0,
  157. 'pay_way' => 4,
  158. 'order_total' => $product['product_price'],
  159. 'order_amount' => $product['product_price'],
  160. 'paid_amount'=> $product['product_price'],
  161. ];
  162. $order = RechargeOrder::create($data);
  163. //生成订单服务详情
  164. OrderGoods::create([
  165. 'sn' => $order['sn'],
  166. 'goods_id' => $goods['id'],
  167. 'category_type' => $goods['category_type'],
  168. 'goods_category_ids' => $goods['goods_category_ids'],
  169. 'goods_category_id' => $goods['goods_category_id'],
  170. 'goods_name' => $goods['goods_name'],
  171. 'goods_image' => $goods['goods_image'],
  172. 'goods_video' => $goods['goods_video'],
  173. 'goods_number' => $goods['goods_number'],
  174. 'good_unit' => $goods['good_unit'],
  175. 'goods_size' => $goods['goods_size'],
  176. 'goods_type' => $goods['goods_type'],
  177. 'goods_brand' => $goods['goods_brand'],
  178. 'install_guide' => $goods['install_guide'],
  179. 'goods_payment_type'=>$goods['goods_payment_type'],
  180. 'base_service_fee' => $goods['base_service_fee'],
  181. 'service_total' => $goods['service_total'],
  182. 'service_fee' => $product['product_price'],
  183. 'service_image' => $goods['service_image'],
  184. 'warranty_period'=>$goods['warranty_period'],
  185. 'fee_schedule' => $goods['fee_schedule'],
  186. 'goods_status' => $goods['goods_status'],
  187. ]);
  188. //判断是否是一口价预支付订单,支付成功后生成尾款订单
  189. if(!$goods->isEmpty() and $goods->goods_payment_type == 3 and bcsub($goods->base_service_fee,$goods->service_fee,2)>=0){
  190. //新增待支付尾款
  191. $order_weikuan_data = [
  192. 'order_type'=>$order['order_type'],
  193. 'sn'=>generate_sn(\app\common\model\orders\RechargeOrder::class, 'sn'),
  194. 'work_id'=>$order['work_id'],
  195. 'user_id'=>$order['user_id'],
  196. 'payment_type'=>2,
  197. 'order_total'=>bcsub($goods->base_service_fee,$product['product_price'],2),
  198. 'order_amount'=>bcsub($goods->base_service_fee,$product['product_price'],2),
  199. 'order_terminal'=>$order['order_terminal']
  200. ];
  201. \app\common\model\recharge\RechargeOrder::create($order_weikuan_data);
  202. }
  203. $thirdOrders->work_id = $service_work->id;
  204. $thirdOrders->save();
  205. self::bookresultcallback($order['opBizCode'],$message['orderId'],2);
  206. Db::commit();
  207. } catch (\Exception $e) {
  208. Db::rollback();
  209. self::setError($e->getMessage());
  210. return false;
  211. }
  212. }
  213. return true;
  214. }
  215. //手动添加订单
  216. public static function submitOrders(array $message)
  217. {
  218. //查询用户是否存在
  219. $userName = $message['userName'];
  220. $mobile = $message['mobile'];
  221. $user = User::where(['mobile' =>$mobile])->findOrEmpty();
  222. if($user->isEmpty()){
  223. $user = LoginLogic::register([
  224. 'password'=>'123456',
  225. 'account'=>$userName,
  226. 'mobile'=>$mobile,
  227. 'channel'=>1,
  228. 'user_type'=>0,
  229. ]);
  230. }
  231. $goods = Goods::findOrEmpty($message['goods_id']);
  232. $pattern = '/(?:省|市)([\w\s]+市)/u';
  233. Db::startTrans();
  234. try {
  235. if (preg_match($pattern, $message['userAddress'], $matches)) {
  236. $city = $matches[1];
  237. }
  238. $area_city = PostageRegion::where(['level'=>2,'name'=>$city])->value('id');
  239. //生成服务工单
  240. $work_data = [
  241. 'work_sn' => generate_sn(ServiceWork::class, 'work_sn'),
  242. 'real_name' => $userName,
  243. 'mobile' => $mobile,
  244. 'address' => $message['userAddress'],
  245. 'province' => 0,
  246. 'city' => $area_city??0,
  247. 'area_name' => $area_city??'',
  248. 'title' => $goods->goods_name,
  249. 'category_type' => $goods['category_type'],
  250. 'goods_category_ids' => $goods['goods_category_ids'],
  251. 'goods_category_id' => $goods['goods_category_id'],
  252. 'base_service_fee' => $goods['base_service_fee'],
  253. 'service_fee' => $message['amount'],
  254. 'work_pay_status'=>WorkEnum::IS_PAY_STATUS,
  255. 'appointment_time' => strtotime($message['appointment_time']),
  256. 'user_id'=>$user['id'],
  257. 'lon'=>$message['lon'],
  258. 'lat'=>$message['lat'],
  259. 'property_activity_id'=>0,
  260. 'user_equity_id'=>0,
  261. 'third_type'=>1,
  262. 'work_total'=>$goods['base_service_fee'],
  263. 'work_amount'=>$goods['base_service_fee']
  264. ];
  265. $service_area_id = ServiceArea::serviceAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
  266. $work_data['service_area_id'] = $service_area_id;
  267. $service_work = ServiceWork::create($work_data);
  268. //生成服务订单
  269. $data = [
  270. 'work_id'=> $service_work['id'],
  271. 'sn' => generate_sn(RechargeOrder::class, 'sn'),
  272. 'order_type'=>0,//服务订单
  273. 'order_terminal' => 1,
  274. 'payment_type'=>$goods['goods_payment_type']==GoodsEnum::ISGOODS_PAYMENT_TYPE?0:1,
  275. 'user_id' => $user['id'],
  276. 'pay_status' => PayEnum::ISPAID,
  277. 'coupon_id'=>0,
  278. 'coupon_price'=>0,
  279. 'pay_way' => 4,
  280. 'order_total' => $message['amount'],
  281. 'order_amount' => $message['amount'],
  282. 'paid_amount'=>$message['amount']
  283. ];
  284. $order = RechargeOrder::create($data);
  285. //生成订单服务详情
  286. OrderGoods::create([
  287. 'sn' => $order['sn'],
  288. 'goods_id' => $goods['id'],
  289. 'category_type' => $goods['category_type'],
  290. 'goods_category_ids' => $goods['goods_category_ids'],
  291. 'goods_category_id' => $goods['goods_category_id'],
  292. 'goods_name' => $goods['goods_name'],
  293. 'goods_image' => $goods['goods_image'],
  294. 'goods_video' => $goods['goods_video'],
  295. 'goods_number' => $goods['goods_number'],
  296. 'good_unit' => $goods['good_unit'],
  297. 'goods_size' => $goods['goods_size'],
  298. 'goods_type' => $goods['goods_type'],
  299. 'goods_brand' => $goods['goods_brand'],
  300. 'install_guide' => $goods['install_guide'],
  301. 'goods_payment_type'=>$goods['goods_payment_type'],
  302. 'base_service_fee' => $goods['base_service_fee'],
  303. 'service_total' => $goods['service_total'],
  304. 'service_fee' => $message['amount'],
  305. 'service_image' => $goods['service_image'],
  306. 'warranty_period'=>$goods['warranty_period'],
  307. 'fee_schedule' => $goods['fee_schedule'],
  308. 'goods_status' => $goods['goods_status'],
  309. ]);
  310. //判断是否是一口价预支付订单,支付成功后生成尾款订单
  311. if(!$goods->isEmpty() and $goods->goods_payment_type == 3 and bcsub($goods->base_service_fee,$goods->service_fee,2)>=0){
  312. //新增待支付尾款
  313. $order_weikuan_data = [
  314. 'order_type'=>$order['order_type'],
  315. 'sn'=>generate_sn(\app\common\model\orders\RechargeOrder::class, 'sn'),
  316. 'work_id'=>$order['work_id'],
  317. 'user_id'=>$order['user_id'],
  318. 'payment_type'=>2,
  319. 'order_total'=>bcsub($goods->base_service_fee,$message['amount'],2),
  320. 'order_amount'=>bcsub($goods->base_service_fee,$message['amount'],2),
  321. 'order_terminal'=>$order['order_terminal']
  322. ];
  323. \app\common\model\recharge\RechargeOrder::create($order_weikuan_data);
  324. }
  325. Db::commit();
  326. } catch (\Exception $e) {
  327. Db::rollback();
  328. self::setError($e->getMessage());
  329. return false;
  330. }
  331. return true;
  332. }
  333. public static function get_sign($sign_key, $data)
  334. {
  335. if ($data == null) {
  336. return null;
  337. }
  338. ksort($data);
  339. $result_str = "";
  340. foreach ($data as $key => $val) {
  341. if ($key != "sign" && $val != null && $val != "") {
  342. $result_str = $result_str . $key . $val;
  343. }
  344. }
  345. $result_str = $sign_key . $result_str;
  346. $ret = bin2hex(sha1($result_str, true));
  347. return $ret;
  348. }
  349. /**
  350. * 商家接单接口
  351. * @param $orderId
  352. * @param $bookStatus
  353. * @return string
  354. */
  355. public static function bookresultcallback($opBizCode,$orderId,$bookStatus=2)
  356. {
  357. //预订结果,2-预订成功,3-预订失败
  358. $url = 'https://api-open-cater.meituan.com/ddzh/yuding/bookresultcallback';
  359. $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
  360. $data = [
  361. 'timestamp'=>time(),
  362. 'appAuthToken'=>$accessToken,
  363. 'charset'=>'utf-8',
  364. 'version'=>'2',
  365. 'developerId'=>self::developerId,
  366. 'businessId'=>58,
  367. 'biz'=>json_encode([
  368. 'orderId'=>$orderId,
  369. 'bookStatus'=>$bookStatus,
  370. "code"=>200,
  371. "type"=>2
  372. ],JSON_UNESCAPED_UNICODE)
  373. ];
  374. $sign_data = self::get_sign(self::assessKey, $data);
  375. $data['sign'] = $sign_data;
  376. return http_request($url,http_build_query($data));
  377. }
  378. /**
  379. * 取消预订
  380. * @param array
  381. * $order
  382. * @return bool
  383. */
  384. public static function cancelOrderHandle(array $order)
  385. {
  386. $message = json_decode($order['message'], true);
  387. $thirdOrders = ThirdOrders::where('orderId',$message['orderId'])->findOrEmpty();
  388. $thirdOrders->bookStatus = 3;
  389. $thirdOrders->save();
  390. Db::startTrans();
  391. try {
  392. // 04-11-12 不做任何限制强制取消,已支付的费用给工程师余额
  393. $serviceWorkInfo = ServiceWork::find($thirdOrders->work_id);
  394. if(!empty($serviceWorkInfo)){
  395. ServiceWork::where('id', $thirdOrders->work_id)->update([
  396. //'work_status' => 9,
  397. 'service_status' => 4,
  398. 'remark' => '美团取消预约订单'
  399. ]);
  400. ServiceWorkLog::create([
  401. 'work_id' => $thirdOrders->work_id,
  402. 'master_worker_id' => $serviceWorkInfo['master_worker_id'],
  403. 'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
  404. ]);
  405. }
  406. Db::commit();
  407. return true;
  408. } catch (\Exception $e) {
  409. Db::rollback();
  410. self::setError($e->getMessage());
  411. return false;
  412. }
  413. }
  414. /**
  415. * 获取美团商品信息
  416. * @param $offset
  417. * @return string
  418. */
  419. public static function queryshopdeal($offset=1)
  420. {
  421. $url = 'https://api-open-cater.meituan.com/ddzh/tuangou/deal/queryshopdeal';
  422. $data = [
  423. 'timestamp'=>time(),
  424. 'appAuthToken'=>self::shop_token2['accessToken'],
  425. 'charset'=>'utf-8',
  426. 'version'=>'2',
  427. 'developerId'=>self::developerId,
  428. 'businessId'=>58,
  429. 'biz'=>json_encode([
  430. 'offset'=>$offset,
  431. 'limit'=>100,
  432. "source"=>2,
  433. ],JSON_UNESCAPED_UNICODE)
  434. ];
  435. $sign_data = self::get_sign(self::assessKey, $data);
  436. $data['sign'] = $sign_data;
  437. return http_request($url,http_build_query($data));
  438. }
  439. /**
  440. * 获取美团商品信息
  441. * @param $offset
  442. * @return string
  443. */
  444. public static function queryshopdeal1($offset=1)
  445. {
  446. $url = 'https://api-open-cater.meituan.com/ddzh/tuangou/deal/queryshopdeal';
  447. $data = [
  448. 'timestamp'=>time(),
  449. 'appAuthToken'=>self::shop_token1['accessToken'],
  450. 'charset'=>'utf-8',
  451. 'version'=>'2',
  452. 'developerId'=>self::developerId,
  453. 'businessId'=>58,
  454. 'biz'=>json_encode([
  455. 'offset'=>$offset,
  456. 'limit'=>100,
  457. "source"=>2,
  458. ],JSON_UNESCAPED_UNICODE)
  459. ];
  460. $sign_data = self::get_sign(self::assessKey, $data);
  461. $data['sign'] = $sign_data;
  462. return http_request($url,http_build_query($data));
  463. }
  464. /**
  465. * 商家改约
  466. * @param $offset
  467. * @return string
  468. */
  469. public static function merchantmodify($data)
  470. {
  471. $url = 'https://api-open-cater.meituan.com/ddzh/yuding/lifereserve/merchantmodify';
  472. $opBizCode = !empty($data['request_msg'])?json_decode($data['request_msg'],true)['opBizCode']:'';
  473. $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
  474. $data = [
  475. 'timestamp'=>time(),
  476. 'appAuthToken'=>$accessToken,
  477. 'charset'=>'utf-8',
  478. 'version'=>'2',
  479. 'developerId'=>self::developerId,
  480. 'businessId'=>58,
  481. 'biz'=>json_encode([
  482. 'reserveOrderId'=>$data['reserveOrderId'],
  483. 'reserveUserName'=>$data['reserveUserName'],
  484. "reservePhone"=>$data['reservePhone'],
  485. "reserveAddress"=>$data['reserveAddress'],
  486. "bookStartTime"=>$data['bookStartTime'],
  487. "bookEndTime"=>$data['bookEndTime'],
  488. ],JSON_UNESCAPED_UNICODE)
  489. ];
  490. $sign_data = self::get_sign(self::assessKey, $data);
  491. $data['sign'] = $sign_data;
  492. return http_request($url,http_build_query($data));
  493. }
  494. /**
  495. * 商家取消预定
  496. * @param $offset
  497. * @return string
  498. */
  499. public static function merchantcancelorder($data)
  500. {
  501. $url = 'https://api-open-cater.meituan.com/ddzh/yuding/lifereserve/merchantcancelorder';
  502. $opBizCode = !empty($data['request_msg'])?json_decode($data['request_msg'],true)['opBizCode']:'';
  503. $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
  504. $data = [
  505. 'timestamp'=>time(),
  506. 'appAuthToken'=>$accessToken,
  507. 'charset'=>'utf-8',
  508. 'version'=>'2',
  509. 'developerId'=>self::developerId,
  510. 'businessId'=>58,
  511. 'biz'=>json_encode([
  512. 'orderId'=>$data['orderId'],
  513. 'cancelReason'=>'取消预定',
  514. "type"=>2,
  515. ],JSON_UNESCAPED_UNICODE)
  516. ];
  517. $sign_data = self::get_sign(self::assessKey, $data);
  518. $data['sign'] = $sign_data;
  519. return http_request($url,http_build_query($data));
  520. }
  521. }