|
|
@@ -2,8 +2,7 @@
|
|
2
|
2
|
|
|
3
|
3
|
namespace app\command;
|
|
4
|
4
|
|
|
5
|
|
-use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
|
|
6
|
|
-use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
|
|
|
5
|
+use app\common\repositories\store\product\ProductRepository;
|
|
7
|
6
|
use think\console\Command;
|
|
8
|
7
|
use think\console\Input;
|
|
9
|
8
|
use think\console\Output;
|
|
|
@@ -16,6 +15,8 @@ class ProductPriceUpdate extends Command
|
|
16
|
15
|
|
|
17
|
16
|
const PRODUCT_IDS = [31053, 32171];
|
|
18
|
17
|
|
|
|
18
|
+ const MER_ID = 3447;
|
|
|
19
|
+
|
|
19
|
20
|
protected function configure()
|
|
20
|
21
|
{
|
|
21
|
22
|
// 指令配置
|
|
|
@@ -34,32 +35,87 @@ class ProductPriceUpdate extends Command
|
|
34
|
35
|
|
|
35
|
36
|
private function priceUpdate()
|
|
36
|
37
|
{
|
|
37
|
|
- // 获取当前数据
|
|
38
|
|
- $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
|
|
39
|
|
- $attrData = Db::name('store_product_attr_value')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
|
|
40
|
|
- Db::startTrans();
|
|
41
|
|
- try {
|
|
42
|
|
- foreach ($productData as $product) {
|
|
43
|
|
- $log = [
|
|
44
|
|
- 'product_id' => $product['product_id'],
|
|
45
|
|
- 'old_price' => $product['price'],
|
|
46
|
|
- 'number' => self::NUMBER,
|
|
47
|
|
- 'new_price' => $product['price'] + self::NUMBER,
|
|
48
|
|
- ];
|
|
49
|
|
- Db::name('product_price_update_log')->insert($log);
|
|
50
|
|
-
|
|
51
|
|
- Db::name('store_product')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
|
|
52
|
|
- Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
|
|
53
|
|
- }
|
|
54
|
|
-
|
|
55
|
|
-;
|
|
56
|
|
- Db::commit();
|
|
57
|
|
- return true;
|
|
58
|
|
- } catch (\Exception $e) {
|
|
59
|
|
- Db::rollback();
|
|
60
|
|
- throw $e;
|
|
|
38
|
+ // 获取商品数据
|
|
|
39
|
+ $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->select()->toArray();
|
|
|
40
|
+
|
|
|
41
|
+
|
|
|
42
|
+ /** @var ProductRepository $repository */
|
|
|
43
|
+ $repository = app()->make(ProductRepository::class);
|
|
|
44
|
+ foreach ($productData as $product) {
|
|
|
45
|
+ $log = [
|
|
|
46
|
+ 'product_id' => $product['product_id'],
|
|
|
47
|
+ 'old_price' => $product['price'],
|
|
|
48
|
+ 'number' => self::NUMBER,
|
|
|
49
|
+ 'new_price' => $product['price'] + self::NUMBER,
|
|
|
50
|
+ ];
|
|
|
51
|
+ Db::name('product_price_update_log')->insert($log);
|
|
|
52
|
+
|
|
|
53
|
+ $attrValue = Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->select()->toArray();
|
|
|
54
|
+ $attrValue[0]['price'] = $attrValue[0]['price'] + self::NUMBER;
|
|
|
55
|
+ $content = Db::name('store_product_content')->where(['product_id' => $product['product_id']])->field('content')->find();
|
|
|
56
|
+
|
|
|
57
|
+ $update = [
|
|
|
58
|
+ 'attr' => [],
|
|
|
59
|
+ 'attrValue' => $attrValue,
|
|
|
60
|
+ 'brand_id' => $product['brand_id'],
|
|
|
61
|
+ 'cate_id' => $product['cate_id'],
|
|
|
62
|
+ 'commission' => $product['commission'],
|
|
|
63
|
+ 'content' => $content['content'],
|
|
|
64
|
+ 'couponData' => [],
|
|
|
65
|
+ 'extension_type' => $product['extension_type'],
|
|
|
66
|
+ 'ficti' => $product['ficti'],
|
|
|
67
|
+ 'give_coupon_ids' => [],
|
|
|
68
|
+ 'icon_type' => [],
|
|
|
69
|
+ 'image' => $product['image'],
|
|
|
70
|
+ 'is_gift_bag' => $product['is_gift_bag'],
|
|
|
71
|
+ 'is_good' => $product['is_good'],
|
|
|
72
|
+ 'keyword' => $product['keyword'],
|
|
|
73
|
+ 'mer_cate_id' => [],
|
|
|
74
|
+ 'pension' => $product['pension'],
|
|
|
75
|
+ 'pension_is' => $product['pension_is'],
|
|
|
76
|
+ 'share_is' => $product['share_is'],
|
|
|
77
|
+ 'slider_image' => explode(',',$product['slider_image']),
|
|
|
78
|
+ 'sort' => $product['sort'],
|
|
|
79
|
+ 'spec_type' => $product['spec_type'],
|
|
|
80
|
+ 'store_info' => $product['store_info'],
|
|
|
81
|
+ 'store_name' => $product['store_name'],
|
|
|
82
|
+ 'temp_id' => $product['temp_id'],
|
|
|
83
|
+ 'type' => $product['type'],
|
|
|
84
|
+ 'unit_name' => $product['unit_name'],
|
|
|
85
|
+ 'volunteer' => $product['volunteer']
|
|
|
86
|
+ ];
|
|
|
87
|
+ $repository->update($product['product_id'],$update,self::MER_ID);
|
|
|
88
|
+ Db::name('product_share')->where('product_id',$product['product_id'])->where('share_channel',1)->update(['url'=>'']);
|
|
61
|
89
|
}
|
|
62
|
90
|
|
|
|
91
|
+
|
|
|
92
|
+
|
|
|
93
|
+ // // 获取当前数据
|
|
|
94
|
+ // $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
|
|
|
95
|
+ // $attrData = Db::name('store_product_attr_value')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
|
|
|
96
|
+ // Db::startTrans();
|
|
|
97
|
+ // try {
|
|
|
98
|
+ // foreach ($productData as $product) {
|
|
|
99
|
+ // $log = [
|
|
|
100
|
+ // 'product_id' => $product['product_id'],
|
|
|
101
|
+ // 'old_price' => $product['price'],
|
|
|
102
|
+ // 'number' => self::NUMBER,
|
|
|
103
|
+ // 'new_price' => $product['price'] + self::NUMBER,
|
|
|
104
|
+ // ];
|
|
|
105
|
+ // Db::name('product_price_update_log')->insert($log);
|
|
|
106
|
+ //
|
|
|
107
|
+ // Db::name('store_product')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
|
|
|
108
|
+ // Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
|
|
|
109
|
+ // }
|
|
|
110
|
+ //
|
|
|
111
|
+ // ;
|
|
|
112
|
+ // Db::commit();
|
|
|
113
|
+ // return true;
|
|
|
114
|
+ // } catch (\Exception $e) {
|
|
|
115
|
+ // Db::rollback();
|
|
|
116
|
+ // throw $e;
|
|
|
117
|
+ // }
|
|
|
118
|
+
|
|
63
|
119
|
}
|
|
64
|
120
|
|
|
65
|
121
|
}
|