Browse Source

Merge branch 'sh/31'

sunhao 5 years ago
parent
commit
d569e92be1

+ 73 - 6
app/Http/Controllers/Admin/OrderController.php

164
                 $v['refund_type'] = '付款码支付';
164
                 $v['refund_type'] = '付款码支付';
165
             }elseif($v['refund_type'] == 3){
165
             }elseif($v['refund_type'] == 3){
166
                 $v['refund_type'] = '个体户支付';
166
                 $v['refund_type'] = '个体户支付';
167
+            }elseif($v['refund_type'] == 4){
168
+                $v['refund_type'] = '充值卡支付';
167
             }else{
169
             }else{
168
                 $v['refund_type'] = '';
170
                 $v['refund_type'] = '';
169
             }  
171
             }  
869
         $order = Order::findOrFail($id);
871
         $order = Order::findOrFail($id);
870
         $order = json_decode(json_encode($order), true);
872
         $order = json_decode(json_encode($order), true);
871
         // 临时处理,只能用自己充值卡
873
         // 临时处理,只能用自己充值卡
872
-        //$order['deposit_phone'] = $order['receiverMobile'];
874
+        $order['deposit_phone'] = $order['receiverMobile'];
873
         $order['receiverMobile'] = substr($order['receiverMobile'], 0, 3).'****'.substr($order['receiverMobile'], 7);
875
         $order['receiverMobile'] = substr($order['receiverMobile'], 0, 3).'****'.substr($order['receiverMobile'], 7);
874
         $order['goods'] = '';
876
         $order['goods'] = '';
875
         $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->whereNull('gift_id')->lists('num','sku_id');
877
         $order_skus = DB::table('order_goods_skus')->where('is_del', 0)->where('order_id', $id)->whereNull('gift_id')->lists('num','sku_id');
891
             $order['goods'] = $goods;
893
             $order['goods'] = $goods;
892
         }
894
         }
893
 
895
 
894
-        $deposit_phone = '';
896
+        $deposit_phone = $order['deposit_phone'];
895
         if($order['payment_type'] == 4){
897
         if($order['payment_type'] == 4){
896
             $consum = CustomerConsum::select('phone')->where('order_id', $id)->first();
898
             $consum = CustomerConsum::select('phone')->where('order_id', $id)->first();
897
-            $deposit_phone = isset($consum->phone) ? $consum->phone : '';
899
+            $deposit_phone = isset($consum->phone) ? $consum->phone : $order['deposit_phone'];
898
         }
900
         }
899
 
901
 
900
         //下单当月礼品
902
         //下单当月礼品
1255
                         $customerInfo->balance = $customerInfo->balance - $order['receivedAmount'];
1257
                         $customerInfo->balance = $customerInfo->balance - $order['receivedAmount'];
1256
                         $customerInfo->save();
1258
                         $customerInfo->save();
1257
                     }elseif($old_order->receivedAmount != $order['receivedAmount']){
1259
                     }elseif($old_order->receivedAmount != $order['receivedAmount']){
1258
-                        $consum = CustomerConsum::where('order_id', $id)->first();                       
1260
+                        $consum = CustomerConsum::where('order_id', $id)->where('type', 0)->first();                       
1259
                         $consum->money = $order['receivedAmount'];
1261
                         $consum->money = $order['receivedAmount'];
1260
                         $consum->save();
1262
                         $consum->save();
1261
                         //更新余额
1263
                         //更新余额
1410
                 if($order->payment_type == 4){
1412
                 if($order->payment_type == 4){
1411
                     //查询消费记录/卡号
1413
                     //查询消费记录/卡号
1412
                     $consum = CustomerConsum::where('order_id', $id)->where('is_del', 0)->first();
1414
                     $consum = CustomerConsum::where('order_id', $id)->where('is_del', 0)->first();
1415
+                    //查询需要返还消费钱数
1416
+                    $fan_money = CustomerConsum::where('order_id', $id)->where('is_del', 0)->sum('money');
1413
                     //消费记录设为删除
1417
                     //消费记录设为删除
1414
                     CustomerConsum::where('order_id', $id)->update(['is_del'=>1]);
1418
                     CustomerConsum::where('order_id', $id)->update(['is_del'=>1]);
1415
                     //余额返还
1419
                     //余额返还
1416
                     $cust = CustomerInfo::select('balance')->where('phone', $consum->phone)->first();
1420
                     $cust = CustomerInfo::select('balance')->where('phone', $consum->phone)->first();
1417
-                    $balance = $cust->balance + $order->receivedAmount;
1421
+                    $balance = $cust->balance + $fan_money;
1418
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1422
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1419
                 }
1423
                 }
1420
 
1424
 
1502
                 if($order->payment_type == 4){
1506
                 if($order->payment_type == 4){
1503
                     //查询消费记录/卡号
1507
                     //查询消费记录/卡号
1504
                     $consum = CustomerConsum::where('order_id', $id)->where('is_del', 0)->first();
1508
                     $consum = CustomerConsum::where('order_id', $id)->where('is_del', 0)->first();
1509
+                    //查询需要返还消费钱数
1510
+                    $fan_money = CustomerConsum::where('order_id', $id)->where('is_del', 0)->sum('money');
1505
                     //消费记录设为删除
1511
                     //消费记录设为删除
1506
                     CustomerConsum::where('order_id', $id)->update(['is_del'=>1]);
1512
                     CustomerConsum::where('order_id', $id)->update(['is_del'=>1]);
1507
                     //余额返还
1513
                     //余额返还
1508
                     $cust = CustomerInfo::select('balance')->where('phone', $consum->phone)->first();
1514
                     $cust = CustomerInfo::select('balance')->where('phone', $consum->phone)->first();
1509
-                    $balance = $cust->balance + $order->receivedAmount;
1515
+                    $balance = $cust->balance + $fan_money;
1510
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1516
                     CustomerInfo::where('phone', $consum->phone)->update(['balance'=>$balance]);
1511
                 }
1517
                 }
1512
 
1518
 
1878
             }else{
1884
             }else{
1879
                 $data['is_refund'] = 1;
1885
                 $data['is_refund'] = 1;
1880
                 if(!$order->refund_type) $data['refund_type'] = 1;
1886
                 if(!$order->refund_type) $data['refund_type'] = 1;
1887
+                if(!$order->refund_time) $data['refund_time'] = date('Y-m-d');
1888
+                if($order->refund_type == 4 && $refund_price != $order->refund_price){
1889
+                    // 充值退补
1890
+                    $res = $this->depositRefund($id, $refund_price);
1891
+                    if(!$res){
1892
+                        return 0;
1893
+                    }
1894
+                }
1881
             }
1895
             }
1882
             $data['refund_price'] = $refund_price;
1896
             $data['refund_price'] = $refund_price;
1883
         }
1897
         }
1884
         if(isset($refund_type)){
1898
         if(isset($refund_type)){
1885
             if(empty($refund_type)){
1899
             if(empty($refund_type)){
1886
                 $refund_type = null;                
1900
                 $refund_type = null;                
1901
+            }elseif($refund_type == 4){
1902
+                //判断是否是充值卡支付方式
1903
+                if($order->payment_type != 4){
1904
+                    return 0;
1905
+                }
1906
+                if($order->refund_price != 0 && $order->refund_type != 4){
1907
+                    $res = $this->depositRefund($id, $order->refund_price);
1908
+                    if(!$res){
1909
+                        return 0;
1910
+                    }
1911
+                }
1912
+            }elseif($refund_type != 4 && $order->refund_type == 4){
1913
+                return 0;
1887
             }
1914
             }
1888
             $data['refund_type'] = (int)$refund_type;
1915
             $data['refund_type'] = (int)$refund_type;
1916
+            if(!$order->refund_time) $data['refund_time'] = date('Y-m-d');
1889
         }
1917
         }
1890
         if($id>0 && !empty($data)){
1918
         if($id>0 && !empty($data)){
1891
             $res = Order::where('id', $id)->update($data);
1919
             $res = Order::where('id', $id)->update($data);
1894
         return 1;
1922
         return 1;
1895
     }
1923
     }
1896
 
1924
 
1925
+    /**
1926
+     * 充值卡退补
1927
+     */
1928
+    public function depositRefund($order_id, $refund_price){
1929
+        //查消费记录
1930
+        $order_consum = DB::table('customer_consum')->where('is_del', 0)->where('order_id', $order_id)->where('type', 0)->first();
1931
+        if(empty($order_consum)){
1932
+            return false;
1933
+        }
1934
+        //查看是否已有退补记录
1935
+        $order_refund = DB::table('customer_consum')->where('is_del', 0)->where('order_id', $order_id)->where('type', 1)->first();
1936
+        $balance = CustomerInfo::where('phone', $order_consum->phone)->pluck('balance');
1937
+        if(empty($order_refund)){
1938
+            if($refund_price>0){
1939
+                //补钱,判断充值卡余额           
1940
+                if($balance - $refund_price < 0){
1941
+                    return false;
1942
+                }
1943
+            }
1944
+            $consum = array();
1945
+            $consum['phone'] = $order_consum->phone;
1946
+            $consum['order_id'] = $order_id;
1947
+            $consum['money'] = $refund_price;
1948
+            $consum['type'] = 1;
1949
+            DB::table('customer_consum')->insert($consum);
1950
+            $balance = $balance - $refund_price;
1951
+        }elseif($order_refund->money != $refund_price){
1952
+            //已有退款,更变le 退款钱数
1953
+            if($balance - $refund_price + $order_refund->money <0 ){
1954
+                return false;
1955
+            }
1956
+            DB::table('customer_consum')->where('id', $order_refund->id)->update(['money'=>$refund_price]);
1957
+            $balance = $balance - $refund_price + $order_refund->money;
1958
+        }
1959
+   
1960
+        CustomerInfo::where('phone', $order_consum->phone)->update(['balance' => $balance]);
1961
+        return true;
1962
+    }
1963
+
1897
     public function warehouse_export(Request $request){
1964
     public function warehouse_export(Request $request){
1898
         
1965
         
1899
         $self_role = session('role_name');        
1966
         $self_role = session('role_name');        

File diff suppressed because it is too large
+ 26 - 6
app/Http/Controllers/Admin/StatisticsController.php


+ 3 - 1
resources/views/deposit/consumList.blade.php

14
                 <tr class="text-c">
14
                 <tr class="text-c">
15
                     {{--<th width="25"><input type="checkbox" name="" value=""></th>--}}
15
                     {{--<th width="25"><input type="checkbox" name="" value=""></th>--}}
16
                     <th width="10%">账号</th>                   
16
                     <th width="10%">账号</th>                   
17
-                    <th width="10%">消费金额</th>
17
+                    <th width="10%">消费(或退补)金额</th>
18
                     <th width="10%">订单ID</th>
18
                     <th width="10%">订单ID</th>
19
+                    <th width="10%">类型</th>
19
                     <th width="10%">时间</th>
20
                     <th width="10%">时间</th>
20
                 </tr>
21
                 </tr>
21
                 </thead>
22
                 </thead>
27
                         <td class="text-c">{{$a['phone']}}</td>
28
                         <td class="text-c">{{$a['phone']}}</td>
28
                         <td class="text-c">{{$a['money']}}</td>
29
                         <td class="text-c">{{$a['money']}}</td>
29
                         <td class="text-c">{{$a['order_id']}}</td>
30
                         <td class="text-c">{{$a['order_id']}}</td>
31
+                        <td class="text-c">@if($a['type'] == 1) 退补 @else 消费 @endif</td>
30
                         <td class="text-c">{{$a['create_time']}}</td>
32
                         <td class="text-c">{{$a['create_time']}}</td>
31
                         
33
                         
32
                     </tr>
34
                     </tr>

+ 2 - 3
resources/views/order/orderedit.blade.php

311
             <div class="row cl"  style="display: none" id='deposit_div'>
311
             <div class="row cl"  style="display: none" id='deposit_div'>
312
                 <label class="form-label col-xs-4 col-sm-2">
312
                 <label class="form-label col-xs-4 col-sm-2">
313
                     <font color='red'> </font>充值卡号:</label>
313
                     <font color='red'> </font>充值卡号:</label>
314
-                <div class="formControls col-xs-6 col-sm-6">
315
-                    <input id='deposit_phone_i' type="text" class="input-text" value="{{old('deposit_phone')}}" placeholder="*默认收货人手机号" disabled name="deposit_phone_i">
316
-                    <input id='deposit_phone' type="hidden" class="input-text" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
314
+                <div class="formControls col-xs-6 col-sm-6">                  
315
+                    <input id='deposit_phone' type="text" class="input-text" value="{{old('deposit_phone')}}" onkeyup="getBalance()" placeholder="" name="deposit_phone">
317
                     <font color='red' id='vip_pay'></font>
316
                     <font color='red' id='vip_pay'></font>
318
                 </div>
317
                 </div>
319
             </div>
318
             </div>

+ 12 - 2
resources/views/order/orderlist.blade.php

179
                                     <option value='1'>微信支付</option>
179
                                     <option value='1'>微信支付</option>
180
                                     <!--option value='2'>付款码支付</option-->
180
                                     <!--option value='2'>付款码支付</option-->
181
                                     <option value='3'>个体户支付</option>
181
                                     <option value='3'>个体户支付</option>
182
+                                    <option value='4'>充值卡支付</option>
182
                                 </select>
183
                                 </select>
183
                                 <span class="sort_icon" hidden  onClick='change_refund_type_click("{{$a['id']}}","{{$a['cost']}}")' style="cursor:pointer"><i class="Hui-iconfont">&#xe647;</i></span>
184
                                 <span class="sort_icon" hidden  onClick='change_refund_type_click("{{$a['id']}}","{{$a['cost']}}")' style="cursor:pointer"><i class="Hui-iconfont">&#xe647;</i></span>
184
                             </td>
185
                             </td>
718
             $.ajax({
719
             $.ajax({
719
                 url: '/admin/order/editLogisticsId?id='+id+'&refund_price='+refund_price,
720
                 url: '/admin/order/editLogisticsId?id='+id+'&refund_price='+refund_price,
720
                 type: 'get',
721
                 type: 'get',
721
-                dateType: 'json',
722
                 success:function(msg){
722
                 success:function(msg){
723
+                    if(msg == 0){
724
+                        alert('操作有误');
725
+                        return false;
726
+                    }
723
                     $("#refund_price_1"+id).html(refund_price);
727
                     $("#refund_price_1"+id).html(refund_price);
724
                     if(!refund_type){
728
                     if(!refund_type){
725
                         $("#refund_type_1"+id).html('微信支付');
729
                         $("#refund_type_1"+id).html('微信支付');
741
             $.ajax({
745
             $.ajax({
742
                 url: '/admin/order/editLogisticsId?id='+id+'&refund_type='+refund_type,
746
                 url: '/admin/order/editLogisticsId?id='+id+'&refund_type='+refund_type,
743
                 type: 'get',
747
                 type: 'get',
744
-                dateType: 'json',
745
                 success:function(msg){
748
                 success:function(msg){
749
+                    if(msg == 0){
750
+                        alert('操作有误');
751
+                        return false;
752
+                    }
746
                     if(refund_type==1){
753
                     if(refund_type==1){
747
                         refund_type = '微信支付';
754
                         refund_type = '微信支付';
748
                     }
755
                     }
752
                     if(refund_type==3){
759
                     if(refund_type==3){
753
                         refund_type = '个体户支付';
760
                         refund_type = '个体户支付';
754
                     }
761
                     }
762
+                    if(refund_type==4){
763
+                        refund_type = '充值卡支付';
764
+                    }
755
                     if(refund_type==0){
765
                     if(refund_type==0){
756
                         refund_type = '';
766
                         refund_type = '';
757
                     }
767
                     }

+ 1 - 0
resources/views/order/predictorderlist.blade.php

160
                                     <option value='1'>微信支付</option>
160
                                     <option value='1'>微信支付</option>
161
                                     <!--option value='2'>付款码支付</option-->
161
                                     <!--option value='2'>付款码支付</option-->
162
                                     <option value='3'>个体户支付</option>
162
                                     <option value='3'>个体户支付</option>
163
+                                    <option value='4'>充值卡支付</option>
163
                                 </select>
164
                                 </select>
164
                                 <span class="sort_icon" hidden  onClick='change_refund_type_click("{{$a['id']}}","{{$a['cost']}}")' style="cursor:pointer"><i class="Hui-iconfont">&#xe647;</i></span>
165
                                 <span class="sort_icon" hidden  onClick='change_refund_type_click("{{$a['id']}}","{{$a['cost']}}")' style="cursor:pointer"><i class="Hui-iconfont">&#xe647;</i></span>
165
                             </td>
166
                             </td>

+ 6 - 0
resources/views/statistics/teamFinanceTotal.blade.php

45
                     <th width="4%">个体户退补单数</th>
45
                     <th width="4%">个体户退补单数</th>
46
                     <th width="4%">个体户退补差价</th>
46
                     <th width="4%">个体户退补差价</th>
47
                     <th width="5%">个体户实际金额</th>
47
                     <th width="5%">个体户实际金额</th>
48
+                    <th width="4%">充值卡退补单数</th>
49
+                    <th width="4%">充值卡退补差价</th>
50
+                    <th width="5%">充值卡实际金额</th>
48
                     <th width="4%">发货单数</th>
51
                     <th width="4%">发货单数</th>
49
                     <th width="5%">货品成本</th>
52
                     <th width="5%">货品成本</th>
50
                     <th width="5%">物流成本</th>
53
                     <th width="5%">物流成本</th>
75
                             <td>{{$a['gth_refund_count']}}</td>
78
                             <td>{{$a['gth_refund_count']}}</td>
76
                             <td>{{$a['gth_refund_price']}}</td>
79
                             <td>{{$a['gth_refund_price']}}</td>
77
                             <td>{{$a['gth_true_amount']}}</td>
80
                             <td>{{$a['gth_true_amount']}}</td>
81
+                            <td>{{$a['czk_refund_count']}}</td>
82
+                            <td>{{$a['czk_refund_price']}}</td>
83
+                            <td>{{$a['czk_true_amount']}}</td>
78
                             <td>{{$a['send_count']}}</td>
84
                             <td>{{$a['send_count']}}</td>
79
                             <td>{{$a['cost']}}</td>
85
                             <td>{{$a['cost']}}</td>
80
                             <td>{{$a['freight_cost']}}</td>
86
                             <td>{{$a['freight_cost']}}</td>