|
@@ -112,4 +112,111 @@ class Base extends \app\BaseController
|
|
|
$action['action_conllect']=implode(",",array_unique(explode(",",$action['action_conllect'])));
|
|
|
return $action;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $good
|
|
|
+ * @param $isZx
|
|
|
+ * @param string $thNo
|
|
|
+ * @return mixed|string
|
|
|
+ * @throws \think\Exception
|
|
|
+ */
|
|
|
+ public function CheckGood($good,$isZx,$thNo=''){
|
|
|
+ $spuCode= makeNo("SKU");
|
|
|
+ //查询是否存在转库存品记录 存在则返回库存编号
|
|
|
+ $newCode= Db::name("good_change_log")->where(["oldCode"=>$good['spuCode']])->value("newCode",'');
|
|
|
+ if($newCode==''){
|
|
|
+ $log=["oldCode"=>$good['spuCode'],
|
|
|
+ "order_source"=>$isZx,
|
|
|
+ "newCode"=>$spuCode,
|
|
|
+ "thCode"=>$thNo,
|
|
|
+ "createrid"=>$this->uid,
|
|
|
+ "creater"=>$this->uname,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ return $newCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($isZx==1){
|
|
|
+ $supplier =Db::name("supplier")->where(["code"=>$good['supplierNo']])->findOrEmpty();
|
|
|
+ if(empty($supplier)) throw new \Exception('非库存商品转库存失败');
|
|
|
+ $good = [
|
|
|
+ 'spuCode' => $spuCode,
|
|
|
+ 'good_code' => $good['good_code'],
|
|
|
+ 'good_name' => $good['good_name'],
|
|
|
+ 'cat_id' => $good['cat_id'],
|
|
|
+ 'brand_id' => $good['brand_id'],
|
|
|
+ 'companyNo' => $good['companyNo'],
|
|
|
+ 'good_unit' => $good['good_unit'],
|
|
|
+ 'good_type' => $good['good_type'],
|
|
|
+ 'moq' => $good['moq'],
|
|
|
+ 'customized' => $good['customized'],
|
|
|
+ 'tax' => $good['tax'],
|
|
|
+ 'supplierNo' => $good['supplierNo'],
|
|
|
+ 'is_auth' => $good['is_auth'],
|
|
|
+ 'auth_img' => $good['auth_img'],
|
|
|
+ 'after_sales' => '',
|
|
|
+ 'craft_desc' => $good['craft_desc'],
|
|
|
+ 'good_remark' => $good['good_remark'],
|
|
|
+ 'weight' => $good['weight'],
|
|
|
+ 'packing_way' => '',
|
|
|
+ 'packing_size' => '',
|
|
|
+ 'packing_spec' => '',
|
|
|
+ 'packing_list' => '',
|
|
|
+ 'packing_weight' => '',
|
|
|
+ 'good_bar' => '',
|
|
|
+ 'supply_area' => $good['supply_area'],
|
|
|
+ 'delivery_place' => '',
|
|
|
+ 'origin_place' => '',
|
|
|
+ 'delivery_day' => '',
|
|
|
+ 'lead_time' => '',
|
|
|
+ 'sample_day' => '',
|
|
|
+ 'sample_fee' => '',
|
|
|
+ 'good_img' => '',//$good['good_img'],
|
|
|
+ 'good_thumb_img' => $good['good_thumb_img'],
|
|
|
+ 'good_info_img' => $good['good_img'],//商品主图对应到商品详情
|
|
|
+ 'cert_fee' => '',
|
|
|
+ 'packing_fee' => '',
|
|
|
+ 'cost_fee' => '',
|
|
|
+ 'mark_fee' => '',
|
|
|
+ 'demo_fee' => '',
|
|
|
+ 'open_fee' => '',
|
|
|
+ 'noble_metal' => $good['noble_metal'],
|
|
|
+ 'noble_weight' => $good['good_weight'],
|
|
|
+ 'is_gold_price' => $good['is_gold_price'],
|
|
|
+ 'cgd_gold_price' => '',
|
|
|
+ 'market_price' => '',
|
|
|
+ 'nake_price' => '',
|
|
|
+ 'is_step' => '',
|
|
|
+ 'is_online' => '0',
|
|
|
+ 'status' =>7,//咨询商品待编辑
|
|
|
+ 'createrid' =>$good['createrid'],
|
|
|
+ 'creater' => $good['creater'],
|
|
|
+ 'field_change' => '',
|
|
|
+ 'is_del' => 0,
|
|
|
+ 'is_support_stock' => 0,
|
|
|
+ 'addtime' => date('Y-m-d H:i:s'),
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
+ 'is_diff' => $good['is_diff'],
|
|
|
+ 'config' => $good['config'],
|
|
|
+ 'other_config' => $good['other_config'],
|
|
|
+ 'chargerid'=>$supplier['personid']??$good['createrid'],
|
|
|
+ 'charger'=>$supplier['person']??$good['creater'],//负责人跟创建人一致
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $good['id']=null;
|
|
|
+ $good['spuCode']=$spuCode;
|
|
|
+ $good['is_stock']=1;
|
|
|
+ $good['is_support_stock']=0;
|
|
|
+ $good['status']=7;
|
|
|
+ $good['addtime']=date("Y-m-d H:i:s");
|
|
|
+ $good['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
+ $insert =Db::name("good_basic")->insert($good);
|
|
|
+ if($insert==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
+ $newAdd=Db::name("good_change_log")->insert($log);
|
|
|
+ if($newAdd==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
+ return $spuCode;
|
|
|
+
|
|
|
+ }
|
|
|
}
|