|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+declare (strict_types=1);
|
|
|
3
|
+
|
|
|
4
|
+namespace app\command;
|
|
|
5
|
+
|
|
|
6
|
+use think\console\Command;
|
|
|
7
|
+use think\console\Input;
|
|
|
8
|
+use think\console\Output;
|
|
|
9
|
+use think\facade\Db;
|
|
|
10
|
+
|
|
|
11
|
+class repairPvLog extends Command
|
|
|
12
|
+{
|
|
|
13
|
+ protected function configure()
|
|
|
14
|
+ {
|
|
|
15
|
+ // 指令配置
|
|
|
16
|
+ $this->setName('repair_pv_log')
|
|
|
17
|
+ ->setDescription('修复老数据pv记录');
|
|
|
18
|
+ }
|
|
|
19
|
+
|
|
|
20
|
+ /**
|
|
|
21
|
+ * @param Input $input
|
|
|
22
|
+ * @param Output $output
|
|
|
23
|
+ * @return void
|
|
|
24
|
+ */
|
|
|
25
|
+ protected function execute(Input $input, Output $output)
|
|
|
26
|
+ {
|
|
|
27
|
+ $user_id_list = Db::name('user')->where([['pv','=',0],['contribute','>',0]])->column('uid');
|
|
|
28
|
+ if($user_id_list){
|
|
|
29
|
+ foreach ($user_id_list as $user_id) {
|
|
|
30
|
+ $order_list = Db::name('store_order')->where(['uid' => $user_id,'paid' => 1,'gzc' => 1])->select();
|
|
|
31
|
+ if($order_list) {
|
|
|
32
|
+ $pv = 0;
|
|
|
33
|
+ foreach ($order_list as $order) {
|
|
|
34
|
+ if($order['mer_id'] == 496){
|
|
|
35
|
+ $pv_tmp = ($order['total_price']/1180) * 700;
|
|
|
36
|
+ $pv_log_data = [
|
|
|
37
|
+ 'uid' => $user_id,
|
|
|
38
|
+ 'pv' => $pv_tmp,
|
|
|
39
|
+ 'status' => 1,
|
|
|
40
|
+ 'mark' => '会员专区消费获得PV(老数据)',
|
|
|
41
|
+ 'order_id' => $order['order_sn'],
|
|
|
42
|
+ 'settlement_time' => '2025-03-01 00:00:00',
|
|
|
43
|
+ 'addtime' => 1740758400
|
|
|
44
|
+ ];
|
|
|
45
|
+ Db::name('user_pv_log')->insert($pv_log_data);
|
|
|
46
|
+ $pv += $pv_tmp;
|
|
|
47
|
+ }
|
|
|
48
|
+ }
|
|
|
49
|
+ if($pv){
|
|
|
50
|
+ Db::name('user')->where(['uid' => $user_id])->update(['pv' => $pv]);
|
|
|
51
|
+ $output->writeln('user_id = ' . $user_id . '添加成功 pv = ' . $pv);
|
|
|
52
|
+ }
|
|
|
53
|
+ }
|
|
|
54
|
+ }
|
|
|
55
|
+ }
|
|
|
56
|
+ $output->writeln('执行结束');
|
|
|
57
|
+ }
|
|
|
58
|
+
|
|
|
59
|
+}
|