|
@@ -5,7 +5,7 @@ namespace app\admin\controller;
|
|
|
use app\admin\model\ActionLog;
|
|
|
use app\admin\model\ChangeLog;
|
|
|
use app\admin\model\DataGroup as DataGroupModel;
|
|
|
-use app\admin\model\ProcessOrder;
|
|
|
+use app\admin\model\GoodCombind;use app\admin\model\GoodStock;use app\admin\model\ProcessOrder;
|
|
|
use app\youzan\model\PlatformYouzan;
|
|
|
use think\App;
|
|
|
use think\Exception;
|
|
@@ -35,6 +35,13 @@ class Goodup extends Base
|
|
|
$where[]=['gb.cat_id',"in",$cat_ids];
|
|
|
$condit[]=['a.cat_id',"in",$cat_ids];
|
|
|
}
|
|
|
+
|
|
|
+ $is_combind = isset($this->post['is_combind']) && $this->post['is_combind'] !=='' ? intval($this->post['is_combind']):'';
|
|
|
+ if($is_combind!==''){
|
|
|
+
|
|
|
+ $where[]=['gb.is_combind','=',$is_combind];
|
|
|
+
|
|
|
+ }
|
|
|
$good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
|
|
|
if($good_name!==""){
|
|
|
$where[]=['gb.good_name',"like","%$good_name%"];
|
|
@@ -136,7 +143,7 @@ class Goodup extends Base
|
|
|
->name('supplier')
|
|
|
->where(['is_del' => 0, 'personid' => $arr])
|
|
|
->column('code');
|
|
|
-
|
|
|
+ array_push($supplierNos,'');
|
|
|
$where[] = ['gb.supplierNo', 'in', $supplierNos];
|
|
|
}
|
|
|
}
|
|
@@ -283,7 +290,12 @@ class Goodup extends Base
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ $is_combind = isset($this->post['is_combind']) && $this->post['is_combind'] !=='' ? intval($this->post['is_combind']):'';
|
|
|
+ if($is_combind!==''){
|
|
|
+
|
|
|
+ $where[]=['gb.is_combind','=',$is_combind];
|
|
|
+
|
|
|
+ }
|
|
|
$brandid = isset($this->post['brandid']) && $this->post['brandid'] !== "" ? intval($this->post['brandid']) : "";
|
|
|
if ($brandid !== "") {
|
|
|
$where[] = ['gb.brand_id', "=", $brandid];
|
|
@@ -465,6 +477,8 @@ class Goodup extends Base
|
|
|
return error_show(1004,"参数customized不能为空");
|
|
|
}
|
|
|
}
|
|
|
+ $isCombind= $this->post['is_combind']??0;
|
|
|
+
|
|
|
$is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
|
|
|
if($is_exclusive===''){
|
|
|
return error_show(1004,"参数is_exclusive不能为空");
|
|
@@ -473,39 +487,39 @@ class Goodup extends Base
|
|
|
if($tax===''){
|
|
|
return error_show(1004,"参数tax不能为空");
|
|
|
}
|
|
|
- $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
|
|
|
- if($supplierNo==''){
|
|
|
- return error_show(1004,"参数supplierNo不能为空");
|
|
|
- }
|
|
|
- $userCommon= \app\admin\common\User::getIns();
|
|
|
- $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
|
|
|
- if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
|
|
|
- $supplierArr=$supplier_temp['data']??[];
|
|
|
- $supplier=$supplierArr['child']??[];
|
|
|
-
|
|
|
- if ($this->level == 2) {
|
|
|
- $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
|
|
|
- if (isset($supplier_account[$supplierNo])) return json_show(1004, '该供应商已开通账号,不允许操作');
|
|
|
- }
|
|
|
-
|
|
|
+ $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=''? trim($this->post['supplierNo']):'';
|
|
|
+ $supplierArr=[];
|
|
|
+ $supplier=[];
|
|
|
+ $userCommon= \app\admin\common\User::getIns();
|
|
|
+
|
|
|
+ if($supplierNo==''){
|
|
|
+ return error_show(1004,'参数supplierNo不能为空');
|
|
|
+ }
|
|
|
+ $supplier_temp =$userCommon->handle('hqInfo',['code'=>$supplierNo]);
|
|
|
+ if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,'供应商信息未找到');
|
|
|
+ $supplierArr=$supplier_temp['data']??[];
|
|
|
+ $supplier=$supplierArr['child']??[];
|
|
|
+
|
|
|
+ if ($this->level == 2) {
|
|
|
+ $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
|
|
|
+ if (isset($supplier_account[$supplierNo])) return json_show(1004, '该供应商已开通账号,不允许操作');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']):"";
|
|
|
if($good_size==''){
|
|
|
return error_show(1004,"参数good_size不能为空");
|
|
|
}
|
|
|
- $proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!=""? trim($this->post['proof_type']):"";
|
|
|
-// if($proof_type==''){
|
|
|
-// return error_show(1004,"参数proof_type不能为空");
|
|
|
-// }
|
|
|
+ $proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!=""? trim($this->post['proof_type']):"";
|
|
|
$proof_url = isset($this->post['proof_url'])&&$this->post['proof_url']!=""? trim($this->post['proof_url']):"";
|
|
|
-// if($proof_url==''){
|
|
|
-// return error_show(1004,"参数proof_url不能为空");
|
|
|
-// }
|
|
|
+
|
|
|
$company_id = isset($this->post['company_id'])&&$this->post['company_id']!=""? trim($this->post['company_id']) :"";
|
|
|
if($company_id==''){
|
|
|
return error_show(1004,"参数company_id不能为空");
|
|
|
}
|
|
|
$companyinfo =$userCommon->handle("getCodeAndName",["code"=>$company_id]);
|
|
|
- if($supplierArr['relation_code']==$company_id){
|
|
|
+ if(isset($supplierArr['relation_code'])&&$supplierArr['relation_code']==$company_id){
|
|
|
return error_show(1004,"业务公司与供应商属于同一家公司");
|
|
|
}
|
|
|
$is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
|
|
@@ -513,9 +527,6 @@ class Goodup extends Base
|
|
|
return error_show(1004,"参数is_auth不能为空");
|
|
|
}
|
|
|
$auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
|
|
|
-// if($auth_img==''){
|
|
|
-// return error_show(1004,"商品不能为空");
|
|
|
-// }
|
|
|
|
|
|
$after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
|
|
|
if($after_sales==""){
|
|
@@ -589,6 +600,7 @@ class Goodup extends Base
|
|
|
if($is_stock==1 && $stock_moq ==0){
|
|
|
return error_show(1004,"库存品备库起订量不能为零");
|
|
|
}
|
|
|
+ if($is_stock==0 && $isCombind==1) return error_show(1004,'非库存品不支持组合商品类型');
|
|
|
$is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"0";
|
|
|
|
|
|
$good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
|
|
@@ -631,18 +643,23 @@ class Goodup extends Base
|
|
|
// return error_show(1004,"启用阶梯,阶梯价不能为空");
|
|
|
// }
|
|
|
$is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
|
|
|
-
|
|
|
- $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
- if($token==''){
|
|
|
- return error_show(105,"参数token不能为空");
|
|
|
- }
|
|
|
-// $user =GetUserInfo($token);
|
|
|
-// if(empty($user)||$user['code']!=0){
|
|
|
-// return error_show(1002,"创建人数据不存在");
|
|
|
-// }
|
|
|
+ $combindList = $this->post["combind_list"]??[];
|
|
|
+
|
|
|
$createrid= $this->uid;
|
|
|
$creater= $this->uname;
|
|
|
$spucode=makeNo("SKU");
|
|
|
+ if($isCombind==1){
|
|
|
+ if(empty($combindList)) return error_show(1004,'组合商品子商品信息不能为空');
|
|
|
+ $spucode=makeNo("SSU");
|
|
|
+ $dchild=[];
|
|
|
+ $valid = Validate::rule(['childCode|子商品成本编号'=>'require','child_name|子商品名称'=>'require','child_num|组合比例'=>'require|number|gt:0']);
|
|
|
+ foreach ($combindList as $value){
|
|
|
+ if($valid->check($value)==false)return error_show(1004,$valid->getError());
|
|
|
+ $value['spuCode'] = $spucode;
|
|
|
+ $value['good_name'] =$good_name;
|
|
|
+ $dchild[]=$value;
|
|
|
+ }
|
|
|
+ }
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$data=[
|
|
@@ -710,6 +727,7 @@ class Goodup extends Base
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
'is_support_barter'=>$is_support_barter,
|
|
|
+ 'is_combind'=>$isCombind,
|
|
|
'chargerid'=>$supplier['personid']??$createrid,
|
|
|
'charger'=>$supplier['person']??$creater,//负责人跟创建人一致
|
|
|
];
|
|
@@ -745,9 +763,7 @@ class Goodup extends Base
|
|
|
$inproof = Db::name("good_proof")->insert($proof);
|
|
|
if($inproof==false)throw new \Exception("商品凭证新建失败");
|
|
|
}
|
|
|
-
|
|
|
-// $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
|
|
|
-// $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
|
|
|
+
|
|
|
$top_cat_id = made($cat_id);//获取所有分类
|
|
|
$top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
|
|
|
if($good_ladder!=="" && !empty($good_ladder)){
|
|
@@ -787,7 +803,9 @@ class Goodup extends Base
|
|
|
throw new \Exception("商品成本创建失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if($isCombind==1 && !empty($dchild)){
|
|
|
+ (new GoodCombind())->saveAll($dchild);
|
|
|
+ }
|
|
|
//修改状态,添加待办
|
|
|
ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
|
|
|
"order_code" =>$spucode,//咨询单详情编号
|
|
@@ -839,9 +857,6 @@ class Goodup extends Base
|
|
|
return error_show(1004,"商品分类不能为空");
|
|
|
}
|
|
|
$brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"0";
|
|
|
-// if($brandid==''){
|
|
|
-// return error_show(1004,"商品品牌不能为空");
|
|
|
-// }
|
|
|
$unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
|
|
|
if($unit==''){
|
|
|
return error_show(1004,"商品单位不能为空");
|
|
@@ -867,23 +882,24 @@ class Goodup extends Base
|
|
|
if($is_exclusive===''){
|
|
|
return error_show(1004,"参数is_exclusive不能为空");
|
|
|
}
|
|
|
-// $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
|
|
|
-// if($customized===''){
|
|
|
-// return error_show(1004,"参数customized不能为空");
|
|
|
-// }
|
|
|
+
|
|
|
$tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
|
|
|
if($tax===''){
|
|
|
return error_show(1004,"参数tax不能为空");
|
|
|
}
|
|
|
$supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
|
|
|
- if($supplierNo==''){
|
|
|
- return error_show(1004,"参数supplierNo不能为空");
|
|
|
- }
|
|
|
+ $isCombind= $this->post['is_combind']??0;
|
|
|
+ $supplierArr=[];
|
|
|
+ $supplier=[];
|
|
|
$userCommon= \app\admin\common\User::getIns();
|
|
|
- $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
|
|
|
- if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
|
|
|
- $supplierArr=$supplier_temp['data']??[];
|
|
|
- $supplier=$supplierArr['child']??[];
|
|
|
+
|
|
|
+ if($supplierNo=='')return error_show(1004,'参数supplierNo不能为空');
|
|
|
+
|
|
|
+ $supplier_temp =$userCommon->handle('hqInfo',['code'=>$supplierNo]);
|
|
|
+ if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,'供应商信息未找到');
|
|
|
+ $supplierArr=$supplier_temp['data']??[];
|
|
|
+ $supplier=$supplierArr['child']??[];
|
|
|
+
|
|
|
$good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']) :"";
|
|
|
if($good_size==''){
|
|
|
return error_show(1004,"参数good_size不能为空");
|
|
@@ -893,7 +909,7 @@ class Goodup extends Base
|
|
|
return error_show(1004,"参数company_id不能为空");
|
|
|
}
|
|
|
$companyinfo =$userCommon->handle("getCodeAndName",["code"=>$company_id]);
|
|
|
- if($supplierArr['relation_code']==$company_id){
|
|
|
+ if(isset($supplierArr['relation_code'])&&$supplierArr['relation_code']==$company_id){
|
|
|
return error_show(1004,"业务公司与供应商属于同一家公司");
|
|
|
}
|
|
|
$is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
|
|
@@ -989,7 +1005,23 @@ class Goodup extends Base
|
|
|
$speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
|
|
|
$proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!=""? trim($this->post['proof_type']):"";
|
|
|
$proof_url = isset($this->post['proof_url'])&&$this->post['proof_url']!=""? trim($this->post['proof_url']):"";
|
|
|
-
|
|
|
+ $combindList = $this->post['combind_list']??[];
|
|
|
+ if($isCombind==1){
|
|
|
+ if(empty($combindList)) return error_show(1004,'组合商品子商品信息不能为空');
|
|
|
+ $dchild=[];
|
|
|
+ $valid = Validate::rule(['childCode|子商品成本编号'=>'require','child_name|子商品名称'=>'require','child_num|组合比例'=>'require|number|gt:0']);
|
|
|
+ foreach ($combindList as $value){
|
|
|
+ if($valid->check($value)==false)return error_show(1004,$valid->getError());
|
|
|
+ $value['spuCode'] = $data['spuCode'];
|
|
|
+ $value['good_name'] =$good_name;
|
|
|
+ $value['updatetime'] =date("Y-m-d H:i:s");
|
|
|
+ if($value['is_del']==1){
|
|
|
+ $usable_stock = Db::name("good")->where(["spuCode"=>$data['spuCode']])->value("usable_stock",0);
|
|
|
+ if($usable_stock>0) return error_show(1004,'组合商品库存未处理完不可删除子商品');
|
|
|
+ }
|
|
|
+ $dchild[]=$value;
|
|
|
+ }
|
|
|
+ }
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$temp=[
|
|
@@ -1035,6 +1067,7 @@ class Goodup extends Base
|
|
|
"good_info_img"=>$good_info_img,
|
|
|
"status"=>$count>0?2:1,
|
|
|
"updatetime" => date("Y-m-d H:i:s"),
|
|
|
+ 'is_combind'=>$isCombind,
|
|
|
'chargerid' => $supplier['personid'] ?? $this->uid,
|
|
|
'charger' => $supplier['person'] ?? $this->uname,//负责人跟创建人一致
|
|
|
];
|
|
@@ -1077,7 +1110,9 @@ class Goodup extends Base
|
|
|
$inproof = Db::name("good_proof")->insert($proof);
|
|
|
if($inproof==false)throw new \Exception("商品凭证新建失败");
|
|
|
}
|
|
|
-
|
|
|
+ if($isCombind==1 && !empty($dchild)){
|
|
|
+ (new GoodCombind())->saveAll($dchild);
|
|
|
+ }
|
|
|
//修改状态,添加待办
|
|
|
ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
"order_code" =>$supcode,//咨询单详情编号
|
|
@@ -1400,14 +1435,25 @@ class Goodup extends Base
|
|
|
$spec = Db::name("good_spec")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
|
|
|
$userCommon = \app\admin\common\User::getIns();
|
|
|
- $sinfo = $userCommon->handle('sInfo',['code'=>$data['supplierNo']]);
|
|
|
-// $names = $userCommon->handle('getCodeAndName', ['code' => [$data['supplierNo'], $data['companyNo']]]);
|
|
|
-
|
|
|
-// $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
|
|
|
-// $data['supplierName'] = $names['data'][$data['supplierNo']] ?? '';//isset($supplier['name'])
|
|
|
- //?$supplier['name']:"";
|
|
|
-// $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
|
|
|
-// $data['company'] = $names['data'][$data['companyNo']] ?? ''; //isset($company['company'])?$company['company']:"";
|
|
|
+ $sinfo = $userCommon->handle('sInfo',['code'=>$data['supplierNo']]);
|
|
|
+ $data['cgderid'] = $sinfo['data']['personid'] ?? '';
|
|
|
+ $data['cgder'] = $sinfo['data']['person'] ?? '';
|
|
|
+ $data['combind_list'] =[];
|
|
|
+ $data['wsm_list']=[];
|
|
|
+ $data['usable_stock']=(new GoodStock())->withJoin(['wsminfo'],'left')
|
|
|
+ ->where(['spuCode' => $supcode, 'wsm_type'=>[2,5]])
|
|
|
+ ->sum('usable_stock');
|
|
|
+ if($data['is_combind']==1){
|
|
|
+ $data['combind_list'] = (new GoodCombind())->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
+ foreach ($data['combind_list'] as &$item){
|
|
|
+ $item['stock'] =bcmul($item['child_num'],$data['usable_stock']);
|
|
|
+ }
|
|
|
+ $data['wsm_list']=(new GoodStock())->withJoin(['wsminfo'] , 'left')
|
|
|
+ ->where(['spuCode'=>$supcode , 'wsm_type'=>[2 , 5]])
|
|
|
+ ->column('good_stock.id stock_id,name,good_stock.wsm_code,usable_stock');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$data['field_change'] = $data['field_change']!=''?json_decode($data['field_change']):"";
|
|
|
if($data['brand_id']!=0){
|
|
|
$brand=Db::name("brand")->where(["id"=>$data['brand_id']])->find();
|
|
@@ -1443,10 +1489,7 @@ class Goodup extends Base
|
|
|
}
|
|
|
}
|
|
|
$data["speclist"]=empty($speclist)?[]:$speclist;
|
|
|
- // $nake=[];
|
|
|
$nakelist = Db::name("good_nake")->where(['spuCode'=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
-// $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
|
|
|
-// $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
|
|
|
$nakearry=[];
|
|
|
if(!empty($nakelist)){
|
|
|
foreach ($nakelist as $value) {
|
|
@@ -1455,8 +1498,7 @@ class Goodup extends Base
|
|
|
}
|
|
|
$data["nakelist"]=$nakearry;
|
|
|
|
|
|
- $data['cgderid'] = $sinfo['data']['personid'] ?? '';
|
|
|
- $data['cgder'] = $sinfo['data']['person'] ?? '';
|
|
|
+
|
|
|
return app_show(0,"获取成功",$data);
|
|
|
}
|
|
|
|
|
@@ -1539,9 +1581,16 @@ class Goodup extends Base
|
|
|
if($online_remark===""){
|
|
|
return error_show(1004,"参数online_remark不能为空");
|
|
|
}
|
|
|
+ $fixed = isset($this->post['is_fixed'])&&$this->post['is_fixed']!==''? intval($this->post['is_fixed']):0;
|
|
|
+ if($fixed==1){
|
|
|
+ //使用实时金价
|
|
|
+ $nake=Db::name('good_nake')->where(['spuCode'=> $spuCode,'is_del'=>0,"nake_fee"=>0])->findOrEmpty();
|
|
|
+ if(!empty($nake)) return error_show(1004,'一口价商品请先完善商品成本单价');
|
|
|
+
|
|
|
+ }
|
|
|
$createrid= $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
$creater= $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
-
|
|
|
+
|
|
|
//区分是否是对接平台
|
|
|
$platform_info=Db::name('platform')
|
|
|
->field('id,platform_type,is_select_pay_rate,status')
|
|
@@ -1556,7 +1605,10 @@ class Goodup extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($platform_info['platform_type']==1) return \app\youzan\logic\Goodup::create([
|
|
|
+ if($platform_info['platform_type']==1){
|
|
|
+ if($fixed==0) return error_show(1005,'有赞平台商品不可使用实时金价');
|
|
|
+
|
|
|
+ return \app\youzan\logic\Goodup::create([
|
|
|
'platform_id'=>$platform,
|
|
|
'online_reason'=>$online_reason,
|
|
|
'online_remark'=>$online_remark,
|
|
@@ -1564,6 +1616,7 @@ class Goodup extends Base
|
|
|
'createrid'=>$createrid,
|
|
|
'creater'=>$creater,
|
|
|
]);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
$data=[];
|
|
@@ -1619,6 +1672,7 @@ class Goodup extends Base
|
|
|
"online_remark"=>$online_remark,
|
|
|
"exam_status"=>$count>0 ?2:1,
|
|
|
"is_online"=>0,
|
|
|
+ "is_fixed"=>$fixed,
|
|
|
"status"=>1,
|
|
|
"is_del"=>0,
|
|
|
"creater"=>$creater,
|
|
@@ -1710,6 +1764,14 @@ class Goodup extends Base
|
|
|
$platform = Db::name("good_platform")->where(["skuCode"=>$post['skuCode'],"is_del"=>0])->find();
|
|
|
if($platform==false){
|
|
|
return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ if($platform['is_fixed']==1){
|
|
|
+ //使用实时金价
|
|
|
+ $nake=Db::name('good_nake')->where(['spuCode'=> $platform['spuCode'],'is_del'=>0,'nake_fee'=>0])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(!empty($nake)) return error_show(1004,'一口价商品请先完善商品成本单价');
|
|
|
+
|
|
|
}
|
|
|
if($post['exam_status']==3){
|
|
|
|
|
@@ -2092,6 +2154,17 @@ class Goodup extends Base
|
|
|
$nake = Db::name("good_nake")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
$ladd=[];
|
|
|
$newCode =makeNo("SKU");
|
|
|
+ if($data['is_combind']==1){
|
|
|
+ $newCode =makeNo('SSU');
|
|
|
+ $combindList = (new GoodCombind())->where(["spuCode"=>$supcode,"is_del"=>0])->hidden(["id"])
|
|
|
+ ->select()->toArray();
|
|
|
+ if(!empty($combindList)){
|
|
|
+ foreach ($combindList as &$item){
|
|
|
+ $item['spuCode']=$newCode;
|
|
|
+ $item['good_name']=$data['good_name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if(!empty($nake)){
|
|
|
foreach ($nake as $value){
|
|
|
$tmp=[];
|
|
@@ -2157,22 +2230,25 @@ class Goodup extends Base
|
|
|
if(!empty($ladd)){
|
|
|
$na = Db::name("good_nake")->insertAll($ladd);
|
|
|
if($na==0){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1005,"成本数据复制失败");
|
|
|
+ throw new \Exception('成本数据复制失败');
|
|
|
}
|
|
|
}
|
|
|
if(!empty($specArr)){
|
|
|
$sp = Db::name("good_spec")->insertAll($specArr);
|
|
|
if($sp==0){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1005,"规格数据复制失败");
|
|
|
+ throw new \Exception('规格数据复制失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($combindList)){
|
|
|
+ $in =(new GoodCombind())->saveAll($combindList);
|
|
|
+ if($in->isEmpty()){
|
|
|
+ throw new \Exception("组合商子商品品信息复制失败");
|
|
|
}
|
|
|
}
|
|
|
Db::commit();
|
|
|
return app_show(0,"复制数据成功",["spuCode"=>$newCode]);
|
|
|
}else{
|
|
|
- Db::rollback();
|
|
|
- return error_show(1005,"数据复制失败");
|
|
|
+ throw new \Exception('数据复制失败');
|
|
|
}
|
|
|
|
|
|
}catch (\Exception $e){
|
|
@@ -2245,34 +2321,41 @@ class Goodup extends Base
|
|
|
if($tax===''){
|
|
|
return error_show(1004,"参数tax不能为空");
|
|
|
}
|
|
|
- $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
|
|
|
- if($supplierNo==''){
|
|
|
- return error_show(1004,"参数supplierNo不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- if (($this->level == 2) && ($supplierNo != $data['supplierNo'])) {
|
|
|
- $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
|
|
|
- if (isset($supplier_account[$supplierNo])) return json_show(1004, '该供应商已开通账号,不允许操作');
|
|
|
- if (isset($supplier_account[$data['supplierNo']])) return json_show(1004, '原供应商已开通账号,不允许操作');
|
|
|
+ $company_id = isset($this->post['companyNo'])&&$this->post['companyNo']!=''? trim($this->post['companyNo']) :'';
|
|
|
+ if($company_id==''){
|
|
|
+ return error_show(1004,'参数companyNo不能为空');
|
|
|
}
|
|
|
-
|
|
|
$userCommon= \app\admin\common\User::getIns();
|
|
|
- $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
|
|
|
- if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
|
|
|
- $supplierArr=$supplier_temp['data']??[];
|
|
|
- $supplier=$supplierArr['child']??[];
|
|
|
+ $companyinfo =$userCommon->handle('getCodeAndName',['code'=>$company_id]);
|
|
|
+ $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
|
|
|
+ $isCombind= $data['is_combind'];
|
|
|
+ $supplierArr=[];
|
|
|
+ $supplier=[];
|
|
|
+
|
|
|
+ if($supplierNo==''){
|
|
|
+ return error_show(1004,"参数supplierNo不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (($this->level == 2) && ($supplierNo != $data['supplierNo'])) {
|
|
|
+ $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
|
|
|
+ if (isset($supplier_account[$supplierNo])) return json_show(1004, '该供应商已开通账号,不允许操作');
|
|
|
+ if (isset($supplier_account[$data['supplierNo']])) return json_show(1004, '原供应商已开通账号,不允许操作');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
|
|
|
+ if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
|
|
|
+ $supplierArr=$supplier_temp['data']??[];
|
|
|
+ $supplier=$supplierArr['child']??[];
|
|
|
+ if($supplierArr['relation_code']==$company_id){
|
|
|
+ return error_show(1004,'业务公司与供应商属于同一家公司');
|
|
|
+ }
|
|
|
+
|
|
|
$good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size']) :"";
|
|
|
if($good_size==''){
|
|
|
return error_show(1004,"参数good_size不能为空");
|
|
|
}
|
|
|
- $company_id = isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo']) :"";
|
|
|
- if($company_id==''){
|
|
|
- return error_show(1004,"参数companyNo不能为空");
|
|
|
- }
|
|
|
- $companyinfo =$userCommon->handle("getCodeAndName",["code"=>$company_id]);
|
|
|
- if($supplierArr['relation_code']==$company_id){
|
|
|
- return error_show(1004,"业务公司与供应商属于同一家公司");
|
|
|
- }
|
|
|
+
|
|
|
$is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
|
|
|
if($is_auth===''){
|
|
|
return error_show(1004,"参数is_auth不能为空");
|
|
@@ -2378,7 +2461,23 @@ class Goodup extends Base
|
|
|
$is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
|
|
|
$proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!=""? trim($this->post['proof_type']):"";
|
|
|
$proof_url = isset($this->post['proof_url'])&&$this->post['proof_url']!=""? trim($this->post['proof_url']):"";
|
|
|
-
|
|
|
+ $combindList = $this->post['combind_list']??[];
|
|
|
+ if($isCombind==1){
|
|
|
+ if(empty($combindList)) return error_show(1004,'组合商品子商品信息不能为空');
|
|
|
+ $dchild=[];
|
|
|
+ $valid = Validate::rule(['childCode|子商品成本编号'=>'require','child_name|子商品名称'=>'require','child_num|组合比例'=>'require|number|gt:0']);
|
|
|
+ foreach ($combindList as $value){
|
|
|
+ if($valid->check($value)==false)return error_show(1004,$valid->getError());
|
|
|
+ $value['spuCode'] = $data['spuCode'];
|
|
|
+ $value['good_name'] =$good_name;
|
|
|
+ $value['updatetime'] =date('Y-m-d H:i:s');
|
|
|
+ if($value['is_del']==1){
|
|
|
+ $usable_stock = Db::name('good')->where(['spuCode'=>$data['spuCode']])->value('usable_stock',0);
|
|
|
+ if($usable_stock>0) return error_show(1004,'组合商品库存未处理完不可删除子商品');
|
|
|
+ }
|
|
|
+ $dchild[]=$value;
|
|
|
+ }
|
|
|
+ }
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$temp=[
|
|
@@ -2394,7 +2493,7 @@ class Goodup extends Base
|
|
|
"customized"=>$customized,
|
|
|
"tax"=>$tax,
|
|
|
"supplierNo"=>$supplierNo,
|
|
|
- "supplierName"=>$supplierArr['name'],
|
|
|
+ "supplierName"=>$supplierArr['name']??"",
|
|
|
"is_auth"=>$is_auth,
|
|
|
"good_size"=>$good_size,
|
|
|
"auth_img"=>$auth_img,
|
|
@@ -2437,6 +2536,7 @@ class Goodup extends Base
|
|
|
"is_step" => count($good_ladder) > 1 ? 1 : 0,
|
|
|
"stock_moq"=>$stock_moq,
|
|
|
"status"=>"0",
|
|
|
+ 'is_combind'=>$isCombind,
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
'is_support_barter'=>$is_support_barter,
|
|
|
'chargerid' => $supplier['personid'] ?? $this->uid,
|
|
@@ -2540,7 +2640,9 @@ class Goodup extends Base
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if($isCombind==1 && !empty($dchild)){
|
|
|
+ (new GoodCombind())->saveAll($dchild);
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
return app_show(0,"更新成功");
|
|
|
}else{
|
|
@@ -2555,12 +2657,13 @@ class Goodup extends Base
|
|
|
|
|
|
public function checkPrice(){
|
|
|
|
|
|
- $param = $this->request->only(['spuCode', 'min_num', 'platform_id', 'relaComNo'], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['spuCode', 'min_num', 'platform_id', 'relaComNo',"is_fixed"], 'post', 'trim');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
'spuCode|商品成本编码' => 'require',
|
|
|
'min_num|起订量' => 'require|number|gt:0',
|
|
|
'platform_id|上线平台ID' => 'require|number|gt:0',
|
|
|
+ 'is_fixed|定价模式' => 'require|number|in:0,1',
|
|
|
'relaComNo'=>'require'
|
|
|
]);
|
|
|
if($val->check($param) == false) return json_show(1005,$val->getError());
|
|
@@ -2601,7 +2704,7 @@ class Goodup extends Base
|
|
|
$sale_cost_fee = 0;
|
|
|
if ($good['is_gold_price'] == 1 && $top_cat_id == 6) {
|
|
|
// $saleprice = $good['noble_weight']*$good["cgd_gold_price"] + $nakelist['cost_fee']/(1-$budget)*$good['noble_weight']+$nakelist['mark_fee']+$nakelist['package_fee']+$nakelist['cert_fee']+$nakelist['nake_fee']+$nakelist['delivery_fee'];
|
|
|
-
|
|
|
+ if($param['is_fixed']==0) $nakelist['nake_fee']=0;
|
|
|
//系统售价=(贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用)/(1-成本售价/100)
|
|
|
$saleprice = ($good['noble_weight'] * $good["cgd_gold_price"] + $nakelist['cost_fee'] * $good['noble_weight'] + $nakelist['mark_fee'] + $nakelist['package_fee'] + $nakelist['cert_fee'] + $nakelist['nake_fee'] + $nakelist['delivery_fee'] + $nakelist['other_fee']) / (1 - $budget);
|
|
|
|