|
|
@@ -21,6 +21,7 @@ use app\adminapi\lists\third\ThirdGoodsLists;
|
|
|
use app\adminapi\logic\third\ThirdGoodsLogic;
|
|
|
use app\adminapi\validate\third\ThirdGoodsValidate;
|
|
|
use app\common\logic\ThirdOrderLogic;
|
|
|
+use app\common\model\third\ThirdGoods;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -105,10 +106,46 @@ class ThirdGoodsController extends BaseAdminController
|
|
|
return $this->data($result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取美团商品
|
|
|
+ * @return \think\response\Json
|
|
|
+ */
|
|
|
public function getMeituanGoods()
|
|
|
{
|
|
|
- $result = ThirdOrderLogic::queryshopdeal();
|
|
|
- return $this->data($result);
|
|
|
+ $data = [];
|
|
|
+ $i = 1;
|
|
|
+ for ($i; $i < 100; $i++){
|
|
|
+ $result = ThirdOrderLogic::queryshopdeal($i);
|
|
|
+ if(empty($result['data']['result'])){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ foreach ($result['data']['result'] as $item){
|
|
|
+ $data[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($data)){
|
|
|
+ $good_data = [];
|
|
|
+ $dealGroupIds = array_column($data, 'dealGroupId');
|
|
|
+ $product_ids = ThirdGoods::whereIn('product_id', $dealGroupIds)->column('product_id');
|
|
|
+ foreach ($data as $key=>$items){
|
|
|
+ if(in_array($items['dealGroupId'], $product_ids)){
|
|
|
+ unset($data[$key]);
|
|
|
+ }
|
|
|
+ $good_data[] = [
|
|
|
+ 'third_type' => 1,
|
|
|
+ 'goods_id' => 0,
|
|
|
+ 'product_id' => $items['dealGroupId'],
|
|
|
+ 'product_name' => $items['title'],
|
|
|
+ 'product_price' => $items['price'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($good_data)){
|
|
|
+ $result = ThirdGoodsLogic::addMeituanGoods($good_data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->success('同步成功', [], 1, 1);
|
|
|
}
|
|
|
|
|
|
|