|
|
@@ -61,7 +61,6 @@ class MtController extends PublicController
|
|
|
noticeUtil::push("美团确认订单报错,没有找到门店拓展信息,美团订单id:{$mtOrderId}", '15280215347');
|
|
|
return Json::encode(['data' => 'ok']);
|
|
|
}
|
|
|
- $accessToken = mtUtil::getAccessToken($shopExt);
|
|
|
$mainId = $shop->mainId ?? 0;
|
|
|
$sjId = $shop->sjId ?? 0;
|
|
|
$customId = $shop->defaultCustomId ?? 0;
|
|
|
@@ -93,8 +92,6 @@ class MtController extends PublicController
|
|
|
|
|
|
Yii::info('商品信息:' . json_encode($mtGoodsData));
|
|
|
|
|
|
- $config = dict::getDict('mtConfig');
|
|
|
- $app = new Application($config);
|
|
|
$productList = [];
|
|
|
|
|
|
$mtCategory = CategoryClass::getByCondition(['mainId' => $mainId, 'style' => 1], true);
|
|
|
@@ -120,79 +117,24 @@ class MtController extends PublicController
|
|
|
|
|
|
$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'];
|
|
|
}
|
|
|
}
|
|
|
- $params = ['app_poi_code' => $shopId, 'app_spu_code' => $mtGoodsSpu, 'access_token' => $accessToken];
|
|
|
- $mgGoodsDetail = $app->retail->getDetail($params);
|
|
|
- Yii::info('获取商品详情:' . $mgGoodsDetail . ' ' . json_encode($params));
|
|
|
- $mgGoodsDetail = json_decode($mgGoodsDetail, true);
|
|
|
- if (isset($mgGoodsDetail['error'])) {
|
|
|
- noticeUtil::push("美团确认订单报错,没有找到商品图片,美团订单id:{$mtOrderId}", '15280215347');
|
|
|
- util::stop();
|
|
|
- }
|
|
|
- $imgString = $mgGoodsDetail['data']['picture'] ?? '';
|
|
|
- if (empty($imgString)) {
|
|
|
- noticeUtil::push("美团确认订单报错,没有商品图片,美团订单id:{$mtOrderId}", '15280215347');
|
|
|
- util::stop();
|
|
|
- }
|
|
|
- noticeUtil::push("美团确认订单,美团订单id:{$mtOrderId},商品图片:" . $imgString, '15280215347');
|
|
|
- $goodsName = $mtGoods['food_name'] ?? '';
|
|
|
$goodsPrice = $mtGoods['price'] ?? 0;
|
|
|
$num = $mtGoods['quantity'] ?? 0;
|
|
|
$goodsNum = bcadd($num, $goodsNum);
|
|
|
- $hasGoods = GoodsClass::getByCondition(['spu' => $mtGoodsSpu], true);
|
|
|
- if (empty($hasGoods)) {
|
|
|
- $imgArr = explode(',', $imgString);
|
|
|
- $shopImg = [];
|
|
|
- foreach ($imgArr as $imgUrl) {
|
|
|
- $shortUrl = httpUtil::downloadRemoteImg($sjId, $shopId, $imgUrl);
|
|
|
- $shopImg[] = $shortUrl;
|
|
|
- if ($orderCover == '') {
|
|
|
- $orderCover = $shortUrl;
|
|
|
- }
|
|
|
- }
|
|
|
- $cover = $shopImg[0];
|
|
|
- $goodsData = [
|
|
|
- 'spu' => $mtGoodsSpu, 'shopImg' => $shopImg,
|
|
|
- 'name' => $goodsName, 'sjId' => $sjId, 'mainId' => $mainId, 'shopId' => $shopId, 'catId' => $catId, 'cover' => $cover, 'unitGoodsPrice' => $goodsPrice, 'num' => $num,
|
|
|
- ];
|
|
|
- $goods = GoodsClass::orderCreateGoods($goodsData);
|
|
|
- Yii::$app->redis->executeCommand('SET', ['mt_goods_spu_' . $mtGoodsSpu, md5($imgString)]);
|
|
|
- } else {
|
|
|
- $id = $hasGoods->id ?? 0;
|
|
|
- $unitType = 0;
|
|
|
- $property = dict::getDict('property', 'goods');
|
|
|
- $goods = [['productId' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $goodsPrice, 'property' => $property]];
|
|
|
-
|
|
|
- $imgMd5 = Yii::$app->redis->executeCommand('GET', ['mt_goods_spu_' . $mtGoodsSpu]);
|
|
|
- if (empty($imgMd5) || $imgMd5 != md5($imgString)) {
|
|
|
- //图片需要更新
|
|
|
- $imgArr = explode(',', $imgString);
|
|
|
- $shopImg = [];
|
|
|
- $currentCover = '';
|
|
|
- foreach ($imgArr as $imgUrl) {
|
|
|
- $shortUrl = httpUtil::downloadRemoteImg($sjId, $shopId, $imgUrl);
|
|
|
- $shopImg[] = $shortUrl;
|
|
|
- if ($currentCover == '') {
|
|
|
- $currentCover = $shortUrl;
|
|
|
- }
|
|
|
- }
|
|
|
- $hasGoods->cover = $currentCover;
|
|
|
- $hasGoods->shopImg = json_encode($shopImg);
|
|
|
- Yii::$app->redis->executeCommand('SET', ['mt_goods_spu_' . $mtGoodsSpu, md5($imgString)]);
|
|
|
- }
|
|
|
- $hasGoods->name = $goodsName;
|
|
|
- $hasGoods->price = $goodsPrice;
|
|
|
- $hasGoods->save();
|
|
|
- if ($orderCover == '') {
|
|
|
- $orderCover = $hasGoods->cover ?? '';
|
|
|
- }
|
|
|
+ $currentGoods = GoodsClass::getByCondition(['spu' => $mtGoodsSpu], true);
|
|
|
+ if (empty($currentGoods)) {
|
|
|
+ noticeUtil::push("美团确认订单报错,数据库没有相应商品,美团订单id:{$mtOrderId}", '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'] ?? '';
|