Forráskód Böngészése

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 1 éve
szülő
commit
894047196f

+ 5 - 0
app/admin/controller/Activity.php

@@ -278,6 +278,11 @@ class Activity extends Base
         if($activity_name==""){
         if($activity_name==""){
             return error_show(1004,"参数activity_name不能为空");
             return error_show(1004,"参数activity_name不能为空");
         }
         }
+        $ist =Db::name("good_activity")->where([["activity_name","=",$activity_name],["status","<",7],["is_del","=",
+        0]])->findOrEmpty();
+        if(!empty($ist)){
+        	return error_show(1004,"活动名称已存在");
+        }
         $platform_code = isset($this->post['platform_code'])&&$this->post['platform_code']!="" ? trim($this->post['platform_code']):"";
         $platform_code = isset($this->post['platform_code'])&&$this->post['platform_code']!="" ? trim($this->post['platform_code']):"";
         if($platform_code==""){
         if($platform_code==""){
             return error_show(1004,"参数platform_code不能为空");
             return error_show(1004,"参数platform_code不能为空");

+ 5 - 2
app/admin/controller/After.php

@@ -637,7 +637,7 @@ class After extends Base
                     if ($param['status'] == 5 && $info['is_receive'] == 0) {
                     if ($param['status'] == 5 && $info['is_receive'] == 0) {
 
 
                         $orde = Db::name("order_out")
                         $orde = Db::name("order_out")
-                            ->field('id,outCode,status')
+                            ->field('id,outCode,status,send_num,error_num')
                             ->where(["outCode" => $info['outCode'], "is_del" => 0])
                             ->where(["outCode" => $info['outCode'], "is_del" => 0])
                             ->findOrEmpty();
                             ->findOrEmpty();
                         if (empty($orde)) throw new Exception('未找到出库单数据');
                         if (empty($orde)) throw new Exception('未找到出库单数据');
@@ -649,7 +649,10 @@ class After extends Base
                         if (empty($sale)) throw new Exception('未找到销售单数据');
                         if (empty($sale)) throw new Exception('未找到销售单数据');
 
 
                         $od_status = $orde['status'];
                         $od_status = $orde['status'];
-                        $orde['status'] = 4;
+//                        $orde['status'] = 4;
+                        if ($info['error_num'] >= $orde['send_num']) $orde['status'] = 4;
+                        $orde['send_num'] -= $info['error_num'];
+                        $orde['error_num'] += $info['error_num'];
                         $orde['updatetime'] = $date;
                         $orde['updatetime'] = $date;
                         $out = Db::name("order_out")->save($orde);
                         $out = Db::name("order_out")->save($orde);
                         if ($out == false) throw new Exception("发货单更新失败");
                         if ($out == false) throw new Exception("发货单更新失败");

+ 150 - 17
app/admin/controller/AfterChild.php

@@ -182,7 +182,7 @@ class AfterChild extends Base
 
 
         $order_return = Db::name('order_return')
         $order_return = Db::name('order_return')
             ->alias('a')
             ->alias('a')
-            ->field('a.id,a.good_code,a.good_name,c.sale_price,c.cat_id,a.error_num,a.apply_id,a.apply_name,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
+            ->field('a.id,a.good_code,a.good_name,a.companyNo,c.sale_price,c.cat_id,a.error_num,a.apply_id,a.apply_name,a.outCode,b.orderCode,c.is_stock,c.order_type,a.status')
             ->leftJoin('order_out b', 'b.outCode=a.outCode AND b.is_del=0')
             ->leftJoin('order_out b', 'b.outCode=a.outCode AND b.is_del=0')
             ->leftJoin('sale c', 'c.orderCode=b.orderCode AND c.is_del=0')
             ->leftJoin('sale c', 'c.orderCode=b.orderCode AND c.is_del=0')
             ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode']])
             ->where(['a.is_del' => 0, 'a.returnCode' => $param['returnCode']])
@@ -214,6 +214,11 @@ class AfterChild extends Base
             'loss_num|丢失数量' => 'require|number|egt:0|max:999999999999',
             'loss_num|丢失数量' => 'require|number|egt:0|max:999999999999',
             'remark|备注' => 'max:255'
             'remark|备注' => 'max:255'
         ]);
         ]);
+        $defective_sum =array_sum(array_column($param['list'],"defective_num"));
+        if($defective_sum>0){
+        	$defective_wsm = Db::name("order_returninfo")->where(["returnCode"=>$param['returnCode']])->findOrEmpty();
+        	if(empty($defective_wsm)|| $defective_wsm['return_wsm']=='') return  json_show(1004, '退货工单次品仓库不存在');
+        }
 
 
         Db::startTrans();
         Db::startTrans();
         try {
         try {
@@ -255,6 +260,7 @@ class AfterChild extends Base
                 }
                 }
                 //如果次品仓入库数量大于0,另生成退货工单,以类型区分
                 //如果次品仓入库数量大于0,另生成退货工单,以类型区分
                 if ($value['defective_num'] > 0) {
                 if ($value['defective_num'] > 0) {
+                	
                     $insert[] = [
                     $insert[] = [
                         'returnCode' => $param['returnCode'],
                         'returnCode' => $param['returnCode'],
                         'orderCode' => $info[$value['id']]['orderCode'],
                         'orderCode' => $info[$value['id']]['orderCode'],
@@ -264,7 +270,7 @@ class AfterChild extends Base
                         'send_wsm_code' => $info[$value['id']]['send_wsm_code'],
                         'send_wsm_code' => $info[$value['id']]['send_wsm_code'],
                         'send_num' => $info[$value['id']]['send_num'],
                         'send_num' => $info[$value['id']]['send_num'],
                         'return_num' => $info[$value['id']]['return_num'],
                         'return_num' => $info[$value['id']]['return_num'],
-                        'return_wsm_code' => $info[$value['id']]['return_wsm_code'],
+                        'return_wsm_code' => $defective_wsm['return_wsm'],
                         'can_sell_num' => $value['can_sell_num'],
                         'can_sell_num' => $value['can_sell_num'],
                         'defective_num' => $value['defective_num'],
                         'defective_num' => $value['defective_num'],
                         'loss_num' => $value['loss_num'],
                         'loss_num' => $value['loss_num'],
@@ -290,7 +296,7 @@ class AfterChild extends Base
                     ->update();
                     ->update();
                 if($ot==false) throw new \Exception('发货工单更新失败');
                 if($ot==false) throw new \Exception('发货工单更新失败');
                 $orde = Db::name('order_out')
                 $orde = Db::name('order_out')
-                            ->field('id,outCode,status')
+                            ->field('id,outCode,status,send_num,error_num')
                             ->where(['outCode' => $info[$value['id']]['outCode'], 'is_del' => 0])
                             ->where(['outCode' => $info[$value['id']]['outCode'], 'is_del' => 0])
                             ->findOrEmpty();
                             ->findOrEmpty();
                         if (empty($orde)) throw new \Exception('未找到出库单数据');
                         if (empty($orde)) throw new \Exception('未找到出库单数据');
@@ -302,7 +308,10 @@ class AfterChild extends Base
                         if (empty($sale)) throw new \Exception('未找到销售单数据');
                         if (empty($sale)) throw new \Exception('未找到销售单数据');
 
 
                         $od_status = $orde['status'];
                         $od_status = $orde['status'];
-                        $orde['status'] = 4;
+                        
+                        if ($info[$value['id']]['return_num'] >= $orde['send_num']) $orde['status'] = 4;
+                        $orde['send_num'] -=$info[$value['id']]['return_num'];
+                        $orde['error_num'] += $info[$value['id']]['return_num'];
                         $orde['updatetime'] = $date;
                         $orde['updatetime'] = $date;
                         $out = Db::name('order_out')->save($orde);
                         $out = Db::name('order_out')->save($orde);
                         if ($out == false) throw new Exception('发货单更新失败');
                         if ($out == false) throw new Exception('发货单更新失败');
@@ -317,10 +326,11 @@ class AfterChild extends Base
                         $sup = Db::name('sale')->save($sale);
                         $sup = Db::name('sale')->save($sale);
                         if ($sup == false) throw new \Exception('销售单更新失败');
                         if ($sup == false) throw new \Exception('销售单更新失败');
             }
             }
+            
 
 
             $total = array_sum(array_column($param['list'], 'can_sell_num'));
             $total = array_sum(array_column($param['list'], 'can_sell_num'));
 
 
-            if ($total > 0) {
+//            if ($total > 0 || ) {
                 if ($order_return['is_stock'] != 1) {
                 if ($order_return['is_stock'] != 1) {
                     //根据转化表判断该非库存品是否转化为库存品
                     //根据转化表判断该非库存品是否转化为库存品
                     $spuCode = Db::name('good_change_stock')
                     $spuCode = Db::name('good_change_stock')
@@ -344,7 +354,7 @@ class AfterChild extends Base
                                     'createrid'=>0,
                                     'createrid'=>0,
                                     'creater'=>'system'
                                     'creater'=>'system'
                                 ]));
                                 ]));
-                                 if($up2==false) throw new \Exception("{$order_return['good_code']} 商品库新增失败");
+                                 if($up2==false) throw new Exception("{$order_return['good_code']} 商品库新增失败");
                             }
                             }
                         } else {
                         } else {
                             $good = Db::name('good_zixun')
                             $good = Db::name('good_zixun')
@@ -422,7 +432,7 @@ class AfterChild extends Base
                                     'is_support_stock' => 1
                                     'is_support_stock' => 1
                                 ]);
                                 ]);
                                
                                
-                               if($up==false) throw new \Exception("咨询商品录入商品库失败");
+                               if($up==false) throw new Exception("咨询商品录入商品库失败");
                             }
                             }
                         }
                         }
 
 
@@ -436,12 +446,45 @@ class AfterChild extends Base
                                     'addtime' => $date,
                                     'addtime' => $date,
                                     'updatetime' => $date,
                                     'updatetime' => $date,
                                 ]);
                                 ]);
-                           if($dd==false) throw new \Exception('关联表新增失败');
+                           if($dd==false) throw new Exception('关联表新增失败');
 
 
                         } else throw new Exception('未找到对应的商品数据');
                         } else throw new Exception('未找到对应的商品数据');
 
 
                     }
                     }
-
+					if($defective_sum>0){
+	                    $defective_stock= Db::name('good_stock')
+	                    ->where(['is_del' => 0, 'spuCode' => $spuCode, 'wsm_code' => $defective_wsm['return_wsm']])
+	                    ->findOrEmpty();
+	                    if(empty($defective_stock)){
+	                         $defective_stockid = Db::name('good_stock')
+	                                ->insertGetId([
+	                                    'project_code' => '',
+	                                    'spuCode' => $spuCode,
+	                                    'wsm_code' => $defective_wsm['return_wsm'],
+	                                    'wait_in_stock' => 0,
+	                                    'wait_out_stock' => 0,
+	                                    'usable_stock' => $defective_sum,
+	                                    'intra_stock' => 0,
+	                                    'total_stock' => $defective_sum,
+	                                    'status' => 1,
+	                                    'is_del' => 0,
+	                                    'warn_stock' => 0,
+	                                    'addtime' => $date,
+	                                    'updatetime' => $date,
+	                                ]);
+	                         if($defective_stockid==0)  throw new Exception('次品仓库库存更新失败');
+	                    }else{
+	                        $defective_stockid = $defective_stock['id'];
+	                          $defective_up=  Db::name('good_stock')
+	                                ->data(['updatetime' => $date])
+	                                ->where(['is_del' => 0, 'id' => $defective_stockid])
+	                                ->inc('usable_stock', $defective_sum)
+	                                ->inc('total_stock', $defective_sum)
+	                                ->update();
+	                          if($defective_up==false)  throw new Exception('次品仓库库存更新失败');
+	                    }
+	                    $total+=$defective_sum;
+                }
                     //新增bn记录,维护旧有bn记录
                     //新增bn记录,维护旧有bn记录
                     $child_bns = Db::name('child_bn')
                     $child_bns = Db::name('child_bn')
                         ->field('id,num,origin_price')
                         ->field('id,num,origin_price')
@@ -450,6 +493,7 @@ class AfterChild extends Base
                         ->cursor();
                         ->cursor();
 
 
                     $origin_price = $j = 0;
                     $origin_price = $j = 0;
+                    
                     foreach ($child_bns as $child_bn) {
                     foreach ($child_bns as $child_bn) {
                         if ($origin_price === 0) $origin_price = $child_bn['origin_price'];
                         if ($origin_price === 0) $origin_price = $child_bn['origin_price'];
                        $bn= Db::name('child_bn')
                        $bn= Db::name('child_bn')
@@ -494,18 +538,69 @@ class AfterChild extends Base
                                 ]);
                                 ]);
                          if($stockinfo==false) throw new \Exception('商品库存BN新增失败');
                          if($stockinfo==false) throw new \Exception('商品库存BN新增失败');
                         }
                         }
+                        if($value['defective_num']>0){
+                        	 $defective_info=   Db::name('good_stock_info')
+                                ->insert([
+                                    'stockid' => $defective_stockid,
+                                    'bnCode' => substr(makeNo('BN'), 0, -2) . str_pad($j++, 2, '0', STR_PAD_LEFT),
+                                    'total_num' => $value['defective_num'],
+                                    'used_num' => 0,
+                                    'balance_num' => $value['defective_num'],
+                                    'origin_price' => $origin_price,
+                                    'addtime' => $date,
+                                    'updatetime' => $date,
+                                ]);
+                         if($defective_info==false) throw new \Exception('次品仓商品库存BN新增失败');
+                        }
+                        
                     }
                     }
                 }
                 }
                 else {
                 else {
+                	$spuCode = $order_return['good_code'];
                     //库存品,直接维护stock和info
                     //库存品,直接维护stock和info
                     $stockids = Db::name('good_stock')
                     $stockids = Db::name('good_stock')
                         ->where(['is_del' => 0, 'spuCode' => $order_return['good_code'], 'wsm_code' => array_column($info, 'return_wsm_code')])
                         ->where(['is_del' => 0, 'spuCode' => $order_return['good_code'], 'wsm_code' => array_column($info, 'return_wsm_code')])
                         ->column('id', 'wsm_code');
                         ->column('id', 'wsm_code');
-
+					if($defective_sum>0){
+	                    $defective_stock= Db::name('good_stock')
+	                    ->where(['is_del' => 0, 'spuCode' => $spuCode, 'wsm_code' => $defective_wsm['return_wsm']])
+	                    ->findOrEmpty();
+	                    if(empty($defective_stock)){
+	                         $defective_stockid = Db::name('good_stock')
+	                                ->insertGetId([
+	                                    'project_code' => '',
+	                                    'spuCode' => $spuCode,
+	                                    'wsm_code' => $defective_wsm['return_wsm'],
+	                                    'wait_in_stock' => 0,
+	                                    'wait_out_stock' => 0,
+	                                    'usable_stock' => $defective_sum,
+	                                    'intra_stock' => 0,
+	                                    'total_stock' => $defective_sum,
+	                                    'status' => 1,
+	                                    'is_del' => 0,
+	                                    'warn_stock' => 0,
+	                                    'addtime' => $date,
+	                                    'updatetime' => $date,
+	                                ]);
+	                         if($defective_stockid==0)  throw new Exception('次品仓库库存更新失败');
+	                    }else{
+	                        $defective_stockid = $defective_stock['id'];
+	                          $defective_up=  Db::name('good_stock')
+	                                ->data(['updatetime' => $date])
+	                                ->where(['is_del' => 0, 'id' => $defective_stockid])
+	                                ->inc('usable_stock', $defective_sum)
+	                                ->inc('total_stock', $defective_sum)
+	                                ->update();
+	                          if($defective_up==false)  throw new Exception('次品仓库库存更新失败');
+	                    }
+//	                    $total+=$defective_sum;
+                }
                     foreach ($param['list'] as $value) {
                     foreach ($param['list'] as $value) {
 
 
                         //定义了stockid,维护bn
                         //定义了stockid,维护bn
-                        if (isset($stockids[$info[$value['id']]['return_wsm_code']])) {
+                        if($value['can_sell_num']>0){
+                        	
+                        	if (isset($stockids[$info[$value['id']]['return_wsm_code']])) {
                             $good_stock_info = Db::name('good_stock_info')
                             $good_stock_info = Db::name('good_stock_info')
                                 ->where(['stockid' => $stockids[$info[$value['id']]['return_wsm_code']]])
                                 ->where(['stockid' => $stockids[$info[$value['id']]['return_wsm_code']]])
                                 ->findOrEmpty();
                                 ->findOrEmpty();
@@ -559,8 +654,9 @@ class AfterChild extends Base
                                 ->inc('usable_stock', $value['can_sell_num'])
                                 ->inc('usable_stock', $value['can_sell_num'])
                                 ->inc('total_stock', $value['can_sell_num'])
                                 ->inc('total_stock', $value['can_sell_num'])
                                 ->update();
                                 ->update();
-                    if($stockinfoe==false) throw new \Exception('商品库存更新失败');
-                        } else {
+                            if($stockinfoe==false) throw new \Exception('商品库存更新失败');
+                        }
+                            else {
                             //新建good_stock和good_stock_info
                             //新建good_stock和good_stock_info
                             $stockid = Db::name('good_stock')
                             $stockid = Db::name('good_stock')
                                 ->insertGetId([
                                 ->insertGetId([
@@ -611,6 +707,43 @@ class AfterChild extends Base
                             }
                             }
 
 
                         }
                         }
+                        }
+                        
+                        if($value['defective_num']>0){
+                        	 
+                          //从child_bn查询bn号并维护,新建到good_stock_info中
+                            $child_bns = Db::name('child_bn')
+                                ->field('id,num,bnCode,origin_price')
+                                ->where(['orderCode' => $order_return['orderCode'], 'outCode' => $order_return['outCode'], 'childCode' => $info[$value['id']]['outChildCode']])
+                                ->order(['num' => 'desc', 'id' => 'asc'])
+                                ->cursor();
+
+                            $total = $value['defective_num'];
+                            foreach ($child_bns as $child_bn) {
+                                $bn=Db::name('child_bn')
+                                    ->data(['updatetime' => $date])
+                                    ->where(['id' => $child_bn['id']])
+                                    ->dec('num', ($child_bn['num'] >= $total) ? $total : $child_bn['num'])
+                                    ->update();
+								if($bn==false) throw new \Exception('商品库存BN更新失败');
+                                $bninfo=Db::name('good_stock_info')
+                                    ->insert([
+                                        'stockid' => $defective_stockid,
+                                        'bnCode' => $child_bn['bnCode'],
+                                        'total_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
+                                        'used_num' => 0,
+                                        'balance_num' => ($child_bn['num'] >= $total) ? $total : $child_bn['num'],
+                                        'origin_price' => $child_bn['origin_price'],
+                                        'addtime' => $date,
+                                        'updatetime' => $date,
+                                    ]);
+								if($bninfo==false) throw new \Exception('次品商品库存BN新增失败');
+                                $total = ($child_bn['num'] >= $total) ? 0 : ($total - $child_bn['num']);
+                                if ($total == 0) break;
+                            }
+
+                        }
+                        
                     }
                     }
 
 
                     //维护商品层面的库存数
                     //维护商品层面的库存数
@@ -622,18 +755,18 @@ class AfterChild extends Base
                     if($goodinfo==false) throw new \Exception('商品可售库存数更新失败');
                     if($goodinfo==false) throw new \Exception('商品可售库存数更新失败');
 
 
                 }
                 }
-            }
-
+//            }
+          
             //售后申请单状态维护
             //售后申请单状态维护
             $Reup=Db::name('order_return')
             $Reup=Db::name('order_return')
                 ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
                 ->where(['is_del' => 0, 'returnCode' => $param['returnCode'], 'status' => 12])
                 ->update(['status' => 5, 'updatetime' => $date]);
                 ->update(['status' => 5, 'updatetime' => $date]);
-			 if($Reup==false) throw new \Exception('售后申请退货状态更新失败');
+			 if($Reup==false) throw new Exception('售后申请退货状态更新失败');
             //售后退货工单设置信息维护
             //售后退货工单设置信息维护
             $Reupchild=Db::name('order_return_prepare')
             $Reupchild=Db::name('order_return_prepare')
                 ->where(['is_del' => 0, 'status' => 1, 'id' => array_column($info, 'id')])
                 ->where(['is_del' => 0, 'status' => 1, 'id' => array_column($info, 'id')])
                 ->update(['updatetime' => $date, 'status' => 3]);
                 ->update(['updatetime' => $date, 'status' => 3]);
-             if($Reupchild==false) throw new \Exception('售后申请退货工单状态更新失败');
+             if($Reupchild==false) throw new Exception('售后申请退货工单状态更新失败');
             $data = [
             $data = [
                             "orderCode" => $order_return['orderCode'],
                             "orderCode" => $order_return['orderCode'],
                             "th_type" => 2,
                             "th_type" => 2,

+ 4 - 4
app/admin/controller/OrderOutChild.php

@@ -530,12 +530,12 @@ class OrderOutChild extends Base
 
 
             foreach ($param as $value) {
             foreach ($param as $value) {
 
 
-                if ($val->check($value) == false) throw new Exception($val->getError());
+                if ($val->check($value) == false) throw new \Exception($val->getError());
 
 
                 //如果是库存品,只能由库管操作
                 //如果是库存品,只能由库管操作
                 //其他商品,若level2只能由供应商负责人操作,level3不限制
                 //其他商品,若level2只能由供应商负责人操作,level3不限制
                 if ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) {
                 if ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) {
-                    if ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']]) throw new Exception('库存品只能由仓库管理员操作');
+                    if ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']]) throw new \Exception('库存品只能由仓库管理员操作');
                 } else {
                 } else {
 //                    if (($this->level == 2) && ($this->uid != $person[$child[$value['outChildCode']]['supplierNo']])) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
 //                    if (($this->level == 2) && ($this->uid != $person[$child[$value['outChildCode']]['supplierNo']])) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
                 }
                 }
@@ -551,7 +551,7 @@ class OrderOutChild extends Base
 //                if (($this->level) == 3 && ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) && ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']])) throw new Exception('库存品只能由仓库管理员操作');
 //                if (($this->level) == 3 && ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) && ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']])) throw new Exception('库存品只能由仓库管理员操作');
 
 
                 //工单
                 //工单
-                if (!isset($child[$value['outChildCode']])) throw new Exception($value['outChildCode'] . '工单不存在或状态不允许发货');
+                if (!isset($child[$value['outChildCode']])) throw new \Exception($value['outChildCode'] . '工单不存在或状态不允许发货');
 
 
               $up=  Db::name('order_out_child')
               $up=  Db::name('order_out_child')
                     ->where(['id' => $child[$value['outChildCode']]['id'], 'is_del' => 0, 'status' => 1])
                     ->where(['id' => $child[$value['outChildCode']]['id'], 'is_del' => 0, 'status' => 1])
@@ -702,7 +702,7 @@ class OrderOutChild extends Base
             }
             }
             return json_show(0, '操作完成');
             return json_show(0, '操作完成');
 
 
-        } catch (Exception $exception) {
+        } catch (\Exception $exception) {
 
 
             Db::rollback();
             Db::rollback();
 
 

+ 7 - 7
app/admin/controller/SaleReport.php

@@ -3297,8 +3297,8 @@ class SaleReport extends Base
 		 	'person_id' => '',
 		 	'person_id' => '',
 		 	'page' => 1,
 		 	'page' => 1,
 		 	'size' => 15,
 		 	'size' => 15,
-		 	'start_day' => date('Y-m-01'),
-		 	'end_day' => date('Y-m-t'),
+//		 	'start_day' => date('Y-m-01'),
+//		 	'end_day' => date('Y-m-t'),
 		 	'order_start_day' => date('Y-m-01'),
 		 	'order_start_day' => date('Y-m-01'),
 		 	'order_end_day' => date('Y-m-t')],
 		 	'order_end_day' => date('Y-m-t')],
 		 	'post', 'trim');
 		 	'post', 'trim');
@@ -3315,8 +3315,8 @@ class SaleReport extends Base
         if ($param['supplier_name'] != '') $where[] = ['a.supplierName', 'like', '%' . $param['supplier_name'] . '%'];
         if ($param['supplier_name'] != '') $where[] = ['a.supplierName', 'like', '%' . $param['supplier_name'] . '%'];
         if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
         if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
         if ($param['companyName'] != '') $where[] = ['a.companyName', 'like', '%' . $param['companyName'] . '%'];
         if ($param['companyName'] != '') $where[] = ['a.companyName', 'like', '%' . $param['companyName'] . '%'];
-         if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
-         if ($param['order_start_day'] != '' && $param['order_end_day'] != '') $where[] = ['c.addtime', 'between',
+//         if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
+         if ($param['order_start_day'] != '' && $param['order_end_day'] != '') $where[] = ['a.addtime', 'between',
          [$param['order_start_day'] . ' 00:00:00', $param['order_end_day'] . ' 23:59:59']];
          [$param['order_start_day'] . ' 00:00:00', $param['order_end_day'] . ' 23:59:59']];
         $count = Db::name("order_out_child")->alias("a")->leftJoin('sale c','a.orderCode=c.orderCode')->where($where)->count();
         $count = Db::name("order_out_child")->alias("a")->leftJoin('sale c','a.orderCode=c.orderCode')->where($where)->count();
         $list = Db::name("order_out_child")
         $list = Db::name("order_out_child")
@@ -3376,7 +3376,7 @@ class SaleReport extends Base
 		 	'depart_id' => '',
 		 	'depart_id' => '',
 		 	'person_id' => '',
 		 	'person_id' => '',
 		 	'supplier_name' => '',
 		 	'supplier_name' => '',
-		 	'start_day' => date('Y-m-01'), 'end_day' => date('Y-m-t'),
+//		 	'start_day' => date('Y-m-01'), 'end_day' => date('Y-m-t'),
 		 	'order_start_day' => date('Y-m-01'), 'order_end_day' => date('Y-m-t'),
 		 	'order_start_day' => date('Y-m-01'), 'order_end_day' => date('Y-m-t'),
 		 	], 'post', 'trim');
 		 	], 'post', 'trim');
 
 
@@ -3392,8 +3392,8 @@ class SaleReport extends Base
         if ($param['supplier_name'] != '') $where[] = ['a.supplierName', 'like', '%' . $param['supplier_name'] . '%'];
         if ($param['supplier_name'] != '') $where[] = ['a.supplierName', 'like', '%' . $param['supplier_name'] . '%'];
         if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
         if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
         if ($param['companyName'] != '') $where[] = ['a.companyName', 'like', '%' . $param['companyName'] . '%'];
         if ($param['companyName'] != '') $where[] = ['a.companyName', 'like', '%' . $param['companyName'] . '%'];
-        if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
-        if ($param['order_start_day'] != '' && $param['order_end_day'] != '') $where[] = ['c.addtime', 'between',
+//        if ($param['start_day'] != '' && $param['end_day'] != '') $where[] = ['a.addtime', 'between', [$param['start_day'] . ' 00:00:00', $param['end_day'] . ' 23:59:59']];
+        if ($param['order_start_day'] != '' && $param['order_end_day'] != '') $where[] = ['a.addtime', 'between',
          [$param['order_start_day'] . ' 00:00:00', $param['order_end_day'] . ' 23:59:59']];
          [$param['order_start_day'] . ' 00:00:00', $param['order_end_day'] . ' 23:59:59']];
         $list = Db::name("order_out_child")
         $list = Db::name("order_out_child")
         ->alias("a")
         ->alias("a")

+ 1 - 1
app/command/ImportOrderFromCAnalysisData.php

@@ -145,7 +145,7 @@ class ImportOrderFromCAnalysisData extends Command
                         $activity_info = Db::name('activity_info')
                         $activity_info = Db::name('activity_info')
                             ->alias('ai')
                             ->alias('ai')
                             ->field('ai.id,ga.activity_name,ga.activity_code,ai.moq_num,ai.activity_price')
                             ->field('ai.id,ga.activity_name,ga.activity_code,ai.moq_num,ai.activity_price')
-                            ->where(['ai.skuCode' => $extend_insert_data['skuCode'], 'ga.activity_name' => $rs['activity_name'], 'ai.is_del' => 0])
+                            ->where(['ai.skuCode' => $extend_insert_data['skuCode'], 'ga.activity_name' => $rs['activity_name'], 'ai.is_del' => 0,"ga.status"=>6])
                             ->leftJoin('good_activity ga', 'ga.activity_code=ai.activity_code AND ga.is_del=0')
                             ->leftJoin('good_activity ga', 'ga.activity_code=ai.activity_code AND ga.is_del=0')
                             ->find();
                             ->find();
                         if (empty($activity_info)) {
                         if (empty($activity_info)) {