商户编辑接口
This commit is contained in:
parent
636df2af31
commit
cc2f74ae0b
@ -12,10 +12,17 @@
|
||||
|
||||
namespace app\controller\api\store\merchant;
|
||||
|
||||
use app\common\repositories\store\MerchantTakeRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\common\repositories\system\config\ConfigValueRepository;
|
||||
use app\common\repositories\user\UserMerchantRepository;
|
||||
use app\validate\merchant\MerchantTakeValidate;
|
||||
use app\validate\merchant\MerchantUpdateValidate;
|
||||
use crmeb\jobs\ChangeMerchantStatusJob;
|
||||
use think\App;
|
||||
use crmeb\basic\BaseController;
|
||||
use app\common\repositories\system\merchant\MerchantRepository as repository;
|
||||
use think\facade\Queue;
|
||||
|
||||
class Merchant extends BaseController
|
||||
{
|
||||
@ -119,4 +126,78 @@ class Merchant extends BaseController
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MerchantUpdateValidate $validate
|
||||
* @return mixed
|
||||
* @author xaboy
|
||||
* @day 2020/6/25
|
||||
*/
|
||||
public function update(MerchantUpdateValidate $validate, MerchantTakeValidate $takeValidate, MerchantTakeRepository $repository)
|
||||
{
|
||||
|
||||
$type = $this->request->param('type',1);
|
||||
$id = $this->request->param('id');
|
||||
if(empty($id)){
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
|
||||
$merchant = Db::name('merchant')->where('mer_id',$id)->find();
|
||||
if ($type == 2) {
|
||||
$data = $this->request->params([
|
||||
'mer_info',
|
||||
'mer_certificate',
|
||||
'service_phone',
|
||||
'mer_avatar',
|
||||
'mer_banner',
|
||||
'mer_state',
|
||||
'mini_banner',
|
||||
'mer_keyword',
|
||||
'mer_address',
|
||||
'long',
|
||||
'lat',
|
||||
['delivery_way',[2]],
|
||||
]);
|
||||
$validate->check($data);
|
||||
$sys_bases_status = systemConfig('sys_bases_status') === '0' ? 0 : 1;
|
||||
if ($sys_bases_status && empty($data['mer_certificate']))
|
||||
return app('json')->fail('店铺资质不可为空');
|
||||
|
||||
app()->make(ConfigValueRepository::class)->setFormData([
|
||||
'mer_certificate' => $data['mer_certificate']
|
||||
], $id);
|
||||
unset($data['mer_certificate']);
|
||||
|
||||
foreach ($data['delivery_way'] as $datum) {
|
||||
if ($datum == 1) {
|
||||
$takeData = $this->request->params(['mer_take_status', 'mer_take_name', 'mer_take_phone', 'mer_take_address', 'mer_take_location', 'mer_take_day', 'mer_take_time']);
|
||||
$takeValidate->check($takeData);
|
||||
$repository->set($id, $takeData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$delivery_way = implode(',',$data['delivery_way']);
|
||||
if (count($data['delivery_way']) == 1 && $data['delivery_way'] != $merchant['delivery_way']) {
|
||||
app()->make(ProductRepository::class)->getSearch([])
|
||||
->where('mer_id',$merchant['mer_id'])
|
||||
->update(['delivery_way' => $delivery_way]);
|
||||
}
|
||||
|
||||
$data['delivery_way'] = $delivery_way;
|
||||
|
||||
} else {
|
||||
$data = $this->request->params(['mer_state']);
|
||||
|
||||
if ($merchant['is_margin'] == 1 && $data['mer_state'] == 1)
|
||||
return app('json')->fail('开启店铺前请先支付保证金');
|
||||
|
||||
if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine'))
|
||||
return app('json')->fail('开启店铺前请先完成微信子商户入驻');
|
||||
}
|
||||
Db::name('merchant')->where('mer_id',$id)->update($data);
|
||||
|
||||
Queue::push(ChangeMerchantStatusJob::class, $id);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -494,6 +494,8 @@ Route::group('api/', function () {
|
||||
Route::get('/detail/:id', 'Merchant/detail');
|
||||
Route::get('/qrcode/:id', 'Merchant/qrcode');
|
||||
Route::get('/local', 'Merchant/localLst');
|
||||
//编辑商户信息
|
||||
Route::post('update', 'Merchant/update');
|
||||
})->prefix('api.store.merchant.');
|
||||
Route::post('store/certificate/:merId', 'api.Auth/getMerCertificate');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user