|
@@ -145,7 +145,7 @@ class Good extends BaseController
|
|
|
$list = Db::name('good_basic')
|
|
|
->alias('gb')
|
|
|
->field('gb.*,u.itemid')
|
|
|
- ->leftJoin("depart_user u", "u.uid=gb.createrid AND u.is_del=0")
|
|
|
+ ->leftJoin("depart_user u", "u.uid=gb.chargerid AND u.is_del=0")
|
|
|
->where($where)
|
|
|
->page($page, $size)
|
|
|
->order("addtime desc")
|
|
@@ -179,7 +179,7 @@ class Good extends BaseController
|
|
|
//如果一个spucode在任意平台上线,那么就视为它上线,即手动把它的is_online值改为1
|
|
|
if (isset($exam_statuss[$value['spuCode']]) || isset($exam_status_yz[$value['spuCode']])) $value['is_online'] = 1;
|
|
|
|
|
|
- $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
+ $value['charger_company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
|
|
|
$data[] = $value;
|
|
|
}
|
|
@@ -208,8 +208,7 @@ class Good extends BaseController
|
|
|
if ($unit == '') {
|
|
|
return json_show(1004, "商品单位不能为空");
|
|
|
}
|
|
|
- $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? intval($this->post['good_type'])
|
|
|
- : "";
|
|
|
+ $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? intval($this->post['good_type']) : "";
|
|
|
if ($good_type === '') {
|
|
|
return json_show(1004, "参数good_type不能为空");
|
|
|
}
|
|
@@ -382,6 +381,11 @@ class Good extends BaseController
|
|
|
$spucode = makeNo("SKU");
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $charger = Db::name('supplier')
|
|
|
+ ->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])
|
|
|
+ ->field('id,creater,createrid')
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
$data = [
|
|
|
"spuCode" => $spucode,
|
|
|
"good_code" => '',
|
|
@@ -444,7 +448,9 @@ class Good extends BaseController
|
|
|
"creater" => $creater,
|
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
|
"updatetime" => date("Y-m-d H:i:s"),
|
|
|
- 'is_support_barter' => $is_support_barter
|
|
|
+ 'is_support_barter' => $is_support_barter,
|
|
|
+ 'chargerid' => $charger['createrid'] ?? 0,
|
|
|
+ 'charger' => $charger['creater'] ?? '',//负责人,取所属供应商的创建人
|
|
|
];
|
|
|
$in = Db::name("good_basic")->insertGetId($data);
|
|
|
if ($in) {
|
|
@@ -1717,104 +1723,105 @@ class Good extends BaseController
|
|
|
}
|
|
|
|
|
|
//商品详情
|
|
|
- public function info(){
|
|
|
+ public function info()
|
|
|
+ {
|
|
|
|
|
|
$this->post = $this->request->filter('trim')->post();
|
|
|
- $skucode=isset($this->post['skuCode'])&&$this->post['skuCode']!=""?trim($this->post['skuCode']):"";
|
|
|
- if($skucode==""){
|
|
|
- return json_show(1005,"参数skuCode不能为空");
|
|
|
- }
|
|
|
- $good_platform = Db::name("good_platform")->where(['skuCode'=>$skucode,"is_del"=>0])->find();
|
|
|
- if($good_platform==false){
|
|
|
- return json_show(1004,"未找到商品数据");
|
|
|
- }
|
|
|
- $data = Db::name("good")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->find();
|
|
|
- if($data==false){
|
|
|
- return json_show(1004,"未找到商品数据");
|
|
|
- }
|
|
|
- $plat =Db::name("platform")->where(["id"=>$good_platform['platform_code']])->find();
|
|
|
- $data['skuCode']=$good_platform['skuCode'];
|
|
|
- $data['platform_code']=$good_platform['id'];
|
|
|
- $data['platform_code_en']=isset($plat['platform_code'])?$plat['platform_code']:"";
|
|
|
- $data['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
|
|
|
- $data['online_reason']=$good_platform['online_reason'];
|
|
|
- $data['online_time']=$good_platform['online_time'];
|
|
|
- $data['online_remark']=$good_platform['online_remark'];
|
|
|
- $data['exam_status']=$good_platform['exam_status'];
|
|
|
- $data['is_online']=$good_platform['is_online'];
|
|
|
- $data['plat_code']=$good_platform['plat_code'];
|
|
|
- $data['exclusive']=makeExcluse($data['is_exclusive']);
|
|
|
- $unit =Db::name("unit")->where(["id"=>$data['good_unit']])->find();
|
|
|
- $data['unit'] = isset($unit['unit'])?$unit['unit']:'';
|
|
|
- $data['cat_info'] = made($data['cat_id'],[]);
|
|
|
- $spec = Db::name("good_spec")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->select()->toArray();
|
|
|
- $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
|
|
|
- $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
|
|
|
- $data['noble_name']=isset($data['noble_metal'])&&$data['noble_metal']!=0?$this->noble[$data['noble_metal']] :"";
|
|
|
- $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
|
|
|
- $data['company'] = isset($company['company'])?$company['company']:"";
|
|
|
- if($data['brand_id']!=0){
|
|
|
- $brand=Db::name("brand")->where(["id"=>$data['brand_id']])->find();
|
|
|
- $data["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
|
|
|
- }else{
|
|
|
- $data["brand_name"]="";
|
|
|
- $data["brand_id"]="";
|
|
|
- }
|
|
|
- $data['origin_place_cn']="";
|
|
|
- $data['delivery_place_cn']="";
|
|
|
- if($data['delivery_place']!==""){
|
|
|
- $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
|
|
|
- list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$data['delivery_place']);
|
|
|
- $data['delivery_place_cn']=GetAddr(json_encode($place));
|
|
|
- }
|
|
|
- if($data['origin_place']!==""){
|
|
|
- $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
|
|
|
- list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$data['origin_place']);
|
|
|
- $data['origin_place_cn']=GetAddr(json_encode($place));
|
|
|
+ $skucode = isset($this->post['skuCode']) && $this->post['skuCode'] != "" ? trim($this->post['skuCode']) : "";
|
|
|
+ if ($skucode == "") {
|
|
|
+ return json_show(1005, "参数skuCode不能为空");
|
|
|
+ }
|
|
|
+ $good_platform = Db::name("good_platform")->where(['skuCode' => $skucode, "is_del" => 0])->find();
|
|
|
+ if ($good_platform == false) {
|
|
|
+ return json_show(1004, "未找到商品数据");
|
|
|
+ }
|
|
|
+ $data = Db::name("good")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->find();
|
|
|
+ if ($data == false) {
|
|
|
+ return json_show(1004, "未找到商品数据");
|
|
|
+ }
|
|
|
+ $plat = Db::name("platform")->where(["id" => $good_platform['platform_code']])->find();
|
|
|
+ $data['skuCode'] = $good_platform['skuCode'];
|
|
|
+ $data['platform_code'] = $good_platform['id'];
|
|
|
+ $data['platform_code_en'] = isset($plat['platform_code']) ? $plat['platform_code'] : "";
|
|
|
+ $data['platform_name'] = isset($plat['platform_name']) ? $plat['platform_name'] : "";
|
|
|
+ $data['online_reason'] = $good_platform['online_reason'];
|
|
|
+ $data['online_time'] = $good_platform['online_time'];
|
|
|
+ $data['online_remark'] = $good_platform['online_remark'];
|
|
|
+ $data['exam_status'] = $good_platform['exam_status'];
|
|
|
+ $data['is_online'] = $good_platform['is_online'];
|
|
|
+ $data['plat_code'] = $good_platform['plat_code'];
|
|
|
+ $data['exclusive'] = makeExcluse($data['is_exclusive']);
|
|
|
+ $unit = Db::name("unit")->where(["id" => $data['good_unit']])->find();
|
|
|
+ $data['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
|
|
|
+ $data['cat_info'] = made($data['cat_id'], []);
|
|
|
+ $spec = Db::name("good_spec")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->select()->toArray();
|
|
|
+ $supplier = Db::name("supplier")->where(["code" => $data['supplierNo']])->find();
|
|
|
+ $data['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
|
|
|
+ $data['noble_name'] = isset($data['noble_metal']) && $data['noble_metal'] != 0 ? $this->noble[$data['noble_metal']] : "";
|
|
|
+ $company = Db::name("business")->where(["companyNo" => $data['companyNo']])->find();
|
|
|
+ $data['company'] = isset($company['company']) ? $company['company'] : "";
|
|
|
+ if ($data['brand_id'] != 0) {
|
|
|
+ $brand = Db::name("brand")->where(["id" => $data['brand_id']])->find();
|
|
|
+ $data["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
|
|
|
+ } else {
|
|
|
+ $data["brand_name"] = "";
|
|
|
+ $data["brand_id"] = "";
|
|
|
+ }
|
|
|
+ $data['origin_place_cn'] = "";
|
|
|
+ $data['delivery_place_cn'] = "";
|
|
|
+ if ($data['delivery_place'] !== "") {
|
|
|
+ $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
|
|
|
+ list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $data['delivery_place']);
|
|
|
+ $data['delivery_place_cn'] = GetAddr(json_encode($place));
|
|
|
+ }
|
|
|
+ if ($data['origin_place'] !== "") {
|
|
|
+ $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
|
|
|
+ list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $data['origin_place']);
|
|
|
+ $data['origin_place_cn'] = GetAddr(json_encode($place));
|
|
|
}
|
|
|
$excluse = makeExcluse($data['is_exclusive']);
|
|
|
- $data['exclusive']=$excluse;
|
|
|
- $data["good_info_img"]=$data['good_info_img']!=""? $data['good_info_img']:[];
|
|
|
- $data["good_img"]=$data['good_img']!=""? $data['good_img']:[];
|
|
|
- $speclist=[];
|
|
|
- if(!empty($spec)){
|
|
|
- foreach ($spec as $value){
|
|
|
- $temp=[];
|
|
|
- $temp['id']=$value['id'];
|
|
|
- $temp['spuCode']=$value['spuCode'];
|
|
|
- $temp['spec_id']=$value['spec_id'];
|
|
|
- $temp['spec_value_id']=$value['spec_value_id'];
|
|
|
- $temp['is_del']=$value['is_del'];
|
|
|
- $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
|
|
|
- $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
|
|
|
- $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
|
|
|
- $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
|
|
|
- $speclist[]=$temp;
|
|
|
+ $data['exclusive'] = $excluse;
|
|
|
+ $data["good_info_img"] = $data['good_info_img'] != "" ? $data['good_info_img'] : [];
|
|
|
+ $data["good_img"] = $data['good_img'] != "" ? $data['good_img'] : [];
|
|
|
+ $speclist = [];
|
|
|
+ if (!empty($spec)) {
|
|
|
+ foreach ($spec as $value) {
|
|
|
+ $temp = [];
|
|
|
+ $temp['id'] = $value['id'];
|
|
|
+ $temp['spuCode'] = $value['spuCode'];
|
|
|
+ $temp['spec_id'] = $value['spec_id'];
|
|
|
+ $temp['spec_value_id'] = $value['spec_value_id'];
|
|
|
+ $temp['is_del'] = $value['is_del'];
|
|
|
+ $sp = Db::name("specs")->where(["id" => $value['spec_id']])->find();
|
|
|
+ $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
|
|
|
+ $spv = Db::name("spec_value")->where(["id" => $value['spec_value_id']])->find();
|
|
|
+ $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
|
|
|
+ $speclist[] = $temp;
|
|
|
}
|
|
|
}
|
|
|
- $data["speclist"]=empty($speclist)?[]:$speclist;
|
|
|
- $ladder = Db::name("good_ladder")->where(['skuCode'=>$skucode,"is_del"=>0])->select()->toArray();
|
|
|
- $data["ladderlist"]=!empty($ladder)?$ladder:[];
|
|
|
- $nakelist = Db::name("good_nake")->where(['spuCode'=>$good_platform['spuCode'],"is_del"=>0])->select()->toArray();
|
|
|
+ $data["speclist"] = empty($speclist) ? [] : $speclist;
|
|
|
+ $ladder = Db::name("good_ladder")->where(['skuCode' => $skucode, "is_del" => 0])->select()->toArray();
|
|
|
+ $data["ladderlist"] = !empty($ladder) ? $ladder : [];
|
|
|
+ $nakelist = Db::name("good_nake")->where(['spuCode' => $good_platform['spuCode'], "is_del" => 0])->select()->toArray();
|
|
|
// $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
|
|
|
|
|
|
$cat_top_list = $data['cat_info'];
|
|
|
$cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
|
|
|
// $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
|
|
|
- $gold_price=0;
|
|
|
- if ($data['is_gold_price']==1 && $cat_top_id==6) {
|
|
|
+ $gold_price = 0;
|
|
|
+ if ($data['is_gold_price'] == 1 && $cat_top_id == 6) {
|
|
|
$gold_price = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->value('price', 0);
|
|
|
}
|
|
|
- $data['gold_price'] =$gold_price;
|
|
|
- $nakearry=[];
|
|
|
- if(!empty($nakelist)){
|
|
|
+ $data['gold_price'] = $gold_price;
|
|
|
+ $nakearry = [];
|
|
|
+ if (!empty($nakelist)) {
|
|
|
|
|
|
//实时金价
|
|
|
- foreach ($nakelist as $value){
|
|
|
- $value['sale_price'] =$value['nake_total'];
|
|
|
+ foreach ($nakelist as $value) {
|
|
|
+ $value['sale_price'] = $value['nake_total'];
|
|
|
|
|
|
//计算最终售价
|
|
|
- if ($data['is_gold_price']==1 && $cat_top_id==6) {
|
|
|
+ if ($data['is_gold_price'] == 1 && $cat_top_id == 6) {
|
|
|
//普通商品:直接用财务提交的售价字段;
|
|
|
//贵金属( 商品重量* 最新金价 + 工艺费(财务定价提交的)* 商品重量+包装费+加标费+证书费+产品裸价+其他费用)=商品库商品直接下单的售价
|
|
|
$value['sale_price'] = ($data['weight'] * $gold_price + $value['cost_fee'] * $data['weight'] + $value['package_fee'] + $value['mark_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['other_fee']);
|
|
@@ -1822,20 +1829,20 @@ class Good extends BaseController
|
|
|
$nakearry[] = $value;
|
|
|
}
|
|
|
}
|
|
|
- $proof =Db::name("good_proof")->where(["spuCode"=>$good_platform['spuCode'],"is_del"=>0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
|
|
|
- $data['proof'] = isset($proof)&&$proof!=false? $proof:[];
|
|
|
- $data["nakelist"]=$nakearry;
|
|
|
+ $proof = Db::name("good_proof")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
|
|
|
+ $data['proof'] = isset($proof) && $proof != false ? $proof : [];
|
|
|
+ $data["nakelist"] = $nakearry;
|
|
|
|
|
|
//补充采购员字段
|
|
|
//成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
|
|
|
$temp_basic_info = Db::name('good_basic')
|
|
|
->field('id,createrid purchase_id,creater purchase')
|
|
|
- ->where(['spuCode'=>$data['spuCode'],'is_del'=>0])
|
|
|
+ ->where(['spuCode' => $data['spuCode'], 'is_del' => 0])
|
|
|
->find();
|
|
|
$data['purchase_id'] = $temp_basic_info['purchase_id'];
|
|
|
$data['purchase'] = $temp_basic_info['purchase'];
|
|
|
|
|
|
- return json_show(0,"获取成功",$data);
|
|
|
+ return json_show(0, "获取成功", $data);
|
|
|
}
|
|
|
|
|
|
|