Просмотр исходного кода

Merge branch 'master' into zengjun

ajun 5 лет назад
Родитель
Сommit
b9d60e82c9

+ 52 - 0
app/Http/Controllers/TestController.php

@@ -956,5 +956,57 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
     public function view(){
         return view('test');
     }
+    public function cleanOrderRepeat(){
+        $orders_repeating=Order::query()
+            ->selectRaw('count(*) as count, code')
+            ->whereNotNull('code')
+            ->groupBy('code')
+            ->having('count', '>', 1)
+            ->limit(10)
+            ->get();
+        $orderCodes=$orders_repeating->each(function ($order){
+            $code_repeating=$order['code'];
+            $orders_toCombine=Order::query()
+                ->where('code',$code_repeating)
+                ->orderByDesc('updated_at')
+                ->get();
+            $orderId_unique=(function()use($orders_toCombine){
+                $order_toLive=$orders_toCombine->first();
+                foreach($orders_toCombine as $key=>$order_toEliminate){
+                    if($key==0)continue;
+                    if(!$order_toLive['batch_id'])$order_toLive['batch_id']=$order_toEliminate['batch_id'];
+                    if(!$order_toLive['owner_id'])$order_toLive['owner_id']=$order_toEliminate['owner_id'];
+                    if(!$order_toLive['status'])$order_toLive['status']=$order_toEliminate['status'];
+                    if(!$order_toLive['created_at'])$order_toLive['created_at']=$order_toEliminate['created_at'];
+                    if(!$order_toLive['code'])$order_toLive['code']=$order_toEliminate['code'];
+                    if(!$order_toLive['shop_id'])$order_toLive['shop_id']=$order_toEliminate['shop_id'];
+                    if(!$order_toLive['owner_id'])$order_toLive['owner_id']=$order_toEliminate['owner_id'];
+                    if(!$order_toLive['client_code'])$order_toLive['client_code']=$order_toEliminate['client_code'];
+                    if(!$order_toLive['logistic_id'])$order_toLive['logistic_id']=$order_toEliminate['logistic_id'];
+                    if(!$order_toLive['consignee_name'])$order_toLive['consignee_name']=$order_toEliminate['consignee_name'];
+                    if(!$order_toLive['consignee_phone'])$order_toLive['consignee_phone']=$order_toEliminate['consignee_phone'];
+                    if(!$order_toLive['province'])$order_toLive['province']=$order_toEliminate['province'];
+                    if(!$order_toLive['city'])$order_toLive['city']=$order_toEliminate['city'];
+                    if(!$order_toLive['district'])$order_toLive['district']=$order_toEliminate['district'];
+                    if(!$order_toLive['address'])$order_toLive['address']=$order_toEliminate['address'];
+                    if(!$order_toLive['wms_status'])$order_toLive['wms_status']=$order_toEliminate['wms_status'];
+                    if(!$order_toLive['status'])$order_toLive['status']=$order_toEliminate['status'];
+                    if(!$order_toLive['warehouse_id'])$order_toLive['warehouse_id']=$order_toEliminate['warehouse_id'];
+                    if(!$order_toLive['wms_edittime'])$order_toLive['wms_edittime']=$order_toEliminate['wms_edittime'];
+                }
+                $order_toLive->save();
+                return $order_toLive['id'];
+            })();
+            $orderIds_toRemove=(function()use($orders_toCombine){
+                $orders_toCombine->shift();
+                return $orders_toCombine->map(function($order){return $order['id'];})->toArray();
+            })();
+//            $orderPackages_toChange=OrderPackage::query()->orWhere
+
+            Order::destroy($orderIds_toRemove);
+        });
+
+        dd(11);
+    }
 
 }

+ 1 - 1
app/RejectedBill.php

@@ -93,7 +93,7 @@ class RejectedBill extends Model
     }
     function save(array $options = [])
     {
-        (new LogisticNumberFeatureController())->createFeatures($this['logistic_number_return'],$this['id_logistic_return']);
+        if($this['logistic_number_return'])(new LogisticNumberFeatureController())->createFeatures($this['logistic_number_return'],$this['id_logistic_return']);
         return parent::save($options);
     }
 

+ 14 - 1
resources/views/order/index/delivering.blade.php

@@ -732,17 +732,27 @@
                     }
                     tempTip.confirm("是否要生成“"+this.checkData+"”的退货单?",()=> {
                         let _this = this;
-                        axios.post('{{url('order/isRejectedBillExist')}}',{data:this.checkData})
+                        let arr = [];
+                        window.tempTip.setDuration(9999);
+                        window.tempTip.waitingTip("生成中,请稍等......")
+                        this.orders.forEach(order=> {
+                            if (this.checkData.includes(order.orderno))arr.push(order.soreference1);
+                        });
+                        axios.post('{{url('order/isRejectedBillExist')}}',{data:arr})
                             .then(function (response) {
                                 if (!response.data.success){
                                     tempTip.confirm(response.data.data+',已存在,是否仍要生成退货单?',function () {
                                         _this.createRejectedBill();
+                                        window.tempTip.cancelWaitingTip();
+                                    },function (){
+                                        window.tempTip.cancelWaitingTip();
                                     });
                                     return;
                                 }
                                 _this.createRejectedBill();
                             }).catch(function (error) {
                             tempTip.setDuration(3000);
+                            tempTip.cancelWaitingTip();
                             tempTip.show('网络错误:'+error);
                         });
                     });
@@ -752,14 +762,17 @@
                     axios.post(url,{data:this.checkData})
                         .then(res=>{
                             if (res.data.success){
+                                tempTip.cancelWaitingTip();
                                 tempTip.setDuration(2000);
                                 tempTip.showSuccess("生成退货单成功!");
                             }else{
+                                tempTip.cancelWaitingTip();
                                 tempTip.setDuration(3000);
                                 tempTip.show(res.data.data);
                             }
                         })
                         .catch(err=>{
+                            tempTip.cancelWaitingTip();
                             tempTip.setDuration(3000);
                             tempTip.show('网络错误:'+err);
                         });