|
|
@@ -46,19 +46,24 @@ class PensionTasks extends Command
|
|
46
|
46
|
$nowTime = time();
|
|
47
|
47
|
try {
|
|
48
|
48
|
//线下符合条件的养老金收集(线下交易后第8天)
|
|
49
|
|
- $this->doOfflineOrderGzc($nowTime, $timeLimit = 1);
|
|
50
|
|
- //在线订单符合条件的养老金收集(线上收货后第30天)
|
|
51
|
|
- $this->doOnlineOrderGzc($timeLimit = 30);
|
|
52
|
|
- //在线订单符合条件的话费养老金收集(话费到账后第1天)
|
|
53
|
|
- $this->doOnlineHuuafeiOrderGzc($timeLimit = 1);
|
|
54
|
|
- //第三方订单符合条件的养老金收集(三方结算后第2天)
|
|
55
|
|
- $this->doThridPddOrderGzc($nowTime, $timeLimit = 2);
|
|
56
|
|
- $this->doThridJdOrderGzc($nowTime, $timeLimit = 2);
|
|
57
|
|
- $this->doThridSnOrderGzc($nowTime, $timeLimit = 2);
|
|
58
|
|
- $this->doThridTaobaoOrderGzc($nowTime, $timeLimit = 2);
|
|
59
|
|
- $this->doThridVipOrderGzc($nowTime, $timeLimit = 2);
|
|
60
|
|
- $this->doThridDyOrderGzc($nowTime, $timeLimit = 2);
|
|
61
|
|
- $this->doThridHfOrderGzc($nowTime, $timeLimit = 2);
|
|
|
49
|
+// $this->doOfflineOrderGzc($nowTime, $timeLimit = 1);
|
|
|
50
|
+// $this->doOnlineOrderGzc($timeLimit = 30);
|
|
|
51
|
+// $this->doOnlineHuuafeiOrderGzc($timeLimit = 30);
|
|
|
52
|
+ $this->onlineOrderNew($timeLimit = 30);
|
|
|
53
|
+ $this->huafeiOrderNew($timeLimit = 30);
|
|
|
54
|
+ $this->pddOrderNew($timeLimit = 30);
|
|
|
55
|
+ $this->jdOrderNew($timeLimit = 30);
|
|
|
56
|
+ $this->suOrderNew($timeLimit = 30);
|
|
|
57
|
+ $this->taobaoOrderNew($timeLimit = 30);
|
|
|
58
|
+ $this->vipOrderNew($timeLimit = 30);
|
|
|
59
|
+ $this->dyOrderNew($timeLimit = 30);
|
|
|
60
|
+// $this->doThridPddOrderGzc($nowTime, $timeLimit = 30);
|
|
|
61
|
+// $this->doThridJdOrderGzc($nowTime, $timeLimit = 30);
|
|
|
62
|
+// $this->doThridSnOrderGzc($nowTime, $timeLimit = 30);
|
|
|
63
|
+// $this->doThridTaobaoOrderGzc($nowTime, $timeLimit = 30);
|
|
|
64
|
+// $this->doThridVipOrderGzc($nowTime, $timeLimit = 30);
|
|
|
65
|
+// $this->doThridDyOrderGzc($nowTime, $timeLimit = 30);
|
|
|
66
|
+// $this->doThridHfOrderGzc($nowTime, $timeLimit = 30);
|
|
62
|
67
|
$this->billGzcAdd($nowTime);
|
|
63
|
68
|
//升级
|
|
64
|
69
|
// $this -> doUpgrade();
|
|
|
@@ -87,88 +92,89 @@ class PensionTasks extends Command
|
|
87
|
92
|
->where('is_gzc', 0)
|
|
88
|
93
|
->where('commission_type', 5)
|
|
89
|
94
|
->select()->toArray();
|
|
90
|
|
- foreach ($cursor as $bill) {
|
|
91
|
|
- $type_shop = $bill['type_shop'] ?? 0;
|
|
92
|
|
-
|
|
93
|
|
- switch ($type_shop){
|
|
94
|
|
- case "0":
|
|
95
|
|
- $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
96
|
|
- break;
|
|
97
|
|
- case "1":
|
|
98
|
|
- $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
99
|
|
- break;
|
|
100
|
|
- case "2":
|
|
101
|
|
- $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
102
|
|
- break;
|
|
103
|
|
- case "3":
|
|
104
|
|
- $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
105
|
|
- break;
|
|
106
|
|
- case "4":
|
|
107
|
|
- $online = '';
|
|
108
|
|
- break;
|
|
109
|
|
- case "5":
|
|
110
|
|
- $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
111
|
|
- break;
|
|
112
|
|
- case "6":
|
|
113
|
|
- $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
114
|
|
- break;
|
|
115
|
|
- case "7":
|
|
116
|
|
- $online = '';
|
|
117
|
|
- break;
|
|
118
|
|
- case "8":
|
|
119
|
|
- $online = '';
|
|
120
|
|
- break;
|
|
121
|
|
- case "9":
|
|
122
|
|
- $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
123
|
|
- break;
|
|
124
|
|
- default:
|
|
125
|
|
- $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
126
|
|
- }
|
|
|
95
|
+ if($cursor) {
|
|
|
96
|
+ foreach ($cursor as $bill) {
|
|
|
97
|
+ $type_shop = $bill['type_shop'] ?? 0;
|
|
|
98
|
+
|
|
|
99
|
+ switch ($type_shop){
|
|
|
100
|
+ case "0":
|
|
|
101
|
+ $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
|
102
|
+ break;
|
|
|
103
|
+ case "1":
|
|
|
104
|
+ $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
105
|
+ break;
|
|
|
106
|
+ case "2":
|
|
|
107
|
+ $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
108
|
+ break;
|
|
|
109
|
+ case "3":
|
|
|
110
|
+ $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
111
|
+ break;
|
|
|
112
|
+ case "4":
|
|
|
113
|
+ $online = '';
|
|
|
114
|
+ break;
|
|
|
115
|
+ case "5":
|
|
|
116
|
+ $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
117
|
+ break;
|
|
|
118
|
+ case "6":
|
|
|
119
|
+ $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
120
|
+ break;
|
|
|
121
|
+ case "7":
|
|
|
122
|
+ $online = '';
|
|
|
123
|
+ break;
|
|
|
124
|
+ case "8":
|
|
|
125
|
+ $online = '';
|
|
|
126
|
+ break;
|
|
|
127
|
+ case "9":
|
|
|
128
|
+ $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
129
|
+ break;
|
|
|
130
|
+ default:
|
|
|
131
|
+ $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
|
132
|
+ }
|
|
127
|
133
|
|
|
128
|
|
- if (!$online) {
|
|
129
|
|
- Log::info($bill['uid'] . '查询不到订单');
|
|
130
|
|
- continue;
|
|
131
|
|
- }
|
|
|
134
|
+ if (!$online) {
|
|
|
135
|
+ Log::info($bill['uid'] . '查询不到订单');
|
|
|
136
|
+ continue;
|
|
|
137
|
+ }
|
|
132
|
138
|
|
|
133
|
|
- $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
|
|
134
|
|
- if (!$certification) {
|
|
135
|
|
- Log::info($online['uid'] . '没有实名认证');
|
|
136
|
|
- continue;
|
|
137
|
|
- }
|
|
|
139
|
+ $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
|
|
|
140
|
+ if (!$certification) {
|
|
|
141
|
+ Log::info($online['uid'] . '没有实名认证');
|
|
|
142
|
+ continue;
|
|
|
143
|
+ }
|
|
138
|
144
|
|
|
139
|
|
- $pension = $bill['number'] ?? 0;
|
|
140
|
|
- if ($pension <= 0) {
|
|
141
|
|
- Log::info($online['order_sn'] . 'pension' . $pension);
|
|
142
|
|
- continue;
|
|
143
|
|
- }
|
|
|
145
|
+ $pension = $bill['number'] ?? 0;
|
|
|
146
|
+ if ($pension <= 0) {
|
|
|
147
|
+ Log::info($online['order_sn'] . 'pension' . $pension);
|
|
|
148
|
+ continue;
|
|
|
149
|
+ }
|
|
144
|
150
|
|
|
145
|
|
- //新增入账明细记录
|
|
146
|
|
- $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
|
|
147
|
|
- $create = [
|
|
148
|
|
- 'uid' => $online['uid'],
|
|
149
|
|
- 'platform_no' => $orderId,
|
|
150
|
|
- 'account_type' => $online['pay_type'] == 1 ? 3 : 2,
|
|
151
|
|
- 'user_name' => $certification['user_name'],
|
|
152
|
|
- 'mobile' => $certification['mobile'],
|
|
153
|
|
- 'user_card' => $certification['user_card'],
|
|
154
|
|
- 'pension' => $pension,
|
|
155
|
|
- 'order_type' => 2,
|
|
156
|
|
- 'out_trade_no' => $online['order_sn'],
|
|
157
|
|
- 'link_id'=> $bill['bill_id']
|
|
158
|
|
- ];
|
|
159
|
|
- $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
|
|
160
|
|
- $check = Db::name("gzc_logs")->where("link_id", $bill['id'])->where("order_type", 2)->count();
|
|
161
|
|
- if ($test_user == 0 && $check <= 0) {
|
|
162
|
|
- $OrderGzcRepository->create($create);
|
|
163
|
|
- Db::name('user_bill')
|
|
164
|
|
- ->where('bill_id', $bill['bill_id'])
|
|
165
|
|
- ->where('commission_type', 5)
|
|
166
|
|
- ->update([
|
|
167
|
|
- 'is_gzc' => 1
|
|
168
|
|
- ]);
|
|
|
151
|
+ //新增入账明细记录
|
|
|
152
|
+ $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
|
|
|
153
|
+ $create = [
|
|
|
154
|
+ 'uid' => $online['uid'],
|
|
|
155
|
+ 'platform_no' => $orderId,
|
|
|
156
|
+ 'account_type' => $online['pay_type'] == 1 ? 3 : 2,
|
|
|
157
|
+ 'user_name' => $certification['user_name'],
|
|
|
158
|
+ 'mobile' => $certification['mobile'],
|
|
|
159
|
+ 'user_card' => $certification['user_card'],
|
|
|
160
|
+ 'pension' => $pension,
|
|
|
161
|
+ 'order_type' => 2,
|
|
|
162
|
+ 'out_trade_no' => $online['order_sn'],
|
|
|
163
|
+ 'link_id'=> $bill['bill_id']
|
|
|
164
|
+ ];
|
|
|
165
|
+ $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
|
|
|
166
|
+ $check = Db::name("gzc_logs")->where("link_id", $bill['id'])->where("order_type", 2)->count();
|
|
|
167
|
+ if ($test_user == 0 && $check <= 0) {
|
|
|
168
|
+ $OrderGzcRepository->create($create);
|
|
|
169
|
+ Db::name('user_bill')
|
|
|
170
|
+ ->where('bill_id', $bill['bill_id'])
|
|
|
171
|
+ ->where('commission_type', 5)
|
|
|
172
|
+ ->update([
|
|
|
173
|
+ 'is_gzc' => 1
|
|
|
174
|
+ ]);
|
|
|
175
|
+ }
|
|
169
|
176
|
}
|
|
170
|
177
|
}
|
|
171
|
|
-
|
|
172
|
178
|
}
|
|
173
|
179
|
|
|
174
|
180
|
|
|
|
@@ -577,7 +583,7 @@ class PensionTasks extends Command
|
|
577
|
583
|
// if (!$certification) {
|
|
578
|
584
|
// Log::info($online['uid'] . '没有实名认证');
|
|
579
|
585
|
// continue;
|
|
580
|
|
- // }
|
|
|
586
|
+ // }
|
|
581
|
587
|
//查询养老金金额
|
|
582
|
588
|
$UserBillRepository = app()->make(UserBillRepository::class);
|
|
583
|
589
|
$bill = $UserBillRepository->getWhere(['uid' => $online['uid'], 'link_id' => $online['order_id'], 'order_sn' => $online['order_sn'], 'commission_type' => 5]);
|
|
|
@@ -616,9 +622,9 @@ class PensionTasks extends Command
|
|
616
|
622
|
$order->gzc = 1;
|
|
617
|
623
|
$order->save();
|
|
618
|
624
|
Db::name('user_bill')
|
|
619
|
|
- ->where('order_sn', $online['order_sn'])
|
|
620
|
|
- ->where('commission_type', 5)
|
|
621
|
|
- ->update(['status'=> 1]);
|
|
|
625
|
+ ->where('order_sn', $online['order_sn'])
|
|
|
626
|
+ ->where('commission_type', 5)
|
|
|
627
|
+ ->update(['status'=> 1]);
|
|
622
|
628
|
|
|
623
|
629
|
// 养老金区域奖励
|
|
624
|
630
|
// $order_data = [
|
|
|
@@ -708,7 +714,7 @@ class PensionTasks extends Command
|
|
708
|
714
|
]);
|
|
709
|
715
|
}
|
|
710
|
716
|
|
|
711
|
|
-
|
|
|
717
|
+
|
|
712
|
718
|
// 结算京豆
|
|
713
|
719
|
$user_sign_jingdou_list = Db::name('user_sign_jingdou')
|
|
714
|
720
|
->where('status', -1)
|
|
|
@@ -805,7 +811,7 @@ class PensionTasks extends Command
|
|
805
|
811
|
}
|
|
806
|
812
|
}
|
|
807
|
813
|
|
|
808
|
|
-
|
|
|
814
|
+
|
|
809
|
815
|
// 结算佣金
|
|
810
|
816
|
$user_bill_list = Db::name('user_bill')
|
|
811
|
817
|
->where('status', 0)
|
|
|
@@ -1524,4 +1530,395 @@ class PensionTasks extends Command
|
|
1524
|
1530
|
]);
|
|
1525
|
1531
|
return $data;
|
|
1526
|
1532
|
}
|
|
|
1533
|
+
|
|
|
1534
|
+ /**
|
|
|
1535
|
+ * 线上订单结算
|
|
|
1536
|
+ * @param $timeLimit
|
|
|
1537
|
+ * @return void
|
|
|
1538
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1539
|
+ * @throws \think\db\exception\DbException
|
|
|
1540
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1541
|
+ */
|
|
|
1542
|
+ public function onlineOrderNew($timeLimit)
|
|
|
1543
|
+ {
|
|
|
1544
|
+ // 普通订单
|
|
|
1545
|
+ $order_data = Db::name('store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->where([['status','in','2,3']])->select();
|
|
|
1546
|
+ $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
1547
|
+ if($order_data) {
|
|
|
1548
|
+ $order_data = $order_data->toArray();
|
|
|
1549
|
+ foreach ($order_data as $online) {
|
|
|
1550
|
+ $status = $StoreOrderStatusRepository->getWhere(['order_id' => $online['order_id'], 'change_type' => 'take']);
|
|
|
1551
|
+ if(!$status) {
|
|
|
1552
|
+ continue;
|
|
|
1553
|
+ }else{
|
|
|
1554
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1555
|
+ if($date < $status['change_time']) continue;
|
|
|
1556
|
+ }
|
|
|
1557
|
+ Db::transaction(function () use ($online) {
|
|
|
1558
|
+ $this->settleAward($online);
|
|
|
1559
|
+ Db::name('store_order')->where('order_id', $online['order_id'])->update(['is_settlement' => 1 ,'settlement_time' => date('Y-m-d H:i:s')]);
|
|
|
1560
|
+ });
|
|
|
1561
|
+ }
|
|
|
1562
|
+ }
|
|
|
1563
|
+ }
|
|
|
1564
|
+
|
|
|
1565
|
+ /**
|
|
|
1566
|
+ * 话费订单结算
|
|
|
1567
|
+ * @param $timeLimit
|
|
|
1568
|
+ * @return void
|
|
|
1569
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1570
|
+ * @throws \think\db\exception\DbException
|
|
|
1571
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1572
|
+ */
|
|
|
1573
|
+ public function huafeiOrderNew($timeLimit)
|
|
|
1574
|
+ {
|
|
|
1575
|
+ // 普通订单
|
|
|
1576
|
+ $order_data = Db::name('order_huafei')->where('status', 3)->where('gzc' , 0)->select();
|
|
|
1577
|
+ if($order_data) {
|
|
|
1578
|
+ $order_data = $order_data->toArray();
|
|
|
1579
|
+ foreach ($order_data as $online) {
|
|
|
1580
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1581
|
+ if($date < $online['finish_time']) continue;
|
|
|
1582
|
+ $online['order_id'] = $online['order_huafei_id'];
|
|
|
1583
|
+ Db::transaction(function () use ($online) {
|
|
|
1584
|
+ $this->settleAward($online);
|
|
|
1585
|
+ Db::name('order_huafei')->where('order_huafei_id', $online['order_huafei_id'])->update(['gzc' => 1 ,'modify_time' => date('Y-m-d H:i:s')]);
|
|
|
1586
|
+ });
|
|
|
1587
|
+ }
|
|
|
1588
|
+ }
|
|
|
1589
|
+ }
|
|
|
1590
|
+
|
|
|
1591
|
+ /**
|
|
|
1592
|
+ * 拼多多订单结算
|
|
|
1593
|
+ * @param $timeLimit
|
|
|
1594
|
+ * @return void
|
|
|
1595
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1596
|
+ * @throws \think\db\exception\DbException
|
|
|
1597
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1598
|
+ */
|
|
|
1599
|
+ public function pddOrderNew($timeLimit)
|
|
|
1600
|
+ {
|
|
|
1601
|
+ // 普通订单
|
|
|
1602
|
+ $order_data = Db::name('order_pdd')->where('pin_order_status', 5)->where('gzc', 0)->select();
|
|
|
1603
|
+ if($order_data) {
|
|
|
1604
|
+ $order_data = $order_data->toArray();
|
|
|
1605
|
+ foreach ($order_data as $online) {
|
|
|
1606
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1607
|
+ if($date < date('Y-m-d H:i:s', $online['pay_time'])) continue;
|
|
|
1608
|
+ $online['order_id'] = $online['order_pdd_id'];
|
|
|
1609
|
+ Db::transaction(function () use ($online) {
|
|
|
1610
|
+ $this->settleAward($online);
|
|
|
1611
|
+ Db::name('order_pdd')->where('order_pdd_id', $online['order_pdd_id'])->update(['gzc' => 1 ,'settle_time' => date('Y-m-d H:i:s')]);
|
|
|
1612
|
+ });
|
|
|
1613
|
+ }
|
|
|
1614
|
+ }
|
|
|
1615
|
+ }
|
|
|
1616
|
+
|
|
|
1617
|
+ /**
|
|
|
1618
|
+ * 京东订单结算
|
|
|
1619
|
+ * @param $timeLimit
|
|
|
1620
|
+ * @return void
|
|
|
1621
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1622
|
+ * @throws \think\db\exception\DbException
|
|
|
1623
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1624
|
+ */
|
|
|
1625
|
+ public function jdOrderNew($timeLimit)
|
|
|
1626
|
+ {
|
|
|
1627
|
+ // 普通订单
|
|
|
1628
|
+ $order_data = Db::name('order_jd')->where('status', 17)->where('gzc', 0)->select();
|
|
|
1629
|
+ if($order_data) {
|
|
|
1630
|
+ $order_data = $order_data->toArray();
|
|
|
1631
|
+ foreach ($order_data as $online) {
|
|
|
1632
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1633
|
+ if($date < $online['finish_time']) continue;
|
|
|
1634
|
+ $online['order_id'] = $online['order_jd_id'];
|
|
|
1635
|
+ Db::transaction(function () use ($online) {
|
|
|
1636
|
+ $this->settleAward($online);
|
|
|
1637
|
+ Db::name('order_jd')->where('order_jd_id', $online['order_jd_id'])->update(['gzc' => 1 ,'modify_time' => date('Y-m-d H:i:s')]);
|
|
|
1638
|
+ });
|
|
|
1639
|
+ }
|
|
|
1640
|
+ }
|
|
|
1641
|
+ }
|
|
|
1642
|
+
|
|
|
1643
|
+ /**
|
|
|
1644
|
+ * 苏宁订单结算
|
|
|
1645
|
+ * @param $timeLimit
|
|
|
1646
|
+ * @return void
|
|
|
1647
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1648
|
+ * @throws \think\db\exception\DbException
|
|
|
1649
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1650
|
+ */
|
|
|
1651
|
+ public function suOrderNew($timeLimit)
|
|
|
1652
|
+ {
|
|
|
1653
|
+ // 普通订单
|
|
|
1654
|
+ $order_data = Db::name('order_su')->where('status', 1)->where('gzc', 0)->select();
|
|
|
1655
|
+ if($order_data) {
|
|
|
1656
|
+ $order_data = $order_data->toArray();
|
|
|
1657
|
+ foreach ($order_data as $online) {
|
|
|
1658
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1659
|
+ if($date < date('Y-m-d H:i:s',$online['pay_time'])) continue;
|
|
|
1660
|
+ $online['order_id'] = $online['order_su_id'];
|
|
|
1661
|
+ Db::transaction(function () use ($online) {
|
|
|
1662
|
+ $this->settleAward($online);
|
|
|
1663
|
+ Db::name('order_su')->where('order_su_id', $online['order_su_id'])->update(['gzc' => 1 ,'settled_time' => date('Y-m-d H:i:s')]);
|
|
|
1664
|
+ });
|
|
|
1665
|
+ }
|
|
|
1666
|
+ }
|
|
|
1667
|
+ }
|
|
|
1668
|
+
|
|
|
1669
|
+ /**
|
|
|
1670
|
+ * 淘宝订单结算
|
|
|
1671
|
+ * @param $timeLimit
|
|
|
1672
|
+ * @return void
|
|
|
1673
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1674
|
+ * @throws \think\db\exception\DbException
|
|
|
1675
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1676
|
+ */
|
|
|
1677
|
+ public function taobaoOrderNew($timeLimit)
|
|
|
1678
|
+ {
|
|
|
1679
|
+ // 普通订单
|
|
|
1680
|
+ $order_data = Db::name('order_tb')->where('tk_status', 3)->where('gzc', 0)->select();
|
|
|
1681
|
+ if($order_data) {
|
|
|
1682
|
+ $order_data = $order_data->toArray();
|
|
|
1683
|
+ foreach ($order_data as $online) {
|
|
|
1684
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1685
|
+ if($date < date('Y-m-d H:i:s',$online['tk_earning_time'])) continue;
|
|
|
1686
|
+ $online['order_id'] = $online['order_tb_id'];
|
|
|
1687
|
+ Db::transaction(function () use ($online) {
|
|
|
1688
|
+ $this->settleAward($online);
|
|
|
1689
|
+ Db::name('order_tb')->where('order_tb_id', $online['order_tb_id'])->update(['gzc' => 1]);
|
|
|
1690
|
+ });
|
|
|
1691
|
+ }
|
|
|
1692
|
+ }
|
|
|
1693
|
+ }
|
|
|
1694
|
+
|
|
|
1695
|
+ /**
|
|
|
1696
|
+ * 唯品会订单结算
|
|
|
1697
|
+ * @param $timeLimit
|
|
|
1698
|
+ * @return void
|
|
|
1699
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1700
|
+ * @throws \think\db\exception\DbException
|
|
|
1701
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1702
|
+ */
|
|
|
1703
|
+ public function vipOrderNew($timeLimit)
|
|
|
1704
|
+ {
|
|
|
1705
|
+ // 普通订单
|
|
|
1706
|
+ $order_data = Db::name('order_vip')->where('status', 2)->where('gzc', 0)->select();
|
|
|
1707
|
+ if($order_data) {
|
|
|
1708
|
+ $order_data = $order_data->toArray();
|
|
|
1709
|
+ foreach ($order_data as $online) {
|
|
|
1710
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1711
|
+ if($date < date('Y-m-d H:i:s',$online['last_update_time'])) continue;
|
|
|
1712
|
+ $online['order_id'] = $online['order_vip_id'];
|
|
|
1713
|
+ Db::transaction(function () use ($online) {
|
|
|
1714
|
+ $this->settleAward($online);
|
|
|
1715
|
+ Db::name('order_vip')->where('order_vip_id', $online['order_vip_id'])->update(['gzc' => 1,'settle_time' => date('Y-m-d H:i:s')]);
|
|
|
1716
|
+ });
|
|
|
1717
|
+ }
|
|
|
1718
|
+ }
|
|
|
1719
|
+ }
|
|
|
1720
|
+
|
|
|
1721
|
+ /**
|
|
|
1722
|
+ * 抖音订单结算
|
|
|
1723
|
+ * @param $timeLimit
|
|
|
1724
|
+ * @return void
|
|
|
1725
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1726
|
+ * @throws \think\db\exception\DbException
|
|
|
1727
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1728
|
+ */
|
|
|
1729
|
+ public function dyOrderNew($timeLimit)
|
|
|
1730
|
+ {
|
|
|
1731
|
+ // 普通订单
|
|
|
1732
|
+ $order_data = Db::name('order_dy')->where('flow_point', 'SETTLE')->where('gzc', 0)->select();
|
|
|
1733
|
+ if($order_data) {
|
|
|
1734
|
+ $order_data = $order_data->toArray();
|
|
|
1735
|
+ foreach ($order_data as $online) {
|
|
|
1736
|
+ $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
|
|
|
1737
|
+ if($date < date('Y-m-d H:i:s',$online['pay_success_time'])) continue;
|
|
|
1738
|
+ $online['order_id'] = $online['order_dy_id'];
|
|
|
1739
|
+ Db::transaction(function () use ($online) {
|
|
|
1740
|
+ $this->settleAward($online);
|
|
|
1741
|
+ Db::name('order_dy')->where('order_dy_id', $online['order_dy_id'])->update(['gzc' => 1,'settle_time' => date('Y-m-d H:i:s')]);
|
|
|
1742
|
+ });
|
|
|
1743
|
+ }
|
|
|
1744
|
+ }
|
|
|
1745
|
+ }
|
|
|
1746
|
+
|
|
|
1747
|
+ /**
|
|
|
1748
|
+ * 结算奖励
|
|
|
1749
|
+ * @param $online
|
|
|
1750
|
+ * @return void
|
|
|
1751
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
1752
|
+ * @throws \think\db\exception\DbException
|
|
|
1753
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
1754
|
+ */
|
|
|
1755
|
+ public function settleAward($online)
|
|
|
1756
|
+ {
|
|
|
1757
|
+ // 结算积分
|
|
|
1758
|
+ $user_sign_score_list = Db::name('user_sign_score')
|
|
|
1759
|
+ ->where('status', -1)
|
|
|
1760
|
+ ->where('order_id', $online['order_id'])
|
|
|
1761
|
+ ->where('pm', 1)
|
|
|
1762
|
+ ->select()
|
|
|
1763
|
+ ->toArray();
|
|
|
1764
|
+ if($user_sign_score_list){
|
|
|
1765
|
+ foreach ($user_sign_score_list as $user_sign_score) {
|
|
|
1766
|
+ // 修改积分
|
|
|
1767
|
+ Db::name('user')
|
|
|
1768
|
+ ->where('uid', $user_sign_score['uid'])
|
|
|
1769
|
+ ->inc('score', (float)$user_sign_score['reward_socre'])
|
|
|
1770
|
+ ->update();
|
|
|
1771
|
+ Db::name('user_sign_score')
|
|
|
1772
|
+ ->where('id', $user_sign_score['id'])
|
|
|
1773
|
+ ->update([
|
|
|
1774
|
+ 'status' => 1,
|
|
|
1775
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1776
|
+ ]);
|
|
|
1777
|
+ }
|
|
|
1778
|
+ }
|
|
|
1779
|
+
|
|
|
1780
|
+ // 结算红包
|
|
|
1781
|
+ $user_sign_hongbao_list = Db::name('user_sign_hongbao')
|
|
|
1782
|
+ ->where('status', -1)
|
|
|
1783
|
+ ->where('order_id', $online['order_id'])
|
|
|
1784
|
+ ->where('type', 1)
|
|
|
1785
|
+ ->select()
|
|
|
1786
|
+ ->toArray();
|
|
|
1787
|
+ if($user_sign_hongbao_list){
|
|
|
1788
|
+ foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
|
|
|
1789
|
+ // 修改红包
|
|
|
1790
|
+ Db::name('user')
|
|
|
1791
|
+ ->where('uid', $user_sign_hongbao['uid'])
|
|
|
1792
|
+ ->inc('hongbao', (float)$user_sign_hongbao['number'])
|
|
|
1793
|
+ ->update();
|
|
|
1794
|
+ Db::name('user_sign_hongbao')
|
|
|
1795
|
+ ->where('id', $user_sign_hongbao['id'])
|
|
|
1796
|
+ ->update([
|
|
|
1797
|
+ 'status' => 1,
|
|
|
1798
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1799
|
+ ]);
|
|
|
1800
|
+ }
|
|
|
1801
|
+ }
|
|
|
1802
|
+
|
|
|
1803
|
+
|
|
|
1804
|
+ // 结算京豆
|
|
|
1805
|
+ $user_sign_jingdou_list = Db::name('user_sign_jingdou')
|
|
|
1806
|
+ ->where('status', -1)
|
|
|
1807
|
+ ->where('order_id', $online['order_id'])
|
|
|
1808
|
+ ->where('type', 1)
|
|
|
1809
|
+ ->select()
|
|
|
1810
|
+ ->toArray();
|
|
|
1811
|
+ if($user_sign_jingdou_list){
|
|
|
1812
|
+ foreach ($user_sign_jingdou_list as $user_sign_jingdou) {
|
|
|
1813
|
+ // 修改京豆
|
|
|
1814
|
+ Db::name('user')
|
|
|
1815
|
+ ->where('uid', $user_sign_jingdou['uid'])
|
|
|
1816
|
+ ->inc('jingdou', (float)$user_sign_jingdou['number'])
|
|
|
1817
|
+ ->update();
|
|
|
1818
|
+ Db::name('user_sign_jingdou')
|
|
|
1819
|
+ ->where('id', $user_sign_jingdou['id'])
|
|
|
1820
|
+ ->update([
|
|
|
1821
|
+ 'status' => 1,
|
|
|
1822
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1823
|
+ ]);
|
|
|
1824
|
+ }
|
|
|
1825
|
+ }
|
|
|
1826
|
+
|
|
|
1827
|
+ // 结算复购金
|
|
|
1828
|
+ $user_sign_fugou_list = Db::name('user_sign_fugou')
|
|
|
1829
|
+ ->where('status', -1)
|
|
|
1830
|
+ ->where('order_id', $online['order_id'])
|
|
|
1831
|
+ ->where('type', 1)
|
|
|
1832
|
+ ->select()
|
|
|
1833
|
+ ->toArray();
|
|
|
1834
|
+ if($user_sign_fugou_list){
|
|
|
1835
|
+ foreach ($user_sign_fugou_list as $user_sign_fugou) {
|
|
|
1836
|
+ // 修改复购金
|
|
|
1837
|
+ Db::name('user')
|
|
|
1838
|
+ ->where('uid', $user_sign_fugou['uid'])
|
|
|
1839
|
+ ->inc('fugou', (float)$user_sign_fugou['number'])
|
|
|
1840
|
+ ->update();
|
|
|
1841
|
+ Db::name('user_sign_fugou')
|
|
|
1842
|
+ ->where('id', $user_sign_fugou['id'])
|
|
|
1843
|
+ ->update([
|
|
|
1844
|
+ 'status' => 1,
|
|
|
1845
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1846
|
+ ]);
|
|
|
1847
|
+ }
|
|
|
1848
|
+ }
|
|
|
1849
|
+
|
|
|
1850
|
+
|
|
|
1851
|
+ // 结算贡献值
|
|
|
1852
|
+ $user_sign_gongxian_list = Db::name('user_sign_gongxian')
|
|
|
1853
|
+ ->where('status', -1)
|
|
|
1854
|
+ ->where('order_id', $online['order_id'])
|
|
|
1855
|
+ ->where('type', 1)
|
|
|
1856
|
+ ->select()
|
|
|
1857
|
+ ->toArray();
|
|
|
1858
|
+ if($user_sign_gongxian_list){
|
|
|
1859
|
+ foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
|
|
|
1860
|
+ // 修改贡献值
|
|
|
1861
|
+ Db::name('user')
|
|
|
1862
|
+ ->where('uid', $user_sign_gongxian['uid'])
|
|
|
1863
|
+ ->inc('contribute', (float)$user_sign_gongxian['number'])
|
|
|
1864
|
+ ->update();
|
|
|
1865
|
+ Db::name('user_sign_gongxian')
|
|
|
1866
|
+ ->where('id', $user_sign_gongxian['id'])
|
|
|
1867
|
+ ->update([
|
|
|
1868
|
+ 'status' => 1,
|
|
|
1869
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1870
|
+ ]);
|
|
|
1871
|
+ /** @var UserRepository $userRepository */
|
|
|
1872
|
+ $userRepository = app()->make(UserRepository::class);
|
|
|
1873
|
+ $userRepository->setUserIdentity($user_sign_gongxian['uid']);
|
|
|
1874
|
+ }
|
|
|
1875
|
+ }
|
|
|
1876
|
+
|
|
|
1877
|
+ // 结算PV值
|
|
|
1878
|
+ $user_pv_list = Db::name('user_pv_log')
|
|
|
1879
|
+ ->where('status', -1)
|
|
|
1880
|
+ ->where('order_id', $online['order_id'])
|
|
|
1881
|
+ ->select()
|
|
|
1882
|
+ ->toArray();
|
|
|
1883
|
+ if($user_pv_list) {
|
|
|
1884
|
+ foreach ($user_pv_list as $user_pv) {
|
|
|
1885
|
+ // 修改pv
|
|
|
1886
|
+ Db::name('user')
|
|
|
1887
|
+ ->where('uid', $user_pv['uid'])
|
|
|
1888
|
+ ->inc('pv', (float)$user_pv['pv'])
|
|
|
1889
|
+ ->update();
|
|
|
1890
|
+ Db::name('user_pv_log')
|
|
|
1891
|
+ ->where('id', $user_pv['id'])
|
|
|
1892
|
+ ->update([
|
|
|
1893
|
+ 'status' => 1,
|
|
|
1894
|
+ 'settlement_time' => date('Y-m-d H:i:s')
|
|
|
1895
|
+ ]);
|
|
|
1896
|
+ }
|
|
|
1897
|
+ }
|
|
|
1898
|
+
|
|
|
1899
|
+
|
|
|
1900
|
+ // 结算佣金养老金
|
|
|
1901
|
+ $user_bill_list = Db::name('user_bill')
|
|
|
1902
|
+ ->where('status', 0)
|
|
|
1903
|
+ ->where([ 'link_id' => $online['order_id']])
|
|
|
1904
|
+ ->where([ 'pm' => 1])
|
|
|
1905
|
+ ->select()
|
|
|
1906
|
+ ->toArray();
|
|
|
1907
|
+ if($user_bill_list){
|
|
|
1908
|
+ foreach ($user_bill_list as $user_bill) {
|
|
|
1909
|
+ Db::name('user')
|
|
|
1910
|
+ ->where('uid', $user_bill['uid'])
|
|
|
1911
|
+ ->inc('brokerage_price', (float)$user_bill['number'])
|
|
|
1912
|
+ ->update();
|
|
|
1913
|
+ Db::name('user_bill')
|
|
|
1914
|
+ ->where('bill_id', $user_bill['bill_id'])
|
|
|
1915
|
+ ->update([
|
|
|
1916
|
+ 'status' => 1,
|
|
|
1917
|
+ 'take_time' => date('Y-m-d H:i:s')
|
|
|
1918
|
+ ]);
|
|
|
1919
|
+ }
|
|
|
1920
|
+ }
|
|
|
1921
|
+ //按角色结算
|
|
|
1922
|
+// $StoreOrderRepository->close_order($online['order_id']);
|
|
|
1923
|
+ }
|
|
1527
|
1924
|
}
|