Преглед изворни кода

Merge branch 'master' of https://git.bjtdba.com/shop/php

hefei пре 1 година
родитељ
комит
7d9f01bcbe

+ 18 - 3
app/controller/api/Notify.php

@@ -159,12 +159,12 @@ class Notify
159 159
                             $fgj_pri=0;//推广者的佣金抽10%到个人复购金
160 160
 
161 161
                             $pv = 0; //待分配的PV
162
-
162
+                            $wenan = '';
163 163
 
164 164
                             //var_dump($store_product_data['concession_pri']);return;
165 165
                             //精彩生活
166 166
                             if($store_order_data['mer_id'] == 439){
167
-
167
+                                $wenan = '精彩生活';
168 168
 
169 169
                                 //分配参数
170 170
                                 $job_par = [];
@@ -398,7 +398,7 @@ class Notify
398 398
 
399 399
                                 //VIP专区
400 400
                             }else if($store_order_data['mer_id'] == 496){
401
-
401
+                                $wenan = '会员专区';
402 402
                                 //业务员和以上推广的等级获得推广佣金
403 403
                                 $le_yw_amount = 0;
404 404
                                 //获赠的贡献值和积分
@@ -744,6 +744,7 @@ class Notify
744 744
 
745 745
 
746 746
                             } else {
747
+                                $wenan = '商贸区';
747 748
                                 // 商贸区
748 749
                                 /** @var \app\common\repositories\merchant\MerchantRepository $merchant */
749 750
                                 $merchant = app()->make(MerchantRepository::class);
@@ -897,6 +898,20 @@ class Notify
897 898
                                     if($vrpri  >= 0 ){
898 899
 
899 900
                                         Db::name("user")->where("uid", $user_data['uid'])->update(['score'=>$vrpri]);
901
+
902
+                                        //消费积分日志
903
+                                        $log_data = [
904
+                                            "uid" => $user_data['uid'],
905
+                                            "reward_socre" => $fzone_paytype['other'],
906
+                                            "addtime" => time(),
907
+                                            "status" => 1,
908
+                                            "order_id" => $store_order_data['order_id'],
909
+                                            "mark" => "购买" . $wenan . "商品消费积分:" . $array_fzone_paytype['other'],
910
+                                            "surplus" => $vrpri,
911
+                                            "pm" => 2,
912
+                                            "source_type" => 5
913
+                                        ];
914
+                                        Db::name("user_sign_score")->insert($log_data);
900 915
                                     }else{
901 916
                                         $note_arr = ["uid"=>$user_data['uid'],"dec_score"=>$array_fzone_paytype['other'],"rem_score"=>$user_data['score'],"msg"=>"积分不足","fzone_paytype"=>$store_order_data['fzone_paytype']];
902 917
                                         Db::name("test_log")->insert(['create_time'=>date('Y-m-d H:i:s'),'note'=>json_encode($note_arr, JSON_UNESCAPED_UNICODE)]);

+ 13 - 0
app/controller/api/store/order/StoreRefundOrder.php

@@ -144,6 +144,19 @@ class StoreRefundOrder extends BaseController
144 144
             if (!$order) return app('json')->fail('订单状态错误');
145 145
             if ($order->status < 0) return app('json')->fail('订单已退款');
146 146
             if ($order->status == 4) return app('json')->fail('订单已申请退款');
147
+
148
+            // 目前退款即 是 全额退款 没有部分退款
149
+            $group_order_id = Db::name('store_order')
150
+                ->where('order_id', $order['order_id'])
151
+                ->value('group_order_id');
152
+            $group_order_map = Db::name('store_group_order')
153
+                ->where('group_order_id', $group_order_id)
154
+                ->field('pay_price,hf_pay_id')
155
+                ->find();
156
+            if (!empty($group_order_map['hf_pay_id'])) {
157
+                $data['refund_price'] = $group_order_map['pay_price'];
158
+            }
159
+
147 160
             if ($type == 1) {
148 161
                 $refund = $this->repository->refund($order, (int)$ids[0], $num, $uid, $data);
149 162
             } else {

+ 79 - 0
app/controller/merchant/store/order/RefundOrder.php

@@ -120,6 +120,85 @@ class RefundOrder extends BaseController
120 120
             $data['status'] = $status;
121 121
             $this->repository->agree($id,$data,$this->request->adminId(),1);
122 122
 
123
+            // 获取订单金额
124
+            $store_order_info = Db::name('store_order')
125
+                ->where('order_id', $refund_order['order_id'])
126
+                ->find();
127
+            $group_order_map = Db::name('store_group_order')
128
+                ->where('group_order_id', $store_order_info['group_order_id'])
129
+                ->field('uid,pay_price,hf_pay_id,fzone_paytype')
130
+                ->find();
131
+            $make = '商贸区';
132
+            if ($store_order_info['mer_id'] == 439) {
133
+                $make = '精彩生活';
134
+            } else if ($store_order_info['mer_id'] == 496) {
135
+                $make = '会员专区';
136
+            }
137
+
138
+            // 如果是组合支付 现金 + 积分 则需要把积分退回
139
+            // 参考 app\controller\api\Notify.php -- 745 $array_fzone_paytype['type']=='b2'
140
+            $array_fzone_paytype = json_decode($group_order_map['fzone_paytype'], true);
141
+            if (!empty($array_fzone_paytype)) {
142
+                if ($array_fzone_paytype['type'] == 'b2') {
143
+                    // {"checked":true,"note":"现金+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
144
+
145
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('score');
146
+                    $vrpri += $array_fzone_paytype['other'];
147
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['score' => $vrpri]);
148
+
149
+                    $data = [
150
+                        "uid" => $store_order_info['uid'],
151
+                        "reward_socre" => $array_fzone_paytype['other'],
152
+                        "addtime" => time(),
153
+                        "status" => 1,
154
+                        "order_id" => $store_order_info['order_id'],
155
+                        "mark" => "{$make}商品申请退款退回积分",
156
+                        "surplus" => $vrpri,
157
+                        "pm" => 1,
158
+                        "source_type" => 3
159
+                    ];
160
+                    Db::name("user_sign_score")->insert($data);//添加积分记录
161
+                } else if ($array_fzone_paytype['type'] == 'a3') {
162
+                    // {"checked":true,"note":"现金+VR","other":1.5,"price":8.5,"total":0.0,"type":"a3","vr":"48799.82"}
163
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
164
+                    $vrpri += $array_fzone_paytype['other'];
165
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
166
+
167
+                    //VR入账
168
+                    $insertdata = [
169
+                        'uid'=> $store_order_info['uid'],
170
+                        'number' =>  $array_fzone_paytype['other'],
171
+                        'surplus' => $vrpri,
172
+                        'mark' => "{$make}商品申请退款退回VR",
173
+                        'order_id'=> $store_order_info['order_id'],
174
+                        'type' => 2,
175
+                        'addtime' => time(),
176
+                        'settlement_time'=> date('Y-m-d H:i:s', time())
177
+                    ];
178
+                    Db::name('user_sign_vr')->insert($insertdata);
179
+
180
+                }
181
+                // else if ($array_fzone_paytype['type'] == 'c1') {
182
+                //     // {"checked":true,"note":"复购金","other":1.5,"price":8.5,"total":0.0,"type":"c1","vr":"48799.82"}
183
+                //     $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('fugou');
184
+                //     $vrpri += $array_fzone_paytype['other'];
185
+                //     Db::name("user")->where("uid", $group_order_map['uid'])->update(['fugou' => $vrpri]);
186
+                //     //支出账号存到log日志
187
+                //     $log_data = [
188
+                //         'uid' => $store_order_info['uid'],
189
+                //         'number' => $array_fzone_paytype['price'],
190
+                //         'mark' => "复购区商品申请退款退回复购金:" . $array_fzone_paytype['price'],
191
+                //         'desc' => "复购金",
192
+                //         'order_id' =>  $store_order_info['order_id'],
193
+                //         'surplus' => $vrpri,
194
+                //         'order_type' => 0,
195
+                //         'type' => 2,
196
+                //         'addtime' => time()
197
+                //     ];
198
+                //     $user_res_log = Db::name("user_sign_fugou")->insert($log_data);
199
+                // }
200
+            }
201
+
123 202
             // 取消 订单所发放的福利
124 203
             $this->repository->cancelOrderBonus($id);
125 204
         }else{