From 0dcf5a35e91e80e910f342db93fba98a894da4ae Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 20 Oct 2023 17:55:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Statistics.php | 117 +++++++++++++++ .../store/merchant/MerchantIntention.php.bak | 139 ------------------ .../api/store/product/StoreProduct.php | 38 +++++ .../merchant/store/product/Product.php | 13 +- route/api.php | 37 +++-- 5 files changed, 187 insertions(+), 157 deletions(-) create mode 100644 app/controller/api/Statistics.php delete mode 100644 app/controller/api/store/merchant/MerchantIntention.php.bak diff --git a/app/controller/api/Statistics.php b/app/controller/api/Statistics.php new file mode 100644 index 00000000..d1ad1eb5 --- /dev/null +++ b/app/controller/api/Statistics.php @@ -0,0 +1,117 @@ +request->param(); + if (isset($parmas['type']) && $parmas['type'] != '') { + switch ($parmas['type']) { + case 'area': + $type = 'area_id'; + break; + case 'street': + $type = 'street_id'; + break; + default: + return app('json')->fail('type:格式错误'); + break; + } + } else { + $type = 'street_id'; + } + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + if (isset($parmas['responsible_area']) && $parmas['responsible_area'] != '') { + $where[] = [$type,'in',explode(',', $parmas['responsible_area'])]; + } + $where[]=['is_del','=',0]; + $where[]=['status','=',1]; + $count=Db::name('merchant')->where($where)->count(); + return app('json')->success(['count'=>$count]); + } + + /** + * 商户商品数量查询 + */ + public function SupplyChainProductCount() + { + $parmas = $this->request->param(); + + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { + return app('json')->fail('mer_intention_id:格式错误'); + } + $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[] = ['mer_id','=',$parmas['mer_intention_id']]; + $where[]=['mer_status','=',1]; + $where[]=['status','=',1]; + $where[]=['is_used','=',1]; + $where[]=['is_show','=',1]; + $count=Db::name('store_product')->where($where)->count(); + return app('json')->success(['count'=>$count]); + } + + /** + * 商户商品库存更新查询 + */ + public function SupplyChainProductStockCount() + { + $parmas = $this->request->param(); + + if (!isset($parmas['start_time']) || $parmas['start_time'] == '') { + return app('json')->fail('start_time:格式错误'); + } + if (!isset($parmas['end_time']) || $parmas['end_time'] == '') { + return app('json')->fail('end_time:格式错误'); + } + if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { + return app('json')->fail('mer_intention_id:格式错误'); + } + $where[]=['create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]]; + $where[] = ['mer_id','=',$parmas['mer_intention_id']]; + $count=Db::name('store_product_stock')->where($where)->count(); + return app('json')->success(['count'=>$count]); + } + + /** + * 商品列表 + */ + public function ProductList(){ + $parmas = $this->request->param(); + + if (!isset($parmas['page']) || $parmas['page'] == '') { + return app('json')->fail('page:格式错误'); + } + $where[]=['mer_status','=',1]; + $where[]=['status','=',1]; + $where[]=['is_used','=',1]; + $where[]=['is_show','=',1]; + if (isset($parmas['keyword']) &&$parmas['keyword'] != '') { + $where[] = ['store_name','like','%'.$parmas['keyword'].'%']; + } + $list=Db::name('store_product')->where($where)->page($parmas['page']) + ->field('product_id,store_name,image,price') + ->limit(10)->select(); + return app('json')->success(['page'=>$parmas['page'],'data'=>$list]); + + } +} diff --git a/app/controller/api/store/merchant/MerchantIntention.php.bak b/app/controller/api/store/merchant/MerchantIntention.php.bak deleted file mode 100644 index cc0f8236..00000000 --- a/app/controller/api/store/merchant/MerchantIntention.php.bak +++ /dev/null @@ -1,139 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\controller\api\store\merchant; - -use app\common\repositories\system\merchant\MerchantAdminRepository; -use app\common\repositories\system\merchant\MerchantCategoryRepository; -use app\common\repositories\system\merchant\MerchantRepository; -use app\common\repositories\system\merchant\MerchantTypeRepository; -use app\validate\api\MerchantIntentionValidate; -use crmeb\services\SmsService; -use crmeb\services\SwooleTaskService; -use crmeb\services\YunxinSmsService; -use think\App; -use crmeb\basic\BaseController; -use app\common\repositories\system\merchant\MerchantIntentionRepository as repository; -use think\exception\ValidateException; - -class MerchantIntention extends BaseController -{ - protected $repository; - protected $userInfo; - - public function __construct(App $app, repository $repository) - { - parent::__construct($app); - $this->repository = $repository; - $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null; - } - - public function create() - { - $data = $this->checkParams(); - if (!systemConfig('mer_intention_open')) { - return app('json')->fail('未开启商户入驻'); - } - if ($this->userInfo) $data['uid'] = $this->userInfo->uid; - $make = app()->make(MerchantRepository::class); - if ($make->fieldExists('mer_name', $data['mer_name'])) - throw new ValidateException('商户名称已存在,不可申请'); - if ($make->fieldExists('mer_phone', $data['phone'])) - throw new ValidateException('手机号已存在,不可申请'); - $adminRepository = app()->make(MerchantAdminRepository::class); - if ($adminRepository->fieldExists('account', $data['phone'])) - throw new ValidateException('手机号已是管理员,不可申请'); - $intention = $this->repository->create($data); - SwooleTaskService::admin('notice', [ - 'type' => 'new_intention', - 'data' => [ - 'title' => '商户入驻申请', - 'message' => '您有一个新的商户入驻申请', - 'id' => $intention->mer_intention_id - ] - ]); - return app('json')->success('提交成功'); - } - - public function update($id) - { - if (!$this->repository->getWhere(['mer_intention_id' => (int)$id, 'uid' => $this->userInfo->uid, 'is_del' => 0])) - return app('json')->fail('数据不存在'); - $data = $this->checkParams(); - if (!systemConfig('mer_intention_open')) { - return app('json')->fail('未开启商户入驻'); - } - $data['create_time'] = date('Y-m-d H:i:s', time()); - $this->repository->updateIntention((int)$id, $data); - SwooleTaskService::admin('notice', [ - 'type' => 'new_intention', - 'data' => [ - 'title' => '商户入驻申请', - 'message' => '您有一个新的商户入驻申请', - 'id' => $id - ] - ]); - return app('json')->success('修改成功'); - } - - public function lst() - { - [$page, $limit] = $this->getPage(); - $data = $this->repository->getList(['uid' => $this->userInfo->uid], $page, $limit); - return app('json')->success($data); - } - - function detail($id) - { - $data = $this->repository->detail((int)$id, $this->userInfo->uid); - if (!$data) { - return app('json')->fail('数据不存在'); - } - if ($data->status == 1) { - $data['login_url'] = rtrim(systemConfig('site_url'), '/') . '/' . config('admin.merchant_prefix'); - } - return app('json')->success($data); - } - - protected function checkParams() - { - $data = $this->request->params(['phone', 'mer_name', 'name', 'code', 'images', 'merchant_category_id', 'mer_type_id']); - app()->make(MerchantIntentionValidate::class)->check($data); - $check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention'); - $data['mer_type_id'] = (int)$data['mer_type_id']; - if (!$check) throw new ValidateException('验证码不正确'); - if (!app()->make(MerchantCategoryRepository::class)->get($data['merchant_category_id'])) throw new ValidateException('商户分类不存在'); - if ($data['mer_type_id'] && !app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id'])) - throw new ValidateException('店铺类型不存在'); - unset($data['code']); - return $data; - } - - /** - * 商户分类 - * @Author:Qinii - * @Date: 2020/9/15 - * @return mixed - */ - public function cateLst() - { - $lst = app()->make(MerchantCategoryRepository::class)->getSelect(); - return app('json')->success($lst); - } - - public function typeLst() - { - $lst = app()->make(MerchantTypeRepository::class)->getSelect(); - return app('json')->success($lst); - } -} - diff --git a/app/controller/api/store/product/StoreProduct.php b/app/controller/api/store/product/StoreProduct.php index d377d26d..cb001a22 100644 --- a/app/controller/api/store/product/StoreProduct.php +++ b/app/controller/api/store/product/StoreProduct.php @@ -23,6 +23,7 @@ use think\App; use crmeb\basic\BaseController; use app\common\repositories\store\product\ProductRepository as repository; use think\facade\Cache; +use think\facade\Db; class StoreProduct extends BaseController { @@ -196,4 +197,41 @@ class StoreProduct extends BaseController } return app('json')->fail('规则不存在'); } + + /** + * 免审编辑 + */ + public function UserFreeTrial($id) + { + $params = [ + "mer_cate_id", + "sort" , + "is_show", + "is_good", + "attr", + "attrValue", + 'spec_type', + 'is_stock' + ]; + $data = $this->request->params($params); + // $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['mer_cate_id'],'is_show' => 1,'mer_id' => $this->request->merId()]); + // if (!$count) throw new ValidateException('商户分类不存在或不可用'); + $data['status'] = 1; + $uid=$this->request->userInfo()['uid']; + $mer_id=Db::name('store_service')->where(['uid'=>$uid,'status'=>1,'is_del'=>0,'is_goods'=>1])->value('mer_id'); + if(!$mer_id){ + return app('json')->fail('编辑免申商品参数错误'); + } + $res=$this->repository->freeTrial($id, $data,$mer_id); + if($res && $params['is_stock']==1){ + $arr=[ + 'mer_id'=>$mer_id, + 'uid'=>$uid, + 'product_id'=>$data['attrValue'][0]['product_id'], + 'create_time'=>date('Y-m-d H:i:s') + ]; + Db::name('store_product_stock')->insert($arr); + } + return app('json')->success('编辑成功'); + } } diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index e2701fa5..0f68632d 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -277,13 +277,22 @@ class Product extends BaseController "is_good", "attr", "attrValue", - 'spec_type' + 'spec_type', + 'is_stock' ]; $data = $this->request->params($params); // $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['mer_cate_id'],'is_show' => 1,'mer_id' => $this->request->merId()]); // if (!$count) throw new ValidateException('商户分类不存在或不可用'); $data['status'] = 1; - $this->repository->freeTrial($id, $data,$this->request->merId()); + $res=$this->repository->freeTrial($id, $data,$this->request->merId()); + if($res && $params['is_stock']==1){ + $arr=[ + 'mer_id'=>$this->request->merId(), + 'product_id'=>$data['attrValue'][0]['product_id'], + 'create_time'=>date('Y-m-d H:i:s') + ]; + Db::name('store_product_stock')->insert($arr); + } return app('json')->success('编辑成功'); } diff --git a/route/api.php b/route/api.php index a19ff21e..93d56dd7 100644 --- a/route/api.php +++ b/route/api.php @@ -39,6 +39,10 @@ Route::group('api/', function () { Route::post('articleCatch', 'api.Upload/article'); //强制登录 Route::group(function () { + + Route::post('user_free_trial/:id', 'api.store.product.StoreProduct/UserFreeTrial')->option([ + '_alias' => '免审编辑', + ]); Route::post('sync/token', 'api.Auth/syncToken'); Route::group('micro', function () { @@ -72,7 +76,7 @@ Route::group('api/', function () { //用户缴纳保证金 Route::post('user/margin', 'api.Auth/doMargin'); Route::get('user/margin/list', 'api.Auth/marginList'); - + //优惠券 Route::group('coupon', function () { Route::post('receive/:id', 'api.store.product.StoreCoupon/receiveCoupon'); @@ -310,10 +314,7 @@ Route::group('api/', function () { Route::post('attr/delete', 'StoreProductAttrTemplate/batchDelete'); Route::get('attr/detail/:id', 'StoreProductAttrTemplate/detail'); Route::get('attr/list', 'StoreProductAttrTemplate/getlist'); - - - - })->prefix('api.server.')->middleware(\app\common\middleware\MerchantServerMiddleware::class,1); + })->prefix('api.server.')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 1); //管理员订单 Route::group('admin/:merId', function () { @@ -334,8 +335,7 @@ Route::group('api/', function () { Route::get('/purchaseOrder', '/purchaseOrder'); Route::post('/settle', '/settle'); Route::post('/confirm', '/confirm'); - - })->prefix('api.server.StoreOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class,0); + })->prefix('api.server.StoreOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 0); //管理员申请转账 Route::get('admin/:merId/apply', 'api.store.merchant.Merchant/apply'); @@ -354,12 +354,12 @@ Route::group('api/', function () { Route::get('express/:id', '/express'); Route::post('status/:id', '/switchStatus'); Route::post('mark/:id', '/mark'); - })->prefix('api.server.StoreRefundOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class,0); + })->prefix('api.server.StoreRefundOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 0); //核销 Route::group('verifier/:merId', function () { Route::get('order/:id', '/detail'); Route::post(':id', '/verify'); - })->prefix('api.store.order.StoreOrderVerify')->middleware(\app\common\middleware\MerchantServerMiddleware::class,0); + })->prefix('api.store.order.StoreOrderVerify')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 0); //社区 Route::group('community', function () { @@ -398,14 +398,13 @@ Route::group('api/', function () { Route::post('/entrust/check/:id', 'Community/checkEntrust'); Route::post('/entrust/addEntrustCart', 'Community/addEntrustCart'); Route::post('/entrust/apply/finish/:id', 'Community/applyFinishEntrust'); - Route::post('/entrust/finish/:id', 'Community/finishEntrust'); + Route::post('/entrust/finish/:id', 'Community/finishEntrust'); })->prefix('api.community.'); Route::group('svip', function () { //价格列表 Route::post('pay/:id', '/createOrder')->middleware(\app\common\middleware\BlockerMiddleware::class); })->prefix('api.user.Svip'); - })->middleware(UserTokenMiddleware::class, true); //非强制登录 @@ -448,7 +447,7 @@ Route::group('api/', function () { Route::get('service/info/:id', 'api.store.service.Service/merchantInfo'); //公共配置 Route::get('config', 'api.Common/config'); - Route::get('has_service/:id','api.store.service.Service/hasService'); + Route::get('has_service/:id', 'api.store.service.Service/hasService'); //专题 Route::group('activity', function () { Route::get('lst/:id', 'api.Common/activityLst'); @@ -583,7 +582,6 @@ Route::group('api/', function () { Route::any('store/test', 'api.Test/test'); Route::get('subscribe', 'api.Common/subscribe'); Route::resource('store/product/cloudWarehouse', 'api.store.product.CloudWarehouse'); - })->middleware(UserTokenMiddleware::class, false); //微信支付回调 @@ -683,10 +681,16 @@ Route::group('api/', function () { Route::get('micro', 'api.Common/micro'); Route::get('version', 'admin.Common/version'); + Route::group('statistics', function () { + Route::get('supply_chain_mer_count', '/SupplyChainMerCount'); + Route::get('supply_chain_product_count', '/SupplyChainProductCount'); + Route::get('supply_chain_product_stock_count', '/SupplyChainProductStockCount'); + Route::get('product_list', '/ProductList'); + })->prefix('api.Statistics'); + //滑块验证码 Route::get('ajcaptcha', 'api.Auth/ajcaptcha'); Route::post('ajcheck', 'api.Auth/ajcheck'); - })->middleware(AllowOriginMiddleware::class) ->middleware(InstallMiddleware::class) ->middleware(CheckSiteOpenMiddleware::class) @@ -703,5 +707,6 @@ Route::group('/pages', function () { Route::group('/open-location', function () { Route::miss('View/h5'); })->middleware(InstallMiddleware::class) - ->middleware(CheckSiteOpenMiddleware::class) - ; + ->middleware(CheckSiteOpenMiddleware::class); + +