小组集中采购更新

This commit is contained in:
mkm 2023-01-10 14:06:15 +08:00
parent a94d5e81f2
commit 1ea9fb9ea1
6 changed files with 82 additions and 8 deletions

View File

@ -197,6 +197,16 @@ class ProductRepository extends BaseRepository
app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType); app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType);
} }
$product = $result; $product = $result;
if ($productType==0){
$find=Db::name('merchant_address')->where('mer_id',$data['mer_id'])->find();
if ($find && $find['street_id']!=0){
$addsdata=[
'address_id'=>$find['street_id'],
'product_id'=>$result->product_id
];
Db::name('merchant_address_product')->insert($addsdata);
}
}
event('product.create',compact('product')); event('product.create',compact('product'));
return $result->product_id; return $result->product_id;
}); });
@ -1503,6 +1513,9 @@ class ProductRepository extends BaseRepository
} }
$ids = is_array($ids) ? $ids : explode(',', $ids); $ids = is_array($ids) ? $ids : explode(',', $ids);
Db::name('store_spu')->where('product_id','in',$ids)->update(['status'=>$status]); Db::name('store_spu')->where('product_id','in',$ids)->update(['status'=>$status]);
if ($product['product_type']==0){
Db::name('merchant_address_product')->where('product_id','in',$ids)->update(['status'=>$status]);
}
$this->dao->updates($ids,[$is => $status]); $this->dao->updates($ids,[$is => $status]);
} }

View File

@ -130,8 +130,23 @@ class MerchantRepository extends BaseRepository
})->requiredNum(), })->requiredNum(),
Elm::select('type_id', '店铺类型')->disabled($is_margin)->options($options)->requiredNum()->col(12)->control($margin), Elm::select('type_id', '店铺类型')->disabled($is_margin)->options($options)->requiredNum()->col(12)->control($margin),
Elm::cascader('geo_street', '商圈')->options(function () {
$slect=Db::name('geo_area')->where('city_code','510500')
->withAttr('children',function ($value,$data){
$select= Db::name('geo_street')->where('area_code',$data['value'])
->field('street_code value,street_name label')
->select();
$arr=[];
foreach ($select as $k=>$v){
$v['value']=(int)$v['value'];
$arr[]=$v;
}
return $arr;
})
->field('area_code value,area_name label')
->select()->toArray();
return $slect;
})->props(['props' => ['checkStrictly' => true, 'emitPath' => false]])->filterable(true),
Elm::input('mer_account', '商户账号')->required()->disabled(!is_null($id))->required(!is_null($id)), Elm::input('mer_account', '商户账号')->required()->disabled(!is_null($id))->required(!is_null($id)),
Elm::password('mer_password', '登录密码')->required()->disabled(!is_null($id))->required(!is_null($id)), Elm::password('mer_password', '登录密码')->required()->disabled(!is_null($id))->required(!is_null($id)),
Elm::input('real_name', '商户姓名'), Elm::input('real_name', '商户姓名'),
@ -198,6 +213,8 @@ class MerchantRepository extends BaseRepository
if($data['type_id'] == 0){ if($data['type_id'] == 0){
$data['type_id'] = ''; $data['type_id'] = '';
} }
$find=Db::name('merchant_address')->where('mer_id')->value('street_id');
$data['geo_street']=$find;
return $this->form($id, $data); return $this->form($id, $data);
} }
@ -233,6 +250,7 @@ class MerchantRepository extends BaseRepository
unset($data['mer_account'], $data['mer_password']); unset($data['mer_account'], $data['mer_password']);
$merchant = $this->dao->create($data); $merchant = $this->dao->create($data);
$make->createMerchantAccount($merchant, $account, $password); $make->createMerchantAccount($merchant, $account, $password);
Db::name('merchant_address')->insert(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]);
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;

View File

@ -28,6 +28,7 @@ use think\App;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Queue; use think\facade\Queue;
/** /**
@ -117,7 +118,6 @@ class Merchant extends BaseController
{ {
if (!$this->repository->exists($id)) if (!$this->repository->exists($id))
return app('json')->fail('数据不存在'); return app('json')->fail('数据不存在');
return app('json')->success(formToData($this->repository->updateForm($id))); return app('json')->success(formToData($this->repository->updateForm($id)));
} }
@ -146,7 +146,12 @@ class Merchant extends BaseController
$margin = $this->repository->checkMargin($id, $data['type_id']); $margin = $this->repository->checkMargin($id, $data['type_id']);
$data['margin'] = $margin['margin']; $data['margin'] = $margin['margin'];
$data['is_margin'] = $margin['is_margin']; $data['is_margin'] = $margin['is_margin'];
$geo_street=$data['geo_street'];//添加商圈
unset($data['geo_street']);
$this->repository->update($id, $data); $this->repository->update($id, $data);
if ($geo_street){
Db::name('merchant_address')->where('mer_id',$id)->update(['street_id'=>$geo_street]);
}
return app('json')->success('编辑成功'); return app('json')->success('编辑成功');
} }
@ -176,7 +181,7 @@ class Merchant extends BaseController
*/ */
public function checkParam(MerchantValidate $validate, $isUpdate = false) public function checkParam(MerchantValidate $validate, $isUpdate = false)
{ {
$data = $this->request->params([['category_id', 0], ['type_id', 0], 'mer_name', 'commission_rate', 'real_name', 'mer_phone', 'mer_keyword', 'mer_address', 'mark', ['sort', 0], ['status', 0], ['is_audit', 0], ['is_best', 0], ['is_bro_goods', 0], ['is_bro_room', 0], ['is_trader', 0],'sub_mchid']); $data = $this->request->params([['geo_street',0],['category_id', 0], ['type_id', 0], 'mer_name', 'commission_rate', 'real_name', 'mer_phone', 'mer_keyword', 'mer_address', 'mark', ['sort', 0], ['status', 0], ['is_audit', 0], ['is_best', 0], ['is_bro_goods', 0], ['is_bro_room', 0], ['is_trader', 0],'sub_mchid']);
if (!$isUpdate) { if (!$isUpdate) {
$data += $this->request->params(['mer_account', 'mer_password']); $data += $this->request->params(['mer_account', 'mer_password']);
}else { }else {

View File

@ -52,6 +52,7 @@ class Auth extends BaseController
{ {
$data['tempCode'] = 'ORDER_PAY_SUCCESS'; $data['tempCode'] = 'ORDER_PAY_SUCCESS';
$data['id'] = '8'; $data['id'] = '8';
halt($data);
app()->make(WechatTemplateMessageService::class)->sendTemplate($data); app()->make(WechatTemplateMessageService::class)->sendTemplate($data);
} }
@ -380,15 +381,12 @@ class Auth extends BaseController
$tokenInfo = $repository->createToken($user); $tokenInfo = $repository->createToken($user);
$repository->loginAfter($user); $repository->loginAfter($user);
$find=Db::name('nk_user')->where('user_id',$user['uid'])->find(); $find=Db::name('nk_user')->where('user_id',$user['uid'])->find();
$user['no_update']=1;
if ($find && $find['n_user_id']!=0){ if ($find && $find['n_user_id']!=0){
$msg=Db::connect('nongke')->name('szxc_information_usermsg')->where('user_id',$find['n_user_id'])->cache(true)->find(); $msg=Db::connect('nongke')->name('szxc_information_usermsg')->where('user_id',$find['n_user_id'])->cache(true)->find();
if ($msg){ if ($msg){
$user['no_update']=0; $user['no_update']=0;
}else{
$user['no_update']=1;
} }
}else{
$user['no_update']=1;
} }
if ($user['phone']==''){ if ($user['phone']==''){
Db::name('user')->where('uid',$user['uid'])->update(['phone'=>$user['account']]); Db::name('user')->where('uid',$user['uid'])->update(['phone'=>$user['account']]);

View File

@ -17,6 +17,7 @@ use crmeb\services\CopyCommand;
use think\App; use think\App;
use crmeb\basic\BaseController; use crmeb\basic\BaseController;
use app\common\repositories\store\product\SpuRepository; use app\common\repositories\store\product\SpuRepository;
use think\facade\Db;
class StoreSpu extends BaseController class StoreSpu extends BaseController
{ {
@ -64,6 +65,42 @@ class StoreSpu extends BaseController
return app('json')->success($data); return app('json')->success($data);
} }
/**代购列表
* @return mixed
*/
public function agency_list(){
// [$page, $limit] = $this->getPage();
$where = $this->request->params([
'keyword',
'cate_id',
'cate_pid',
'order',
'price_on',
'price_off',
'brand_id',
'pid',
'mer_cate_id',
'product_type',
'action',
'common',
'is_trader',
'product_ids',
'mer_id'
]);
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ? $where['order'] : 'star';
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data=Db::name('merchant_address_product')->alias('a')
->where('a.address_id',510504100)
->where('a.status',1)
->join('store_product p','a.product_id=p.product_id')
->field('p.product_id,p.store_name,p.sales,p.price,p.image')
->select();
$count=Db::name('merchant_address_product')->where('address_id',510504100)
->where('status',1)->count();
return app('json')->success(['count'=>$count,'list'=>$data]);
}
/** /**
* TODO 商户的商品搜索列表 * TODO 商户的商品搜索列表
* @param $id * @param $id

View File

@ -429,6 +429,9 @@ Route::group('api/', function () {
Route::get('/coupon_product', 'StoreSpu/getProductByCoupon'); Route::get('/coupon_product', 'StoreSpu/getProductByCoupon');
//热卖排行 //热卖排行
Route::get('/get_hot_ranking', 'StoreSpu/getHotRanking'); Route::get('/get_hot_ranking', 'StoreSpu/getHotRanking');
Route::get('/agency_list', 'StoreSpu/agency_list');
})->prefix('api.store.product.'); })->prefix('api.store.product.');
//直播 //直播