修复错误
This commit is contained in:
parent
fd62937b7f
commit
5cf43a6f59
@ -124,6 +124,9 @@ class MerchantIntentionRepository extends BaseRepository
|
|||||||
'type_id' => $intention['mer_type_id'],
|
'type_id' => $intention['mer_type_id'],
|
||||||
'real_name' => $intention['name'],
|
'real_name' => $intention['name'],
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
|
'area_id' => $intention['area_id'],
|
||||||
|
'street_id' => $intention['street_id'],
|
||||||
|
'village_id' => $intention['village_id'],
|
||||||
'is_audit' => 1,
|
'is_audit' => 1,
|
||||||
'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1,
|
'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1,
|
||||||
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
|
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
|
||||||
@ -148,7 +151,6 @@ class MerchantIntentionRepository extends BaseRepository
|
|||||||
'site' => systemConfig('site_name'),
|
'site' => systemConfig('site_name'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) {
|
Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) {
|
||||||
if ($data['status'] == 1) {
|
if ($data['status'] == 1) {
|
||||||
if ($create) {
|
if ($create) {
|
||||||
|
@ -253,10 +253,10 @@ class MerchantRepository extends BaseRepository
|
|||||||
|
|
||||||
$merchant = $this->dao->create($data);
|
$merchant = $this->dao->create($data);
|
||||||
$make->createMerchantAccount($merchant, $account, $password);
|
$make->createMerchantAccount($merchant, $account, $password);
|
||||||
$address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]);
|
$address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['street_id'],'area_id'=>$data['area_id'],'village_id'=>$data['village_id']]);
|
||||||
// if($data['area_id'] && $data['village_id']){
|
if($data['area_id'] && $data['village_id']){
|
||||||
// Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]);
|
Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]);
|
||||||
// }
|
}
|
||||||
app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id);
|
app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id);
|
||||||
app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id);
|
app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id);
|
||||||
return $merchant;
|
return $merchant;
|
||||||
|
@ -12,10 +12,18 @@
|
|||||||
|
|
||||||
namespace app\controller\api\store\merchant;
|
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\common\repositories\user\UserMerchantRepository;
|
||||||
|
use app\validate\merchant\MerchantTakeValidate;
|
||||||
|
use app\validate\merchant\MerchantUpdateValidate;
|
||||||
|
use crmeb\jobs\ChangeMerchantStatusJob;
|
||||||
use think\App;
|
use think\App;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use app\common\repositories\system\merchant\MerchantRepository as repository;
|
use app\common\repositories\system\merchant\MerchantRepository as repository;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Queue;
|
||||||
|
|
||||||
class Merchant extends BaseController
|
class Merchant extends BaseController
|
||||||
{
|
{
|
||||||
@ -118,5 +126,109 @@ class Merchant extends BaseController
|
|||||||
$where['delivery_way'] = 1;
|
$where['delivery_way'] = 1;
|
||||||
return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
|
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]],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 如果手机号不存在,则使用入驻时的手机号
|
||||||
|
$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('店铺资质不可为空');
|
||||||
|
|
||||||
|
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_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('修改成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
* @author xaboy
|
||||||
|
* @day 2020/7/21
|
||||||
|
*/
|
||||||
|
public function info(MerchantTakeRepository $repository)
|
||||||
|
{
|
||||||
|
$id = $this->request->param('id');
|
||||||
|
if(empty($id)){
|
||||||
|
return app('json')->fail('参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = Db::name('merchant')->where('mer_id',$id)->find();
|
||||||
|
// $append = ['merchantCategory', 'merchantType', 'mer_certificate'];
|
||||||
|
// if ($merchant['is_margin'] == -10)
|
||||||
|
// $append[] = 'refundMarginOrder';
|
||||||
|
|
||||||
|
// $data = $merchant->append($append)->hidden(['mark', 'reg_admin_id', 'sort'])->toArray();
|
||||||
|
$delivery = $repository->get($id) + systemConfig(['tx_map_key']);
|
||||||
|
$data = array_merge($data,$delivery);
|
||||||
|
$data['sys_bases_status'] = systemConfig('sys_bases_status') === '0' ? 0 : 1;
|
||||||
|
|
||||||
|
return app('json')->success($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user