sunxbiao 1 год назад
Родитель
Сommit
5ba4f1c605

+ 5 - 0
app/common/model/merchant/order/OrderGzc.php

@@ -12,6 +12,7 @@ namespace app\common\model\merchant\order;
12 12
 
13 13
 use app\common\model\BaseModel;
14 14
 use app\common\model\user\User;
15
+use app\common\model\user\UserBill;
15 16
 
16 17
 class OrderGzc extends BaseModel
17 18
 {
@@ -31,4 +32,8 @@ class OrderGzc extends BaseModel
31 32
         return $this->hasOne(User::class, 'uid', 'uid');
32 33
     }
33 34
 
35
+    public function bill()
36
+    {
37
+        return $this->hasOne(UserBill::class, 'bill_id', 'link_id');
38
+    }
34 39
 }

+ 88 - 26
app/common/repositories/merchant/order/OrderGzcRepository.php

@@ -17,6 +17,7 @@ use app\traits\GzcApiRequest;
17 17
 use Carbon\Carbon;
18 18
 use crmeb\services\SpreadsheetExcelService;
19 19
 use FormBuilder\Factory\Elm;
20
+use think\facade\Db;
20 21
 use think\facade\Log;
21 22
 use think\facade\Route;
22 23
 
@@ -50,36 +51,97 @@ class OrderGzcRepository extends BaseRepository
50 51
         // 导出
51 52
         $is_excel = request()->param('is_excel', 0);
52 53
         if ($is_excel == 1) {
53
-            $data = $query->with('user')->select();
54
+            $data = $query->with(['user', 'bill'])->select()->toArray();
55
+
54 56
             $arr = [];
55
-            foreach ($data as $item) {
56
-                $arr[] = [
57
-                    $item['id'],
58
-                    $item['platform_no'],
59
-                    $item['user']['nickname'],
60
-                    $item['user']['account'],
61
-                    $item['user_name'],
62
-                    $item['mobile'],
63
-                    $item['user_card'],
64
-                    $item['bank_name'],
65
-                    $item['branch_name'],
66
-                    $item['bank_account'],
67
-                    $item['bank_no'],
68
-                    $item['alipay_account'],
69
-                    $item['alipay_no'],
70
-                    $item['wxpay_account'],
71
-                    $item['wxpay_no'],
72
-                    $item['out_trade_no'],
73
-                    $item['pension'],
74
-                    $item['gzc'] == 1 ? '已发起' : '待发起',
75
-                    $item['gzc_deposit_no'],
76
-                    $item['gzc_confirm_result'],
77
-                    $item['create_time'],
78
-                    $item['update_time']
57
+            if (!empty($data)) {
58
+                $orderTypeMap = [];
59
+                $orderDetailMap = [];
60
+                $orderMap = [
61
+                    0 => ['table' => 'rrx_store_order', 'name' => '平台订单', 'pk' => 'order_id', 'field' => 'order_id, total_price AS order_money, pay_price AS pay_money, con_pri AS commission, mer_id'],
62
+                    1 => ['table' => 'rrx_order_pdd', 'name' => '拼多多', 'pk' => 'order_pdd_id', 'field' => 'order_pdd_id AS order_id, order_money, pay_money, commission'],
63
+                    2 => ['table' => 'rrx_order_vip', 'name' => '唯品会', 'pk' => 'order_vip_id', 'field' => 'order_vip_id AS order_id, pay_money AS order_money, pay_money, commission'],
64
+                    3 => ['table' => 'rrx_order_su', 'name' => '苏宁', 'pk' => 'order_su_id', 'field' => 'order_su_id AS order_id, total_amount AS order_money, pay_amount AS pay_money, commission'],
65
+                    5 => ['table' => 'rrx_order_tb', 'name' => '淘宝', 'pk' => 'order_tb_id', 'field' => 'order_tb_id AS order_id, alipay_total_price AS order_money, alipay_total_price AS pay_money, commission'],
66
+                    6 => ['table' => 'rrx_order_jd', 'name' => '京东', 'pk' => 'order_jd_id', 'field' => 'order_jd_id AS order_id, pay_money AS order_money, pay_money AS pay_money, commission'],
67
+                    9 => ['table' => 'rrx_order_huafei', 'name' => '话费', 'pk' => 'order_huafei_id', 'field' => 'order_huafei_id AS order_id, pay_money AS order_money, pay_money AS pay_money, commission'],
68
+                    10 => ['table' => 'rrx_order_merchant', 'name' => '线下扫码', 'pk' => 'id', 'field' => 'id AS order_id, money AS order_money, money AS pay_money, available AS commission']
79 69
                 ];
70
+
71
+                foreach ($data as $gzcData) {
72
+                    if (!empty($gzcData['link_id']) && !empty($gzcData['bill'])) {
73
+                        $orderTypeMap[$gzcData['bill']['type_shop']][$gzcData['bill']['link_id']][] = $gzcData['id'];
74
+
75
+                    }
76
+                }
77
+
78
+                if (!empty($orderTypeMap)) {
79
+                    foreach ($orderTypeMap as $orderType => $map) {
80
+                        if (isset($orderMap[$orderType])) {
81
+                            $config = $orderMap[$orderType];
82
+                            $result = Db::table($config['table'])
83
+                                ->whereIn($config['pk'], array_keys($map))
84
+                                ->field($config['field'])
85
+                                ->select()
86
+                                ->toArray();
87
+                            if (!empty($result)) {
88
+                                foreach ($result as $orderData) {
89
+                                    foreach ($map[$orderData['order_id']] as $gzcId) {
90
+                                        if (0 === (int)$orderType && !empty($orderData['mer_id'] ?? '')) {
91
+                                            if ($orderData['mer_id'] == 496) {
92
+                                                $orderData['commission'] = '';
93
+                                                $orderData['source'] = '会员专区';
94
+                                            } else if ($orderData['mer_id'] == 439) {
95
+                                                $orderData['source'] = '精彩生活区';
96
+                                            } else if ($orderData['mer_id'] == 491) {
97
+                                                $orderData['commission'] = '';
98
+                                                $orderData['source'] = '复购区';
99
+                                            } else {
100
+                                                $orderData['source'] = '商贸区';
101
+                                            }
102
+                                        } else {
103
+                                            $orderData['source'] = $orderMap[$orderType]['name'];
104
+                                        }
105
+                                        $orderDetailMap[$gzcId] = $orderData;
106
+                                    }
107
+                                }
108
+                            }
109
+                        }
110
+                    }
111
+                }
112
+
113
+                foreach ($data as $item) {
114
+                    $arr[] = [
115
+                        $item['id'],
116
+                        $item['platform_no'],
117
+                        $item['user']['nickname'],
118
+                        $item['user']['account'],
119
+                        $item['user_name'],
120
+                        $item['mobile'],
121
+                        $item['user_card'],
122
+                        $item['bank_name'],
123
+                        $item['branch_name'],
124
+                        $item['bank_account'],
125
+                        $item['bank_no'],
126
+                        $item['alipay_account'],
127
+                        $item['alipay_no'],
128
+                        $item['wxpay_account'],
129
+                        $item['wxpay_no'],
130
+                        $orderDetailMap[$item['id']]['source'] ?? '',
131
+                        $orderDetailMap[$item['id']]['order_money'] ?? '',
132
+                        $orderDetailMap[$item['id']]['commission'] ?? '',
133
+                        $item['out_trade_no'],
134
+                        $item['pension'],
135
+                        $item['gzc'] == 1 ? '已发起' : '待发起',
136
+                        $item['gzc_deposit_no'],
137
+                        $item['gzc_confirm_result'],
138
+                        $item['create_time'],
139
+                        $item['update_time']
140
+                    ];
141
+                }
80 142
             }
81 143
             return $this->getStatisticsExcel([
82
-                'ID', '平台申请单号', '用户昵称', '用户账号', '实名认证姓名', '实名认证电话', '实名认证证件号', '银行名称', '银行名称', '开户账号', '转账流水号', '支付宝账号', '支付宝流水号', '微信账号', '微信流水号', '关联订单', '养老金', '处理状态', '公证处入账编号', '公证处入账结果', '创建时间', '更新时间'
144
+                'ID', '平台申请单号', '用户昵称', '用户账号', '实名认证姓名', '实名认证电话', '实名认证证件号', '银行名称', '银行名称', '开户账号', '转账流水号', '支付宝账号', '支付宝流水号', '微信账号', '微信流水号', '订单来源', '订单金额', '订单利润', '关联订单', '养老金', '处理状态', '公证处入账编号', '公证处入账结果', '创建时间', '更新时间'
83 145
             ], $arr, '公证处入账明细');
84 146
         }
85 147
 

+ 2 - 2
app/controller/api/Auth.php

@@ -1361,7 +1361,7 @@ class Auth extends BaseController
1361 1361
 
1362 1362
     public function verify(UserAuthValidate $validate)
1363 1363
     {
1364
-        $data = $this->request->params(['phone', 'code', 'key',"type"]);
1364
+        $data = $this->request->params(['phone', 'code', 'key',"type", 'areaCode']);
1365 1365
         $validate->sceneVerify()->check($data);
1366 1366
         log::info("发送短信方法");
1367 1367
         if ($data['type']=="register"){
@@ -1382,7 +1382,7 @@ class Auth extends BaseController
1382 1382
         }
1383 1383
         $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
1384 1384
         $sms_time = systemConfig('sms_time') ? systemConfig('sms_time') : 30 ;
1385
-        $res = app()->make(AliYunSmsService::class)->send($data['phone'],  $sms_code);
1385
+        $res = app()->make(AliYunSmsService::class)->send(($data['areaCode'] ?? '') . $data['phone'],  $sms_code);
1386 1386
         if($res['Code']!='OK'){
1387 1387
             Db::name('log')->insert(['data'=>'幸福保短信发送失败:'.json_encode($res,256)]);
1388 1388
             return app('json')->fail('操作过于频繁,请稍后重试~');

+ 1 - 1
app/validate/api/UserAuthValidate.php

@@ -17,7 +17,7 @@ class UserAuthValidate extends Validate
17 17
     protected $failException = true;
18 18
 
19 19
     protected $rule = [
20
-        'phone|手机号' => 'require|mobile',
20
+        // 'phone|手机号' => 'require|mobile',
21 21
         'pwd|密码' => 'require|min:6',
22 22
         'sms_code|短信验证码' => 'require|max:4',
23 23
     ];

+ 23 - 4
crmeb/services/AliYunSmsService.php

@@ -36,13 +36,32 @@ class AliYunSmsService
36 36
             ->regionId('cn-hangzhou')
37 37
             ->asDefaultClient();
38 38
         $templateParam['code'] = $code;
39
+        $content = '';
39 40
         log::info("发送短信方法");
40 41
         switch ($templateId) {
41 42
             case 'AUTHCODE':
42
-                $SignName = '融合华夏';
43
-                $TemplateCode = 'SMS_311255692';
43
+                // 移除所有非数字字符(保留+)
44
+                $mobile = preg_replace('/[^0-9+]/', '', $mobile);
44 45
 
45
-                $content = '【华夏幸福保】您的验证码是:' . $code;
46
+                if (strpos($mobile, '+') === false || strpos($mobile, '+86') === 0) {
47
+                    if (strpos($mobile, '+86') === 0) {
48
+                        $mobile = substr($mobile, 3);
49
+                    }
50
+                    $SignName = '融合华夏';
51
+                    $TemplateCode = 'SMS_311255692';
52
+                    $content = '【华夏幸福保】您的验证码是:' . $code;
53
+                } else {
54
+                    if (strpos($mobile, '+') === 0) {
55
+                        $mobile = substr($mobile, 1);
56
+                    }
57
+                    $SignName = '融合华夏';
58
+                    $TemplateCode = 'SMS_492105133';
59
+                    $templateParam = [
60
+                        'code_zh' => $code,
61
+                        'code_en' => $code
62
+                    ];
63
+                    $content = '【融合华夏】您的验证码是:' . $code . ',请输入此验证码以完成验证流程。Your verification code is:' . $code . '. Please enter this code to complete your verification process.';
64
+                }
46 65
                 break;
47 66
             case 'ONESELFCARRY':
48 67
                 $SignName = '华夏幸福保';
@@ -78,7 +97,7 @@ class AliYunSmsService
78 97
                 ->request();
79 98
 
80 99
             log::info("短信:返回参数");
81
-            log::info($result);
100
+            log::info(json_encode($result->toArray()));
82 101
             Db::name('sms_record')->insert(['phone' => $mobile, 'content' => $content, 'template' => $TemplateCode, 'create_time'=>date("Y-m-d H:i:s")]);
83 102
             return $result->toArray();
84 103
         // } catch (ClientException $e) {