|
|
@@ -5,13 +5,13 @@ namespace app\controller\api\store\product;
|
|
5
|
5
|
use app\common\repositories\store\product\ProductRepository;
|
|
6
|
6
|
use app\common\repositories\user\UserThirdRepository;
|
|
7
|
7
|
use think\App;
|
|
8
|
|
-use crmeb\basic\BaseController;
|
|
|
8
|
+// use crmeb\basic\BaseController;
|
|
9
|
9
|
use think\Exception;
|
|
10
|
10
|
use think\exception\ValidateException;
|
|
11
|
11
|
use think\facade\Db;
|
|
12
|
12
|
use think\facade\Log;
|
|
13
|
13
|
|
|
14
|
|
-class Jd extends BaseController
|
|
|
14
|
+class Jd
|
|
15
|
15
|
{
|
|
16
|
16
|
public $appid = '';
|
|
17
|
17
|
public $key = '';
|
|
|
@@ -23,11 +23,15 @@ class Jd extends BaseController
|
|
23
|
23
|
public function __construct(App $app)
|
|
24
|
24
|
{
|
|
25
|
25
|
|
|
26
|
|
- parent::__construct($app);
|
|
27
|
|
- $this->appid = '4100076550';
|
|
28
|
|
- $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d';
|
|
29
|
|
- $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc';
|
|
30
|
|
- $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a';
|
|
|
26
|
+ // parent::__construct($app);
|
|
|
27
|
+ $this->appid = '4101490811';
|
|
|
28
|
+ $this->key = 'a7c43c21f3e156d2fd41dfbe884b9f62592ceb03b9f199c0811c82e35be53c0580a2638a7af39e74';
|
|
|
29
|
+ $this->appKey = 'e99703d01cbb6a2e48a8a34f19af9d87';
|
|
|
30
|
+ $this->secretKey = 'cea7578d5a314ef88086daa4ee3a5b4d';
|
|
|
31
|
+ // $this->appid = '4100076550';
|
|
|
32
|
+ // $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d';
|
|
|
33
|
+ // $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc';
|
|
|
34
|
+ // $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a';
|
|
31
|
35
|
$this->userThird = app()->make(UserThirdRepository::class);
|
|
32
|
36
|
$this->url = 'https://api.jd.com/routerjson';
|
|
33
|
37
|
}
|
|
|
@@ -150,57 +154,30 @@ class Jd extends BaseController
|
|
150
|
154
|
/*京粉精选商品查询接口*/
|
|
151
|
155
|
public function jdList()
|
|
152
|
156
|
{
|
|
153
|
|
-// [$page, $limit] = $this->getPage();
|
|
154
|
|
-// $apiName = 'jd.union.open.goods.jingfen.query';
|
|
155
|
|
-// $params = [
|
|
156
|
|
-// 'goodsReq'=>[
|
|
157
|
|
-// 'eliteId'=>2,
|
|
158
|
|
-// 'pageIndex'=>$page??1,
|
|
159
|
|
-// 'pageSize' =>20,
|
|
160
|
|
-// ]
|
|
161
|
|
-// ];
|
|
162
|
|
-// $result = $this->getUrlResult($apiName,$params);
|
|
163
|
|
-// $result = json_decode($result,true);
|
|
164
|
|
-// $result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['result'],true);
|
|
165
|
|
-// $result =$result['data']??[];
|
|
166
|
|
-// $goodsList = [];
|
|
167
|
|
-//
|
|
168
|
|
-// foreach ($result as $k=> $goods) {
|
|
169
|
|
-// $goodsList[] = [
|
|
170
|
|
-// 'type' => 6,//京东商品
|
|
171
|
|
-// 'skuId' =>$goods['skuId'],//skuid
|
|
172
|
|
-// 'id' => $goods['brandCode']??'', //id
|
|
173
|
|
-// 'thumb' => $goods['imageInfo']['imageList'][0]['url']??'',//商品缩略图
|
|
174
|
|
-// 'name' => $goods['skuName'],//名称
|
|
175
|
|
-// 'commission' =>app()->make(ProductRepository::class)->yanglaojin(0,$goods['commissionInfo']['commission']??''),//佣金
|
|
176
|
|
-// 'commission_rate' => $goods['commissionInfo']['commissionShare']??'',//佣金比例
|
|
177
|
|
-// 'sales' => "",
|
|
178
|
|
-// 'coupon_money' => $goods['couponInfo']['couponList'] ?? [],
|
|
179
|
|
-// 'lowestCouponPrice' => $goods['priceInfo']['price']??'', //券后价lowestCouponPrice
|
|
180
|
|
-// 'price' => $goods['priceInfo']['price']??'', //价格
|
|
181
|
|
-// ];
|
|
182
|
|
-// }
|
|
|
157
|
+ $keyword = request()->param('keyword', '');
|
|
|
158
|
+ $_cid = request()->param('cid', '');
|
|
|
159
|
+
|
|
|
160
|
+ // [$page, $limit] = $this->getPage();
|
|
|
161
|
+ [$page, $limit] = [1, 10];
|
|
|
162
|
+
|
|
|
163
|
+
|
|
|
164
|
+ $goods_obj = Db::name('third_party_goods')
|
|
|
165
|
+ ->where('type', 2);
|
|
|
166
|
+ if ($keyword) {
|
|
|
167
|
+ $goods_obj = $goods_obj->where('json', 'like', '%' . $keyword . '%');
|
|
|
168
|
+ }
|
|
|
169
|
+ if ($_cid) {
|
|
|
170
|
+ $goods_obj = $goods_obj->where('cid', $_cid);
|
|
|
171
|
+ }
|
|
|
172
|
+ $list = $goods_obj->page($page, $limit)
|
|
|
173
|
+ ->select()->toArray();
|
|
183
|
174
|
|
|
184
|
|
- [$page, $limit] = $this->getPage();
|
|
185
|
|
- $list = Db::name('third_party_goods')
|
|
186
|
|
- ->where('type', 2)
|
|
187
|
|
- ->page($page, $limit)
|
|
188
|
|
- ->field('json')
|
|
189
|
|
- ->select()
|
|
190
|
|
- ->toArray();
|
|
191
|
175
|
$formatList = [];
|
|
192
|
176
|
foreach ($list as $value) {
|
|
193
|
177
|
$json = json_decode($value['json'], true);
|
|
194
|
|
- $json['pension'] = $json['pension']??'0';
|
|
195
|
|
- $json['pv'] = $json['pension'];
|
|
196
|
|
- $json['yanglaojin'] = $json['pension'];
|
|
197
|
|
-
|
|
198
|
|
- // $json['shopName'] = "";
|
|
199
|
|
- // $json['monthSales'] = "0";
|
|
200
|
|
- // $json['cid'] = "0";
|
|
201
|
|
- $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
|
|
202
|
|
- $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
|
|
203
|
|
- $json['cid'] = isset($value['cid'])?$json['cid']:0;
|
|
|
178
|
+ $json['commission_'] = $json['lowestCouponPrice'];
|
|
|
179
|
+ $json['monthSales'] = 0;
|
|
|
180
|
+ $json['cid'] = $value['cid'] ?? 0;
|
|
204
|
181
|
$formatList[] = $json;
|
|
205
|
182
|
}
|
|
206
|
183
|
shuffle($formatList);
|
|
|
@@ -278,22 +255,46 @@ class Jd extends BaseController
|
|
278
|
255
|
/*京东商品详情*/
|
|
279
|
256
|
public function jdDetail()
|
|
280
|
257
|
{
|
|
281
|
|
-
|
|
282
|
258
|
try {
|
|
283
|
|
- $sku = $this->request->param(['skuId']);
|
|
284
|
|
- $apiName = 'jd.union.open.goods.promotiongoodsinfo.query';
|
|
285
|
|
- $params = [
|
|
286
|
|
- 'skuIds' => $sku['skuId'],
|
|
|
259
|
+ $sku = request()->param('skuId', '');
|
|
|
260
|
+ if (empty($sku)) {
|
|
|
261
|
+ return app('json')->fail('商品下架不存在', null, 401);
|
|
|
262
|
+ }
|
|
|
263
|
+ // 老版本
|
|
|
264
|
+ // $apiName = 'jd.union.open.goods.promotiongoodsinfo.query';
|
|
|
265
|
+ // $params = [
|
|
|
266
|
+ // 'skuIds' => $sku['skuId'],
|
|
|
267
|
+ // ];
|
|
|
268
|
+ // $result = $this->getUrlResult($apiName, $params);
|
|
|
269
|
+ // $result = json_decode($result, true);
|
|
|
270
|
+ // $result = json_decode($result['jd_union_open_goods_promotiongoodsinfo_query_responce']['queryResult'], true);
|
|
|
271
|
+ // $result = $result['data'][0] ?? [];
|
|
|
272
|
+ // $goodsDetail = $this->doGetJtDetail($result);
|
|
|
273
|
+
|
|
|
274
|
+ $third_party_goods_detail = Db::name('third_party_goods')
|
|
|
275
|
+ ->whereLike('json', '%' . $sku . '%')
|
|
|
276
|
+ ->find();
|
|
|
277
|
+ $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
|
|
|
278
|
+ $formatData = [
|
|
|
279
|
+ 'goodsName' => $third_party_goods_json_detail['name'],
|
|
|
280
|
+ 'imgUrl' => $third_party_goods_json_detail['imageList'][0],
|
|
|
281
|
+ 'unitPrice' => $third_party_goods_json_detail['price'],//原价
|
|
|
282
|
+ 'wlUnitPrice' => $third_party_goods_json_detail['lowestCouponPrice'],
|
|
|
283
|
+ 'couMoney' => $third_party_goods_json_detail['coupon_money'][0]['discount'],
|
|
|
284
|
+ 'nowPrice' => $third_party_goods_json_detail['lowestCouponPrice'],//现价
|
|
|
285
|
+ 'detail' => $third_party_goods_json_detail['imageList'],
|
|
|
286
|
+
|
|
|
287
|
+ 'commission' => $third_party_goods_json_detail['commission'],
|
|
|
288
|
+ 'pv' => $third_party_goods_json_detail['pv'],
|
|
|
289
|
+ 'yanglaojin' => $third_party_goods_json_detail['yanglaojin'],
|
|
|
290
|
+ 'gongxian' => $third_party_goods_json_detail['gongxian'],
|
|
|
291
|
+ 'jifen' => $third_party_goods_json_detail['jifen'],
|
|
|
292
|
+ 'discount_link' => $third_party_goods_json_detail['coupon_link'],
|
|
|
293
|
+ 'materialUrl' => ''
|
|
287
|
294
|
];
|
|
288
|
|
- $result = $this->getUrlResult($apiName, $params);
|
|
289
|
|
- $result = json_decode($result, true);
|
|
290
|
|
- $result = json_decode($result['jd_union_open_goods_promotiongoodsinfo_query_responce']['queryResult'], true);
|
|
291
|
|
- $result = $result['data'][0] ?? [];
|
|
292
|
|
- $goodsDetail = $this->doGetJtDetail($result);
|
|
293
|
|
- return app("json")->success($goodsDetail);
|
|
294
|
|
- } catch (\Exception $e) {
|
|
295
|
|
- Db::name('log')->insert(['data'=>'微信审核------'.$e->getMessage().$e->getFile().$e->getLine()]);
|
|
296
|
295
|
|
|
|
296
|
+ return app("json")->success($formatData);
|
|
|
297
|
+ } catch (\Exception $e) {
|
|
297
|
298
|
return app('json')->fail('商品下架不存在', null, 401);
|
|
298
|
299
|
}
|
|
299
|
300
|
}
|
|
|
@@ -323,11 +324,26 @@ class Jd extends BaseController
|
|
323
|
324
|
];
|
|
324
|
325
|
// var_dump($third_party_goods_json_detail['coupon_money'][0]['link']);
|
|
325
|
326
|
//加入转链地址
|
|
326
|
|
- $formatData['materialUrl'] = $this->linkChange($goodsDetail['materialUrl'], $this->request->uid(), $third_party_goods_json_detail['coupon_money'][0]['link'] ?? '');;
|
|
|
327
|
+ $formatData['materialUrl'] = $this->linkChange($goodsDetail['materialUrl'], $this->request->uid(), $third_party_goods_json_detail['coupon_money'][0]['link'] ?? '');
|
|
327
|
328
|
$return[] = $formatData;
|
|
328
|
329
|
return $return;
|
|
329
|
330
|
}
|
|
330
|
331
|
|
|
|
332
|
+ public function changLinkApi()
|
|
|
333
|
+ {
|
|
|
334
|
+ $skuId = request()->param('skuId', '');
|
|
|
335
|
+ if (empty($skuId)) {
|
|
|
336
|
+ return app('json')->fail('商品下架不存在', null, 401);
|
|
|
337
|
+ }
|
|
|
338
|
+
|
|
|
339
|
+ $third_party_goods_detail = Db::name('third_party_goods')->whereLike('json', '%' . $skuId . '%')->find();
|
|
|
340
|
+ $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
|
|
|
341
|
+
|
|
|
342
|
+ $url = $this->linkChange($third_party_goods_json_detail['materialUrl'], 1592, $third_party_goods_json_detail['coupon_money'][0]['link'] ?? '');
|
|
|
343
|
+
|
|
|
344
|
+ return app("json")->success(['url' => $url]);
|
|
|
345
|
+ }
|
|
|
346
|
+
|
|
331
|
347
|
/*转链*/
|
|
332
|
348
|
public function linkChange($url, $uid,$couponUrl)
|
|
333
|
349
|
{
|
|
|
@@ -347,8 +363,9 @@ class Jd extends BaseController
|
|
347
|
363
|
'promotionCodeReq' => [
|
|
348
|
364
|
'materialId' => $url,
|
|
349
|
365
|
'siteId' => $this->appid,
|
|
350
|
|
- 'positionId' => pow(11, 5) + $uid, //自定义,和订单关联
|
|
351
|
|
- 'couponUrl' => $couponUrl
|
|
|
366
|
+ 'positionId' => pow(10, 5) + $uid, //自定义,和订单关联
|
|
|
367
|
+ 'couponUrl' => $couponUrl,
|
|
|
368
|
+ 'sceneId' => 1
|
|
352
|
369
|
],
|
|
353
|
370
|
];
|
|
354
|
371
|
$result = $this->getUrlResult($apiName, $params);
|
|
|
@@ -365,117 +382,138 @@ class Jd extends BaseController
|
|
365
|
382
|
set_time_limit(0);
|
|
366
|
383
|
|
|
367
|
384
|
$eliteIdList = [
|
|
368
|
|
- '1', //好券商品
|
|
369
|
|
- '2', //精选卖场
|
|
370
|
|
- '10', //9.9包邮
|
|
371
|
|
- '15', //京东配送
|
|
372
|
|
- '22', //实时热销榜
|
|
373
|
|
-// '23', //为你推荐
|
|
374
|
|
- '24', //数码家电
|
|
375
|
|
- '25', //超市
|
|
376
|
|
- '26', //母婴玩具
|
|
377
|
|
- '27', //家具日用
|
|
378
|
|
- '28', //美妆穿搭
|
|
379
|
|
- '30', //图书文具
|
|
380
|
|
- '31', //今日必推
|
|
381
|
|
- '32', //京东好物
|
|
382
|
|
- '33', //京东秒杀
|
|
383
|
|
- '34', //拼购商品
|
|
384
|
|
- '40', //高收益榜
|
|
385
|
|
- '41', //自营热卖榜
|
|
386
|
|
-// '108', //秒杀进行中
|
|
387
|
|
- '109', //新品首发
|
|
388
|
|
- '110', //自营
|
|
389
|
|
- '112', //京东爆品
|
|
390
|
|
- '125', //首购商品
|
|
391
|
|
- '129', //高佣榜单
|
|
392
|
|
-// '130', //视频商品
|
|
393
|
|
-// '153', //历史最低价商品榜
|
|
394
|
|
-// '238', //新人价商品
|
|
395
|
|
-// '315', //秒杀未开始
|
|
396
|
|
- '341', //3C新品
|
|
397
|
|
- '342', //智能新品
|
|
398
|
|
- '343', //3C长尾商品
|
|
399
|
|
- '345', //时尚新品
|
|
400
|
|
- '346', //时尚爆品
|
|
401
|
|
-// '1001', //选品库
|
|
402
|
|
-// '515', //订单接龙商品
|
|
403
|
|
-// '519', //官方活动
|
|
404
|
|
- '12254', //超级补贴
|
|
405
|
|
- '12318', //便宜包邮
|
|
406
|
|
- '12339', //超市卡
|
|
|
385
|
+ // '1', //好券商品
|
|
|
386
|
+ '2', //精选卖场
|
|
|
387
|
+ // '10', //9.9包邮
|
|
|
388
|
+ // '15', //京东配送
|
|
|
389
|
+ // '22', //实时热销榜
|
|
|
390
|
+ // // '23', //为你推荐
|
|
|
391
|
+ // '24', //数码家电
|
|
|
392
|
+ // '25', //超市
|
|
|
393
|
+ // '26', //母婴玩具
|
|
|
394
|
+ // '27', //家具日用
|
|
|
395
|
+ // '28', //美妆穿搭
|
|
|
396
|
+ // '30', //图书文具
|
|
|
397
|
+ // '31', //今日必推
|
|
|
398
|
+ // '32', //京东好物
|
|
|
399
|
+ // '33', //京东秒杀
|
|
|
400
|
+ // '34', //拼购商品
|
|
|
401
|
+ // '40', //高收益榜
|
|
|
402
|
+ // '41', //自营热卖榜
|
|
|
403
|
+ // // '108', //秒杀进行中
|
|
|
404
|
+ // '109', //新品首发
|
|
|
405
|
+ // '110', //自营
|
|
|
406
|
+ // '112', //京东爆品
|
|
|
407
|
+ // '125', //首购商品
|
|
|
408
|
+ // '129', //高佣榜单
|
|
|
409
|
+ // // '130', //视频商品
|
|
|
410
|
+ // // '153', //历史最低价商品榜
|
|
|
411
|
+ // // '238', //新人价商品
|
|
|
412
|
+ // // '315', //秒杀未开始
|
|
|
413
|
+ // '341', //3C新品
|
|
|
414
|
+ // '342', //智能新品
|
|
|
415
|
+ // '343', //3C长尾商品
|
|
|
416
|
+ // '345', //时尚新品
|
|
|
417
|
+ // '346', //时尚爆品
|
|
|
418
|
+ // // '1001', //选品库
|
|
|
419
|
+ // // '515', //订单接龙商品
|
|
|
420
|
+ // // '519', //官方活动
|
|
|
421
|
+ // '12254', //超级补贴
|
|
|
422
|
+ // '12318', //便宜包邮
|
|
|
423
|
+ // '12339', //超市卡
|
|
407
|
424
|
];
|
|
408
|
|
- Log::info("===============get_jd_goods_list===================");
|
|
409
|
|
-// $eliteIdList = [1];
|
|
410
|
425
|
foreach ($eliteIdList as $eliteId) {
|
|
411
|
|
- $jq_query=$this->jd_query($eliteId,1);
|
|
412
|
|
- $yema=(int)ceil($jq_query['totalCount']/50);
|
|
413
|
|
- for ($page = 1; $page <= $yema; $page++) {
|
|
414
|
|
- $result=$this->jd_query($eliteId,$page);
|
|
415
|
|
- if(isset($result['data']) && $result['data']){
|
|
416
|
|
- $this->formatGoodsList($result['data']);
|
|
|
426
|
+ $page = 1;
|
|
|
427
|
+ $yema = 1; // 初始化为1确保至少执行一次
|
|
|
428
|
+ do {
|
|
|
429
|
+ $result = $this->jd_query($eliteId, $page);
|
|
|
430
|
+ // 首次请求时更新总页数
|
|
|
431
|
+ if ($page === 1 && isset($result['totalCount'])) {
|
|
|
432
|
+ $yema = (int)ceil($result['totalCount'] / 50);
|
|
417
|
433
|
}
|
|
418
|
|
- }
|
|
|
434
|
+ // 处理有效数据
|
|
|
435
|
+ if (isset($result['data']) && $result['data']) {
|
|
|
436
|
+ $this->formatGoodsList($result['data'], $eliteId);
|
|
|
437
|
+ }
|
|
|
438
|
+ exit();
|
|
|
439
|
+ $page++;
|
|
|
440
|
+ } while ($page <= $yema);
|
|
419
|
441
|
}
|
|
420
|
442
|
return 'ok';
|
|
421
|
443
|
}
|
|
422
|
444
|
//请求京东联盟接口描述:京东联盟精选优质商品,每日更新,可通过频道ID查询各个频道下的精选商品。用获取的优惠券链接调用转链接口时,需传入搜索接口link字段返回的原始优惠券链接,切勿对链接进行任何encode、decode操作,否则将导致转链二合一推广链接时校验失败。
|
|
423
|
|
- public function jd_query($eliteId,$page){
|
|
|
445
|
+ public function jd_query($eliteId, $page)
|
|
|
446
|
+ {
|
|
424
|
447
|
$apiName = 'jd.union.open.goods.jingfen.query';
|
|
425
|
448
|
$params = [
|
|
426
|
449
|
'goodsReq' => [
|
|
427
|
|
- 'eliteId' => $eliteId,
|
|
|
450
|
+ 'eliteId' => $eliteId,
|
|
428
|
451
|
'pageIndex' => $page ?? 1,
|
|
429
|
|
- 'pageSize' => 50,
|
|
|
452
|
+ 'pageSize' => 50,
|
|
430
|
453
|
]
|
|
431
|
454
|
];
|
|
432
|
455
|
$result = $this->getUrlResult($apiName, $params);
|
|
433
|
456
|
$result = json_decode($result, true);
|
|
434
|
457
|
|
|
435
|
458
|
$result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['queryResult'], true);
|
|
436
|
|
-// $result = $result['data'] ?? [];
|
|
|
459
|
+ // $result = $result['data'] ?? [];
|
|
437
|
460
|
return $result;
|
|
438
|
461
|
}
|
|
439
|
462
|
|
|
440
|
463
|
//格式化从京东联盟获取到的商品列表
|
|
441
|
|
- public function formatGoodsList($goodsList)
|
|
|
464
|
+ public function formatGoodsList($goodsList, $eliteId)
|
|
442
|
465
|
{
|
|
443
|
466
|
$install = [];
|
|
444
|
467
|
foreach ($goodsList as $goods) {
|
|
|
468
|
+ // 优惠券信息
|
|
|
469
|
+ if (empty($goods['couponInfo']['couponList'])) continue;
|
|
|
470
|
+ $maxCoupon = [];
|
|
|
471
|
+ foreach ($goods['couponInfo']['couponList'] as $coupon) {
|
|
|
472
|
+ if ($maxCoupon === [] || $coupon['discount'] > $maxCoupon['discount']) {
|
|
|
473
|
+ $maxCoupon = $coupon;
|
|
|
474
|
+ }
|
|
|
475
|
+ }
|
|
|
476
|
+ $couponMoney = [
|
|
|
477
|
+ [
|
|
|
478
|
+ 'discount' => $maxCoupon['discount'],//优惠券金额
|
|
|
479
|
+ 'getStartTime' => date('Y-m-d', intval($maxCoupon['getStartTime'] / 1000)),
|
|
|
480
|
+ 'getEndTime' => date('Y-m-d', intval($maxCoupon['getEndTime'] / 1000)),
|
|
|
481
|
+ ]
|
|
|
482
|
+ ];
|
|
|
483
|
+
|
|
|
484
|
+ // 券后佣金,(促销价-优惠券面额)*佣金比例
|
|
445
|
485
|
$commissionMoney = $goods['commissionInfo']['couponCommission'] ?? 0;
|
|
|
486
|
+
|
|
446
|
487
|
//养老金
|
|
447
|
|
- $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
|
|
448
|
|
-// var_dump($goods);
|
|
449
|
|
-// return;
|
|
450
|
|
- if ($oldMoney < 0.1) continue;
|
|
451
|
|
- if (!isset($goods['couponInfo']['couponList'][0])) continue;
|
|
452
|
|
- foreach ($goods['couponInfo']['couponList'] as $coupon){
|
|
|
488
|
+ // $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
|
|
|
489
|
+ $yongjin = bcmul($commissionMoney, bcsub(1, 0.0038, 5), 2);
|
|
453
|
490
|
|
|
454
|
|
- }
|
|
455
|
|
- $goods['couponInfo']['couponList'][0]['getStartTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getStartTime'] / 1000));
|
|
456
|
|
- $goods['couponInfo']['couponList'][0]['getEndTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getEndTime'] / 1000));
|
|
457
|
491
|
$formatList = [
|
|
458
|
|
- 'type' => 6,//京东商品
|
|
459
|
|
- 'skuId' => $goods['skuId'],//skuid
|
|
460
|
|
- 'id' => $goods['brandCode'] ?? '', //id
|
|
461
|
|
- 'thumb' => $goods['imageInfo']['imageList'][0]['url'] ?? '',//商品缩略图
|
|
462
|
|
- 'name' => $goods['skuName'],//名称
|
|
463
|
|
- 'commission' => $oldMoney,//佣金
|
|
464
|
|
- 'commission_rate' => $goods['commissionInfo']['commissionShare'] ?? '',//佣金比例
|
|
465
|
|
- 'sales' => "",
|
|
466
|
|
- 'coupon_money' => $goods['couponInfo']['couponList'] ?? [],
|
|
|
492
|
+ 'type' => 6,//京东商品
|
|
|
493
|
+ 'skuId' => $goods['itemId'] ?? '',//itemId 京东官方 已不返回skuId , 使用 联盟商品ID 代替skuId
|
|
|
494
|
+ 'id' => $goods['brandCode'] ?? '', //id
|
|
|
495
|
+ 'name' => $goods['skuName'],//名称
|
|
|
496
|
+ 'thumb' => $goods['imageInfo']['imageList'][0]['url'] ?? '',//商品缩略图
|
|
|
497
|
+
|
|
|
498
|
+ 'pv' => bcmul($commissionMoney, 0.7, 2),//PV金额
|
|
|
499
|
+ 'gongxian' => bcmul($commissionMoney, 0.7, 2),
|
|
|
500
|
+ 'jifen' => bcmul($commissionMoney, 0.7, 2),
|
|
|
501
|
+ 'yanglaojin' => bcmul($yongjin, 0.3, 2),
|
|
|
502
|
+
|
|
|
503
|
+ 'commission' => $commissionMoney,//佣金
|
|
|
504
|
+ 'commission_rate' => $goods['commissionInfo']['commissionShare'] ?? '',//佣金比例
|
|
|
505
|
+ 'coupon_money' => $couponMoney,
|
|
|
506
|
+ 'coupon_link' => $maxCoupon['link'],
|
|
467
|
507
|
'lowestCouponPrice' => decimal2($goods['priceInfo']['lowestCouponPrice']), //券后价lowestCouponPrice
|
|
468
|
|
- 'price' => $goods['priceInfo']['price'], //价格
|
|
469
|
|
- 'imageList' => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集
|
|
|
508
|
+ 'price' => $goods['priceInfo']['price'], //价格
|
|
|
509
|
+ 'imageList' => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集
|
|
|
510
|
+ 'materialUrl' => $goods['materialUrl']
|
|
470
|
511
|
];
|
|
471
|
|
- $install[]=['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2];
|
|
472
|
|
-// Db::name("third_party_goods")->insert(['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2]);
|
|
|
512
|
+ $install[] = ['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $commissionMoney, 'type' => 2, 'cid' => $eliteId];
|
|
473
|
513
|
}
|
|
474
|
|
- if($install){
|
|
|
514
|
+ if ($install) {
|
|
475
|
515
|
Db::name("third_party_goods")->insertAll($install);
|
|
476
|
516
|
}
|
|
477
|
|
-
|
|
478
|
|
-// return $formatList;
|
|
479
|
517
|
}
|
|
480
|
518
|
|
|
481
|
519
|
/*订单获取(时间段,时间不能超过一小时)*/
|