wugg 1 năm trước cách đây
mục cha
commit
1477a183ac

+ 12 - 18
app/admin/controller/OrderOutChild.php

@@ -7,13 +7,16 @@ use app\admin\model\ActionLog;
 use app\admin\model\DataGroup as DataGroupModel;
 use app\admin\model\GoodStockInfo;
 use app\admin\model\ProcessOrder;
-use think\Exception;
+use think\App;use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
 
+
 class OrderOutChild extends Base
 {
 
+	 public $white = ["*"];
+	 public function __construct(App $app) {parent::__construct($app);}
     //分单时可用仓库列表
     public function getWsmList()
     {
@@ -282,8 +285,7 @@ class OrderOutChild extends Base
             a.supplierName 供应商名称,a.addtime 下单时间,
             a.apply_name 申请人,
             case p.use_type when 0 then "无" when 1 then "to B" when 2 then "to C" end 对接类型,
-            a.post_name 物流公司,a.post_code 物流单号,a.post_fee 物流费用,a.is_post 是否包邮,a.post_supplier_code 物流供应商编号,a.post_supplier_name 物流供应商,
-            e.addr 收货地址,e.addr_code,e.contactor 收货联系人,e.mobile 联系方式,m.cgdNo 采购单号,d.remark 备注')
+            a.post_name 物流公司,a.post_code 物流单号,a.post_fee 物流费用,e.addr 收货地址,e.addr_code,e.contactor 收货联系人,e.mobile 联系方式,m.cgdNo 采购单号,d.remark 备注')
             ->leftJoin('warehouse_info c', 'c.wsm_code=a.wsm_code AND c.is_del=0')
             ->leftJoin('order_addr e', 'a.addrid=e.id')
             ->leftJoin('order_send m', 'a.outCode=m.outCode')
@@ -505,9 +507,7 @@ class OrderOutChild extends Base
             'outChildCode|发货工单号' => 'require|max:255',
             'post_name|物流公司' => 'require|max:255',
             'post_code|物流单号' => 'require|max:255',
-            'post_fee|物流费用' => 'require|egt:0|max:99999999.99',
-            'is_post|是否包邮' => 'require|egt:0|in:0,1',
-            'post_supplier_code|物流供应商' => 'require|max:255'
+            'post_fee|物流费用' => 'require|egt:0|max:99999999.99'
         ]);
 
         Db::startTrans();
@@ -524,20 +524,17 @@ class OrderOutChild extends Base
                 ->column('contactor', 'wsm_code');
 
             $yz_tmp = [];
-			$supplier=array_unique(array_column($param,"post_supplier_code"));
-			$supArr = \app\admin\common\User::getIns()->handle('getCodeAndName', ["code"=>$supplier]);
-			$suplierArr=$supArr["data"]??[];
             foreach ($param as $value) {
 
                 if ($val->check($value) == false) throw new \Exception($val->getError());
 
                 //如果是库存品,只能由库管操作
                 //其他商品,若level2只能由供应商负责人操作,level3不限制
-                if ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) {
-                    if ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']]) throw new \Exception('库存品只能由仓库管理员操作');
-                } else {
-//                    if (($this->level == 2) && ($this->uid != $person[$child[$value['outChildCode']]['supplierNo']])) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
-                }
+//                if ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) {
+//                    if ($this->uid != $wsm_contactor[$child[$value['outChildCode']]['wsm_code']]) throw new \Exception('库存品只能由仓库管理员操作');
+//                } else {
+////                    if (($this->level == 2) && ($this->uid != $person[$child[$value['outChildCode']]['supplierNo']])) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
+//                }
 
 //                if ($this->level == 2) {
 //                    if ($sale[$child[$value['outChildCode']]['orderCode']]['is_stock'] == 1) {
@@ -558,9 +555,6 @@ class OrderOutChild extends Base
                         'post_name' => $value['post_name'],
                         'post_code' => $value['post_code'],
                         'post_fee' => $value['post_fee'],
-                        'is_post' => $value['is_post'],
-                        'post_supplier_code' => $value['post_supplier_code'],
-                        'post_supplier_name' =>$suplierArr[$value['post_supplier_code']]??"",
                         'status' => 2,
                         'sendtime' => $date,
                         'updatetime' => $date,
@@ -700,7 +694,7 @@ class OrderOutChild extends Base
 
             //如果是有赞订单 且 所属发货单全部发货了,将发货信息推到有赞
             //有赞信息有可能推送失败(比如超过72小时,不允许多次修改等),所以不应该和这里的事务放到一起
-
+			event("outChildSend",array_unique(array_column($param,"outChildCode")));
             foreach ($yz_tmp as $temp) {
                 curl_request(config('app.yz_domain') . 'api/yz_out_send', ['orderCode' => $temp['orderCode'], 'out_stype' => $temp['post_name'], 'post_code' => $temp['post_code'], 'uid' => $this->uid, 'uname' => $this->uname, 'order_out' => $temp['outCode']]);
             }

+ 20 - 0
app/admin/listener/OutChildSend.php

@@ -0,0 +1,20 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\listener;
+
+use app\admin\model\OrderOutChild;
+use app\model\FhdChild;
+class OutChildSend
+{
+    /**
+     * 事件监听处理
+     *
+     * @return mixed
+     */
+    public function handle($event)
+    {
+        $child = OrderOutChild::whereIn("outChildCode",$event)->hidden(["id"])->select()->toArray();
+        (new FhdChild())->SaveAll($child);
+    }
+}

+ 69 - 0
app/command/CopyGood.php

@@ -0,0 +1,69 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;use think\facade\Db;
+
+class CopyGood extends Command
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('copygood')
+            ->setDescription('the copygood command');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        // 指令输出D
+        $spuCode= Db::name("changgood")->cursor();
+        Db::startTrans();
+        try{
+        	foreach ($spuCode as $key=>$value){
+        		echo $value['good_code']."\r\n";
+        		$spu=substr(makeNo('SKU'),0,-4).str_pad(strval($key+1),4,'0',STR_PAD_LEFT);
+        		$goodInfo = Db::name("good_basic")->where(["spuCode"=>$value['good_code']])->findOrEmpty();
+        		if(empty($goodInfo)){
+        			echo $value['good_code']."无数据\r\n";
+        			continue;
+        		}
+        		unset($goodInfo['id']);
+        		$goodInfo['spuCode']=$spu;
+        		$goodInfo['companyNo']='GS2402020907088731';
+        		$goodInfo['companyName']='北京泰文创供应链管理有限公司';
+        		$goodInfo['createrid']=0;
+        		$goodInfo['creater']='system';
+        		 Db::name('good_basic')->save($goodInfo);
+        		 $this->makeNake($value['good_code'],$spu);
+        		 $this->makeSpec($value['good_code'],$spu);
+        		 Db::name('changgood')->where($value)->save(["change_code"=>$spu]);
+        	}
+        
+        		Db::commit();
+        }catch (\Exception $e){
+        	Db::rollback();
+        	$output->writeln($e->getMessage());
+        	
+        }
+        $output->writeln('copygood');
+    }
+    
+    public function makeNake($old,$new){
+//    	spuCode,min_num,nake_fee,cost_fee,delivery_fee,cert_fee,mark_fee,package_fee,other_fee,nake_total
+    	$Dbname = Db::name("good_nake")->where(["spuCode"=>$old,"is_del"=>0])
+    	->column("'{$new}' spuCode,min_num,nake_fee,cost_fee,delivery_fee,cert_fee,mark_fee,package_fee,other_fee,nake_total");
+    	Db::name('good_nake')->insertAll($Dbname);
+    }
+    
+    public function makeSpec($old,$new){
+//    	spuCode,min_num,nake_fee,cost_fee,delivery_fee,cert_fee,mark_fee,package_fee,other_fee,nake_total
+    	$Dbname = Db::name('good_spec')->where(['spuCode'=>$old,'is_del'=>0])
+    	->column("'{$new}' spuCode,spec_id,spec_value_id");
+    	Db::name('good_spec')->insertAll($Dbname);
+    }
+}

+ 1 - 0
app/event.php

@@ -16,6 +16,7 @@ return [
         'GoodOff' => [\app\bbc\listener\GoodOffine::class],
         'thdata' => [\app\admin\listener\ThData::class],
         'CgdCreate' => [\app\admin\listener\Cgdmake::class],
+        'outChildSend' => [\app\admin\listener\outChildSend::class],
      
     ],
 

+ 16 - 0
app/model/FhdChild.php

@@ -0,0 +1,16 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class FhdChild extends Model
+{
+   protected $connection='mysql_cxinv';
+   protected $createTime='addtime';
+   protected $updateTime='updatetime';
+}