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))
return app('json')->fail('数据不存在');
$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);
if(!$adminInfo){
$pwd =password_hash(rand(100000,999999), PASSWORD_BCRYPT);

View File

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