|
@@ -13,133 +13,142 @@ use think\facade\Validate;
|
|
|
|
|
|
class Base extends \app\BaseController
|
|
|
{
|
|
|
- public $post=[];
|
|
|
- public $uid=0;//账户id
|
|
|
- public $uname='';//账户名称
|
|
|
- public $roleid=0;//角色id
|
|
|
- public $level=0;//角色等级,1.系统超级管理员,2.企业管理员,3.企业人员
|
|
|
- private $white=['login'];
|
|
|
+ public $post = [];
|
|
|
+ public $uid = 0;//账户id
|
|
|
+ public $uname = '';//账户名称
|
|
|
+ public $roleid = 0;//角色id
|
|
|
+ public $level = 0;//角色等级,1.系统超级管理员,2.企业管理员,3.企业人员
|
|
|
+ private $white = ['login'];
|
|
|
|
|
|
public function __construct(App $app)
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
- $this->post =$this->request->post();
|
|
|
+ $this->post = $this->request->post('',null,'trim');
|
|
|
|
|
|
- if(!in_array($this->request->pathinfo(),$this->white)) $this->validateToken();
|
|
|
+ if (!in_array($this->request->pathinfo(), $this->white)) $this->validateToken();
|
|
|
}
|
|
|
|
|
|
public function validateToken()
|
|
|
{
|
|
|
+
|
|
|
//这个地方不能用return json_show()方法,无法阻止代码继续执行
|
|
|
$val = Validate::rule([
|
|
|
- 'token'=>'require',
|
|
|
+ 'token' => 'require',
|
|
|
// 'supplierNo'=>'length:18',
|
|
|
]);
|
|
|
|
|
|
- if(!$val->check($this->post)) return error_show(1004,$val->getError());
|
|
|
+ if (!$val->check($this->post)) return error_show(1004, $val->getError());
|
|
|
|
|
|
// $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
// if($token==""){
|
|
|
// return error_show(101,'token不能为空');
|
|
|
// }
|
|
|
$effetc = VerifyTokens($this->post['token']);
|
|
|
- if(!empty($effetc) && $effetc['code']!=0) return error_show($effetc['code'], $effetc['message']);
|
|
|
- if(($this->post['supplierNo'] !='') && !in_array($this->post['supplierNo'],array_column($effetc['data']['company_relaton'],'companyCode'))) return error_show(1004,'尚未关联企业');
|
|
|
+ if (!empty($effetc) && $effetc['code'] != 0) return error_show($effetc['code'], $effetc['message']);
|
|
|
+ if (($this->post['supplierNo'] != '') && !in_array($this->post['supplierNo'], array_column($effetc['data']['company_relaton'], 'companyCode'))) return error_show(1004, '尚未关联企业');
|
|
|
+
|
|
|
+ $this->uid = isset($effetc['data']['id']) ? $effetc['data']['id'] : "";
|
|
|
+ $this->uname = isset($effetc['data']['nickname']) ? $effetc['data']['nickname'] : "";
|
|
|
|
|
|
- $this->uid=isset($effetc['data']['id']) ?$effetc['data']['id']:"";
|
|
|
- $this->uname=isset($effetc['data']['nickname']) ?$effetc['data']['nickname']:"";
|
|
|
+ $where_role = [['a.uid', '=', $this->uid], ['a.is_del', '=', 0], ['a.status', '=', 1]];
|
|
|
+ if (isset($this->post['supplierNo']) && $this->post['supplierNo'] != '') {
|
|
|
+ $where_role[] = ['a.supplierNo', '=', $this->post['supplierNo']];
|
|
|
+ $where_role[] = ['b.level', '<>', 1];
|
|
|
+ } else $where_role[] = ['b.level', '=', 1];
|
|
|
|
|
|
$role = Db::name('user_role')
|
|
|
->alias('a')
|
|
|
->field('a.id,a.status,a.roleid,b.role_name,b.level')
|
|
|
- ->leftJoin('role b','b.id=a.roleid')
|
|
|
- ->where(['a.uid'=>$this->uid,'a.is_del'=>0,'a.status'=>1,'b.supplierNo'=>$this->post['supplierNo']])
|
|
|
+ ->leftJoin('role b', 'b.id=a.roleid')
|
|
|
+ ->where($where_role)
|
|
|
->findOrEmpty();
|
|
|
|
|
|
- if(empty($role) || $role['status']==0) return error_show(102,'该企业尚未开通对应角色');
|
|
|
+ if (empty($role) || $role['status'] == 0) return error_show(102, '该企业尚未开通对应角色');
|
|
|
|
|
|
$this->roleid = $role['roleid'];//权限id
|
|
|
$this->level = $role['level'];//权限等级
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function checkRole(){
|
|
|
+ public function checkRole()
|
|
|
+ {
|
|
|
|
|
|
- $uid = Db::name("user_role")->where(['uid'=>$this->uid,"is_del"=>0,"status"=>1])->find();
|
|
|
- if($uid==false){
|
|
|
+ $uid = Db::name("user_role")->where(['uid' => $this->uid, "is_del" => 0, "status" => 1])->find();
|
|
|
+ if ($uid == false) {
|
|
|
return [];
|
|
|
}
|
|
|
- $action=[];
|
|
|
- $this->roleid=$uid['roleid'];
|
|
|
- $role =Db::name("role_action")->where(["role_id"=>$uid['roleid'],"status"=>1])->find();
|
|
|
- $action['action_conllect']=isset($role['action_conllect'])? $role['action_conllect']:'';
|
|
|
- $action['write'][]=$this->uid;
|
|
|
- $group=[];
|
|
|
- $group = Db::name("role_group")->where("FIND_IN_SET($this->uid,group_user) > 0")->column("id");
|
|
|
- $where="to_user=$this->uid";
|
|
|
- if(!empty($group)){
|
|
|
- $where.=" or to_group in (".implode(",",$group).")";
|
|
|
+ $action = [];
|
|
|
+ $this->roleid = $uid['roleid'];
|
|
|
+ $role = Db::name("role_action")->where(["role_id" => $uid['roleid'], "status" => 1])->find();
|
|
|
+ $action['action_conllect'] = isset($role['action_conllect']) ? $role['action_conllect'] : '';
|
|
|
+ $action['write'][] = $this->uid;
|
|
|
+ $group = [];
|
|
|
+ $group = Db::name("role_group")->where("FIND_IN_SET($this->uid,group_user) > 0")->column("id");
|
|
|
+ $where = "to_user=$this->uid";
|
|
|
+ if (!empty($group)) {
|
|
|
+ $where .= " or to_group in (" . implode(",", $group) . ")";
|
|
|
}
|
|
|
|
|
|
- $paltform = Db::name("user_platform")->where(["uid"=>$this->uid,"is_del"=>0])->find();
|
|
|
- $action['platform']= $paltform!=false ? explode(",",$paltform['platform']) :[];
|
|
|
- $share =Db::name("role_share")->where(["is_del"=>0,"status"=>1])->where($where) ->select();
|
|
|
- if(!empty($share)){
|
|
|
- foreach ($share as $value){
|
|
|
- if($value['action']==1){
|
|
|
- if($value['share_user']!=""){
|
|
|
- $action['write'][]=$value['share_user'];
|
|
|
- $user=Db::name("user_role")->where(['uid'=>$value['share_user'],"is_del"=>0,"status"=>1])->find();
|
|
|
- if($user!=false){
|
|
|
- $role =Db::name("role_action")->where(["role_id"=>$user['roleid'],"status"=>1])->find();
|
|
|
- if($role!=false){
|
|
|
- $conlect =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect'])])->column("id");
|
|
|
- $shar=explode(",",$value['action_collect']);
|
|
|
- $wish =array_intersect($conlect,$shar);
|
|
|
- $action['action_conllect'].=empty($wish)?"":",".implode(",",$wish);
|
|
|
+ $paltform = Db::name("user_platform")->where(["uid" => $this->uid, "is_del" => 0])->find();
|
|
|
+ $action['platform'] = $paltform != false ? explode(",", $paltform['platform']) : [];
|
|
|
+ $share = Db::name("role_share")->where(["is_del" => 0, "status" => 1])->where($where)->select();
|
|
|
+ if (!empty($share)) {
|
|
|
+ foreach ($share as $value) {
|
|
|
+ if ($value['action'] == 1) {
|
|
|
+ if ($value['share_user'] != "") {
|
|
|
+ $action['write'][] = $value['share_user'];
|
|
|
+ $user = Db::name("user_role")->where(['uid' => $value['share_user'], "is_del" => 0, "status" => 1])->find();
|
|
|
+ if ($user != false) {
|
|
|
+ $role = Db::name("role_action")->where(["role_id" => $user['roleid'], "status" => 1])->find();
|
|
|
+ if ($role != false) {
|
|
|
+ $conlect = Db::name("action")->where(['menuid' => explode(",", $value['action_collect'])])->column("id");
|
|
|
+ $shar = explode(",", $value['action_collect']);
|
|
|
+ $wish = array_intersect($conlect, $shar);
|
|
|
+ $action['action_conllect'] .= empty($wish) ? "" : "," . implode(",", $wish);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- if($value['action']===0){
|
|
|
- if($value['share_user']!="") $action['write'][]=$value['share_user'];
|
|
|
- if($value['action_collect']!=''){
|
|
|
- $act =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect']),"action_code"=>'001'])->column("id");
|
|
|
- $action['action_conllect'].=empty($act)?"":",".implode(",",$act);
|
|
|
+ if ($value['action'] === 0) {
|
|
|
+ if ($value['share_user'] != "") $action['write'][] = $value['share_user'];
|
|
|
+ if ($value['action_collect'] != '') {
|
|
|
+ $act = Db::name("action")->where(['menuid' => explode(",", $value['action_collect']), "action_code" => '001'])->column("id");
|
|
|
+ $action['action_conllect'] .= empty($act) ? "" : "," . implode(",", $act);
|
|
|
}
|
|
|
}
|
|
|
- if($value['action']===''){
|
|
|
- if($value['share_user']!="") $action['write'][]=$value['share_user'];
|
|
|
- if($value['action_collect']!=''){
|
|
|
- $act =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect']),"action_code"=>'001'])->column("id");
|
|
|
- $action['action_conllect'].=empty($act)?"":",".implode(",",$act);
|
|
|
+ if ($value['action'] === '') {
|
|
|
+ if ($value['share_user'] != "") $action['write'][] = $value['share_user'];
|
|
|
+ if ($value['action_collect'] != '') {
|
|
|
+ $act = Db::name("action")->where(['menuid' => explode(",", $value['action_collect']), "action_code" => '001'])->column("id");
|
|
|
+ $action['action_conllect'] .= empty($act) ? "" : "," . implode(",", $act);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//离职交接权限
|
|
|
- $resgin= Db::name("resign_info")->where([["hand_uid","=",$this->uid],["is_del","=",0],['status',"=",4]])
|
|
|
+ $resgin = Db::name("resign_info")->where([["hand_uid", "=", $this->uid], ["is_del", "=", 0], ['status', "=", 4]])
|
|
|
->column(['resign_uid']);
|
|
|
- if(!empty($resgin)){
|
|
|
- $action['write']= array_unique(array_merge($action['write'],$resgin));
|
|
|
+ if (!empty($resgin)) {
|
|
|
+ $action['write'] = array_unique(array_merge($action['write'], $resgin));
|
|
|
}
|
|
|
|
|
|
// 超级管理员看到所有人的数据
|
|
|
- if($uid['roleid']==1 || $uid['roleid']==33){
|
|
|
- $action['write']=[];
|
|
|
+ if ($uid['roleid'] == 1 || $uid['roleid'] == 33) {
|
|
|
+ $action['write'] = [];
|
|
|
}
|
|
|
- $action['roleid']=$uid['roleid'];
|
|
|
- $action['action_conllect']=implode(",",array_unique(explode(",",$action['action_conllect'])));
|
|
|
+ $action['roleid'] = $uid['roleid'];
|
|
|
+ $action['action_conllect'] = implode(",", array_unique(explode(",", $action['action_conllect'])));
|
|
|
return $action;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//用户数据权限检查
|
|
|
- protected function checkDataShare(){
|
|
|
+ protected function checkDataShare()
|
|
|
+ {
|
|
|
|
|
|
- if($this->roleid==1 || $this->roleid==33) return [];// 超级管理员(roleid==1)和最高领导(roleid==33)能看到所有人的数据
|
|
|
+ if ($this->roleid == 1 || $this->roleid == 33) return [];// 超级管理员(roleid==1)和最高领导(roleid==33)能看到所有人的数据
|
|
|
|
|
|
$data = get_group_share_uid($this->uid);
|
|
|
/**
|
|
@@ -152,126 +161,127 @@ class Base extends \app\BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param $good
|
|
|
- * @param $isZx
|
|
|
- * @param string $thNo
|
|
|
- * @return mixed|string
|
|
|
- * @throws \think\Exception
|
|
|
- */
|
|
|
- public function CheckGoodZx($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',
|
|
|
- 'is_stock' => '1',
|
|
|
- '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,true);
|
|
|
- if($insert==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
- //修改状态,添加待办
|
|
|
- ActionLog::logAdd($this->post['token'], [
|
|
|
- "order_code" =>$newCode,//咨询单详情编号
|
|
|
- "status" => 0,//这里的status是之前的值
|
|
|
- "action_remark" => '非库存品退货转库存',//备注
|
|
|
- "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
- ], "SPCB", 7,$good);
|
|
|
-
|
|
|
- ProcessOrder::AddProcess($this->post['token'], [
|
|
|
- "order_type" => 'SPCB',
|
|
|
- "order_code" =>$newCode,//咨询单详情编号
|
|
|
- "order_id" => $insert,
|
|
|
- "order_status" =>7,
|
|
|
- "before_status"=>0,
|
|
|
- 'holder_id'=>$good['createrid'],
|
|
|
- ]);
|
|
|
- $newAdd=Db::name("good_change_log")->insert($log);
|
|
|
- if($newAdd==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
- return $spuCode;
|
|
|
+ * @param $good
|
|
|
+ * @param $isZx
|
|
|
+ * @param string $thNo
|
|
|
+ * @return mixed|string
|
|
|
+ * @throws \think\Exception
|
|
|
+ */
|
|
|
+ public function CheckGoodZx($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',
|
|
|
+ 'is_stock' => '1',
|
|
|
+ '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, true);
|
|
|
+ if ($insert == false) throw new \Exception("非库存商品转库存失败", 1005);
|
|
|
+ //修改状态,添加待办
|
|
|
+ ActionLog::logAdd($this->post['token'], [
|
|
|
+ "order_code" => $newCode,//咨询单详情编号
|
|
|
+ "status" => 0,//这里的status是之前的值
|
|
|
+ "action_remark" => '非库存品退货转库存',//备注
|
|
|
+ "action_type" => "create"//新建create,编辑edit,更改状态status
|
|
|
+ ], "SPCB", 7, $good);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess($this->post['token'], [
|
|
|
+ "order_type" => 'SPCB',
|
|
|
+ "order_code" => $newCode,//咨询单详情编号
|
|
|
+ "order_id" => $insert,
|
|
|
+ "order_status" => 7,
|
|
|
+ "before_status" => 0,
|
|
|
+ 'holder_id' => $good['createrid'],
|
|
|
+ ]);
|
|
|
+ $newAdd = Db::name("good_change_log")->insert($log);
|
|
|
+ if ($newAdd == false) throw new \Exception("非库存商品转库存失败", 1005);
|
|
|
+ return $spuCode;
|
|
|
|
|
|
}
|
|
|
|