This commit is contained in:
mkm 2023-11-20 13:42:46 +08:00
parent f363de8995
commit ee92e1f33c
2 changed files with 28 additions and 25 deletions

View File

@ -244,7 +244,8 @@ class Merchant extends BaseController
if (!$this->repository->exists($id)) if (!$this->repository->exists($id))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
$admins=$this->request->adminInfo(); $admins=$this->request->adminInfo();
if($admins['admin_id']!=1){ $admin_arr=explode(',',env('MERCHANT_Arr'));
if($admins['admin_id']!=1 && !in_array($admins['roles'],$admin_arr)){
$adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2); $adminInfo = $adminRepository->merIdByAdmin($id,['account'=>'yy'.$admins['account']],2);
if(!$adminInfo){ if(!$adminInfo){
$pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT); $pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT);

View File

@ -58,14 +58,14 @@ class StoreProduct extends BaseController
public function lst($merId) public function lst($merId)
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['cate_id', 'keyword', ['type',20], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels',['order','sort']]); $where = $this->request->params(['cate_id', 'keyword', ['type', 20], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels', ['order', 'sort']]);
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); $typeCode = Db::name('merchant_type')->where('mer_type_id', $merchant['type_id'])->value('type_code');
// if ($merchant['type_id']==12){ // if ($merchant['type_id']==12){
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) {
$product_type=98;//供应链 $product_type = 98; //供应链
}else{ } else {
$product_type=0;//普通商品 $product_type = 0; //普通商品
} }
$where = array_merge($where, $this->repository->switchType($where['type'], $merId, $product_type)); $where = array_merge($where, $this->repository->switchType($where['type'], $merId, $product_type));
return app('json')->success($this->repository->getList($merId, $where, $page, $limit)); return app('json')->success($this->repository->getList($merId, $where, $page, $limit));
@ -82,21 +82,26 @@ class StoreProduct extends BaseController
public function create($merId, StoreProductValidate $validate) public function create($merId, StoreProductValidate $validate)
{ {
$res = $this->request->params($this->repository::CREATE_PARAMS); $res = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($res,$merId); $data = $this->repository->checkParams($res, $merId);
$data['mer_id'] = $merId; $data['mer_id'] = $merId;
$data['is_gift_bag'] = 0; $data['is_gift_bag'] = 0;
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$data['status'] = $merchant->is_audit ? 0 : 1; $data['status'] = $merchant->is_audit ? 0 : 1;
$data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1; $data['mer_status'] = ($merchant['is_del'] || !$merchant['mer_state'] || !$merchant['status']) ? 0 : 1;
$data['rate'] = 3; $data['rate'] = 3;
$typeCode=Db::name('merchant_type')->where('mer_type_id',$merchant['type_id'])->value('type_code'); $typeCode = Db::name('merchant_type')->where('mer_type_id', $merchant['type_id'])->value('type_code');
if ($merchant['type_id']==12){ $product_type = 0; //普通商品
if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ if ($merchant['type_id'] == 12) {
$product_type=98;//供应链 if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) {
}else{ $product_type = 98; //供应链
$product_type=0;//普通商品 }
} }
$productId = $this->repository->create($data, $product_type, 1); $productId = $this->repository->create($data, $product_type, 1);
if ($productId) {
return app('json')->success('添加成功');
} else {
return app('json')->fail('添加失败');
}
// $unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique'); // $unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique');
// if (!empty($unique) && $stockNum > 0) { // if (!empty($unique) && $stockNum > 0) {
// $this->repository->stockIn($merId, [ // $this->repository->stockIn($merId, [
@ -104,8 +109,6 @@ class StoreProduct extends BaseController
// 'unique' => $unique, // 'unique' => $unique,
// 'number' => $stockNum, // 'number' => $stockNum,
// ]); // ]);
}
return app('json')->success('添加成功');
} }
/** /**
@ -120,7 +123,7 @@ class StoreProduct extends BaseController
public function update($merId, $id, StoreProductValidate $validate) public function update($merId, $id, StoreProductValidate $validate)
{ {
$res = $this->request->params($this->repository::CREATE_PARAMS); $res = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($res,$merId,$id); $data = $this->repository->checkParams($res, $merId, $id);
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
if (!$this->repository->merExists($merId, $id)) if (!$this->repository->merExists($merId, $id))
@ -167,7 +170,7 @@ class StoreProduct extends BaseController
$status = $this->request->param('status', 0) == 1 ? 1 : 0; $status = $this->request->param('status', 0) == 1 ? 1 : 0;
if (!$this->repository->merExists($merId, $id)) if (!$this->repository->merExists($merId, $id))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
$this->repository->switchShow($id,$status, 'is_show',$merId); $this->repository->switchShow($id, $status, 'is_show', $merId);
return app('json')->success('修改成功'); return app('json')->success('修改成功');
} }
@ -194,9 +197,9 @@ class StoreProduct extends BaseController
$data['extension_status'] = systemConfig('extension_status'); $data['extension_status'] = systemConfig('extension_status');
$data['integral_status'] = 0; $data['integral_status'] = 0;
$data['integral_rate'] = 0; $data['integral_rate'] = 0;
if(systemConfig('integral_status') && merchantConfig($merId,'mer_integral_status')) { if (systemConfig('integral_status') && merchantConfig($merId, 'mer_integral_status')) {
$data['integral_status'] = 1; $data['integral_status'] = 1;
$data['integral_rate'] = merchantConfig($merId,'mer_integral_rate'); $data['integral_rate'] = merchantConfig($merId, 'mer_integral_rate');
} }
$merchant = app()->make(MerchantRepository::class)->get($merId); $merchant = app()->make(MerchantRepository::class)->get($merId);
$data['delivery_way'] = $merchant->delivery_way; $data['delivery_way'] = $merchant->delivery_way;
@ -239,15 +242,14 @@ class StoreProduct extends BaseController
public function stockIn() public function stockIn()
{ {
$params = $this->request->param(); $params = $this->request->param();
if($params['unique']==''){ if ($params['unique'] == '') {
return app('json')->fail('多规格编号不能为空'); return app('json')->fail('多规格编号不能为空');
} }
$res=$this->repository->stockIn($this->merId, $params); $res = $this->repository->stockIn($this->merId, $params);
if($res){ if ($res) {
return app('json')->success('入库成功'); return app('json')->success('入库成功');
}else{ } else {
return app('json')->fail('入库失败'); return app('json')->fail('入库失败');
} }
} }
} }