'ok']); //error_reporting(E_ALL); $post = Yii::$app->request->post(); $mtOrderId = $post['order_id'] ?? 0; $thirdSn = $post['day_seq'] ?? 0; //4秒内不允许第三方重复通知 $cacheKey = 'mt_finish_order_' . $mtOrderId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { Yii::info("美团推送完成订单报错,出现重复通知,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}"); return Json::encode(['data' => 'ok']); } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']); // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回 if (empty($post)) { return Json::encode(['data' => 'ok']); } Yii::info('confirmOrderData: ' . json_encode($post)); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shopId = $post['app_poi_code'] ?? ''; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { noticeUtil::push("美团推送完成订单报错,没有找到门店,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (empty($shopExt)) { noticeUtil::push("美团推送完成订单报错,没有找到门店拓展信息,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $mainId = $shop->mainId ?? 0; $sjId = $shop->sjId ?? 0; $customId = $shop->defaultCustomId ?? 0; if (empty($customId)) { noticeUtil::push("美团推送完成订单报错,没有找到客户哦,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $custom = CustomClass::getById($customId); if (empty($custom)) { noticeUtil::push("美团推送完成订单报错,没有找到客户,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $order = OrderClass::getByCondition(['fromType' => 4, 'thirdOrderId' => $mtOrderId], true); if (empty($order)) { noticeUtil::push("美团推送完成订单报错,没有找到客户,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } if ($order->status != 2 || $order->status != 3) { noticeUtil::push("美团推送完成订单报错,订单不是待完成订单,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } //开发中,待完成 $transaction->commit(); return Json::encode(['data' => 'ok']); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push("确认订单报错了,美团订单id:{$mtOrderId} 美团编号:{$thirdSn},错误信息:{$msg}", '15280215347'); return Json::encode(['data' => 'ok']); } } public function actionGoodsAdd() { return Json::encode(['data' => 'ok']); $post = Yii::$app->request->post(); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { if (isset($post['retail_data']) == false) { //noticeUtil::push("..美团添加商品,通知我们时出错了,没有获取到请求的具体信息", '15280215347'); return Json::encode(['data' => 'ok']); Yii::$app->end(); } $retailData = $post['retail_data']; $retail = urldecode(urldecode($retailData)); $info = json_decode($retail); $obj = $info[0] ?? null; $shopId = $obj->app_poi_code ?? 0; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有找到门店", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $sjId = $shop->sjId ?? 0; $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (empty($ext)) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有找到门店拓展信息", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $mainId = $shop->mainId ?? 0; if (empty($mainId)) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有main信息24", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true); if (empty($mtCategory)) { $mtCategory = CategoryClass::add(['style' => 1, 'categoryName' => '美团', 'mainId' => $mainId, 'sjId' => $sjId], true); } $catId = $mtCategory->id ?? 0; if (empty($catId)) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有美团的分类id", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $config = dict::getDict('mtConfig'); $app = new Application($config); $accessToken = mtUtil::getAccessToken($ext); $appSpuCode = $obj->app_spu_code ?? ''; $hasGoods = GoodsClass::getByCondition(['mainId' => $mainId, 'spu' => $appSpuCode], true); if (!empty($hasGoods)) { noticeUtil::push("..美团添加商品,通知我们时,发现已经有这个商品了,mainId:{$mainId} spu:{$appSpuCode}", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $params = ['app_poi_code' => (string)$shopId, 'app_spu_code' => $appSpuCode, 'access_token' => $accessToken]; $goodsInfo = $app->retail->getDetail($params); Yii::info('获取商品详情:' . $goodsInfo . ' ' . json_encode($params)); $goodsInfo = json_decode($goodsInfo, true); if (isset($goodsInfo['error'])) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有找到商品!", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } $imgString = $goodsInfo['data']['picture'] ?? ''; if (empty($imgString)) { noticeUtil::push("..美团添加商品,通知我们时出错了,没有商品图片...", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } noticeUtil::push("..美团添加商品,通知我们,商品图片:" . $imgString); $goodsName = $goodsInfo['data']['name'] ?? ''; $goodsPrice = $goodsInfo['data']['price'] ?? ''; $description = $goodsInfo['data']['description'] ?? ''; $sh = strstr($description, '【鲜花】') !== false ? 1 : 0; $shopImg = []; $cover = ''; $imgArr = explode(',', $imgString); if (!empty($imgArr)) { foreach ($imgArr as $imgUrl) { $shortUrl = httpUtil::downloadRemoteImg($sjId, $shopId, $imgUrl); $shopImg[] = $shortUrl; if ($cover == '') { $cover = $shortUrl; } } } $catIds = [$catId]; $addData = [ 'name' => $goodsName, 'flower' => 1, 'property' => 0, 'price' => $goodsPrice, 'sjId' => $sjId, 'mainId' => $mainId, 'shopId' => $shopId, 'status' => 0, 'delStatus' => 0, 'shopImg' => $shopImg, 'catIds' => $catIds, 'cover' => $cover, 'spu' => $appSpuCode, 'sh' => $sh, ]; GoodsClass::addGoods($addData); $transaction->commit(); return Json::encode(['data' => 'ok']); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push("..美团添加商品,通知我们时出错了,错误信息:{$msg}", '15280215347'); //return Json::encode(['data' => 'ok']); Yii::$app->end(); } } //删除商品 ssh 20220914 public function actionGoodsDel() { return Json::encode(['data' => 'ok']); $post = Yii::$app->request->post(); if (isset($post['retail_data']) == false) { //noticeUtil::push("美团删除商品,通知我们时出错了,没有获取到相应信息", '15280215347'); return Json::encode(['data' => 'ok']); } $retailData = $post['retail_data']; $retail = urldecode(urldecode($retailData)); $info = json_decode($retail); $obj = $info[0] ?? null; $shopId = $obj->app_poi_code ?? 0; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { noticeUtil::push("美团删除商品,通知我们时出错了,没有找到门店", '15280215347'); return Json::encode(['data' => 'ok']); } $sjId = $shop->sjId ?? 0; $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (empty($ext)) { noticeUtil::push("美团删除商品,通知我们时出错了,没有找到门店拓展信息", '15280215347'); return Json::encode(['data' => 'ok']); } $mainId = $shop->mainId ?? 0; if (empty($mainId)) { noticeUtil::push("美团删除商品,通知我们时出错了,没有main信息25", '15280215347'); return Json::encode(['data' => 'ok']); } $mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true); if (empty($mtCategory)) { $mtCategory = CategoryClass::add(['style' => 1, 'categoryName' => '美团', 'mainId' => $mainId, 'sjId' => $sjId], true); } $catId = $mtCategory->id ?? 0; if (empty($catId)) { noticeUtil::push("美团删除商品,通知我们时出错了,没有美团的分类id", '15280215347'); return Json::encode(['data' => 'ok']); } $appSpuCode = $obj->app_spu_code ?? ''; $hasGoods = GoodsClass::getByCondition(['mainId' => $mainId, 'spu' => $appSpuCode], true); if (empty($hasGoods)) { return Json::encode(['data' => 'ok']); } $hasGoods->delStatus = 1; $hasGoods->save(); $goodsId = $hasGoods->id ?? 0; GoodsCategoryClass::updateByCondition(['gId' => $goodsId], ['delStatus' => 1]); return Json::encode(['data' => 'ok']); } //修改商品 ssh 20220914 public function actionGoodsUpdate() { return Json::encode(['data' => 'ok']); $post = Yii::$app->request->post(); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { if (isset($post['retail_data']) == false) { //noticeUtil::push("美团修改商品,通知我们时出错了,没有获取到相应信息", '15280215347'); return Json::encode(['data' => 'ok']); } $retailData = $post['retail_data']; $retail = urldecode(urldecode($retailData)); $info = json_decode($retail); $obj = $info[0] ?? null; $shopId = $obj->app_poi_code ?? 0; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { noticeUtil::push("美团修改商品,通知我们时出错了,没有找到门店", '15280215347'); return Json::encode(['data' => 'ok']); } $sjId = $shop->sjId ?? 0; $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (empty($ext)) { noticeUtil::push("美团修改商品,通知我们时出错了,没有找到门店拓展信息", '15280215347'); return Json::encode(['data' => 'ok']); } $mainId = $shop->mainId ?? 0; if (empty($mainId)) { noticeUtil::push("美团修改商品,通知我们时出错了,没有main信息26", '15280215347'); return Json::encode(['data' => 'ok']); } $mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true); if (empty($mtCategory)) { $mtCategory = CategoryClass::add(['style' => 1, 'categoryName' => '美团', 'mainId' => $mainId, 'sjId' => $sjId], true); } $catId = $mtCategory->id ?? 0; if (empty($catId)) { noticeUtil::push("美团修改商品,通知我们时出错了,没有美团的分类id", '15280215347'); return Json::encode(['data' => 'ok']); } $config = dict::getDict('mtConfig'); $app = new Application($config); $accessToken = mtUtil::getAccessToken($ext); $appSpuCode = $obj->app_spu_code ?? ''; $hasGoods = GoodsClass::getByCondition(['mainId' => $mainId, 'spu' => $appSpuCode], true); if (empty($hasGoods)) { noticeUtil::push("美团修改商品,通知我们时,没有发现这个商品,mainId:{$mainId} spu:{$appSpuCode}", '15280215347'); return Json::encode(['data' => 'ok']); } $hasGoodsId = $hasGoods->id ?? 0; $params = ['app_poi_code' => $shopId, 'app_spu_code' => $appSpuCode, 'access_token' => $accessToken]; $goodsInfo = $app->retail->getDetail($params); Yii::info('获取商品详情:' . $goodsInfo . ' ' . json_encode($params)); $goodsInfo = json_decode($goodsInfo, true); if (isset($goodsInfo['error'])) { noticeUtil::push("美团修改商品,通知我们时出错了,没有找到商品图片", '15280215347'); return Json::encode(['data' => 'ok']); } $imgString = $goodsInfo['data']['picture'] ?? ''; if (empty($imgString)) { noticeUtil::push("美团修改商品,通知我们时出错了,没有商品图片...", '15280215347'); return Json::encode(['data' => 'ok']); } $goodsName = $goodsInfo['data']['name'] ?? ''; $goodsPrice = $goodsInfo['data']['price'] ?? ''; $description = $goodsInfo['data']['description'] ?? ''; $sh = strstr($description, '【鲜花】') !== false ? 1 : 0; $currentStr = md5($goodsName . '_' . $goodsPrice . '_' . $description . '_' . $sh . '_' . $imgString); $cacheKey = 'mt_goods_id_' . $hasGoodsId; $cacheStr = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if ($cacheStr == $currentStr) { //商品没有更新 return Json::encode(['data' => 'ok']); } else { Yii::$app->redis->executeCommand('SET', [$cacheKey, $currentStr]); } noticeUtil::push("美团修改商品,通知我们,商品图片:" . $imgString); $shopImg = []; $cover = ''; $imgArr = explode(',', $imgString); if (!empty($imgArr)) { foreach ($imgArr as $imgUrl) { $shortUrl = httpUtil::downloadRemoteImg($sjId, $shopId, $imgUrl); $shopImg[] = $shortUrl; if ($cover == '') { $cover = $shortUrl; } } } $hasGoods->price = $goodsPrice; $hasGoods->name = $goodsName; $hasGoods->cover = $cover; $hasGoods->sh = $sh; $hasGoods->shopImg = json_encode($shopImg); $hasGoods->save(); $transaction->commit(); return Json::encode(['data' => 'ok']); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push("美团修改商品,通知我们时出错了,错误信息:{$msg}", '15280215347'); return Json::encode(['data' => 'ok']); } } //已确认订单通知 public function actionConfirmOrder() { return Json::encode(['data' => 'ok']); //error_reporting(E_ALL); $post = Yii::$app->request->post(); $mtOrderId = $post['order_id'] ?? 0; $thirdSn = $post['day_seq'] ?? 0; //4秒内不允许第三方重复通知 $cacheKey = 'mt_confirm_order_' . $mtOrderId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { Yii::info("美团已确认订单通知,出现重复通知,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}"); return Json::encode(['data' => 'ok']); } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']); // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回 if (empty($post)) { return Json::encode(['data' => 'ok']); } Yii::info('confirmOrderData: ' . json_encode($post)); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shopId = $post['app_poi_code'] ?? ''; $shop = ShopClass::getById($shopId, true); if (empty($shop)) { noticeUtil::push("美团确认订单报错,没有找到门店,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (empty($shopExt)) { noticeUtil::push("美团确认订单报错,没有找到门店拓展信息,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $mainId = $shop->mainId ?? 0; $sjId = $shop->sjId ?? 0; $customId = $shop->defaultCustomId ?? 0; if (empty($customId)) { noticeUtil::push("美团确认订单报错,没有找到客户哦,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $custom = CustomClass::getById($customId); if (empty($custom)) { noticeUtil::push("美团确认订单报错,没有找到客户,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } foreach ($post as $k => $val) { $post[$k] = urldecode($val); } MtOrderClass::add($post); $detail = $post['detail'] ?? ''; if (empty($detail)) { noticeUtil::push("美团确认订单报错,没有找到商品,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $mtGoodsData = json_decode($detail, true); if (empty($mtGoodsData)) { noticeUtil::push("美团确认订单报错,没有找到商品哦,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } Yii::info('商品信息:' . json_encode($mtGoodsData)); $productList = []; $mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true); if (empty($mtCategory)) { $mtCategory = CategoryClass::add(['style' => 1, 'categoryName' => '美团', 'mainId' => $mainId, 'sjId' => $sjId], true); } $catId = $mtCategory->id ?? 0; if (empty($catId)) { noticeUtil::push("美团确认订单报错,美团默认分类没有找到,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $caution = isset($post['caution']) && !empty($post['caution']) ? $post['caution'] : ''; $remark = $caution; $bookMobile = $post['order_phone_number'] ?? ''; $receiveMobile = $post['recipient_phone'] ?? ''; $receiveUserName = $post['recipient_name'] ?? ''; $fullAddress = $post['recipient_address'] ?? ''; $cover = ''; $goodsNum = 0; foreach ($mtGoodsData as $mtKey => $mtGoods) { $mtGoodsSpu = $mtGoods['app_spu_code'] ?? ''; if (empty($mtGoodsSpu)) { if (isset($mtGoods['app_food_code']) && !empty($mtGoods['app_food_code'])) { $mtGoodsSpu = $mtGoods['app_food_code']; } } $goodsPrice = $mtGoods['price'] ?? 0; $num = $mtGoods['quantity'] ?? 0; $goodsNum = bcadd($num, $goodsNum); $currentGoods = GoodsClass::getByCondition(['spu' => $mtGoodsSpu], true); if (empty($currentGoods)) { noticeUtil::push("美团确认订单报错,数据库没有相应商品,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); return Json::encode(['data' => 'ok']); } $id = $currentGoods->id ?? 0; $unitType = 0; $property = dict::getDict('property', 'goods'); $goods = [['productId' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $goodsPrice, 'property' => $property]]; $productList = array_merge($goods, $productList); } $poi_receive_detail_yuan = $post['poi_receive_detail_yuan'] ?? ''; if (empty($poi_receive_detail_yuan)) { noticeUtil::push("美团确认订单报错,订单金额有问题,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); util::stop(); } $poi_receive_detail_yuan_data = json_decode($poi_receive_detail_yuan, true); if (is_array($poi_receive_detail_yuan_data) == false) { noticeUtil::push("美团确认订单报错,订单金额有问题哦,美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); util::stop(); } $onlinePayment = $poi_receive_detail_yuan_data['onlinePayment'] ?? 0; if ($onlinePayment == 0) { noticeUtil::push("美团确认订单报错,订单金额有问题!美团订单id:{$mtOrderId} 美团编号:{$thirdSn}", '15280215347'); util::stop(); } $modifyPrice = $onlinePayment; //技术服务费 $foodShareFeeChargeByPoi = $poi_receive_detail_yuan_data['foodShareFeeChargeByPoi'] ?? 0; $reconciliationExtras = $poi_receive_detail_yuan_data['reconciliationExtras'] ?? ''; //履约服务费 $performanceServiceFee = 0; if (!empty($reconciliationExtras)) { $extArr = json_decode($reconciliationExtras, true); $performanceServiceFee = $extArr['performanceServiceFee'] ?? 0; } //运费 $sendCost = $post['shipping_fee'] ?? 0; //打包费 $labourCost = $post['package_bag_money_yuan'] ?? 0; //服务费和手续费 $serviceFee = bcadd($foodShareFeeChargeByPoi, $performanceServiceFee, 2); $estimate_arrival_time = $post['estimate_arrival_time'] ?? 0; $reachPeriod = date("H:i", $estimate_arrival_time); $reachDate = date("Y-m-d", $estimate_arrival_time); $reachTime = $estimate_arrival_time; $orderData = [ 'product' => $productList, 'fromType' => dict::getDict('fromType', 'mt'), 'labourCost' => $labourCost, 'sendCost' => $sendCost, 'shopId' => $shopId, 'mainId' => $mainId, 'sjId' => $sjId, 'modifyPrice' => $modifyPrice, 'serviceFee' => $serviceFee, 'thirdSn' => $thirdSn, 'cover' => $cover, 'reachTime' => $reachTime, 'reachDate' => $reachDate, 'reachPeriod' => $reachPeriod, 'remark' => $remark, 'goodsNum' => $goodsNum, 'bookMobile' => $bookMobile, 'receiveMobile' => $receiveMobile, 'receiveUserName' => $receiveUserName, 'fullAddress' => $fullAddress, 'thirdOrderId' => $mtOrderId, ]; $hasPay = dict::getDict('hasPay', 'payed'); //多处调用这个方法,注意同步修改,搜索关键词 createHdNewOrder 这个没有维护,可以不用考虑 $order = OrderService::createHdOrder($orderData, $custom, $hasPay); $transaction->commit(); //新制作单提示 $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); ShopExtClass::newWorkRemind($shopExt, $order); return Json::encode(['data' => 'ok']); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push("确认订单报错了,美团订单id:{$mtOrderId} 美团编号:{$thirdSn},错误信息:{$msg}", '15280215347'); return Json::encode(['data' => 'ok']); } } //取消订单 public function actionCancelOrder() { return Json::encode(['data' => 'ok']); $post = Yii::$app->request->post(); $mtOrderId = $post['order_id'] ?? 0; $shopId = $post['app_poi_code'] ?? ''; if (empty($post)) { return Json::encode(['data' => 'ok']); } Yii::info('cancelOrderData: ' . json_encode($post)); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { //4秒内不允许第三方重复通知 $cacheKey = 'mt_cancel_order_' . $mtOrderId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { Yii::info("美团取消订单通知,出现重复通知,orderId:{$mtOrderId}"); return Json::encode(['data' => 'ok']); } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']); $mt = dict::getDict('fromType', 'mt'); $order = OrderClass::getByCondition(['fromType' => $mt, 'thirdOrderId' => $mtOrderId], true); if (empty($order)) { //没有接单时取消订单 return Json::encode(['data' => 'ok']); } //订单取消,金额全部退还 $shop = ShopClass::getById($shopId, true); if (empty($shop)) { return Json::encode(['data' => 'ok']); } $sjId = $shop->sjId ?? 0; $mainId = $shop->mainId ?? 0; $post = []; $post['price'] = $order->actPrice ?? 0; $post['refundType'] = HdRefundClass::REFUND_TYPE_MONEY_GOOD; $post['id'] = $order->id ?? 0; $post['shopId'] = $shopId; $post['sjId'] = $sjId; $post['shopAdminId'] = 0; $post['mainId'] = $mainId; $post['shopAdminName'] = '美团APP'; $orderSn = $order->orderSn ?? ''; $orderGoods = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); $productData = []; if (!empty($orderGoods)) { foreach ($orderGoods as $goodsItem) { $productData[] = ['productId' => $goodsItem->goodsId, 'num' => $goodsItem->num, 'unitPrice' => $goodsItem->unitPrice, 'property' => 0,]; } } $orderItem = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($orderItem)) { foreach ($orderItem as $singe) { $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1,]; } } $post['product'] = $productData; HdRefundService::addRefund($post, $order); $transaction->commit(); DistributionCommissionClass::tryCalcDistributionAfterPay((int)($order->id ?? 0)); //制作单取消通知 $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); ShopExtClass::orderCancelRemind($shopExt, $order); return Json::encode(['data' => 'ok']); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push("取消报错了,美团订单id:{$mtOrderId} ,错误信息:{$msg}", '15280215347'); return Json::encode(['data' => 'ok']); } } //推送已支付订单 public function actionNewOrder() { return Json::encode(['data' => 'ok']); } //部分退款 public function actionPartRefund() { return Json::encode(['data' => 'ok']); } //全部退款 public function actionAllRefund() { return Json::encode(['data' => 'ok']); } }