|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+
|
|
|
3
|
+namespace app\command;
|
|
|
4
|
+
|
|
|
5
|
+use app\common\model\user\UserCertification;
|
|
|
6
|
+use app\common\repositories\merchant\order\OrderGzcRepository;
|
|
|
7
|
+use think\console\Command;
|
|
|
8
|
+use think\console\Input;
|
|
|
9
|
+use think\console\Output;
|
|
|
10
|
+use think\facade\Db;
|
|
|
11
|
+use think\facade\Log;
|
|
|
12
|
+
|
|
|
13
|
+class GzcAddByBillCommand extends Command
|
|
|
14
|
+{
|
|
|
15
|
+ protected function configure()
|
|
|
16
|
+ {
|
|
|
17
|
+ // 配置命令名称及描述
|
|
|
18
|
+ $this->setName('gzcAddByBill')
|
|
|
19
|
+ ->setDescription('从bill表中查询未提交到公证处的养老金记录,并提交公证处');
|
|
|
20
|
+ }
|
|
|
21
|
+
|
|
|
22
|
+ protected function execute(Input $input, Output $output)
|
|
|
23
|
+ {
|
|
|
24
|
+ // 在这里执行任务的具体内容
|
|
|
25
|
+ $output->writeln('定时任务执行中...');
|
|
|
26
|
+
|
|
|
27
|
+ $nowTime = time();
|
|
|
28
|
+ $this->billGzcAdd($nowTime);
|
|
|
29
|
+
|
|
|
30
|
+ $output->writeln('定时任务执行完成');
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ /**
|
|
|
34
|
+ * 线下支付订单公证处IN10入账
|
|
|
35
|
+ * @param $nowTime
|
|
|
36
|
+ * author: php迷途小书童
|
|
|
37
|
+ * created: 2021/3/20 9:26
|
|
|
38
|
+ */
|
|
|
39
|
+ public function billGzcAdd($nowTime)
|
|
|
40
|
+ {
|
|
|
41
|
+ /** @var OrderGzcRepository $OrderGzcRepository */
|
|
|
42
|
+ $OrderGzcRepository = app()->make(OrderGzcRepository::class);
|
|
|
43
|
+ $cursor = Db::name('user_bill')
|
|
|
44
|
+ ->where('status', 1)
|
|
|
45
|
+ ->where('is_gzc', 0)
|
|
|
46
|
+ ->where('commission_type', 5)
|
|
|
47
|
+ ->select()
|
|
|
48
|
+ ->toArray();
|
|
|
49
|
+ if ($cursor) {
|
|
|
50
|
+ foreach ($cursor as $bill) {
|
|
|
51
|
+ $type_shop = $bill['type_shop'] ?? 0;
|
|
|
52
|
+ switch ($type_shop) {
|
|
|
53
|
+ case "0":
|
|
|
54
|
+ $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
|
55
|
+ break;
|
|
|
56
|
+ case "1":
|
|
|
57
|
+ $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
58
|
+ break;
|
|
|
59
|
+ case "2":
|
|
|
60
|
+ $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
61
|
+ break;
|
|
|
62
|
+ case "3":
|
|
|
63
|
+ $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
64
|
+ break;
|
|
|
65
|
+ case "4":
|
|
|
66
|
+ $online = '';
|
|
|
67
|
+ break;
|
|
|
68
|
+ case "5":
|
|
|
69
|
+ $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
70
|
+ break;
|
|
|
71
|
+ case "6":
|
|
|
72
|
+ $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
73
|
+ break;
|
|
|
74
|
+ case "7":
|
|
|
75
|
+ $online = '';
|
|
|
76
|
+ break;
|
|
|
77
|
+ case "8":
|
|
|
78
|
+ $online = '';
|
|
|
79
|
+ break;
|
|
|
80
|
+ case "9":
|
|
|
81
|
+ $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
|
|
|
82
|
+ break;
|
|
|
83
|
+ default:
|
|
|
84
|
+ $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
|
|
|
85
|
+ }
|
|
|
86
|
+ if (!$online) {
|
|
|
87
|
+ Log::info($bill['uid'] . '查询不到订单');
|
|
|
88
|
+ continue;
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+ $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
|
|
|
92
|
+ if (!$certification) {
|
|
|
93
|
+ Log::info($online['uid'] . '没有实名认证');
|
|
|
94
|
+ continue;
|
|
|
95
|
+ }
|
|
|
96
|
+
|
|
|
97
|
+ $pension = $bill['number'] ?? 0;
|
|
|
98
|
+ if ($pension <= 0) {
|
|
|
99
|
+ Log::info($online['order_sn'] . 'pension' . $pension);
|
|
|
100
|
+ continue;
|
|
|
101
|
+ }
|
|
|
102
|
+
|
|
|
103
|
+ //新增入账明细记录
|
|
|
104
|
+ list($msec, $sec) = explode(' ', microtime());
|
|
|
105
|
+ $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
|
|
|
106
|
+ $orderId = 'IN10' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
|
|
|
107
|
+ $create = [
|
|
|
108
|
+ 'uid' => $online['uid'],
|
|
|
109
|
+ 'platform_no' => $orderId,
|
|
|
110
|
+ 'account_type' => 1,
|
|
|
111
|
+ 'user_name' => $certification['user_name'],
|
|
|
112
|
+ 'mobile' => $certification['mobile'],
|
|
|
113
|
+ 'user_card' => $certification['user_card'],
|
|
|
114
|
+ 'pension' => $pension,
|
|
|
115
|
+ 'order_type' => $type_shop,
|
|
|
116
|
+ 'out_trade_no' => $online['order_sn'],
|
|
|
117
|
+ 'link_id' => $bill['bill_id']
|
|
|
118
|
+ ];
|
|
|
119
|
+ $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
|
|
|
120
|
+ $check = Db::name("gzc_logs")->where("link_id", $bill['bill_id'])->where("order_type", $type_shop)->count();
|
|
|
121
|
+ if ($test_user == 0 && $check <= 0) {
|
|
|
122
|
+ $OrderGzcRepository->create($create);
|
|
|
123
|
+ Db::name('user_bill')
|
|
|
124
|
+ ->where('bill_id', $bill['bill_id'])
|
|
|
125
|
+ ->where('commission_type', 5)
|
|
|
126
|
+ ->update([
|
|
|
127
|
+ 'is_gzc' => 1,
|
|
|
128
|
+ 'gzc' => 1
|
|
|
129
|
+ ]);
|
|
|
130
|
+ }
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ }
|
|
|
134
|
+}
|