商户信息填写提交
This commit is contained in:
parent
fce64220b9
commit
4480f95d65
@ -13,14 +13,22 @@
|
||||
namespace app\controller\api\store\merchant;
|
||||
|
||||
use app\common\model\system\merchant\MerchantType;
|
||||
use app\common\repositories\store\MerchantTakeRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\common\repositories\system\config\ConfigValueRepository;
|
||||
use app\common\repositories\system\financial\FinancialRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
use app\common\repositories\user\UserMerchantRepository;
|
||||
use app\validate\merchant\MerchantFinancialAccountValidate;
|
||||
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\Db;
|
||||
use think\facade\Queue;
|
||||
|
||||
class Merchant extends BaseController
|
||||
{
|
||||
@ -237,4 +245,90 @@ class Merchant extends BaseController
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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]],
|
||||
'credit_buy',
|
||||
'settle_cycle',
|
||||
'interest_rate',
|
||||
]);
|
||||
|
||||
if (empty($data['service_phone'])) {
|
||||
return app('json')->fail('客户电话不能为空');
|
||||
}
|
||||
// 如果手机号不存在,则使用入驻时的手机号
|
||||
$data['service_phone'] = empty($data['service_phone']) ? $merchant['mer_phone'] : $data['service_phone'];
|
||||
|
||||
$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('店铺资质不可为空');
|
||||
|
||||
$merCertificate = merchantConfig($id, 'mer_certificate');
|
||||
if (!is_array($merCertificate)) {
|
||||
$merCertificate = explode(',', $merCertificate);
|
||||
}
|
||||
$merCertificate[0] = $data['mer_certificate'];
|
||||
app()->make(ConfigValueRepository::class)->setFormData([
|
||||
'mer_certificate' => $merCertificate
|
||||
], $id);
|
||||
unset($data['mer_certificate']);
|
||||
|
||||
foreach ($data['delivery_way'] as $datum) {
|
||||
if ($datum == 1) {
|
||||
$takeData = $this->request->params(['mer_take_status', 'mer_take_location', 'mer_take_day', 'mer_take_time']);
|
||||
$takeData['mer_take_name'] = $merchant['mer_name'];
|
||||
$takeData['mer_take_address'] = $data['mer_address'];
|
||||
$takeData['mer_take_phone'] = $merchant['mer_phone'];
|
||||
$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('修改成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -536,6 +536,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