Explorar o código

修复退款问题

sunxbiao hai 1 ano
pai
achega
599237200e

+ 9 - 1
app/common/repositories/store/order/StoreRefundOrderRepository.php

@@ -1087,7 +1087,15 @@ class StoreRefundOrderRepository extends BaseRepository
1087 1087
 
1088 1088
 
1089 1089
         $pay_type=Db::name('store_order')->where('order_id',$res['order_id'])->find();
1090
-        if($pay_type['pay_type']==5){
1090
+        // 本想根据订单实际支付金额 进行判断 ,结果 这些字段 都声明了 每一个使用正确赋值正确的,无语
1091
+        // 只能用前边人 写的 支付类型做判断了  硬编码...
1092
+        $group_order_map = Db::name('store_group_order')
1093
+            ->where('group_order_id', $pay_type['group_order_id'])
1094
+            ->field('uid,pay_price,hf_pay_id,fzone_paytype')
1095
+            ->find();
1096
+        $array_fzone_paytype = json_decode($group_order_map['fzone_paytype'], true);
1097
+        // 'a1' 不能退 会员专区
1098
+        if ($pay_type['pay_type'] == 5 || in_array($array_fzone_paytype['type'], ['b1', 'b3', 'b5'])) {
1091 1099
             Db::name('store_order')->where('order_id',$res['order_id'])->update(['status'=>'-1']);
1092 1100
 
1093 1101
 //            $special_merchant = merchantConfig($pay_type['pay_mer_id'], 'special_merchant');

+ 85 - 1
app/controller/merchant/store/order/RefundOrder.php

@@ -142,7 +142,41 @@ class RefundOrder extends BaseController
142 142
             // 参考 app\controller\api\Notify.php -- 745 $array_fzone_paytype['type']=='b2'
143 143
             $array_fzone_paytype = json_decode($group_order_map['fzone_paytype'], true);
144 144
             if (!empty($array_fzone_paytype)) {
145
-                if ($array_fzone_paytype['type'] == 'b2') {
145
+                if ($array_fzone_paytype['type'] == 'b1') {
146
+                    // VR+积分 {"checked":true,"note":"VR+积分","other":210.0,"price":970.0,"total":0.0,"type":"b1","vr":"47557.5"}
147
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
148
+                    $vrpri += $array_fzone_paytype['price'];
149
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
150
+                    Db::name("user_sign_vr")->insert([
151
+                        'uid' => $store_order_info['uid'],
152
+                        'number' => $array_fzone_paytype['price'],
153
+                        'mark' => "{$make}商品申请退款退回VR",
154
+                        'desc' => "VR",
155
+                        'order_type' => 0,
156
+                        'order_id' => $store_order_info['order_id'],
157
+                        'surplus' => $vrpri,
158
+                        'type' => 1,
159
+                        'addtime' => time()
160
+                    ]);
161
+
162
+                    // {"checked":true,"note":"VR+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
163
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('score');
164
+                    $vrpri += $array_fzone_paytype['other'];
165
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['score' => $vrpri]);
166
+
167
+                    $data = [
168
+                        "uid" => $store_order_info['uid'],
169
+                        "reward_socre" => $array_fzone_paytype['other'],
170
+                        "addtime" => time(),
171
+                        "status" => 1,
172
+                        "order_id" => $store_order_info['order_id'],
173
+                        "mark" => "{$make}商品申请退款退回积分",
174
+                        "surplus" => $vrpri,
175
+                        "pm" => 1,
176
+                        "source_type" => 3
177
+                    ];
178
+                    Db::name("user_sign_score")->insert($data);//添加积分记录
179
+                } else if ($array_fzone_paytype['type'] == 'b2') {
146 180
                     // {"checked":true,"note":"现金+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
147 181
 
148 182
                     $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('score');
@@ -161,6 +195,40 @@ class RefundOrder extends BaseController
161 195
                         "source_type" => 3
162 196
                     ];
163 197
                     Db::name("user_sign_score")->insert($data);//添加积分记录
198
+                } else if ($array_fzone_paytype['type'] == 'b3') {
199
+                    // VR+积分 {"checked":true,"note":"VR+积分","other":210.0,"price":970.0,"total":0.0,"type":"b1","vr":"47557.5"}
200
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
201
+                    $vrpri += $array_fzone_paytype['price'];
202
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
203
+                    Db::name("user_sign_vr")->insert([
204
+                        'uid' => $store_order_info['uid'],
205
+                        'number' => $array_fzone_paytype['price'],
206
+                        'mark' => "{$make}商品申请退款退回VR",
207
+                        'desc' => "VR",
208
+                        'order_type' => 0,
209
+                        'order_id' => $store_order_info['order_id'],
210
+                        'surplus' => $vrpri,
211
+                        'type' => 1,
212
+                        'addtime' => time()
213
+                    ]);
214
+
215
+                    // {"checked":true,"note":"VR+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
216
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('jingdou');
217
+                    $vrpri += $array_fzone_paytype['other'];
218
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['jingdou' => $vrpri]);
219
+
220
+                    Db::name('user_sign_jingdou')->insert([
221
+                        'uid' => $store_order_info['uid'],
222
+                        'number' => $array_fzone_paytype['other'],
223
+                        'status' => 1,
224
+                        'mark' => "{$make}商品申请退款退回京豆",
225
+                        'addtime' => time(),
226
+                        'surplus' => $vrpri,
227
+                        'settlement_time' => date('Y-m-d H:i:s'),
228
+                        'type' => 1,
229
+                        'order_type' => 0,
230
+                        'order_id' => $store_order_info['order_id']
231
+                    ]);
164 232
                 } else if ($array_fzone_paytype['type'] == 'b4') {
165 233
                     // {"checked":true,"note":"现金+积分","other":1.5,"price":8.5,"total":0.0,"type":"b2","vr":"48799.82"}
166 234
 
@@ -180,6 +248,22 @@ class RefundOrder extends BaseController
180 248
                         'order_type' => 0,
181 249
                         'order_id' => $store_order_info['order_id']
182 250
                     ]);
251
+                } else if ($array_fzone_paytype['type'] == 'b5') {
252
+                    // {"checked":true,"note":"VR","other":0.0,"price":1.0,"total":0.0,"type":"b5","vr":"10"}
253
+                    $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');
254
+                    $vrpri += $array_fzone_paytype['price'];
255
+                    Db::name("user")->where("uid", $group_order_map['uid'])->update(['vr' => $vrpri]);
256
+                    Db::name("user_sign_vr")->insert([
257
+                        'uid' => $store_order_info['uid'],
258
+                        'number' => $array_fzone_paytype['price'],
259
+                        'mark' => "{$make}商品申请退款退回VR",
260
+                        'desc' => "VR",
261
+                        'order_type' => 0,
262
+                        'order_id' => $store_order_info['order_id'],
263
+                        'surplus' => $vrpri,
264
+                        'type' => 1,
265
+                        'addtime' => time()
266
+                    ]);
183 267
                 } else if ($array_fzone_paytype['type'] == 'a3') {
184 268
                     // {"checked":true,"note":"现金+VR","other":1.5,"price":8.5,"total":0.0,"type":"a3","vr":"48799.82"}
185 269
                     $vrpri = Db::name("user")->where("uid", $group_order_map['uid'])->value('vr');