Merge branch 'profit_sharing' into dev

This commit is contained in:
luofei 2023-05-25 14:26:26 +08:00
commit 2070b17459
12 changed files with 42 additions and 43 deletions

View File

@ -53,8 +53,7 @@ class MerchantDao extends BaseDao
$query->where('is_trader', $where['is_trader']);
})
->when(isset($where['street_id']) && $where['street_id'] !== '', function ($query) use ($where) {
$mer_id = Db::name('merchant_address')->where('street_id', $where['street_id'])->column('mer_id');
$query->whereIn('mer_id',$mer_id ?: '' );
$query->where('street_id', $where['street_id']);
})
->when(isset($where['is_best']) && $where['is_best'] !== '', function ($query) use ($where) {
$query->where('is_best', $where['is_best']);

View File

@ -1325,6 +1325,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'integral' => $cart['integral'] ? bcdiv($cart['integral']['use'], $cart['cart_num'], 0) : 0,
'integral_total' => $cart['integral'] ? $cart['integral']['use'] : 0,
'product_type' => $cart['product_type'],
'source' => $cart['source'],
'source_id' => $cart['source_id'],
'cart_info' => json_encode($order_cart)
];
}

View File

@ -241,8 +241,8 @@ class ProductRepository extends BaseRepository
$product['mer_labels'] = $data['mer_labels'];
app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType);
}
// $product = $result;
// event('product.create',compact('product'));
$product = $result;
event('product.create',compact('product'));
return $result->product_id;
});
}

View File

@ -83,7 +83,9 @@ class MerchantCategoryRepository extends BaseRepository
$form = Elm::createForm($action, [
Elm::input('category_name', '分类名称')->required(),
Elm::number('commission_rate', '手续费(%)', 0)->required()->max(100)->precision(2)
Elm::number('commission_rate', '手续费(%)', 0)->required()->max(100)->precision(2),
Elm::frameImage('background', '背景图', '/' . config('admin.admin_prefix') . '/setting/uploadPicture?field=background&type=1')->width('896px')->height('480px')->props(['footer' => false])->modal(['modal' => false, 'custom-class' => 'suibian-modal']),
Elm::textarea('description', '简介')->required(),
]);
return $form->formData($formData)->setTitle(is_null($id) ? '添加商户分类' : '编辑商户分类');

View File

@ -221,8 +221,11 @@ class MerchantRepository extends BaseRepository
if($data['type_id'] == 0){
$data['type_id'] = '';
}
$find=Db::name('merchant_address')->where('mer_id',$id)->find();
$data['geo_address']=$find;
$data['geo_address'] = [
'area_id' => $data['area_id'],
'street_id' => $data['street_id'],
'village_id' => $data['village_id'],
];
return $data;
// return $this->form($id, $data);
}
@ -260,10 +263,6 @@ class MerchantRepository extends BaseRepository
$merchant = $this->dao->create($data);
$merchant['merchant_admin']=$make->createMerchantAccount($merchant, $account, $password);
$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']){
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(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id);
return $merchant;

View File

@ -148,16 +148,7 @@ class Merchant extends BaseController
$data['margin'] = $margin['margin'];
$data['is_margin'] = $margin['is_margin'];
$datas=$data;
unset($datas['area_id'],$datas['street_id'],$datas['village_id']);
$this->repository->update($id, $datas);
$adds=Db::name('merchant_address')->where('mer_id',$id)->find();
if($adds){
$adds1=['area_id'=>$data['area_id'],'street_id'=>$data['street_id'],'village_id'=>$data['village_id']];
Db::name('merchant_address')->where('mer_id',$id)->update($adds1);
}else{
$adds1=['mer_id'=>$id,'area_id'=>$data['area_id'],'street_id'=>$data['street_id'],'village_id'=>$data['village_id']];
Db::name('merchant_address')->insert($adds1);
}
return app('json')->success('编辑成功');
}

View File

@ -154,7 +154,7 @@ class MerchantCategory extends BaseController
*/
public function checkParams(MerchantCategoryValidate $validate)
{
$data = $this->request->params(['category_name', ['commission_rate', 0]]);
$data = $this->request->params(['category_name', ['commission_rate', 0], 'background', 'description']);
$validate->check($data);
return $data;
}

View File

@ -493,11 +493,15 @@ class Common extends BaseController
}
//获取云店铺
public function get_cloud_shop($street_code){
$find=DB::name('merchant')->alias('m')->where('m.type_id',11)->where('m.is_del',0)->where('m.status',1)
->join('merchant_address a','a.mer_id=m.mer_id and a.street_id='.$street_code)
->join('merchant_category c','m.category_id=c.merchant_category_id')
->field('m.mer_id,category_id,category_name')->select();
public function get_cloud_shop(int $street_code){
$find=DB::name('merchant')
->alias('m')
->where('m.type_id',11)
->where('m.is_del',0)
->where('m.status',1)
->where('m.street_id',$street_code)
->join('merchant_category c','m.category_id=c.merchant_category_id')
->field('m.mer_id,category_id,category_name,c.background,c.description')->select();
return app('json')->success($find??[]);
}
}

View File

@ -116,7 +116,7 @@ class StoreCart extends BaseController
//更新购物车
$cart_id = $cart['cart_id'];
$cart_num = ['cart_num' => ($cart['cart_num'] + $data['cart_num'])];
if ($entryMerId) {
if ($entryMerId && $entryMerId != $result['product']['mer_id']) {
$cart_num['source_id'] = $entryMerId;
$cart_num['source'] = StoreCartDao::SOURCE_CLOUD;
}
@ -125,7 +125,7 @@ class StoreCart extends BaseController
//添加购物车
$data['uid'] = $this->request->uid();
$data['mer_id'] = $result['product']['mer_id'];
if ($entryMerId) {
if ($entryMerId && $entryMerId != $result['product']['mer_id']) {
$data['source_id'] = $entryMerId;
$data['source'] = StoreCartDao::SOURCE_CLOUD;
}

View File

@ -113,15 +113,11 @@ class StoreMicropayOrder extends BaseController
$addressId=Db::name('user_address')->where('uid',$uid)->find();
$merchant=Db::name('merchant')->where('mer_id',$mer_id)->find();
if (!$addressId){
$merchant_address=Db::name('merchant_address')->where('mer_id',$mer_id)->find();
if (!$merchant_address){
return app('json')->fail('商户地址不存在');
}
if ($merchant_address['area_id']==0||$merchant_address['street_id']==0||$merchant_address['village_id']==0){
if ($merchant['area_id']==0||$merchant['street_id']==0||$merchant['village_id']==0){
return app('json')->fail('商户地址不完整');
}
$area_name=Db::name('geo_area')->where('area_code',$merchant_address['area_id'])->value('area_name');
$street_name=Db::name('geo_street')->where('street_code',$merchant_address['street_id'])->value('street_name');
$area_name=Db::name('geo_area')->where('area_code',$merchant['area_id'])->value('area_name');
$street_name=Db::name('geo_street')->where('street_code',$merchant['street_id'])->value('street_name');
$district_id=Db::name('city_area')->where('name',$area_name)->value('id');
$street_id=Db::name('city_area')->where('name',$street_name)->value('id');
$data=[

View File

@ -90,23 +90,28 @@ class StoreSpu extends BaseController
/**
* TODO 镇云仓库商户的商品搜索列表
* @param $id
* @param int $id
* @return mixed
* @author Qinii
* @day 12/24/20
*/
public function cloudMerProductLst($id)
public function cloudMerProductLst(int $id)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params([
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
]);
if ($where['action']) unset($where['product_type']);
$category_id=Db::name('merchant')->where('mer_id',$id)->value('category_id');
$mer_id=Db::name('merchant')->where('mer_state',1)->where('status',1)->where('category_id',$category_id)->where('type_id',Merchant::TypeCloudWarehouse)->value('mer_id');
if (!$mer_id){
$currentMerchant = Db::name('merchant')->where('mer_id',$id)->field('category_id,street_id')->find();
$mer_id = Db::name('merchant')
->where('street_id',$currentMerchant['street_id'])
->where('mer_state',1)
->where('status',1)
->where('category_id',$currentMerchant['category_id'])
->where('type_id',Merchant::TypeCloudWarehouse)
->value('mer_id');
if (!$mer_id) {
return app('json')->success(['count'=>0,'list'=>[]]);
}
$where['mer_id'] = $mer_id;
$where['entry_mer_id'] = $id;

View File

@ -40,7 +40,8 @@ class ProductCreate
}
}
//镇街云仓
$is_product=0;
//不再导入镇街云仓
/*$is_product=0;
if ($merchant['type_id']==10){
$townMerchantId = Db::name('merchant')->where('status',1)->where('mer_state',1)->where('category_id',$merchant['category_id'])->where('type_id',11)->value('mer_id');
if ($townMerchantId){
@ -60,7 +61,7 @@ class ProductCreate
}
}
}
}*/
}
public function CloudMerchanSpu($data,$event){