diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index ae6db49c..bb364a5e 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -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']); diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 278f7847..a943f81d 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -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) ]; } diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index f8f28b8c..3db07cb4 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -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; }); } diff --git a/app/common/repositories/system/merchant/MerchantCategoryRepository.php b/app/common/repositories/system/merchant/MerchantCategoryRepository.php index 02998579..34d596b5 100644 --- a/app/common/repositories/system/merchant/MerchantCategoryRepository.php +++ b/app/common/repositories/system/merchant/MerchantCategoryRepository.php @@ -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) ? '添加商户分类' : '编辑商户分类'); diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index eb531ce3..8ff28c91 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -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; diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 16b053b1..1e813551 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -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('编辑成功'); } diff --git a/app/controller/admin/system/merchant/MerchantCategory.php b/app/controller/admin/system/merchant/MerchantCategory.php index a66c7e84..43e974e2 100644 --- a/app/controller/admin/system/merchant/MerchantCategory.php +++ b/app/controller/admin/system/merchant/MerchantCategory.php @@ -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; } diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index c404164f..ed1c0635 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -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??[]); } } diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index 43e6124b..f02441a8 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -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; } diff --git a/app/controller/api/store/order/StoreMicropayOrder.php b/app/controller/api/store/order/StoreMicropayOrder.php index 5521995f..b12d65fc 100644 --- a/app/controller/api/store/order/StoreMicropayOrder.php +++ b/app/controller/api/store/order/StoreMicropayOrder.php @@ -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=[ diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 31ffe100..e404246f 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -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; diff --git a/app/listener/ProductCreate.php b/app/listener/ProductCreate.php index e9229199..b6be7f27 100644 --- a/app/listener/ProductCreate.php +++ b/app/listener/ProductCreate.php @@ -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){