diff --git a/.gitignore b/.gitignore index 575640412..a0a855bf2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ .env /tests/tmp /tests/.phpunit.result.cache -public/uploads \ No newline at end of file +public/uploads +public/image/barcode +public/image \ No newline at end of file diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 3ad24544d..20335665f 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -704,8 +704,8 @@ class WorkbenchController extends BaseAdminController ] ], "month" => [ - WorkbenchLogic::month_order_count($dates_two,'本月订单数'), - WorkbenchLogic::month_order_count($dates_two,'本月支付人数') + WorkbenchLogic::month_order_count('本月订单数'), + WorkbenchLogic::month_order_count('本月支付人数') ] ] ]; diff --git a/app/admin/controller/financial_transfers/FinancialTransfersController.php b/app/admin/controller/financial_transfers/FinancialTransfersController.php new file mode 100644 index 000000000..9f98930d8 --- /dev/null +++ b/app/admin/controller/financial_transfers/FinancialTransfersController.php @@ -0,0 +1,136 @@ +dataLists(new FinancialTransfersLists()); + } + + //确认 + public function send_transfers() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('send'); + $result = FinancialTransfersLogic::dealsend($params); + + if (true === $result) { + return $this->success('发送成功', [],1,1 ); + } + return $this->fail(FinancialTransfersLogic::getError()); + + } + + //财务上传凭证 + public function success_send() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('success'); + $update = [ + 'transfer_picture'=>$params['transfer_picture'] + ]; + $update['status'] = -1; + if($params['status']){ + $update['status'] = 3; + $update['pay_status'] = 1; + } + $update['fail_msg'] = $params['fail_msg']??''; + $result = FinancialTransfersLogic::dealchange($update,$params['id']); + + if (true === $result) { + return $this->success('转账成功',[],1,1); + } + return $this->fail(FinancialTransfersLogic::getError()); + + } + + + + + + + + + /** + * @notes 添加 + * @return \think\response\Json + * @author admin + * @date 2024/06/14 10:10 + */ + public function add() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('add'); + $result = FinancialTransfersLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(FinancialTransfersLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author admin + * @date 2024/06/14 10:10 + */ + public function edit() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('edit'); + $result = FinancialTransfersLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(FinancialTransfersLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author admin + * @date 2024/06/14 10:10 + */ + public function delete() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('delete'); + FinancialTransfersLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author admin + * @date 2024/06/14 10:10 + */ + public function detail() + { + $params = (new FinancialTransfersValidate())->goCheck('detail'); + $result = FinancialTransfersLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/controller/store_branch_product/StoreBranchProductController.php b/app/admin/controller/store_branch_product/StoreBranchProductController.php index c26452cb4..8b97950eb 100644 --- a/app/admin/controller/store_branch_product/StoreBranchProductController.php +++ b/app/admin/controller/store_branch_product/StoreBranchProductController.php @@ -5,6 +5,7 @@ namespace app\admin\controller\store_branch_product; use app\admin\controller\BaseAdminController; use app\admin\lists\store_branch_product\StoreBranchProductLists; +use app\admin\lists\store_branch_product_exchange\StoreBranchProductExchangeLists; use app\admin\logic\store_branch_product\StoreBranchProductLogic; use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\store_product\StoreProductValidate; @@ -27,7 +28,11 @@ class StoreBranchProductController extends BaseAdminController */ public function lists() { - return $this->dataLists(new StoreBranchProductLists()); + if($this->request->get('exchange',0)==1){ + return $this->dataLists(new StoreBranchProductExchangeLists()); + }else{ + return $this->dataLists(new StoreBranchProductLists()); + } } diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index 0bfbb0d32..4e9046b04 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -98,15 +98,16 @@ class StoreProductController extends BaseAdminController { $product_arr = $this->request->post('product_arr'); $store_arr = $this->request->post('store_arr'); + $stock_type = $this->request->post('stock_type',1); if (count($store_arr) == 1) { $store_id = $store_arr[0]; foreach ($product_arr as $key => $arr) { - Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'admin_id' => $this->adminId]); + Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId]); } } else { foreach ($product_arr as $key => $arr) { foreach ($store_arr as $k => $store_id) { - Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'admin_id' => $this->adminId]); + Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id,'stock_type'=>$stock_type, 'admin_id' => $this->adminId]); } } } diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index 2b55bb1f6..b2046e788 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -57,7 +57,8 @@ class UserController extends BaseAdminController */ public function edit() { - $params = (new UserValidate())->post()->goCheck('edit'); + // $params = (new UserValidate())->post()->goCheck('edit'); + $params = $this->request->post(); $result = UserLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); diff --git a/app/admin/controller/user_label/UserLabelController.php b/app/admin/controller/user_label/UserLabelController.php new file mode 100644 index 000000000..b03673825 --- /dev/null +++ b/app/admin/controller/user_label/UserLabelController.php @@ -0,0 +1,95 @@ +dataLists(new UserLabelLists()); + } + + + /** + * @notes 添加用户标签 + * @return \think\response\Json + * @author admin + * @date 2024/06/17 17:02 + */ + public function add() + { + $params = (new UserLabelValidate())->post()->goCheck('add'); + $result = UserLabelLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserLabelLogic::getError()); + } + + + /** + * @notes 编辑用户标签 + * @return \think\response\Json + * @author admin + * @date 2024/06/17 17:02 + */ + public function edit() + { + $params = (new UserLabelValidate())->post()->goCheck('edit'); + $result = UserLabelLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserLabelLogic::getError()); + } + + + /** + * @notes 删除用户标签 + * @return \think\response\Json + * @author admin + * @date 2024/06/17 17:02 + */ + public function delete() + { + $params = (new UserLabelValidate())->post()->goCheck('delete'); + UserLabelLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取用户标签详情 + * @return \think\response\Json + * @author admin + * @date 2024/06/17 17:02 + */ + public function detail() + { + $params = (new UserLabelValidate())->goCheck('detail'); + $result = UserLabelLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/financial_transfers/FinancialTransfersLists.php b/app/admin/lists/financial_transfers/FinancialTransfersLists.php new file mode 100644 index 000000000..8c989e285 --- /dev/null +++ b/app/admin/lists/financial_transfers/FinancialTransfersLists.php @@ -0,0 +1,77 @@ + ['store_id', 'admin_id', 'uid', 'status', 'initiation_time', 'confirmation_time', 'mark', 'money', 'remark_time','create_time'], + 'between_time' => 'create_time', + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/14 10:10 + */ + public function lists(): array + { + $data = FinancialTransfers::with(['store','staff','admin'])->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + foreach ($data as &$value){ + if($value['initiation_time']){ + $value['initiation_time'] = date('Y-m-d H:i:s',$value['initiation_time']); + } + + if($value['confirmation_time']){ + $value['confirmation_time'] = date('Y-m-d H:i:s',$value['confirmation_time']); + + } + + } + return $data; + } + + + /** + * @notes 获取数量 + * @return int + * @author admin + * @date 2024/06/14 10:10 + */ + public function count(): int + { + return FinancialTransfers::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php b/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php new file mode 100644 index 000000000..f4144ab48 --- /dev/null +++ b/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php @@ -0,0 +1,125 @@ + ['product_id', 'cate_id','store_id','status'], + '%pipe_like%' => ['store_name_code'=>'store_name|bar_code'], + '%like%' => ['store_name'], + ]; + } + + + /** + * @notes 获取门店列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 17:45 + */ + public function lists(): array + { + $status = $this->params['status'] ?? ''; + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProductExchange::where($this->searchWhere)->where($where) + ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status']) + ->when(!empty($this->adminInfo['store_id']), function ($query) { + $query->where('store_id', $this->adminInfo['store_id']); + }) + ->when(!empty($status), function ($query) use ($status) { + if ($status == 1) { + $query->where('status', $status); + } elseif ($status == 2) { + $query->where('status', 0); + } elseif ($status == 3) { + $query->where('stock', '<=', 0); + } elseif ($status == 4) { + $query->where('stock', '<', 10)->where('stock', '>', 0); + } + }) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','stock'=>'desc','id' => 'desc']) + ->select() + ->each(function ($item) { + $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); + $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); + $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取门店列表数量 + * @return int + * @author admin + * @date 2024/05/31 17:45 + */ + public function count(): int + { + $status = $this->params['status'] ?? ''; + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProductExchange::where($this->searchWhere)->where($where) + ->when(!empty($this->adminInfo['store_id']), function ($query) { + $query->where('store_id', $this->adminInfo['store_id']); + }) + ->when(!empty($status), function ($query) use ($status) { + if ($status == 1) { + $query->where('status', $status); + } elseif ($status == 2) { + $query->where('status', 0); + } elseif ($status == 3) { + $query->where('stock', '<=', 0); + } elseif ($status == 4) { + $query->where('stock', '<', 10)->where('stock', '>', 0); + } + }) + ->count(); + } + +} diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 59bb61b77..c5b70125e 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -4,6 +4,7 @@ namespace app\admin\lists\store_branch_product; use app\admin\lists\BaseAdminDataLists; +use app\common\model\cate\Cate; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -47,8 +48,22 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI public function lists(): array { $status = $this->params['status'] ?? ''; - return StoreBranchProduct::where($this->searchWhere) - ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status']) + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + if(empty($where) && $class_all){ + //2或者1 + $where[]=['cate_id','=',$class_all]; + } + + return StoreBranchProduct::where($this->searchWhere)->where($where) + ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) @@ -85,7 +100,16 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI public function count(): int { $status = $this->params['status'] ?? ''; - return StoreBranchProduct::where($this->searchWhere) + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProduct::where($this->searchWhere)->where($where) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php index c3ef16898..fd996b83b 100644 --- a/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php +++ b/app/admin/lists/store_finance_flow/StoreFinanceFlowLists.php @@ -33,6 +33,7 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt return [ '=' => ['store_id', 'user_id', 'create_time', 'staff_id'], 'between_time'=>'create_time', + '%pipe_like%' => ['keyword'=>'order_sn'], ]; } @@ -63,13 +64,14 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt } if ($item['financial_pm'] == 0) { $item['number'] = '-' . $item['number']; + $item['financial_type_name'] = '订单支出:'.OrderEnum::getFinancialType($item['financial_type']); } else { + $item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']).'获得'; $item['number'] = '+' . $item['number']; } $item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name'); $item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : ''; $item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']); - $item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']); }) ->toArray(); } diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index a32f501f4..8d2d6969b 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_name', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) + ->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/lists/system_store/SystemStoreLists.php b/app/admin/lists/system_store/SystemStoreLists.php index 40b3804ea..d961fcce8 100644 --- a/app/admin/lists/system_store/SystemStoreLists.php +++ b/app/admin/lists/system_store/SystemStoreLists.php @@ -44,7 +44,9 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac public function lists(): array { return SystemStore::where($this->searchWhere) - ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show','day_start','day_end']) + ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show','day_start','day_end' + ,'bank','bank_code','bank_address','realname' + ]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item){ diff --git a/app/admin/lists/system_store_storage/SystemStoreStorageLists.php b/app/admin/lists/system_store_storage/SystemStoreStorageLists.php index 900eb1e33..59cfcd955 100644 --- a/app/admin/lists/system_store_storage/SystemStoreStorageLists.php +++ b/app/admin/lists/system_store_storage/SystemStoreStorageLists.php @@ -29,7 +29,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['store_id', 'admin_id', 'staff_id', 'status'], + '=' => ['store_id', 'admin_id', 'staff_id', 'status','type'], ]; } diff --git a/app/admin/lists/user_label/UserLabelLists.php b/app/admin/lists/user_label/UserLabelLists.php new file mode 100644 index 000000000..4e142b649 --- /dev/null +++ b/app/admin/lists/user_label/UserLabelLists.php @@ -0,0 +1,65 @@ + ['label_name'], + ]; + } + + + /** + * @notes 获取用户标签列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/17 17:02 + */ + public function lists(): array + { + return UserLabel::where($this->searchWhere) + ->field(['label_id', 'label_name']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['label_id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户标签数量 + * @return int + * @author admin + * @date 2024/06/17 17:02 + */ + public function count(): int + { + return UserLabel::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/financial_transfers/FinancialTransfersLogic.php b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php new file mode 100644 index 000000000..8a571e70e --- /dev/null +++ b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php @@ -0,0 +1,156 @@ + $params['store_id'], + 'admin_id' => $params['admin_id'], + 'uid' => $params['uid'], + 'status' => $params['status'], + 'initiation_time' => $params['initiation_time'], + 'confirmation_time' => $params['confirmation_time'], + 'mark' => $params['mark'], + 'money' => $params['money'], + 'remark_time' => $params['remark_time'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/14 10:05 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + FinancialTransfers::where('id', $params['id'])->update([ + 'store_id' => $params['store_id'], + 'admin_id' => $params['admin_id'], + 'uid' => $params['uid'], + 'status' => $params['status'], + 'initiation_time' => $params['initiation_time'], + 'confirmation_time' => $params['confirmation_time'], + 'mark' => $params['mark'], + 'money' => $params['money'], + 'remark_time' => $params['remark_time'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/14 10:05 + */ + public static function delete(array $params): bool + { + return FinancialTransfers::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author admin + * @date 2024/06/14 10:05 + */ + public static function detail($params): array + { + return FinancialTransfers::findOrEmpty($params['id'])->toArray(); + } + + public static function dealsend($params) + { + Db::startTrans(); + try { + FinancialTransfers::where('id',$params['id']) + ->update( + [ + 'status'=>1, + 'initiation_time'=>time() + ] + ); + + Db::commit(); + return true; + }catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + + + } + + + public static function dealchange($params,$id) + { + Db::startTrans(); + try { + FinancialTransfers::where('id',$id) + ->update( + $params + ); + + Db::commit(); + return true; + }catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + + + } + + +} \ No newline at end of file diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index 7222a920a..ce3508e37 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -67,9 +67,9 @@ class StoreBranchProductLogic extends BaseLogic } $data['cate_id']=$params['cate_id']; }else{ - if($params['statis']!=$StoreProduct['statis']){ - if($params['statis']==1){ - StoreProductLogic::updateGoodsclass($params['cate_id']); + if($params['status']!=$StoreProduct['status']){ + if($params['status']==1){ + StoreProductLogic::updateGoodsclass($StoreProduct['cate_id'],$StoreProduct['store_id']); }else{ self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id'],0); @@ -92,7 +92,7 @@ class StoreBranchProductLogic extends BaseLogic public static function store_product_cate_update($id,$cate_id,$store_id,$type=1) { $find=Db::name('store_product_cate')->where(['cate_id'=>$cate_id,'store_id'=>$store_id])->find(); - if($find['pid']>0){ + if($find &&$find['pid']>0){ $two=Db::name('store_product_cate')->where(['cate_id'=>$find['pid'],'store_id'=>$store_id])->find(); Db::name('store_product_cate')->where('id',$find['id'])->dec('count',1)->update(); Db::name('store_product_cate')->where('id',$two['id'])->dec('count',1)->update(); @@ -101,7 +101,7 @@ class StoreBranchProductLogic extends BaseLogic } } if($type==1){ - StoreProductLogic::updateGoodsclass($cate_id); + StoreProductLogic::updateGoodsclass($cate_id,$store_id); } } /** diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 7629e7066..6aee0d22b 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -9,6 +9,7 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_attr_value\StoreProductAttrValue; +use app\common\model\store_product_cate\StoreProductCate; use app\common\model\system_store\SystemStore; use app\common\model\system_store_storage\SystemStoreStorage; use app\Request; @@ -48,6 +49,8 @@ class StoreProductLogic extends BaseLogic 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], + 'swap' => $params['swap'] ?? 0, + 'batch' => $params['batch'] ?? 0, ]; // if ($params['rose'] > 0) { // $rose_price = bcmul($params['cost'], $params['rose'], 2); @@ -93,6 +96,33 @@ class StoreProductLogic extends BaseLogic } } + public static function deleteRelatedData($cate_id) + { + $data_to_delete = StoreProductCate::where('cate_id', $cate_id)->select(); + foreach ($data_to_delete as $item) { + + if ($item['pid'] != 0) { + self::deleteRelatedData($item['pid']); + StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]); + } + + if ($item['pid'] == 0 && in_array($item['count'], [0, 1])) { + StoreProductCate::where('id', $item['id'])->update(['delete_time' => time()]); + } + } + } + + // 递归减少分类数据的count值 + public static function decreaseCount($cate_id) + { + $data_to_decrease = StoreProductCate::where('cate_id', $cate_id)->select(); + foreach ($data_to_decrease as $item) { + if ($item['pid'] != 0) { + self::decreaseCount($item['pid']); + } + StoreProductCate::where('id', $item['id'])->update(['count' => $item['count'] - 1]); + } + } /** * @notes 编辑商品列表 @@ -118,14 +148,38 @@ class StoreProductLogic extends BaseLogic 'is_return' => $params['is_return'], 'price' => $params['price'], 'vip_price' => $params['vip_price'], - 'cost' => $params['cost'], + 'batch' => $params['batch'], + 'swap' => $params['swap'] ?? 0, ]; + StoreProduct::where('id', $params['id'])->update($data); + + /*$old_cate = StoreBranchProduct::where('product_id', $params['id'])->field('cate_id,store_id') + ->select(); + // 获取分类ID + foreach ($old_cate as $vv) { + $related_data = Db::name('store_product_cate')->where('cate_id', $vv['cate_id'])->select(); + //删除之前的分类 + foreach ($related_data as $value) { + if ($value['count'] == 1) { + self::deleteRelatedData($value['cate_id']); + } elseif ($value['count'] > 1) { + self::decreaseCount($value['cate_id']); + } + //新增对应的分类 + self::updateGoodsclass($params['cate_id'], $value['store_id']); + } + }*/ + + + //修改 StoreBranchProduct::where('product_id', $params['id'])->update([ 'price' => $params['price'], 'vip_price' => $params['vip_price'], - 'cost' => $params['cost'] + 'cost' => $params['cost'], + 'batch'=>$params['batch'],'store_name'=>$params['store_name'] ]); + Db::commit(); return true; } catch (\Exception $e) { @@ -145,7 +199,9 @@ class StoreProductLogic extends BaseLogic */ public static function delete(array $params): bool { - return StoreProduct::destroy($params['id']); + $res = StoreProduct::destroy($params['id']); + StoreBranchProduct::where('product_id', $params['id'])->update(['delete_time' => time()]); + return $res; } @@ -177,7 +233,7 @@ class StoreProductLogic extends BaseLogic /** * 更新商品分类 */ - public static function updateGoodsclass($cate_id, $type = 0) + public static function updateGoodsclass($cate_id, $store_id = 0, $type = 0) { $one = StoreCategory::where('id', $cate_id)->find(); if ($one) { @@ -185,23 +241,31 @@ class StoreProductLogic extends BaseLogic $two = StoreCategory::where('id', $one['pid'])->find(); if ($two) { if ($two['pid'] != 0) { - self::cate_update($cate_id, $two['id'], 0, 3); - self::cate_update($two['id'], $two['pid'], 0, 2); - self::cate_update($two['pid'], 0, 0, 1); + self::cate_update($cate_id, $two['id'], $store_id, 3); + self::cate_update($two['id'], $two['pid'], $store_id, 2); + self::cate_update($two['pid'], 0, $store_id, 1); + } else { + if ($one['pid'] == 0) { + self::cate_update($one['id'], 0, $store_id, 1); + } else { + self::cate_update($one['id'], $one['pid'], $store_id, 2); + self::cate_update($one['pid'], 0, $store_id, 1); + } } } } } - public static function cate_update($cate_id = 0, $pid = 0, $product_id = 0, $level = 1) + public static function cate_update($cate_id = 0, $pid = 0, $store_id = 0, $level = 1) { - $find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'level' => $level])->find(); + $find = Db::name('store_product_cate')->where(['store_id' => $store_id, 'cate_id' => $cate_id, 'level' => $level])->find(); if ($find) { Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update(); } else { - Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); + Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => $store_id, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); } } + /** * 复制商品到门店 */ diff --git a/app/admin/logic/system_store/SystemStoreLogic.php b/app/admin/logic/system_store/SystemStoreLogic.php index 853247438..695ea00b6 100644 --- a/app/admin/logic/system_store/SystemStoreLogic.php +++ b/app/admin/logic/system_store/SystemStoreLogic.php @@ -45,6 +45,10 @@ class SystemStoreLogic extends BaseLogic 'province' => $params['province_code'], 'city' => $params['city_code'], 'area' => $params['area_code'], + 'bank' => $params['bank']??'', + 'bank_code' => $params['bank_code']??'', + 'bank_address' => $params['bank_address']??'', + 'realname' => $params['realname']??'', 'street' => $params['street_code'], 'is_store' => $params['is_store'] ?? 0, 'is_send' => $params['is_send'] ?? 0, @@ -102,6 +106,10 @@ class SystemStoreLogic extends BaseLogic 'day_time' => $params['day_time'] ?? 0, 'is_store' => $params['is_store'] ?? 0, 'is_send' => $params['is_send'] ?? 0, + 'bank' => $params['bank']??'', + 'bank_code' => $params['bank_code']??'', + 'bank_address' => $params['bank_address']??'', + 'realname' => $params['realname']??'', 'default_delivery' => $params['default_delivery'] ?? 2, ]); $res=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->find(); diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index aaa9bf58e..ff86b002b 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -15,7 +15,11 @@ namespace app\admin\logic\user; use app\common\enum\user\UserTerminalEnum; use app\common\logic\BaseLogic; +use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\user\User; +use app\common\model\user\UserAddress; +use app\common\model\user\UserRecharge; +use app\common\model\user_label\UserLabel; use think\facade\Db; use app\common\service\FileService; use Webman\Config; @@ -52,7 +56,6 @@ class UserLogic extends BaseLogic 'mobile' => $params['mobile'], 'sex' => $params['sex'], 'is_disable' => $params['is_disable'], - 'user_money' => $params['user_money'] ]); Db::commit(); @@ -63,6 +66,47 @@ class UserLogic extends BaseLogic return false; } } + + public static function StoreAdd(array $params) + { + $passwordSalt = Config::get('project.unique_identification'); + $password = create_password(123456, $passwordSalt); + $defaultAvatar = config('project.default_image.admin_avatar'); + $avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar; + + Db::startTrans(); + try { + $data=[ + 'avatar' => $avatar, + 'real_name' => $params['real_name']??"", + 'nickname' => '用户'.time(), + 'account' => $params['mobile'], + 'password' => $password, + 'mobile' => $params['mobile'], + 'user_ship' => $params['user_ship']??0, + + ]; + $res=User::create($data); + UserAddress::create([ + 'uid' => $res['id'], + 'real_name' => $params['real_name']??"", + 'mobile' => $params['mobile'], + 'province' => $params['province'], + 'city' => $params['city'], + 'area' => $params['area'], + 'street' => $params['street'], + 'village' => $params['village'], + 'brigade' => $params['brigade'], + 'is_default' => 1, + ]); + Db::commit(); + return $res; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } /** * @notes 编辑用户列表 * @param array $params @@ -75,15 +119,15 @@ class UserLogic extends BaseLogic Db::startTrans(); try { User::where('id', $params['id'])->update([ - 'avatar' => $params['avatar'] ?? '', - 'real_name' => $params['real_name'], - 'nickname' => $params['nickname'], - 'account' => $params['account'], - 'password' => $params['password'] ?? '', - 'mobile' => $params['mobile'] ?? '', - 'sex' => $params['sex'] ?? 0, - 'is_disable' => $params['is_disable'] ?? 0, - 'user_money' => $params['user_money'] ?? 0 + // 'avatar' => $params['avatar'] ?? '', + // 'real_name' => $params['real_name'], + // 'nickname' => $params['nickname'], + // 'account' => $params['account'], + // 'password' => $params['password'] ?? '', + // 'mobile' => $params['mobile'] ?? '', + // 'sex' => $params['sex'] ?? 0, + // 'is_disable' => $params['is_disable'] ?? 0, + 'label_id'=>$params['label_id'] ]); Db::commit(); @@ -105,8 +149,8 @@ class UserLogic extends BaseLogic public static function detail(int $userId): array { $field = [ - 'id', 'account', 'nickname', 'avatar', 'real_name', - 'sex', 'mobile', 'create_time', 'login_time', 'channel' + 'id', 'account', 'nickname', 'avatar', 'real_name','integral','label_id', + 'sex', 'mobile', 'create_time', 'login_time', 'channel','now_money','purchase_funds' ]; $user = User::where(['id' => $userId])->field($field) @@ -114,6 +158,8 @@ class UserLogic extends BaseLogic $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']); $user->sex = $user->getData('sex'); + $user['number']=StoreFinanceFlow::where('other_uid',$userId)->where(['status'=>0,'financial_pm'=>1,'type'=>1])->sum('number'); + $user['label_name']=$user->label_id?UserLabel::where('label_id',$user->label_id)->value('label_name'):""; return $user->toArray(); } diff --git a/app/admin/logic/user_label/UserLabelLogic.php b/app/admin/logic/user_label/UserLabelLogic.php new file mode 100644 index 000000000..d8a766b7c --- /dev/null +++ b/app/admin/logic/user_label/UserLabelLogic.php @@ -0,0 +1,94 @@ + $params['label_name'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑用户标签 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/17 17:02 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserLabel::where('label_id', $params['label_id'])->update([ + 'label_name' => $params['label_name'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除用户标签 + * @param array $params + * @return bool + * @author admin + * @date 2024/06/17 17:02 + */ + public static function delete(array $params): bool + { + return UserLabel::destroy($params['label_id']); + } + + + /** + * @notes 获取用户标签详情 + * @param $params + * @return array + * @author admin + * @date 2024/06/17 17:02 + */ + public static function detail($params): array + { + return UserLabel::findOrEmpty($params['label_id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/financial_transfers/FinancialTransfersValidate.php b/app/admin/validate/financial_transfers/FinancialTransfersValidate.php new file mode 100644 index 000000000..ff106e15b --- /dev/null +++ b/app/admin/validate/financial_transfers/FinancialTransfersValidate.php @@ -0,0 +1,108 @@ + 'require', + 'store_id' => 'require', + 'money' => 'require', + 'status' => 'require|number', + 'transfer_picture' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'store_id' => '店铺id', + 'money' => '金额', + 'status' => '状态', + 'transfer_picture' => '财务上传凭证', + ]; + + + public function sceneSend() + { + return $this->only(['id']); + } + + + public function sceneConfirm() + { + return $this->only(['id','status']); + } + + public function sceneSuccess() + { + return $this->only(['id','transfer_picture','status']); + } + + + + /** + * @notes 添加场景 + * @return FinancialTransfersValidate + * @author admin + * @date 2024/06/14 10:10 + */ + public function sceneAdd() + { + return $this->only(['store_id','money']); + } + + + /** + * @notes 编辑场景 + * @return FinancialTransfersValidate + * @author admin + * @date 2024/06/14 10:10 + */ + public function sceneEdit() + { + return $this->only(['id','store_id','money']); + } + + + /** + * @notes 删除场景 + * @return FinancialTransfersValidate + * @author admin + * @date 2024/06/14 10:10 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return FinancialTransfersValidate + * @author admin + * @date 2024/06/14 10:10 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/admin/validate/user/UserValidate.php b/app/admin/validate/user/UserValidate.php index b6a91c8ee..90911234c 100644 --- a/app/admin/validate/user/UserValidate.php +++ b/app/admin/validate/user/UserValidate.php @@ -24,10 +24,16 @@ class UserValidate extends BaseValidate 'nickname' => 'require', 'account' => 'require', 'password' => 'require', - 'mobile' => 'require|mobile', + 'mobile' => 'require|unique:user', 'is_disable' => 'in:0,1', 'sex' => 'in:1,2', - 'user_money' => 'float' + 'province' => 'require', + 'city' => 'require', + 'area' => 'require', + 'street' => 'require', + 'village' => 'require', + 'brigade' => 'require', + 'user_ship' => 'require', ]; @@ -44,7 +50,13 @@ class UserValidate extends BaseValidate 'mobile' => '用户电话', 'is_disable' => '是否禁用', 'sex' => '用户性别', - 'user_money' => '用户余额', + 'province' => '省', + 'city' => '市', + 'area' => '区', + 'street' => '街道', + 'village' => '村', + 'brigade' => ' 队', + 'user_ship' => ' 会员类型', ]; @@ -59,6 +71,10 @@ class UserValidate extends BaseValidate return $this->remove('id',true); } + public function scenestoreAdd() + { + return $this->only(['mobile','province','city','district','street','village','brigade','user_ship']); + } /** * @notes 编辑场景 @@ -68,7 +84,7 @@ class UserValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','avatar','real_name','nickname','account','password','mobile','is_disable','sex','user_money'])->remove('password','require'); + return $this->only(['id','avatar','real_name','nickname','account','password','mobile','is_disable','sex'])->remove('password','require'); } diff --git a/app/admin/validate/user_label/UserLabelValidate.php b/app/admin/validate/user_label/UserLabelValidate.php new file mode 100644 index 000000000..2289e5630 --- /dev/null +++ b/app/admin/validate/user_label/UserLabelValidate.php @@ -0,0 +1,84 @@ + 'require', + 'label_name' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'label_id' => 'label_id', + 'label_name' => '标签名称', + ]; + + + /** + * @notes 添加场景 + * @return UserLabelValidate + * @author admin + * @date 2024/06/17 17:02 + */ + public function sceneAdd() + { + return $this->only(['label_name']); + } + + + /** + * @notes 编辑场景 + * @return UserLabelValidate + * @author admin + * @date 2024/06/17 17:02 + */ + public function sceneEdit() + { + return $this->only(['label_id','label_name']); + } + + + /** + * @notes 删除场景 + * @return UserLabelValidate + * @author admin + * @date 2024/06/17 17:02 + */ + public function sceneDelete() + { + return $this->only(['label_id']); + } + + + /** + * @notes 详情场景 + * @return UserLabelValidate + * @author admin + * @date 2024/06/17 17:02 + */ + public function sceneDetail() + { + return $this->only(['label_id']); + } + +} \ No newline at end of file diff --git a/app/api/controller/BaseApiController.php b/app/api/controller/BaseApiController.php index e3d9026ad..516bf8bec 100644 --- a/app/api/controller/BaseApiController.php +++ b/app/api/controller/BaseApiController.php @@ -2,8 +2,7 @@ namespace app\api\controller; use app\common\controller\BaseLikeController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class BaseApiController extends BaseLikeController { diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 1205aadba..5ccf27950 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -2,57 +2,61 @@ namespace app\api\controller; +use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\tools\GenerateTableValidate; use app\admin\logic\tools\GeneratorLogic; use app\common\logic\store_order\StoreOrderLogic; +use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\system_store\SystemStore; use app\common\service\pay\PayService; use app\common\service\wechat\WechatTemplate; use Exception; use support\Cache; use think\facade\Db; use Webman\Config; -use hg\apidoc\annotation as ApiDoc; use support\Log; use Yansongda\Pay\Exception\InvalidSignException; use Monolog\Handler\RotatingFileHandler; use Webman\RedisQueue\Redis; -#[ApiDoc\NotParse()] + class IndexController extends BaseApiController { - public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street']; + public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config']; public function index() { - Redis::send('push-platform-print', ['order_id' => 119]); - d(2); - + $arr = StoreBranchProduct::select(); + foreach ($arr as $item) { + StoreProductLogic::updateGoodsclass($item['cate_id'], $item['store_id']); + } + d(1); try { - $wechat = new PayService(1); - $time = time(); - $order = [ - 'out_trade_no' => 'PF1717558027664507', - 'out_refund_no' => 'BO'.$time, - 'amount' => [ - 'refund' => 1, - 'total' => 1, - 'currency' => 'CNY', - ], - // '_action' => 'jsapi', // jsapi 退款,默认 - // '_action' => 'app', // app 退款 - // '_action' => 'combine', // 合单退款 - // '_action' => 'h5', // h5 退款 - // '_action' => 'miniapp', // 小程序退款 - // '_action' => 'native', // native 退款 + $wechat = new PayService(1); + $time = time(); + $order = [ + 'out_trade_no' => 'PF1717558027664507', + 'out_refund_no' => 'BO' . $time, + 'amount' => [ + 'refund' => 1, + 'total' => 1, + 'currency' => 'CNY', + ], + // '_action' => 'jsapi', // jsapi 退款,默认 + // '_action' => 'app', // app 退款 + // '_action' => 'combine', // 合单退款 + // '_action' => 'h5', // h5 退款 + // '_action' => 'miniapp', // 小程序退款 + // '_action' => 'native', // native 退款 - ]; + ]; - $res = $wechat->wechat->refund($order); - Cache::set('kk',json_decode($res,true)); + $res = $wechat->wechat->refund($order); + Cache::set('kk', json_decode($res, true)); } catch (Exception $e) { - \support\Log::info($e->extra['message']?? $e->getMessage()); - throw new \Exception($e->extra['message']?? $e->getMessage()); + \support\Log::info($e->extra['message'] ?? $e->getMessage()); + throw new \Exception($e->extra['message'] ?? $e->getMessage()); } d(1); @@ -63,15 +67,15 @@ class IndexController extends BaseApiController - try{ - $a=new WechatTemplate(); - $a->NewQuotationNotification(['openid'=>'ocqhF6UfFQXE-SbzbP5YVQJlQAh0','data1'=>'阿萨','data2'=>date('Y-m-d H:i:s'),'data3'=>'占山','data3'=>18982406440]); - }catch (Exception $e){ + try { + $a = new WechatTemplate(); + $a->NewQuotationNotification(['openid' => 'ocqhF6UfFQXE-SbzbP5YVQJlQAh0', 'data1' => '阿萨', 'data2' => date('Y-m-d H:i:s'), 'data3' => '占山', 'data3' => 18982406440]); + } catch (Exception $e) { d($e); } -d(22); + d(22); $auth_code = $this->request->get('code'); $pay = (new PayService()); $order = [ @@ -81,7 +85,7 @@ d(22); 'auth_code' => (string)$auth_code ], 'amount' => [ - 'total' =>1, + 'total' => 1, ], 'scene_info' => [ "store_info" => [ @@ -89,14 +93,13 @@ d(22); ] ], ]; - - try{ - $a= $pay->wechat->pos($order); - }catch (\Exception $th) { - d($th); + try { + $a = $pay->wechat->pos($order); + } catch (\Exception $th) { + d($th); } -d($a); + d($a); $params = ['store_id' => 2, 'pay_type' => 17]; $a = StoreOrderLogic::createOrder([1], 0, null, $params); d($a); @@ -139,7 +142,7 @@ d($a); */ public function city() { - $province_code = $this->request->get('code'); + $province_code = $this->request->get('province_code'); $list = Db::name('geo_city')->where('province_code', $province_code)->select()?->toArray(); return $this->success('ok', $list); } @@ -148,7 +151,7 @@ d($a); */ public function area() { - $city_code = $this->request->get('code'); + $city_code = $this->request->get('city_code'); $list = Db::name('geo_area')->where('city_code', $city_code)->select()?->toArray(); return $this->success('ok', $list); } @@ -161,4 +164,36 @@ d($a); $list = Db::name('geo_street')->where('area_code', $area_code)->select()?->toArray(); return $this->success('ok', $list); } + + /** + * @notes 获取村列表 + */ + public function village() + { + $area_code = $this->request->get('street_code'); + $list = Db::name('geo_village')->where('street_code', $area_code)->select()?->toArray(); + return $this->success('ok', $list); + } + /** + * @notes 获取队列表 + */ + public function brigade() + { + $list = Db::name('geo_brigade')->select()?->toArray(); + return $this->success('ok', $list); + } + + /** + * @notes 获取队列表 + */ + public function config() + { + $store_id = getenv('STORE_ID') ?? 1; + $find = SystemStore::where('id', $store_id)->find(); + $list = [ + 'id' => $find['id'], + 'store_name' => $find['name'], + ]; + return $this->success('ok', $list); + } } diff --git a/app/api/controller/LoginController.php b/app/api/controller/LoginController.php index d58b2ab1f..2e1ba315c 100644 --- a/app/api/controller/LoginController.php +++ b/app/api/controller/LoginController.php @@ -6,8 +6,7 @@ use app\api\logic\LoginLogic; use app\common\model\system_store\SystemStore; use app\api\validate\{LoginAccountValidate, WechatLoginValidate}; use app\common\model\user\UserAuth; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class LoginController extends BaseApiController { @@ -19,7 +18,7 @@ class LoginController extends BaseApiController public function account() { $params=$this->request->post(); - $params = (new LoginAccountValidate())->post()->goCheck(); +// $params = (new LoginAccountValidate())->post()->goCheck(); $result = LoginLogic::login($params); if (false === $result) { return $this->fail(LoginLogic::getError()); diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index bcff5cf6d..90e6bfceb 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -9,8 +9,7 @@ use app\common\model\store_order\StoreOrder; use app\common\service\pay\PayService; use support\Cache; use support\Log; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + /** * 支付 @@ -69,6 +68,7 @@ class PayController extends BaseApiController public function wechatQuery() { $order_no = $this->request->get('order_no'); + $recharge = $this->request->get('recharge',0); $order = [ 'out_trade_no' => $order_no, ]; @@ -76,7 +76,11 @@ class PayController extends BaseApiController $res = $app->wechat->query($order); if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { - PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + if($recharge==0){ + PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + }else{ + PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + } return $this->success('支付成功'); } else { return $this->fail('订单支付中'); diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php index 6ca026202..dc2993465 100644 --- a/app/api/controller/UploadController.php +++ b/app/api/controller/UploadController.php @@ -4,8 +4,7 @@ use app\common\service\UploadService; use Exception; - use hg\apidoc\annotation as ApiDoc; - #[ApiDoc\NotParse()] + class UploadController extends BaseApiController { diff --git a/app/api/controller/cate/CateController.php b/app/api/controller/cate/CateController.php index 17e573afe..5f6e4bb87 100644 --- a/app/api/controller/cate/CateController.php +++ b/app/api/controller/cate/CateController.php @@ -5,8 +5,7 @@ namespace app\api\controller\cate; use app\api\controller\BaseApiController; use app\api\lists\cate\CateLists; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + /** * 商品分类控制器 diff --git a/app/api/controller/order/CartController.php b/app/api/controller/order/CartController.php index 06ad4b0d1..7c74e03fc 100644 --- a/app/api/controller/order/CartController.php +++ b/app/api/controller/order/CartController.php @@ -8,9 +8,8 @@ use app\api\controller\BaseApiController; use app\api\lists\order\CartList; use app\common\model\order\Cart; use app\common\model\store_branch_product\StoreBranchProduct; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class CartController extends BaseApiController { public function list() diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index fa1f79a2c..27553902d 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -16,9 +16,7 @@ use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use Webman\RedisQueue\Redis; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('订单')] class OrderController extends BaseApiController { public $notNeedLogin = ['refund_reason']; @@ -32,15 +30,15 @@ class OrderController extends BaseApiController return $this->dataLists(new OrderList()); } - #[ - ApiDoc\Title('核销码查数据'), - ApiDoc\url('/api/order/order/write_code'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('核销码查数据'), + // ApiDoc\url('/api/order/order/write_code'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function write_code() { $code = $this->request->post('code'); @@ -54,18 +52,18 @@ class OrderController extends BaseApiController return $this->success('ok', $res); } - #[ - ApiDoc\Title('核销订单列表'), - ApiDoc\url('/api/order/order/write_list'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "status", type: "int", require: true, desc: "1:待核销;2:已核销"), - ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), - ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"), - ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('核销订单列表'), + // ApiDoc\url('/api/order/order/write_list'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "status", type: "int", require: true, desc: "1:待核销;2:已核销"), + // ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), + // ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"), + // ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function write_list() { $status = (int)$this->request->post('status', 1); @@ -83,15 +81,15 @@ class OrderController extends BaseApiController return $this->success('ok', $res); } - #[ - ApiDoc\Title('核销数量'), - ApiDoc\url('/api/order/order/write_count'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('核销数量'), + // ApiDoc\url('/api/order/order/write_count'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function write_count() { $info = $this->userInfo; @@ -100,41 +98,41 @@ class OrderController extends BaseApiController return $this->success('ok', $res); } - #[ - ApiDoc\Title('订单校验'), - ApiDoc\url('/api/order/order/checkOrder'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "购物车id"), - ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), - ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"), - ApiDoc\Param(name: "verify_code", type: "int", require: true, desc: "校验码"), - ApiDoc\Param(name: "shipping_type", type: "int", require: true, desc: "配送方式"), - ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [ - ['name' => 'create_time', 'desc' => '订单创建时间', 'type' => 'int'], - ['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'], - ['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'], - ['name' => 'pay_price', 'desc' => '实际支付金额', 'type' => 'float'], - ['name' => 'total_num', 'desc' => '订单总数量', 'type' => 'int'], - ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'int'], - ['name' => 'cart_id', 'desc' => '购物车id', 'type' => 'string'], - ['name' => 'store_id', 'desc' => '店铺id', 'type' => 'int'], - ['name' => 'shipping_type', 'desc' => '配送方式', 'type' => 'int'], - ]], - ['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [ - ['name' => 'goods', 'desc' => '商品id', 'type' => 'int'], - ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'int'], - ['name' => 'total', 'desc' => '商品总价', 'type' => 'float'], - ['name' => 'price', 'desc' => '商品单价', 'type' => 'float'], - ['name' => 'product_id', 'desc' => '商品id', 'type' => 'int'], - ['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' => 'string'], - ['name' => 'verify_code', 'desc' => '校验码', 'type' => 'string'], - ]], - ]), - ] + // #[ + // ApiDoc\Title('订单校验'), + // ApiDoc\url('/api/order/order/checkOrder'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "购物车id"), + // ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), + // ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"), + // ApiDoc\Param(name: "verify_code", type: "int", require: true, desc: "校验码"), + // ApiDoc\Param(name: "shipping_type", type: "int", require: true, desc: "配送方式"), + // ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'order', 'desc' => '订单信息', 'type' => 'array', 'children' => [ + // ['name' => 'create_time', 'desc' => '订单创建时间', 'type' => 'int'], + // ['name' => 'order_id', 'desc' => '订单id', 'type' => 'int'], + // ['name' => 'total_price', 'desc' => '订单总金额', 'type' => 'float'], + // ['name' => 'pay_price', 'desc' => '实际支付金额', 'type' => 'float'], + // ['name' => 'total_num', 'desc' => '订单总数量', 'type' => 'int'], + // ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'int'], + // ['name' => 'cart_id', 'desc' => '购物车id', 'type' => 'string'], + // ['name' => 'store_id', 'desc' => '店铺id', 'type' => 'int'], + // ['name' => 'shipping_type', 'desc' => '配送方式', 'type' => 'int'], + // ]], + // ['name' => 'cart_list', 'desc' => '购物车商品列表', 'type' => 'array', 'children' => [ + // ['name' => 'goods', 'desc' => '商品id', 'type' => 'int'], + // ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'int'], + // ['name' => 'total', 'desc' => '商品总价', 'type' => 'float'], + // ['name' => 'price', 'desc' => '商品单价', 'type' => 'float'], + // ['name' => 'product_id', 'desc' => '商品id', 'type' => 'int'], + // ['name' => 'old_cart_id', 'desc' => '原购物车id', 'type' => 'string'], + // ['name' => 'verify_code', 'desc' => '校验码', 'type' => 'string'], + // ]], + // ]), + // ] public function checkOrder() { $cartId = (array)$this->request->post('cart_id', []); @@ -154,19 +152,19 @@ class OrderController extends BaseApiController return $this->data($res); } - #[ - ApiDoc\Title('创建订单'), - ApiDoc\url('/api/order/order/createOrder'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "id"), - ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"), - ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), - ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"), - ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('创建订单'), + // ApiDoc\url('/api/order/order/createOrder'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "cart_id", type: "int", require: true, desc: "id"), + // ApiDoc\Param(name: "store_id", type: "int", require: true, desc: "店铺id"), + // ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), + // ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"), + // ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function createOrder() { $cartId = (array)$this->request->post('cart_id', []); @@ -185,8 +183,16 @@ class OrderController extends BaseApiController $user=User::where('id',$this->userId)->find(); $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); + if ($order != false) { + if($order['pay_price'] <= 0){ + $pay_type = 3; + } switch ($pay_type) { + case PayEnum::PURCHASE_FUNDS: + //采购款支付 + PayNotifyLogic::handle('purchase_funds', $order['order_id']); + return $this->success('采购款支付成功'); case PayEnum::BALANCE_PAY: //余额支付 PayNotifyLogic::handle('balancePay', $order['order_id']); @@ -260,18 +266,18 @@ class OrderController extends BaseApiController return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving, 'all' => $all, 'applyRefund' => $applyRefund, 'refund' => $refund]); } - #[ - ApiDoc\Title('订单支付'), - ApiDoc\url('/api/order/order/pay'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), - ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), - ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"), - ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单支付'), + // ApiDoc\url('/api/order/order/pay'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), + // ApiDoc\Param(name: "address_id", type: "int", require: true, desc: "地址id"), + // ApiDoc\Param(name: "auth_code", type: "string", require: true, desc: "付款码"), + // ApiDoc\Param(name: "pay_type", type: "int", require: true, desc: "支付类型"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function pay() { $order_id = (int)$this->request->post('order_id'); @@ -349,23 +355,29 @@ class OrderController extends BaseApiController } - #[ - ApiDoc\Title('订单详情'), - ApiDoc\url('/api/order/order/detail'), - ApiDoc\Method('GET'), - ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单详情'), + // ApiDoc\url('/api/order/order/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function detail() { $order_id = (int)$this->request->get('order_id'); + $lat = $this->request->get('lat',''); + $lng = $this->request->get('long',''); $where = [ 'id' => $order_id, 'uid' => $this->userId, ]; $url = 'https://'.$this->request->host(true); - $order = OrderLogic::detail($where,$url); + $parm = [ + 'lat'=>$lat, + 'long'=>$lng + ]; + $order = OrderLogic::detail($where,$url,$parm); if ($order) { return $this->data($order); } else { @@ -444,15 +456,15 @@ class OrderController extends BaseApiController } } - #[ - ApiDoc\Title('核销'), - ApiDoc\url('/api/order/order/writeoff_order'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "verify_code", type: "string", require: true, desc: "验证码"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('核销'), + // ApiDoc\url('/api/order/order/writeoff_order'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "verify_code", type: "string", require: true, desc: "验证码"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function writeoff_order() { $params = (new OrderValidate())->post()->goCheck('check'); @@ -484,19 +496,19 @@ class OrderController extends BaseApiController } - #[ - ApiDoc\Title('订单退款申请'), - ApiDoc\url('/api/order/order/apply_refund'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "refund_message", type: "string", require: true, desc: "退款原因"), - ApiDoc\Param(name: "refund_num", type: "int", require: true, desc: "退款数量"), - ApiDoc\Param(name: "id", type: "int", require: true, desc: "订单id"), - ApiDoc\Param(name: "old_cart_id", type: "int", require: true, desc: "购物车id"), - ApiDoc\Param(name: "refund_type", type: "int", require: true, desc: "退款申请类型"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单退款申请'), + // ApiDoc\url('/api/order/order/apply_refund'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "refund_message", type: "string", require: true, desc: "退款原因"), + // ApiDoc\Param(name: "refund_num", type: "int", require: true, desc: "退款数量"), + // ApiDoc\Param(name: "id", type: "int", require: true, desc: "订单id"), + // ApiDoc\Param(name: "old_cart_id", type: "int", require: true, desc: "购物车id"), + // ApiDoc\Param(name: "refund_type", type: "int", require: true, desc: "退款申请类型"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function apply_refund() { $params = (new OrderValidate())->post()->goCheck('add'); @@ -506,14 +518,14 @@ class OrderController extends BaseApiController return $this->success('申请成功'); } - #[ - ApiDoc\Title('订单退款原因'), - ApiDoc\url('/api/order/order/refund_reason'), - ApiDoc\Method('GET'), - ApiDoc\Param(), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单退款原因'), + // ApiDoc\url('/api/order/order/refund_reason'), + // ApiDoc\Method('GET'), + // ApiDoc\Param(), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function refund_reason() { $data = DictData::where('type_value', 'reason')->where('status', YesNoEnum::YES) @@ -522,14 +534,14 @@ class OrderController extends BaseApiController } - #[ - ApiDoc\Title('取消售后'), - ApiDoc\url('/api/order/order/cancel_sale'), - ApiDoc\Method('GET'), - ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('取消售后'), + // ApiDoc\url('/api/order/order/cancel_sale'), + // ApiDoc\Method('GET'), + // ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function cancel_sale() { $order_id = (int)$this->request->get('order_id'); diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index d1d54fa36..804325ac7 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -3,8 +3,7 @@ namespace app\api\controller\product; use app\api\controller\BaseApiController; use app\api\lists\product\ProductLists; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class ProductController extends BaseApiController{ public $notNeedLogin = ['lists']; @@ -13,7 +12,7 @@ class ProductController extends BaseApiController{ */ public function lists(){ - return $this->dataLists(new ProductLists()); + return $this->dataLists(new ProductLists(),1); } /** diff --git a/app/api/controller/shop/IndexController.php b/app/api/controller/shop/IndexController.php index 9f797da5e..b1cf77793 100644 --- a/app/api/controller/shop/IndexController.php +++ b/app/api/controller/shop/IndexController.php @@ -9,8 +9,7 @@ use app\common\model\dict\DictData; use app\common\model\merchant\Merchant; use app\common\model\supplier\Supplier; use think\facade\Db; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class IndexController extends BaseApiController{ public $notNeedLogin = ['apply','get_token','merchat_type','record','apply_detail']; diff --git a/app/api/controller/store/ProductRecordController.php b/app/api/controller/store/ProductRecordController.php index f9d1f6e46..660de6eed 100644 --- a/app/api/controller/store/ProductRecordController.php +++ b/app/api/controller/store/ProductRecordController.php @@ -3,8 +3,6 @@ namespace app\api\controller\store; use app\api\controller\BaseApiController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('收银机商品统计')] class ProductRecordController extends BaseApiController { diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 6b4dd010d..97bd8068d 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -2,13 +2,18 @@ namespace app\api\controller\store; +use app\admin\logic\user\UserLogic as UserUserLogic; use app\api\lists\store\SystemStoreLists; use app\api\controller\BaseApiController; use app\api\logic\store\StoreLogic; -use app\common\service\pay\PayService; -use Webman\Config; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] +use app\api\logic\user\UserLogic; +use app\api\validate\UserValidate; +use app\common\enum\PayEnum; +use app\common\logic\PaymentLogic; +use app\common\logic\PayNotifyLogic; +use app\common\model\user\User; +use app\common\model\user_recharge\UserRecharge; +use Webman\RedisQueue\Redis; class StoreController extends BaseApiController { @@ -19,19 +24,78 @@ class StoreController extends BaseApiController } + /** + * 门店信息 + */ public function detail() { $store_id = (int)$this->request->get('store_id'); - $where = [ - 'id' => $store_id - ]; + $phone = (int)$this->request->get('phone'); + $where = []; + if($phone){ + $where['phone'] = $phone; + } + if($store_id){ + $where['id'] = $store_id; + } + $info = StoreLogic::search($where); if ($info) { - return $this->data($info); + return $this->success('ok',$info??[]); } else { return $this->fail('店铺不存在'); } } + /** + * 门店会员充值 + */ + public function recharge() + { + $params = (new UserValidate())->post()->goCheck('rechargeStoreMoney'); + $auth_code = $this->request->post('auth_code'); //微信支付条码 + $find=User::where('mobile',$params['mobile'])->find(); + if(!$find){ + $find=UserUserLogic::StoreAdd($params); + }else{ + $find['real_name']=$params['real_name']; + $find->save(); + } + $data=[ + 'store_id'=>$params['store_id'], + 'uid'=>$find['id'], + 'staff_id'=>0, + 'order_id'=>getNewOrderId('CZ'), + 'price'=>0.01, + 'recharge_type'=>'INDUSTRYMEMBERS', + ]; + $order = UserRecharge::create($data); + $order['pay_price']=$order['price']; + $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); + if (PaymentLogic::hasError()) { + return $this->fail(PaymentLogic::getError(), $params); + } + if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { + PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result); + } else { + Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']); + return $this->success('用户支付中'); + } + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); + } + + /** + * 门店会员充值数量 + */ + public function recharge_count() + { + $store_id = $this->request->get('store_id',0); + $count=0; + if($store_id){ + $count= UserRecharge::where(['store_id'=>$store_id,'recharge_type'=>'INDUSTRYMEMBERS','paid'=>1])->count(); + } + return $this->success('ok',['count'=>$count]); + + } } diff --git a/app/api/controller/store/TransactionRecordController.php b/app/api/controller/store/TransactionRecordController.php index c0b2bb023..37dd6b288 100644 --- a/app/api/controller/store/TransactionRecordController.php +++ b/app/api/controller/store/TransactionRecordController.php @@ -3,8 +3,7 @@ namespace app\api\controller\store; use app\api\controller\BaseApiController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('收银机盈收统计')] + class TransactionRecordController extends BaseApiController { diff --git a/app/api/controller/user/AddressController.php b/app/api/controller/user/AddressController.php index 931446ade..781f6f9e3 100644 --- a/app/api/controller/user/AddressController.php +++ b/app/api/controller/user/AddressController.php @@ -6,8 +6,7 @@ use app\api\controller\BaseApiController; use app\api\lists\user\UserAddressList; use app\api\logic\user\AddressLogic; use app\api\validate\UserAddressValidate; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class AddressController extends BaseApiController { diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 67c7efbd1..2f2e921e9 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -7,10 +7,7 @@ use app\api\logic\user\UserLogic; use app\api\validate\UserValidate; use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; -use hg\apidoc\annotation as ApiDoc; -use taoser\Validate; -#[ApiDoc\title('用户')] /** * 用户控制器 @@ -19,15 +16,15 @@ use taoser\Validate; */ class UserController extends BaseApiController { - #[ - ApiDoc\Title('获取小程序手机号'), - ApiDoc\url('/api/user/user/getMobileByMnp'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "code", type: "string", require: true, desc: "换取手机的code"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('获取小程序手机号'), + // ApiDoc\url('/api/user/user/getMobileByMnp'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "code", type: "string", require: true, desc: "换取手机的code"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function getMobileByMnp() { $params = (new UserValidate())->post()->goCheck('getMobileByMnp'); @@ -41,45 +38,45 @@ class UserController extends BaseApiController } - #[ - ApiDoc\Title('用户个人信息'), - ApiDoc\url('/api/user/user/info'), - ApiDoc\Method('POST'), - ApiDoc\Param(), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('用户个人信息'), + // ApiDoc\url('/api/user/user/info'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function info() { return $this->success('success', UserLogic::info($this->userId)); } - #[ - ApiDoc\Title('充值金额'), - ApiDoc\url('/api/user/user/rechange_amount'), - ApiDoc\Method('Get'), - ApiDoc\Param(), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('充值金额'), + // ApiDoc\url('/api/user/user/rechange_amount'), + // ApiDoc\Method('Get'), + // ApiDoc\Param(), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function rechange_amount() { $res = UserLogic::rechange_level(); return $this->success('ok',$res); } - #[ - ApiDoc\Title('小程序充值'), - ApiDoc\url('/api/user/user/recharge'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "price", type: "string", require: true, desc: "金额"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('小程序充值'), + // ApiDoc\url('/api/user/user/recharge'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "price", type: "string", require: true, desc: "金额"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function recharge() { $params = (new UserValidate())->post()->goCheck('rechargeMoney'); @@ -92,19 +89,18 @@ class UserController extends BaseApiController return $this->fail(PaymentLogic::getError(), $params); } return $this->success('', $result); - } - #[ - ApiDoc\Title('会员账户详情'), - ApiDoc\url('/api/user/user/capital_flow'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"), - ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('会员账户详情'), + // ApiDoc\url('/api/user/user/capital_flow'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"), + // ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function capital_flow() { $page_no = (int)$this->request->post('page_no',1); @@ -122,15 +118,15 @@ class UserController extends BaseApiController return $this->success('ok',$res); } - #[ - ApiDoc\Title('会员账户统计'), - ApiDoc\url('/api/user/user/capital_count'), - ApiDoc\Method('POST'), - ApiDoc\Param(), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('会员账户统计'), + // ApiDoc\url('/api/user/user/capital_count'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function capital_count() { $res = UserLogic::capital_count($this->userId); diff --git a/app/api/controller/user/UserFeedbackController.php b/app/api/controller/user/UserFeedbackController.php index 3ad0f9030..46cedd303 100644 --- a/app/api/controller/user/UserFeedbackController.php +++ b/app/api/controller/user/UserFeedbackController.php @@ -6,8 +6,7 @@ use app\api\logic\user\UserFeedbackLogic; use app\admin\validate\user\UserFeedbackValidate; use app\api\controller\BaseApiController; - use hg\apidoc\annotation as ApiDoc; - #[ApiDoc\NotParse()] + class UserFeedbackController extends BaseApiController { diff --git a/app/api/controller/user/UserRechargeController.php b/app/api/controller/user/UserRechargeController.php new file mode 100644 index 000000000..ba97d6a54 --- /dev/null +++ b/app/api/controller/user/UserRechargeController.php @@ -0,0 +1,24 @@ +dataLists(new UserRechargeLists()); + } + } diff --git a/app/api/controller/user/UserVisitController.php b/app/api/controller/user/UserVisitController.php index 5570e2efe..d777c094a 100644 --- a/app/api/controller/user/UserVisitController.php +++ b/app/api/controller/user/UserVisitController.php @@ -5,25 +5,23 @@ namespace app\api\controller\user; use app\api\controller\BaseApiController; use app\api\logic\user\UserVisitLogic; use app\api\validate\VisitValidate; -use hg\apidoc\annotation as ApiDoc; use Illuminate\Support\Facades\Request; use support\Response; -#[ApiDoc\title('用户访问')] class UserVisitController extends BaseApiController { public $notNeedLogin = ['productLog']; - #[ - ApiDoc\Title('添加访问商品记录'), - ApiDoc\url('/api/user/UserVisit/productLog'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "product_id", type: "int", require: true, desc: "product_id商品id"), - ApiDoc\Param(name: "cate_id", type: "int", require: true, desc: "分类id"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('添加访问商品记录'), + // ApiDoc\url('/api/user/UserVisit/productLog'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "product_id", type: "int", require: true, desc: "product_id商品id"), + // ApiDoc\Param(name: "cate_id", type: "int", require: true, desc: "分类id"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function productLog(): Response { $params = (new VisitValidate())->post()->goCheck('add'); @@ -37,16 +35,16 @@ class UserVisitController extends BaseApiController } - #[ - ApiDoc\Title('用户访问页面记录'), - ApiDoc\url('/api/user/UserVisit/htmlLog'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "url", type: "string", require: true, desc: "路径"), - ApiDoc\Param(name: "stay_time", type: "int", require: true, desc: "停留时间"), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('用户访问页面记录'), + // ApiDoc\url('/api/user/UserVisit/htmlLog'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "url", type: "string", require: true, desc: "路径"), + // ApiDoc\Param(name: "stay_time", type: "int", require: true, desc: "停留时间"), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function htmlLog() { $ip = $this->request->getRealIp(); diff --git a/app/api/lists/cate/CateLists.php b/app/api/lists/cate/CateLists.php index 87a8fb73c..e924419bf 100644 --- a/app/api/lists/cate/CateLists.php +++ b/app/api/lists/cate/CateLists.php @@ -46,6 +46,7 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface $level = Request()->get('level', 1); $this->searchWhere[] = ['level', '=', $level]; $this->searchWhere[] = ['count', '>', 0]; + $this->searchWhere[] = ['delete_time', '=', null]; $cate_arr = Db::name('store_product_cate')->where($this->searchWhere)->column('cate_id'); $lists = []; if ($cate_arr) { diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index d68559b77..ca28189b1 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -63,7 +63,8 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists foreach ($list as $key => &$item) { $find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']]) - ->field('product_id,image,price,cost,store_name,unit') + ->field('product_id,image,price,cost,store_name,unit,delete_time') + ->withTrashed() ->find(); // if (isset($check) && $check['status'] == 1) { // $find['price'] = $find['cost']; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index f757b8f00..f208633c8 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -88,17 +88,23 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li } } if(!$found){ - $this->searchWhere[]=['store_id','=',2]; + $store_id = DictType::where('type','store')->value('remark')??5; + $this->searchWhere[]=['store_id','=',$store_id]; } $class_all=$this->request->get('class_all'); $where=[]; if($class_all){ + //查3级别的 $arr=Cate::where('pid',$class_all)->column('id'); if($arr){ $arr2=Cate::where('pid','in',$arr)->column('id'); $where[]=['cate_id','in',array_merge($arr,$arr2)]; } } + if(empty($where) && $class_all){ + //2或者1 + $where[]=['cate_id','=',$class_all]; + } $this->searchWhere[]=['status','=',1]; @@ -107,7 +113,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li if($M_store_id){ $where[]=['store_id','=',$M_store_id]; $data = StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id', 'product_id','cate_id','store_name', 'cost','store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) + ->field(['id', 'product_id','cate_id','store_name', 'cost','store_id','price', 'bar_code','image','sales','store_info','delete_time','unit','batch']) ->limit($this->limitOffset, $this->limitLength) ->with(['className','unitName']) ->order($this->sortOrder) @@ -116,7 +122,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li }else{ $data = StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id', 'product_id','cate_id','store_name','cost', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit']) + ->field(['id', 'product_id','cate_id','store_name','cost', 'store_id','price', 'bar_code','image','sales','store_info','delete_time','unit','batch']) ->limit($this->limitOffset, $this->limitLength) ->with(['className','unitName']) ->order($this->sortOrder) @@ -159,7 +165,8 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li } } if(!$found){ - $this->searchWhere[]=['store_id','=',2]; + $store_id = DictType::where('type','store')->value('remark')??5; + $this->searchWhere[]=['store_id','=',$store_id]; } $class_all=$this->request->get('class_all'); $where=[]; @@ -170,6 +177,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li $where[]=['cate_id','in',array_merge($arr,$arr2)]; } } + if(empty($where)&& $class_all){ + //2或者1 + $where[]=['cate_id','=',$class_all]; + } $M_store_id=$this->request->__get('store_id'); $this->searchWhere[]=['status','=',1]; $this->searchWhere[]=['stock','>',0]; diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index 2688c24cc..52bef3231 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -49,7 +49,7 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac $latitude = $this->request->get('latitude',''); $longitude = $this->request->get('longitude',''); if(empty($longitude) || empty($latitude)){ - throw new MyBusinessException('缺失经纬度'); + throw new Exception('缺失经纬度'); } $where[]=['is_show','=',YesNoEnum::YES]; $data = SystemStore::where($this->searchWhere)->where($where) diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php new file mode 100644 index 000000000..2090f6420 --- /dev/null +++ b/app/api/lists/user/UserRechargeLists.php @@ -0,0 +1,62 @@ + ['store_id','recharge_type'], + ]; + } + + + /** + * @notes 获取用户充值表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function lists(): array + { + return UserRecharge::where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $data['real_name'] =User::where('id',$data['uid'])->value('real_name'); + }) + ->toArray(); + } + + + /** + * @notes 获取用户充值表数量 + * @return int + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function count(): int + { + return UserRecharge::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e016bff55..dcfa9efab 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -8,6 +8,7 @@ use app\common\enum\UserShipEnum; use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\logic\CapitalFlowLogic; +use app\common\logic\PayNotifyLogic; use app\common\logic\StoreFinanceFlowLogic; use app\common\model\dict\DictData; use app\common\model\dict\DictType; @@ -23,6 +24,7 @@ use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserShip; +use app\common\model\user_spread_log\UserSpreadLog; use Picqer\Barcode\BarcodeGeneratorJPG; use Picqer\Barcode\BarcodeGeneratorPNG; use support\exception\BusinessException; @@ -45,6 +47,7 @@ class OrderLogic extends BaseLogic public static $pay_price; public static $cost; public static $profit; + public static $store_price;//门店零售价 public static $activity_price; /** @@ -64,44 +67,55 @@ class OrderLogic extends BaseLogic try { self::$total_price = 0; self::$pay_price = 0; - self::$cost = 0; //成本 + self::$cost = 0; //成本由采购价替代原成本为门店零售价 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 + self::$store_price = 0; //门店零售价 /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,product_id')->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } unset($cart_select[$k]['id']); $cart_select[$k]['price'] = $find['price']; + $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 - if ($user && $user['user_ship'] >= 1) { + $cart_select[$k]['vip'] = 0; + if ($user && $user['user_ship'] == 1) { + //更新 会员为1的时候原价减去会员价 $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); $cart_select[$k]['deduction_price'] =$deduction_price_count; self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - $onePrice = bcsub($find['vip_price'], $find['cost'], 2); - - }else{ - $onePrice = bcsub($find['price'], $find['cost'], 2); + $cart_select[$k]['vip'] =1; } + if ($user && $user['user_ship'] == 4) { + //更新 为4商户的时候减去商户价格 + $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + $cart_select[$k]['deduction_price'] =$deduction_price_count; + self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + } + //利润 - $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 - $cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本 + // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 + $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 + $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2)??0; //门店零售价 + $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2)??0; //vip售价 + $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; - + //vip1待返回金额 + $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'],2); +// d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] ); $cartInfo = $cart_select[$k]; $cartInfo['name'] = $find['store_name']; $cartInfo['image'] = $find['image']; - - $cartInfo['vip_price'] = 0; //$cart_select[$k]['total'] - $vipPrice ?? 0; $cart_select[$k]['cart_info'] = json_encode($cartInfo); $cart_select[$k]['branch_product_id'] = $find['branch_product_id']; //理论上每笔都是拆分了 @@ -111,10 +125,16 @@ class OrderLogic extends BaseLogic $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); - self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 2); - self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); + self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); + self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 + // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } - $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 + if ($user && $user['user_ship'] == 1) { + $pay_price = self::$pay_price; + }else{ + $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 + } + $vipPrice = 0; //成本价 收益 $order = [ @@ -122,7 +142,7 @@ class OrderLogic extends BaseLogic 'order_id' => $params['order_id'] ?? getNewOrderId('PF'), 'total_price' => self::$total_price, //总价 'cost' => self::$cost, //成本价1- - 'profit' => self::$profit, //利润 + 'profit' =>0, //利润 'pay_price' => $pay_price, //后期可能有降价抵扣 'vip_price' => $vipPrice, 'total_num' => count($cart_select), //总数 @@ -134,13 +154,17 @@ class OrderLogic extends BaseLogic 'activity' => '减免', 'activity_price' => self::$activity_price, 'activities' => self::$activity_price>0?1:0, - 'deduction_price' => self::$activity_price - + 'deduction_price' => self::$activity_price, + 'is_vip' => 0, ]; $order['default_delivery'] = 0; if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } + if($user && $user['user_ship']>=1 &&$user['user_ship']<=3){ + $order['is_vip'] = 1; + + } } catch (\Exception $e) { self::setError($e->getMessage()); return false; @@ -164,8 +188,8 @@ class OrderLogic extends BaseLogic return false; } $_order = $orderInfo['order']; - $_order['uid'] = request()->userId; - $user = User::where('id', \request()->userId)->find(); + $_order['uid'] = $user['id']; + $_order['spread_uid'] =$params['spread_uid']??0;// UserSpreadLog::where('uid',request()->userId)->value('old_spread_uid')??0;//预留分享关系 $_order['real_name'] = $user['real_name']; $_order['mobile'] = $user['mobile']; $_order['pay_type'] = $orderInfo['order']['pay_type']; @@ -176,7 +200,7 @@ class OrderLogic extends BaseLogic $_order['reservation'] = YesNoEnum::YES; } if ($addressId > 0) { - $address = UserAddress::where(['id' => $addressId, 'uid' => Request()->userId])->find(); + $address = UserAddress::where(['id' => $addressId, 'uid' => $user['id']])->find(); if ($address) { $_order['real_name'] = $address['real_name']; $_order['user_phone'] = $address['phone']; @@ -190,7 +214,7 @@ class OrderLogic extends BaseLogic $generator = new BarcodeGeneratorPNG(); $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); $findPath = '/image/barcode/'.time().'.png'; - $savePath = 'public'.$findPath; + $savePath = public_path().$findPath; file_put_contents($savePath, $barcode); $_order['verify_img'] = $findPath; Db::startTrans(); @@ -200,10 +224,10 @@ class OrderLogic extends BaseLogic $updateData = []; foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order->id; - $goods_list[$k]['uid'] = request()->userId; + $goods_list[$k]['uid'] = $user['id']; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->find(); + $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find(); $updateData[] = [ 'id' => $v['branch_product_id'], 'stock' => $StoreBranchProduct['stock']-$v['cart_num'], @@ -290,17 +314,16 @@ class OrderLogic extends BaseLogic public static function purchaseAgain($order_id) { - $arr = StoreOrderCartInfo::where('oid', $order_id)->field('product_id,cart_num,staff_id')->select(); + $arr = StoreOrderCartInfo::where('oid', $order_id)->field('product_id,cart_num,staff_id,store_id')->select(); $data = []; foreach ($arr as $k => $v) { $data[$k]['product_id'] = $v['product_id']; - $unique = StoreProductAttrValue::where('product_id', $v['product_id'])->value('v'); - $data[$k]['product_attr_unique'] = $unique; +// $unique = StoreProductAttrValue::where('product_id', $v['product_id'])->value('v'); + $data[$k]['product_attr_unique'] = ''; $data[$k]['cart_num'] = $v['cart_num']; $data[$k]['type'] = ''; $data[$k]['uid'] = Request()->userId; - $store_id = StoreProduct::where('id', $v['product_id'])->value('store_id'); - $data[$k]['store_id'] = $store_id; + $data[$k]['store_id'] = $v['store_id']; $data[$k]['staff_id'] = $v['staff_id']; $data[$k]['combination_id'] = 0; $data[$k]['seckill_id'] = 0; @@ -320,7 +343,7 @@ class OrderLogic extends BaseLogic } - public static function detail($params,$url=''): array + public static function detail($params,$url='',$param=[]): array { $find = StoreOrder::where($params)->findOrEmpty()->toArray(); if ($find) { @@ -342,6 +365,24 @@ class OrderLogic extends BaseLogic if($find['verify_img']){ $find['verify_img'] = $url.$find['verify_img']; } + //处理返回最近的店铺 + if($param['lat'] && $param['long']){ + $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); + $nearestStore = null; + $minDistance = PHP_FLOAT_MAX; + foreach ($storeAll as $value){ + $value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$param['lat'] ,$param['long']); + if ($value['distance'] < $minDistance) { + $minDistance = $value['distance']; + $nearestStore = $value; + } + } + if ($nearestStore) { + $find['near_store'] =$nearestStore; + + } + + } } return $find; } @@ -385,18 +426,24 @@ class OrderLogic extends BaseLogic 'status' => OrderEnum::RECEIVED_GOODS, 'is_writeoff' => OrderEnum::IS_OK, 'update_time' => time(), + 'store_id' => $params['store_id'], + 'staff_id' => $params['staff_id']??0, ], ['id' => $data['id']]); (new StoreOrderCartInfo())->update([ 'verify_code'=>$params['verify_code'].'-1', 'writeoff_time' => time(), 'is_writeoff' => YesNoEnum::YES, + 'store_id' => $params['store_id'], + 'staff_id' => $params['staff_id']??0, 'update_time' => time(), ], ['oid' => $data['id']]); - $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']); - if (!empty($financeFlow)) { - $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store'); - $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']); - } + // $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']); + // if (!empty($financeFlow)) { + // $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store'); + // $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']); + // } + $order=StoreOrder::where('id',$data['id'])->find(); + PayNotifyLogic::afterPay($order); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/api/logic/user/AddressLogic.php b/app/api/logic/user/AddressLogic.php index 068aa6f0d..097204ab5 100644 --- a/app/api/logic/user/AddressLogic.php +++ b/app/api/logic/user/AddressLogic.php @@ -67,8 +67,14 @@ class AddressLogic extends BaseLogic 'phone' => $params['phone'], 'detail' => $params['detail'], 'is_default' => $params['is_default'], + 'province' => $params['province'], + 'city' => $params['city'], + 'area' => $params['area'], + 'street' => $params['street'], + 'village' => $params['village'], + 'brigade' => $params['brigade'], ]; - UserAddress::where('uid', $params['uid'])->where('id', $params['address_id'])->update($data); + UserAddress::where('uid', $params['uid'])->where('id', $params['id'])->update($data); Db::commit(); return true; } catch (\Exception $e) { @@ -93,7 +99,7 @@ class AddressLogic extends BaseLogic /** - * @notes 获取购物车表详情 + * @notes 获取地址详情 * @param $params * @return array * @author likeadmin @@ -101,6 +107,6 @@ class AddressLogic extends BaseLogic */ public static function detail($params): array { - return UserAddress::field('id address_id,real_name,phone,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray(); + return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where($params)->findOrEmpty()->toArray(); } } diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 0428c03a3..e6b493914 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -6,6 +6,7 @@ namespace app\api\logic\user; use app\common\{logic\BaseLogic, model\dict\DictData, model\finance\CapitalFlow, + model\store_finance_flow\StoreFinanceFlow, model\store_order\StoreOrder, model\system_store\DeliveryService, model\system_store\SystemStore, @@ -14,6 +15,8 @@ use app\common\{logic\BaseLogic, model\user\UserRecharge, model\user\UserShip, service\wechat\WeChatMnpService}; +use think\facade\Db; + /** * 会员逻辑层 @@ -66,7 +69,8 @@ class UserLogic extends BaseLogic public static function info($uid) { $data = User::with(['userShip'])->where('id',$uid) - ->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship') + ->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship + ,purchase_funds,integral') ->find(); //判断是不是员工 if($data){ @@ -88,6 +92,10 @@ class UserLogic extends BaseLogic $data['store_id'] = $check['store_id']; } } + $data['return_money'] = Db::name('vip_flow')-> + where(['user_id'=>$uid,'status'=>0]) + ->sum('number'); + }else{ $data = []; } diff --git a/app/api/validate/UserAddressValidate.php b/app/api/validate/UserAddressValidate.php index 30a1360b6..b7911da0e 100644 --- a/app/api/validate/UserAddressValidate.php +++ b/app/api/validate/UserAddressValidate.php @@ -63,7 +63,7 @@ class UserAddressValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['real_name','phone','detail','address_id']); + return $this->only(['real_name','phone','id']); } diff --git a/app/api/validate/UserValidate.php b/app/api/validate/UserValidate.php index ddc907b23..d670e7327 100644 --- a/app/api/validate/UserValidate.php +++ b/app/api/validate/UserValidate.php @@ -16,10 +16,14 @@ class UserValidate extends BaseValidate protected $rule = [ 'code' => 'require', + 'store_id' => 'require', + 'mobile' => 'require', ]; protected $message = [ 'code.require' => '参数缺失', + 'store_id.require' => '门店id', + 'mobile.require' => '手机', ]; @@ -57,5 +61,14 @@ class UserValidate extends BaseValidate { return $this->only(['price']); } + /** + * @notes 充值 + * @return UserValidate + * @Time: 2024/6/4 22:50 + */ + public function sceneRechargeStoreMoney() + { + return $this->only(['price']); + } } \ No newline at end of file diff --git a/app/common/controller/BaseLikeController.php b/app/common/controller/BaseLikeController.php index 79cf2b9f9..13c07d9c8 100644 --- a/app/common/controller/BaseLikeController.php +++ b/app/common/controller/BaseLikeController.php @@ -7,9 +7,8 @@ namespace app\common\controller; use app\BaseController; use app\common\lists\BaseDataLists; use app\common\service\JsonService; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class BaseLikeController extends BaseController { public $notNeedLogin = []; @@ -47,7 +46,7 @@ class BaseLikeController extends BaseController * @author 令狐冲 * @date 2021/7/8 00:40 */ - protected function dataLists(BaseDataLists $lists = null) + protected function dataLists(BaseDataLists $lists = null,$remark = 0) { //列表类和控制器一一对应,"app/应用/controller/控制器的方法" =》"app\应用\lists\"目录下 //(例如:"app/admin/controller/auth/AdminController.php的lists()方法" =》 "app/admin/lists/auth/AminLists.php") @@ -56,7 +55,7 @@ class BaseLikeController extends BaseController // $listName = str_replace('.', '\\', App::getNamespace() . '\\lists\\' . $this->request->controller() . ucwords($this->request->action())); // $lists = invoke($listName); } - return JsonService::dataLists($lists); + return JsonService::dataLists($lists,$remark); } @@ -74,10 +73,7 @@ class BaseLikeController extends BaseController return JsonService::fail($msg, $data, $code, $show); } - #[ApiDoc\NotParse()] - #[ - ApiDoc\Title('是否免登录验证'), - ] + public function isNotNeedLogin() : bool { $notNeedLogin = $this->notNeedLogin; diff --git a/app/common/controller/Definitions.php b/app/common/controller/Definitions.php index 8e1e81085..11d053590 100644 --- a/app/common/controller/Definitions.php +++ b/app/common/controller/Definitions.php @@ -2,22 +2,21 @@ namespace app\common\controller; -use hg\apidoc\annotation as ApiDoc; class Definitions { - #[ - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ] + // #[ + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ] public function token() { } - #[ - ApiDoc\Query("page_no", type: "int", require: false, default: 1, desc: "页码"), - ApiDoc\Query("page_size", type: "int", require: false, default: 25, desc: "每页条数"), - ] + // #[ + // ApiDoc\Query("page_no", type: "int", require: false, default: 1, desc: "页码"), + // ApiDoc\Query("page_size", type: "int", require: false, default: 25, desc: "每页条数"), + // ] public function page() { diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index c6ea7ec5b..8a5ca32e1 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -16,9 +16,15 @@ class OrderEnum * @MERCHANT_ORDER_PAY 商户订单支付 * @PLATFORM_ORDER_OBTAINS 平台订单获得 * @SUPPLIER_ORDER_OBTAINS 供应链订单获得 + * @VIP_ORDER_OBTAINS 会员订单获得 + * @VILLAGE_ORDER_OBTAINS 村长获得 + * @BRIGADE_ORDER_OBTAINS 队长获得 + * @OTHER_ORDER_OBTAINS 其他获得 * @PLATFORM_ORDER_PAY 平台订单支付 * @SYSTEM_SET 系统设置 * @OWN_GET 平台收入 + * @ORDER_MARGIN 商户保证金 + * @PURCHASE_FUNDS 采购款收银 */ const USER_ORDER_PAY = 1; const MERCHANT_ORDER_OBTAINS = 2; @@ -28,11 +34,18 @@ class OrderEnum const SUPPLIER_ORDER_OBTAINS = 6; const PLATFORM_ORDER_PAY = 7; const SYSTEM_SET = 8; - const CASHIER_ORDER_PAY = 9; + const CASHIER_ORDER_PAY = 9;//微信条码 const CASHIER_CASH_ORDER_PAY = 10; - const ORDER_MARGIN = 11; - const ORDER_COMMITION = 12; + const VIP_ORDER_OBTAINS = 12; + const CASHIER_ORDER_ALI_PAY = 13;//支付宝条码 + const VILLAGE_ORDER_OBTAINS = 14; + const BRIGADE_ORDER_OBTAINS = 15; + const OTHER_ORDER_OBTAINS = 16; + + const CASHIER_FACE_PAY = 17;//现金收银 + + const PURCHASE_FUNDS = 18;//采购款收银 /** @@ -87,6 +100,7 @@ class OrderEnum /**小程序下单**/ const ONLINE = [1,2]; + const OFFLINE = [3]; /** * 账户类型 * @USER 用户 @@ -118,6 +132,10 @@ class OrderEnum const REFUND_STATUS_FINISH = 2; const CANCEL_SALE = 3; + //判断资金流水是否余额支付 + const BALANCE_PAYMEN_NO = 1; + + /** * @notes 获取支付类型 * @param bool $value @@ -131,11 +149,20 @@ class OrderEnum self::USER_ORDER_PAY => '用户订单支付', self::MERCHANT_ORDER_PAY => '商户订单支付', self::PLATFORM_ORDER_PAY => '平台订单支付', - self::MERCHANT_ORDER_OBTAINS => '商户订单获得', - self::ORDER_HANDLING_FEES => '订单手续费', - self::PLATFORM_ORDER_OBTAINS => '平台订单获得', - self::SUPPLIER_ORDER_OBTAINS => '供应商订单获得', + self::MERCHANT_ORDER_OBTAINS => '商户', + self::ORDER_HANDLING_FEES => '手续费', + self::PLATFORM_ORDER_OBTAINS => '平台', + self::SUPPLIER_ORDER_OBTAINS => '供应商', self::SYSTEM_SET => '平台设置', + self::VILLAGE_ORDER_OBTAINS => '村长', + self::BRIGADE_ORDER_OBTAINS=>'队长', + self::ORDER_MARGIN=>'保证金', + self::VIP_ORDER_OBTAINS=>'会员', + self::OTHER_ORDER_OBTAINS=>'其他', + + + + ]; diff --git a/app/common/enum/PayEnum.php b/app/common/enum/PayEnum.php index 8065e8fac..7cf6e2364 100644 --- a/app/common/enum/PayEnum.php +++ b/app/common/enum/PayEnum.php @@ -31,6 +31,7 @@ class PayEnum * @GOODS_FIRST_PAYMENT_LATER 先货后款 * @CORPORATE_TRANSFER 对公转账 * @CASH_PAY 现金支付 + * @PURCHASE_FUNDS 采购款收银 */ const BALANCE_PAY = 3; const WECHAT_PAY = 1; @@ -49,7 +50,7 @@ class PayEnum const GOODS_FIRST_PAYMENT_LATER = 15; const CORPORATE_TRANSFER = 16; const CASH_PAY = 17; - + const PURCHASE_FUNDS = 18;//采购款收银 //支付状态 const UNPAID = 0; //未支付 const ISPAID = 1; //已支付 @@ -99,6 +100,7 @@ class PayEnum self::ALIPAY_QRCODE => '支付宝二维码', self::ALIPAY_BARCODE => '支付宝条码', self::BALANCE_PAY => '余额支付', + self::PURCHASE_FUNDS => '采购款收银', ]; if ($value === true) { diff --git a/app/common/enum/UserShipEnum.php b/app/common/enum/UserShipEnum.php index ea4b84ccf..772a54456 100644 --- a/app/common/enum/UserShipEnum.php +++ b/app/common/enum/UserShipEnum.php @@ -8,9 +8,14 @@ class UserShipEnum * 会员等级 */ const VIP1 = 1; - const VIP2 = 7; - const VIP3 = 8; - const VIP4 = 9; - const VIP5 = 10; + const VIP2 = 2; + const VIP3 = 3; + const VIP4 = 4; + const VIP5 = 5; + + /** + * 切换折扣价 + */ + const DISCOUNT_ARRAY = [4,5,6]; } \ No newline at end of file diff --git a/app/common/lists/user/UserShipLists.php b/app/common/lists/user/UserShipLists.php new file mode 100644 index 000000000..e4ea31103 --- /dev/null +++ b/app/common/lists/user/UserShipLists.php @@ -0,0 +1,63 @@ +0,'title'=>'一般用户']; + + $lists = UserShip::where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->field($field) + ->order('sort desc') + ->select() + ->toArray(); + return array_merge($arr,$lists); + } + + + /** + * @notes 获取数量 + * @return int + * @author 乔峰 + * @date 2022/9/22 15:51 + */ + public function count(): int + { + return UserShip::where($this->searchWhere)->count(); + } +} \ No newline at end of file diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index e8ac3a513..1b6aea9ba 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -2,6 +2,7 @@ namespace app\common\logic; +use app\common\enum\OrderEnum; use app\common\model\finance\CapitalFlow; class CapitalFlowLogic extends BaseLogic @@ -49,27 +50,29 @@ class CapitalFlowLogic extends BaseLogic /** * 用户支出 * @param $category + * @param $store_id * @param $linkType * @param $linkId * @param $amount * @param $mark * @return mixed */ - public function userExpense($category, $linkType, $linkId, $amount, $mark = '',$payType=0) + public function userExpense($category, $linkType, $linkId, $amount, $mark = '',$payType=0,$store_id=0) { $model = new CapitalFlow(); $model->uid = $this->user['id']; $model->category = $category; + $model->store_id = $store_id; $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - // if($payType == 1){ + if($payType == OrderEnum::BALANCE_PAYMEN_NO){ $model->before_balance = $this->user['now_money']; $model->balance = $this->user['now_money']; - // }else{ - // $model->before_balance = $this->user['now_money']; - // $model->balance = bcsub($this->user['now_money'], $amount, 2); - // } + }else{ + $model->before_balance = $this->user['now_money']; + $model->balance = bcsub($this->user['now_money'], $amount, 2); + } $model->create_time = date('Y-m-d H:i:s'); $model->type = 'out'; $model->title = $this->getTitle($category, $amount); diff --git a/app/common/logic/CashFlowLogic.php b/app/common/logic/CashFlowLogic.php index 9a1d06004..4f0a39bdd 100644 --- a/app/common/logic/CashFlowLogic.php +++ b/app/common/logic/CashFlowLogic.php @@ -2,6 +2,7 @@ namespace app\common\logic; +use app\common\enum\YesNoEnum; use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; class CashFlowLogic extends BaseLogic @@ -13,6 +14,7 @@ class CashFlowLogic extends BaseLogic $model->store_id = $storeId; $model->cash_price = $amount; $model->receivable = $amount; + $model->status = YesNoEnum::YES;//收银台收了默认算完成了 $model->save(); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5cbe5aebe..a7aa59456 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -2,6 +2,7 @@ namespace app\common\logic; +use app\api\logic\order\OrderLogic; use app\common\enum\OrderEnum; use app\common\enum\PayEnum; use app\common\enum\user\UserShipEnum; @@ -10,10 +11,13 @@ use app\common\model\finance\PayNotifyLog; use app\common\model\pay\PayNotify; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\system_store\SystemStore; use app\common\model\user\User; +use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; use app\common\model\user\UserShip; +use app\common\model\user_sign\UserSign; use app\common\service\PushService; use support\Log; use think\facade\Db; @@ -27,11 +31,11 @@ use Webman\RedisQueue\Redis; class PayNotifyLogic extends BaseLogic { - public static function handle($action, $orderSn, $extra = []) + public static function handle($action, $orderSn, $extra = [], $type = 'wechat') { - // Db::startTrans(); - // try { - if ($action != 'cash_pay' && $action != 'balancePay') { + Db::startTrans(); + try { + if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds') { $payNotifyLogLogic = new PayNotifyLogLogic(); if ($action == 'refund') { $payNotifyLogLogic->insert($action, $extra, PayNotifyLog::TYPE_REFUND); @@ -39,14 +43,14 @@ class PayNotifyLogic extends BaseLogic $payNotifyLogLogic->insert($action, $extra); } } - self::$action($orderSn, $extra); - // Db::commit(); + self::$action($orderSn, $extra, $type); + Db::commit(); return true; - // } catch (\Exception $e) { - // Db::rollback(); - // Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile()); - // throw new \Exception($e->getMessage()); - // } + } catch (\Exception $e) { + Db::rollback(); + Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile()); + throw new \Exception($e->getMessage()); + } } /** @@ -75,11 +79,64 @@ class PayNotifyLogic extends BaseLogic $user->now_money = bcsub($user['now_money'], $order['pay_price'], 2); $user->save(); + if ($order['spread_uid'] > 0 && $user['user_ship'] == 1) { + $oldUser = User::where('id',$order['spread_uid'])->value('purchase_funds'); + if ($oldUser < $order['pay_price']) { + $order['pay_price'] = $oldUser; + } + } $capitalFlowDao = new CapitalFlowLogic($user); - $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price']); - self::afterPay($order); - Redis::send('push-platform-print', ['id' => $order['id']], 60); + $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']); + // self::afterPay($order); + // Redis::send('push-platform-print', ['id' => $order['id']], 60); + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + } + + /** + * 采购款支付 + * @param $orderSn + * @param $extra + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function purchase_funds($orderSn, $extra = []) + { + $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); + $user = User::where('id', $order['uid'])->find(); + if ($user['purchase_funds'] < $order['pay_price']) { + throw new \Exception('采购款不足'); + } + $order->money = $order['pay_price']; + $order->paid = 1; + $order->pay_time = time(); + if (!$order->save()) { + throw new \Exception('订单保存出错'); + } + // 减去采购款 + $user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2); + $user->save(); + + $capitalFlowDao = new CapitalFlowLogic($user); + $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $order['id'], $order['pay_price'],'',1,$order['store_id']); + if ($user['user_ship'] == 1) { + self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS); + } + + if($extra && $extra['store_id']){ + $params = [ + 'verify_code'=>$order['verify_code'], + 'store_id'=>$extra['store_id'], + 'staff_id'=>$extra['staff_id'] + ]; + OrderLogic::writeOff($params); + } + + // self::afterPay($order); + // Redis::send('push-platform-print', ['id' => $order['id']], 60); + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } /** @@ -105,29 +162,25 @@ class PayNotifyLogic extends BaseLogic $extra['transaction_id'] = time(); } $user = User::where('id', $order['uid'])->find(); - if ($order->pay_type == 9) { + if ($order->pay_type == OrderEnum::CASHIER_ORDER_PAY || $order->pay_type == OrderEnum::CASHIER_ORDER_ALI_PAY) { //收银台支付 $order->status = 2; + self::afterPay($order, $extra['transaction_id']); } else { $capitalFlowDao = new CapitalFlowLogic($user); //微信支付和用户余额无关 - $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1); - } - self::afterPay($order, $extra['transaction_id']); - - //活动期间消费 - $check = DictType::where('type', 'activities')->find(); - if (isset($check) && $check['status'] == 1 && in_array($order->pay_type,[9,17])==false && $user['user_ship'] == 0) { - self::dealChange($order['uid']); + $capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1,$order['store_id']); } - if ($order->pay_type == 9) { - $extra['create_time'] = $order['create_time']; - PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); - } else { - PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); - } - Redis::send('push-platform-print', ['id' => $order['id']]); + + // if ($order->pay_type == 9) { + // $extra['create_time'] = $order['create_time']; + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); + // Redis::send('push-platform-print', ['id' => $order['id']]); + // } + // else { + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); + // } if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5); } @@ -155,13 +208,17 @@ class PayNotifyLogic extends BaseLogic /** * 充值 */ - public static function recharge($orderSn, $extra = []) + public static function recharge($orderSn, $extra = [], $type = 'wechat') { $order = UserRecharge::where('order_id', $orderSn)->findOrEmpty(); if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { return true; } - $price = bcdiv($extra['amount']['payer_total'], 100, 2); + if ($type == 'wechat') { + $price = bcdiv($extra['amount']['payer_total'], 100, 2); + } else { + $price = $extra['buyer_pay_amount']; + } $order->price = $price; $order->paid = 1; $order->pay_time = time(); @@ -171,19 +228,23 @@ class PayNotifyLogic extends BaseLogic //用户的财务add $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price); - + if ($user->isEmpty()) { return true; } bcscale(2); - $user->now_money = bcadd($user->now_money, $price, 2); + // $user->now_money = bcadd($user->now_money, $price, 2);//v.1 + //更新等级 + if ($price >= 0.01) { + $user->user_ship = 1; //v.1 + } + $user->purchase_funds = bcadd($user->purchase_funds, $price, 2); $user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2); $user->save(); - //更新等级 - self::dealLevel($uid, $user->total_recharge_amount); - if (!empty($extra['payer']['openid']) ) { - Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'],'logistics_type'=>3], 5); + + if (!empty($extra['payer']['openid'])) { + Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 5); } return true; } @@ -204,9 +265,10 @@ class PayNotifyLogic extends BaseLogic if (!$order->save()) { throw new \Exception('订单保存出错'); } + self::afterPay($order); $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); - Redis::send('push-platform-print', ['id' => $order['id']]); + // Redis::send('push-platform-print', ['id' => $order['id']]); } /** @@ -234,16 +296,17 @@ class PayNotifyLogic extends BaseLogic } if ($order->pay_type == 9) { $order->status = 2; + self::afterPay($order); } - self::afterPay($order); - if ($order->pay_type == 9) { - $extra['create_time'] = $order['create_time']; - PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); - } else { - PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - } - Redis::send('push-platform-print', ['id' => $order['id']]); + // if ($order->pay_type == 9) { + // $extra['create_time'] = $order['create_time']; + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); + // Redis::send('push-platform-print', ['id' => $order['id']]); + // } + // else { + // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + // } return true; } @@ -255,56 +318,171 @@ class PayNotifyLogic extends BaseLogic public static function afterPay($order, $transaction_id = 0) { $financeLogic = new StoreFinanceFlowLogic(); - $financeLogic->order = $order; - $financeLogic->user = ['uid' => $order['uid']]; - if ($order->pay_type != 9 || $order->pay_type != 10) { - $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY); //用户单入账 - //商户应该获得的钱 每个商品的price-ot_price 利润 - if (isset($order->profit) && $order->profit > 0) { - //手续费 - $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); - $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_COMMITION, $order['store_id']); //手续费入账 - - $financeLogic->out($transaction_id, $order['profit'], OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0); //商户获得的 - //冻结金额的 - $frozen = bcsub($order->profit, $fees, 2); - //缴纳齐全了就加商户没有就加到平台 - $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); - $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //剩余额度 - if ($deposit > 0 && $frozen > 0) { - $amount = min($deposit, $frozen); - $financeLogic->in($transaction_id, $amount, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id']); + $user_sing = new UserSign(); + $vipFen = 0; + if ($order['uid'] > 0) { + // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 + //用户下单该用户等级为1得时候才处理冻结金额 + $user = User::where('id', $order['uid'])->find(); + //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) + if ($order['spread_uid'] > 0) { + $oldUser = User::where('id',$order['spread_uid'])->field('purchase_funds,user_ship')->find(); + if ($oldUser && $oldUser['user_ship'] == 1){ + if ($oldUser['purchase_funds'] < $order['pay_price']) { + $vipFen = $oldUser['purchase_funds']; + } } } - $financeLogic->save(); - } - } + elseif ($user['user_ship'] == 1){ + $vipFrozenAmount = self::dealFrozenPrice($order['id']); + //为1的时候要去减活动价 +// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2); +// d($final_price,$vipFrozenAmount); + $order['pay_price'] = bcsub($order['pay_price'],$vipFrozenAmount,2); + self::dealVipAmount($order, $order['pay_type']); + } - //等级处理 - public static function dealLevel($uid, $total_money) - { - $userShip = UserShip::where('limit', '<=', $total_money) - ->field('id,title,limit') - ->order('limit', 'desc') - ->find(); - $info = User::where('id', $uid)->findOrEmpty(); - if ($info && $userShip) { - if ($info->user_ship != $userShip['id']) { - $info->user_ship = $userShip['id']; - $info->save(); + $user_number = bcmul($order['pay_price'], '0.10', 2); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '购买商品获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $user_number, + ]; + $user_sing->save($sing); + User::where('id', $order['uid'])->inc('integral', $user_number)->update(); + } + + + $financeLogic->order = $order; + $financeLogic->user = ['uid' => $order['uid']]; + // if ($order->pay_type != 9 || $order->pay_type != 10) { + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 + $count_frees = 0; + + //平台手续费 + $fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2); + $count_frees = bcadd($count_frees, $fees, 2); + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 + } + // $frozen = bcsub($order->profit, $fees, 2); + //缴纳齐全了就加商户没有就加到平台 + $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); + $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 + $store_profit = bcdiv(bcmul($order['pay_price'], '0.05', 2), 1, 2); + $count_frees = bcadd($count_frees, $store_profit, 2); + if ($deposit > 0) { + if ($deposit > $store_profit) { + if ($store_profit > 0) { + $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + } else { + $money = bcsub($store_profit, $deposit, 2); + if ($deposit > 0) { + $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + if ($money) { + SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update(); + $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + } + } + } else { + if ($store_profit > 0) { + SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update(); + $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 } } - return true; - } + // if ($order['is_vip'] >= 1) { + if ($order['spread_uid'] > 0) { + $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; + if($vipFen){ + $fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2); + }else{ + $fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2); + } + $count_frees = bcadd($count_frees, $fees, 2); + if ($fees > 0) { + User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update(); + $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + } + $fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2); + $count_frees = bcadd($count_frees, bcmul($fees, 3, 2), 2); + $village_uid = 0; + $brigade_uid = 0; + //查询用户对应的村长和队长 + if ($order['uid'] > 0) { + $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); + if ($address) { + $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); + if ($arr1) { + $uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); + if ($uid) { + User::where('id', $uid)->inc('integral', $fees)->update(); + $village_uid=$uid; + } + } + $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); + if ($arr2) { + $uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); + if ($uid) { + User::where('id', $uid)->inc('integral', $fees)->update(); + $brigade_uid=$uid; + } + } + } + } + if ($fees > 0) { + //村长获得 + $sing = []; - //处理活动期间直接改用户的等级 - public static function dealChange($uid) - { - User::where('id', $uid)->update(['user_ship' => UserShipEnum::LEVEL_ONE]); - return true; + $sing[] = [ + 'uid' => $village_uid, + 'order_id' => $order['order_id'], + 'title' => '村长订单获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $fees, + ]; + $sing[] = [ + 'uid' => $brigade_uid, + 'order_id' => $order['order_id'], + 'title' => '队长订单获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $fees, + ]; + // if ($village_uid > 0) { + // $financeLogic->other_arr['vip_uid'] = $village_uid; + // } + // $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + // $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //队长获得 + // if ($brigade_uid > 0) { + // $financeLogic->other_arr['vip_uid'] = $brigade_uid; + // } + // $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + // $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $user_sing->saveAll($sing); + //其他获得 + $financeLogic->other_arr['vip_uid'] = 0; + $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + // } + $fees = bcsub($order['pay_price'], $count_frees, 2); + //供应链订单获得 + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + // } + $financeLogic->save(); + // } } - /** * 回调日志 * @param $order @@ -324,4 +502,54 @@ class PayNotifyLogic extends BaseLogic ]; PayNotify::create($data); } + + /** + * 冻结金额 + * @param $oid + * @return int|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + + public static function dealFrozenPrice($oid) + { + $detail = StoreOrderCartInfo::where('oid',$oid)->select()->toArray(); + $total_vip = 0; + foreach ($detail as $value){ + $total_vip +=$value['cart_info']['vip_frozen_price']; + } + return $total_vip; + } + + + /** + * 处理用户为vip1时得冻结资金 + * @param $order + * @param $pay_type + * @param $transaction_id + * @return true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function dealVipAmount($order,$pay_type =1,$transaction_id = 0) + { + $total_vip = self::dealFrozenPrice($order['id']); + $data=[ + 'order_id' => $order['id'], + 'transaction_id' => $transaction_id??0, + 'order_sn' =>$order['order_id'], + 'user_id' => $order['uid'], + 'number' => $total_vip, + 'pay_type' => $pay_type??1, + 'status' => 0, + 'store_id' => $order['store_id'], + 'staff_id' => $order['staff_id'], + 'create_time'=>time() + ]; + Db::name('vip_flow')->insert($data); + return true; + } + } diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 98b0c7fb4..51df608a2 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -74,7 +74,7 @@ class PaymentLogic extends BaseLogic /** * 微信条码支付 */ - public static function codepay($auth_code, $order) + public static function codepay($auth_code, $order,$description='条码商品') { $pattern = '/^(10|11|12|13|14|15)\d{16}$/'; @@ -83,7 +83,7 @@ class PaymentLogic extends BaseLogic return false; } $order = [ - 'description' => '条码商品', + 'description' => $description, 'out_trade_no' => (string)$order['order_id'], 'payer' => [ 'auth_code' => (string)$auth_code diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index c1489abb8..ac7d66070 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -11,6 +11,7 @@ class StoreFinanceFlowLogic extends BaseLogic public $order; public $user; + public $other_arr; public $index = 0; public $financeSn; public $list = []; @@ -24,9 +25,9 @@ class StoreFinanceFlowLogic extends BaseLogic * @param $staffId * @param $status */ - public function out($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1) + public function out($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7) { - $this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id); + $this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id,$pay_type); } /** @@ -38,31 +39,49 @@ class StoreFinanceFlowLogic extends BaseLogic * @param $staffId * @param $status */ - public function in($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1) + public function in($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7) { - $this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id); + $this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id,$pay_type); } - public function setData($number, $financialType, $pm, $storeId, $staffId, $status,$transaction_id) + public function setData($number, $financialType, $pm, $storeId, $staffId, $status,$transaction_id,$pay_type=7) { if (empty($this->financeSn)) { $this->financeSn = $this->getSn(); } - $this->list[] = [ + $data=[ 'order_id' => $this->order['id'], 'transaction_id' => $transaction_id, 'order_sn' => $this->order['order_id'], 'user_id' => $this->user['uid'], + 'other_uid' => $this->other_arr['vip_uid']??0, 'financial_type' => $financialType, 'financial_pm' => $pm, 'number' => $number, - 'pay_type' => PayEnum::WECHAT_PAY_MINI, - 'status' => $status, + 'pay_type' => $pay_type, + 'status' => 0, 'store_id' => $storeId !== '' ? $storeId : $this->order['store_id'], 'staff_id' => $staffId !== '' ? $staffId : $this->order['staff_id'], 'financial_record_sn' => $this->financeSn . ($this->index++), 'create_time'=>time() ]; + switch($financialType){ + case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户 + case OrderEnum::ORDER_MARGIN: // 商户保证金 + $data['type'] =OrderEnum::MERCHANT; + break; + case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台 + case OrderEnum::ORDER_HANDLING_FEES: // 手续费 + $data['type'] =OrderEnum::PLATFORM; + break; + case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链 + $data['type'] =OrderEnum::SUPPLIER; + break; + default: // 用户 + $data['type'] =OrderEnum::USER; + break; + } + $this->list[] = $data; } public function save() diff --git a/app/common/logic/VipLogic.php b/app/common/logic/VipLogic.php new file mode 100644 index 000000000..d47b95051 --- /dev/null +++ b/app/common/logic/VipLogic.php @@ -0,0 +1,183 @@ +select()->toArray(); + $total_vip = 0; + foreach ($detail as $value){ + $total_vip +=$value['cart_info']['vip_frozen_price']; + } + $data=[ + 'order_id' => $order['id'], + 'transaction_id' => $transaction_id??0, + 'order_sn' =>$order['order_id'], + 'user_id' => $order['uid'], +// 'financial_type' => $financialType, + 'number' => $total_vip, + 'pay_type' => $pay_type??1, + 'status' => 0, + 'store_id' => $order['store_id'], + 'staff_id' => $order['staff_id'], + 'create_time'=>time() + ]; + Db::name('vip_flow')->insert($data); + //todo 限制执行 +// self::afterPay($order,$transaction_id,$total_vip); + return true; + } + + + + + + + + public static function afterPay($order, $transaction_id = 0,$Vipmoney=0) + { + $financeLogic = new StoreFinanceFlowLogic(); + $financeLogic->order = $order; + $financeLogic->user = ['uid' => $order['uid']]; + + $financeLogic->in($transaction_id, $Vipmoney, OrderEnum::USER_ORDER_PAY); //用户订单支付 + $count_frees = 0; + + //平台手续费 + $fees = bcdiv(bcmul($Vipmoney, '0.02', 2), 1, 2); + $count_frees = bcadd($count_frees, $fees, 2); + if ($fees > 0) { + $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 + } + // $frozen = bcsub($order->profit, $fees, 2); + //缴纳齐全了就加商户没有就加到平台 + $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); + $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 + $store_profit = bcdiv(bcmul($Vipmoney, '0.05', 2), 1, 2); + $count_frees = bcadd($count_frees, $store_profit, 2); + if ($deposit > 0) { + if ($deposit > $store_profit) { + if ($store_profit > 0) { + $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + } else { + $money = bcsub($store_profit, $deposit, 2); + if ($deposit > 0) { + $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + if ($money) { + SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update(); + $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + } + } + } else { + if ($store_profit > 0) { + SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update(); + $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费 + } + } + + if ($order['is_vip'] >= 1) { + if ($order['spread_uid'] > 0) { + $financeLogic->other_arr['vip_uid'] = $order['spread_uid']; + $fees = bcdiv(bcmul($Vipmoney, '0.08', 2), 1, 2); + $count_frees = bcadd($count_frees, $fees, 2); + if ($fees > 0) { + User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update(); + $financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //vip订单获得 + $financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + } + $fees = bcdiv(bcmul($Vipmoney, '0.01', 2), 1, 2); + $count_frees = bcadd($count_frees, bcmul($fees, 3, 2), 2); + $village_uid = 0; + $brigade_uid = 0; + //查询用户对应的村长和队长 + if ($order['uid'] > 0) { + $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); + if ($address) { + $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); + if ($arr1) { + $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id'); + if($village_uid){ + User::where('id', $village_uid)->inc('integral', $fees)->update(); + } + } + $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); + if ($arr2) { + $brigade_uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id'); + if($brigade_uid){ + User::where('id', $brigade_uid)->inc('integral', $fees)->update(); + } + } + } + } + if ($fees > 0) { + //村长获得 + $sing=[]; + $user_sing=new UserSign(); + + $sing[]=[ + 'uid'=>$village_uid, + 'title'=>'村长订单获得兑换券', + 'store_id'=>$order['store_id'], + 'number'=>$fees, + ]; + $sing[]=[ + 'uid'=>$brigade_uid, + 'title'=>'队长订单获得兑换券', + 'store_id'=>$order['store_id'], + 'number'=>$fees, + ]; + // if ($village_uid > 0) { + // $financeLogic->other_arr['vip_uid'] = $village_uid; + // } + // $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + // $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + //队长获得 + // if ($brigade_uid > 0) { + // $financeLogic->other_arr['vip_uid'] = $brigade_uid; + // } + // $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + // $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + $user_sing->saveAll($sing); + //其他获得 + $financeLogic->other_arr['vip_uid'] = 0; + $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + } + } + + $fees=bcsub($Vipmoney, $count_frees, 2); + //供应链订单获得 + if ($fees > 0) { + $financeLogic->in($transaction_id,$fees , OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + + } + $financeLogic->save(); + + } + + +} \ No newline at end of file diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index c1111141a..b5e6bf98c 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -4,6 +4,7 @@ namespace app\common\logic\store_order; use app\common\enum\OrderEnum; use app\common\enum\PayEnum; +use app\common\enum\UserShipEnum; use app\common\logic\BaseLogic; use app\common\enum\YesNoEnum; use app\common\model\dict\DictType; @@ -12,7 +13,9 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\user\User; use app\common\service\pay\PayService; +use app\common\service\SmsService; use Exception; use support\Cache; use think\facade\Db; @@ -23,6 +26,7 @@ class StoreOrderLogic extends BaseLogic public static $pay_price; public static $cost; public static $profit; + public static $store_price;//门店零售价 public static $activity_price; /** * @notes 获取购物车商品信息 @@ -44,27 +48,47 @@ class StoreOrderLogic extends BaseLogic self::$cost = 0; //成本 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 - + self::$store_price = 0; //门店零售价 /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } unset($cart_select[$k]['id']); $cart_select[$k]['price'] = $find['price']; + $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 - + $cart_select[$k]['vip'] = 0; + if ($user && $user['user_ship'] == 1) { + //更新 会员为1的时候原价减去会员价 + $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); + $cart_select[$k]['deduction_price'] =$deduction_price_count; + self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + $cart_select[$k]['vip'] =1; + } + + if ($user && $user['user_ship'] == 4) { + //更新 为4商户的时候减去商户价格 + $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + $cart_select[$k]['deduction_price'] =$deduction_price_count; + self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + } //利润 - $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润 - $cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本 + // $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润 + $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 + $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2)??0; //门店零售价 + $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2)??0; //vip售价 $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; + //vip1待返回金额 + + $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'],2); $cartInfo = $cart_select[$k]; $cartInfo['name'] = $find['store_name']; $cartInfo['image'] = $find['image']; @@ -73,7 +97,7 @@ class StoreOrderLogic extends BaseLogic // if ($vipPrice) { // $cartInfo['price'] = $vipPrice; // } - $cartInfo['vip_price'] = 0;//$cart_select[$k]['total'] - $vipPrice ?? 0; + //$cart_select[$k]['total'] - $vipPrice ?? 0; $cart_select[$k]['cart_info'] = json_encode($cartInfo); $cart_select[$k]['branch_product_id'] = $find['branch_product_id']; //理论上每笔都是拆分了 @@ -84,10 +108,17 @@ class StoreOrderLogic extends BaseLogic self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 2); - self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); + self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 + // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } - //TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级 - $pay_price = self::$pay_price; + if ($user && $user['user_ship'] == 1) { + $pay_price = self::$pay_price; + $activity_string = ''; + }else{ + $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 + $activity_string = '减免'; + } + $vipPrice = 0; //成本价 收益 $order = [ @@ -95,7 +126,7 @@ class StoreOrderLogic extends BaseLogic 'order_id' =>$params['order_id'] ?? getNewOrderId('PF'), 'total_price' => self::$total_price, //总价 'cost' => self::$cost,//成本价 - 'profit' => self::$profit,//利润 + 'profit' => 0,//利润 'pay_price' => $pay_price,//后期可能有降价抵扣 'vip_price' => $vipPrice, 'total_num' => count($cart_select),//总数 @@ -104,14 +135,17 @@ class StoreOrderLogic extends BaseLogic 'cart_id' => implode(',', $cartId), 'store_id' => $params['store_id'] ?? 0, 'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提 - 'activity' =>'减免', - 'activity_price' =>self::$activity_price, + 'activity' =>$activity_string, + 'activity_price' =>self::$activity_price,//活动优惠价 'activities' => self::$activity_price>0?1:0, 'default_delivery'=>1, 'original_price'=>self::$total_price, - 'deduction_price' => self::$activity_price - + 'deduction_price' => self::$activity_price,//抵扣金额 ]; + if($user && $user['user_ship']!=4){ + $order['is_vip']=1; + } + } catch (\Exception $e) { self::setError($e->getMessage()); return false; @@ -135,7 +169,7 @@ class StoreOrderLogic extends BaseLogic return false; } $_order = $orderInfo['order']; - $_order['deduction_price'] = 0; + $_order['uid'] = $user['id']??0; $_order['pay_type'] = $orderInfo['order']['pay_type']; $_order['verify_code'] = $verify_code; if (isset($params['reservation_time'])) { @@ -148,7 +182,7 @@ class StoreOrderLogic extends BaseLogic $goods_list = $orderInfo['cart_list']; foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order['id']; - $goods_list[$k]['uid'] = 0; + $goods_list[$k]['uid'] = $user['id']??0; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id $stock = StoreBranchProduct::where('id',$v['branch_product_id'])->value('stock'); @@ -190,6 +224,12 @@ class StoreOrderLogic extends BaseLogic $order['refund_type_name'] = OrderEnum::refundType($order['refund_type']) ?? ''; $order['pay_type_name'] =PayEnum::getPaySceneDesc($order['pay_type']) ?? ''; + $detail =StoreOrderCartInfo::where('oid',$order['id'])->find()->toArray(); + $vip =0; + if(isset($detail['cart_info']['vip']) && $detail['cart_info']['vip'] == 1){ + $vip = 1; + } + $order['vip'] = $vip; return $order->toArray(); } @@ -302,4 +342,30 @@ class StoreOrderLogic extends BaseLogic } + + public function dealSendSms($param,$type = 0) + { + $code = generateRandomCode(); + $phone = User::where('id',$param['uid'])->value('mobile'); + if(empty($phone)){ + throw new \Exception('用户未设置手机号'); + } + $template = getenv('SMS_TEMPLATE'); + if($type){ + $check =(new SmsService())->client($phone,$template,$code,1); + }else{ + $check =(new SmsService())->client($phone,$template,$code); + } + + if($check){ + $remark = $param['uid'].'_smsPay'; + Cache::set($remark,$code,5*60); + return true; + }else{ + return false; + } + + } + + } diff --git a/app/common/model/financial_transfers/FinancialTransfers.php b/app/common/model/financial_transfers/FinancialTransfers.php new file mode 100644 index 000000000..dede4d2f9 --- /dev/null +++ b/app/common/model/financial_transfers/FinancialTransfers.php @@ -0,0 +1,45 @@ +hasOne(SystemStore::class, 'id','store_id') + ->bind(['store_name'=>'name', 'store_phone'=>'phone','store_detailed_address'=>'detailed_address','store_simple_address'=>'address','store_bank'=>'bank','store_bank_code'=>'bank_code','store_bank_address'=>'bank_address','store_realName'=>'realname']); + } + + + public function staff() + { + return $this->hasOne(SystemStoreStaff::class, 'id', 'store_staff_id')->bind(['staff_name']); + } + + + public function admin() + { + return $this->hasOne(Admin::class, 'id','admin_id') + ->bind(['admin_name'=>'name']); + + } + +} \ No newline at end of file diff --git a/app/common/model/store_branch_product_exchange/StoreBranchProductExchange.php b/app/common/model/store_branch_product_exchange/StoreBranchProductExchange.php new file mode 100644 index 000000000..24ad4cbc3 --- /dev/null +++ b/app/common/model/store_branch_product_exchange/StoreBranchProductExchange.php @@ -0,0 +1,24 @@ +export == ExportEnum::INFO && $lists instanceof ListsExcelInterface) { @@ -109,6 +112,12 @@ class JsonService 'page_no' => $lists->pageNo, 'page_size' => $lists->pageSize, ]; + $store_id = DictType::where('type','store')->value('remark')??5; + if($remark){ + $data['store'] = StoreLogic::search([ + 'id' => $store_id + ]); + } $data['extend'] = []; if ($lists instanceof ListsExtendInterface) { $data['extend'] = $lists->extend(); diff --git a/app/common/service/SmsService.php b/app/common/service/SmsService.php new file mode 100644 index 000000000..af0d86ba0 --- /dev/null +++ b/app/common/service/SmsService.php @@ -0,0 +1,82 @@ + 5.0, + + // 默认发送配置 + 'default' => [ + // 网关调用策略,默认:顺序调用 + 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, + + // 默认可用的发送网关 + 'gateways' => [ + 'yunpian', 'aliyun', + ], + ], + // 可用的网关配置 + 'gateways' => [ + 'errorlog' => [ + 'file' => runtime_path() . '/logs/' . date('Ymd') . '/easy-sms.log', + ], + 'aliyun' => [ + 'access_key_id' => 'LTAI5t7mhH3ij2cNWs1zhPmv', + 'access_key_secret' => 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu', + 'sign_name' => '里海科技', + ], + //... + ], + ]; + $this->config=$config; + + } + + public function client($phone,$template,$code,$type = 0) + { + try{ + $easySms = new EasySms($this->config); + + if($type){//预留发送到货短信 + $res = $easySms->send($phone, [ + 'content' => '您的验证码为: '.$code, + 'template' => $template, + 'data' => [ + 'code' => $code + ], + ]); + + }else{ + $res = $easySms->send($phone, [ + 'content' => '您的验证码为: '.$code, + 'template' => $template, + 'data' => [ + 'code' => $code + ], + ]); + } + + if($res && $res['aliyun']['status'] == 'success'){ + return true; + }else{ + return false; + } + }catch(NoGatewayAvailableException $e){ + throw new BusinessException($e->getMessage()); + } + + } +} diff --git a/app/functions.php b/app/functions.php index 2328a71b2..0aacbdc0e 100644 --- a/app/functions.php +++ b/app/functions.php @@ -405,6 +405,20 @@ if (!function_exists('haversineDistance')) { } } +/** + * 随机验证码 + */ +if (!function_exists('generateRandomCode')) { + function generateRandomCode($length = 4) { + $code = ''; + for ($i = 0; $i < $length; $i++) { + $code .= random_int(0, 9); + } + return $code; + } +} + + if (!function_exists('reset_index')) { /** * 重置数组索引 diff --git a/app/queue/redis/CodePaySend.php b/app/queue/redis/CodePaySend.php index c3b33c55b..d944b9eec 100644 --- a/app/queue/redis/CodePaySend.php +++ b/app/queue/redis/CodePaySend.php @@ -30,7 +30,11 @@ class CodePaySend implements Consumer ]; $res = $pay->wechat->query($order); if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { - PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + if(isset($data['pay_type']) && $data['pay_type']=='recharge'){ + PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + }else{ + PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + } }else{ throw new BusinessException('订单支付中', 200); } diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index a96e88ad4..d2cb8e0e4 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -5,6 +5,7 @@ namespace app\queue\redis; use app\admin\logic\store_product\StoreProductLogic; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue; +use app\common\model\store_branch_product_exchange\StoreBranchProductExchange; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\model\system_store_storage\SystemStoreStorage; @@ -28,9 +29,18 @@ class StoreStorageSend implements Consumer { $product_arr = $data['product_arr']; $store_id = $data['store_id']; + $stock_type = $data['stock_type']; $admin_id = $data['admin_id']; - Log::error('StoreStorageSend: ' . json_encode($data)); $find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray(); + if($stock_type == 1){ + $this->ordinary($product_arr,$store_id,$admin_id,$find); + }elseif($stock_type == 2){ + $this->exchange($product_arr,$store_id,$admin_id,$find); + } + } + + /**普通 */ + public function ordinary($product_arr,$store_id,$admin_id,$find){ $store_find = StoreBranchProduct::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray(); if ($find && !$store_find) { $attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty(); @@ -45,9 +55,12 @@ class StoreStorageSend implements Consumer 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], 'price' => $find['price'], +// 'cost' => $find['cost'], //v1.0 'cost' => $find['cost'], + 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'], 'unit' => $find['unit'], + 'batch' => $find['batch'], 'store_id' => $store_id, 'sales' => 0, 'stock' => 0, @@ -65,7 +78,7 @@ class StoreStorageSend implements Consumer if ($product_arr['stock'] > 0) { $this->storage($find, $store_id, $admin_id, $product_arr); } - StoreProductLogic::updateGoodsclass($find['cate_id']); + StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id); Db::commit(); return true; } catch (\Exception $e) { @@ -77,7 +90,7 @@ class StoreStorageSend implements Consumer Db::startTrans(); try { if ($product_arr['stock'] > 0) { - $this->storage($find, $store_id, $admin_id, $product_arr); + $this->storage($find, $store_id, $admin_id, $product_arr,1); } Db::commit(); return true; @@ -89,13 +102,64 @@ class StoreStorageSend implements Consumer } } - public function storage($find, $store_id, $admin_id, $product_arr) + /**兑换 */ + public function exchange($product_arr,$store_id,$admin_id,$find){ + $store_find = StoreBranchProductExchange::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray(); + if ($find && !$store_find) { + Db::startTrans(); + try { + $product = [ + 'product_id' => $find['id'], + 'image' => $find['image'], + 'store_name' => $find['store_name'], + 'store_info' => $find['store_info'], + 'keyword' => $find['keyword'], + 'bar_code' => $find['bar_code'], + 'cate_id' => $find['cate_id'], + 'price' => $find['price'], + 'cost' => $find['cost'], + 'purchase' => $find['purchase'], + 'vip_price' => $find['vip_price'], + 'unit' => $find['unit'], + 'store_id' => $store_id, + 'sales' => 0, + 'stock' => 0, + ]; + StoreBranchProductExchange::create($product); + if ($product_arr['stock'] > 0) { + $this->storage($find, $store_id, $admin_id, $product_arr); + } + // StoreProductLogic::updateGoodsclass($find['cate_id'],$store_id); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile()); + return false; + } + } else { + Db::startTrans(); + try { + if ($product_arr['stock'] > 0) { + $this->storage($find, $store_id, $admin_id, $product_arr,2); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile()); + return false; + } + } + } + public function storage($find, $store_id, $admin_id, $product_arr,$stock_type=1) { $storage = [ 'product_id' => $product_arr['id'], 'store_id' => $store_id, 'nums' => $product_arr['stock'], 'admin_id' => $admin_id, + 'type' => $stock_type, ]; if ($find['stock'] < $product_arr['stock']) { $storage['status'] = -1; diff --git a/app/statistics/controller/IndexController.php b/app/statistics/controller/IndexController.php new file mode 100644 index 000000000..040fc8193 --- /dev/null +++ b/app/statistics/controller/IndexController.php @@ -0,0 +1,107 @@ +fail(OrderLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', ['dayPayPrice' => $res,'title'=>'喻寺镇农(特)产品交易大数据']); + } + public function user() + { + $today = strtotime(date('Y-m-d')); + $dates=[]; + // 循环输出前5天的日期 + for ($i = 0; $i <= 4; $i++) { + // 计算前第$i天的日期时间戳 + $timestamp = $today - ($i * 86400); // 86400秒等于1天 + + // 将时间戳格式化为日期 + $date = date('Y-m-d', $timestamp); + $dates[]=$date; + } + $res = UserLogic::userCount(5,$dates); + if (UserLogic::hasError()) { + return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } + + /** + * 中间商品统计 + */ + public function product_count() + { + $res = ProductLogic::Count(5); + if (ProductLogic::hasError()) { + return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } + /** + * 订单统计 + */ + public function order_user_num_count() + { + $res = OrderLogic::Count(5); + if (ProductLogic::hasError()) { + return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } + /** + * 商品销量排行榜统计 + */ + public function sales_ranking() + { + $res = ProductLogic::sales(5); + if (ProductLogic::hasError()) { + return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } + /** + * 成交用户数据 + */ + public function user_trade_count() + { + $dates = []; + + $today = new DateTime(); + $thirtyDaysAgo = new DateTime($today->format('Y-m-d')); + $thirtyDaysAgo->modify('-30 days'); + for ($i = 0; $i < 31; $i++) { + $date = new DateTime($thirtyDaysAgo->format('Y-m-d')); + $date->modify('+' . $i . ' days'); + $dates[] = $date->format('Y-m-d'); + } + $res = UserLogic::TradeCount(5, $dates); + if (UserLogic::hasError()) { + return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } + /** + * 当日订单金额 + */ + public function street_currday_order_count() + { + $res = OrderLogic::Currday(5); + if (ProductLogic::hasError()) { + return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 + } + return $this->success('ok', $res); + } +} diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php new file mode 100644 index 000000000..83d7054df --- /dev/null +++ b/app/statistics/logic/OrderLogic.php @@ -0,0 +1,69 @@ +whereDay('create_time')->count(); + $orderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereDay('create_time')->group('uid')->count(); + $monthOrderNum = StoreOrder::where('store_id', $store_id)->whereMonth('create_time')->count(); + $monthOrderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereMonth('create_time')->group('uid')->count(); + $data = [ + "orderNum" => $orderNum, + "monthOrderNum" => $monthOrderNum, + "monthOrderNumRate" => 0, + "orderNumRate" => 0, + "orderPayNum" => $orderPayNum, + "monthOrderPayNum" => $monthOrderPayNum, + "monthOrderPayRate" => 0, + "orderOrderPayRate" => 0 + ]; + return $data; + } + public static function Currday($store_id) + { + $date = date("Y-m-d"); + $startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳 + $endTime = strtotime($date . ' 23:59:59'); // 当天的结束时间戳 + + $interval = 4 * 60 * 60; // 4小时的秒数 + $data = []; + for ($time = $startTime; $time < $endTime; $time += $interval) { + + $endTimeSegment = $time + $interval; + $startTimeSegment = date('Y-m-d H:i:s', $time); + $yesterendTimeSegment = date('Y-m-d H:i:s', $endTimeSegment - 86400); + $endTimeSegment = date('Y-m-d H:i:s', $endTimeSegment); + $yesterstartTimeSegment = date('Y-m-d H:i:s', $time - 86400); + // 统计当前时间段的订单 + $todayAmount = StoreOrder::where('store_id', $store_id) + ->where('paid', 1) + ->whereBetween('create_time', [strtotime($startTimeSegment), strtotime($endTimeSegment)]) + ->sum('pay_price'); + $yesterdayAmount = StoreOrder::where('store_id', $store_id) + ->where('paid', 1) + ->whereBetween('create_time', [strtotime($yesterstartTimeSegment), strtotime($yesterendTimeSegment)]) + ->sum('pay_price'); + $data[] = [ + 'todayAmount' => $todayAmount, + 'yesterdayAmount' => $yesterdayAmount, + ]; + } + return $data; + } + public static function dayPayPrice($store_id) + { + $todayAmount = UserRecharge::where('store_id', $store_id) + ->where('paid', 1) + ->whereDay('create_time') + ->sum('price'); + + return $todayAmount; + } +} diff --git a/app/statistics/logic/ProductLogic.php b/app/statistics/logic/ProductLogic.php new file mode 100644 index 000000000..1b6a8aa83 --- /dev/null +++ b/app/statistics/logic/ProductLogic.php @@ -0,0 +1,51 @@ +count(); + $yestertodayProductCount=StoreBranchProduct::where('store_id',$store_id)->where('create_time', '<',strtotime(date('Y-md'))-1)->count(); + if ($yestertodayProductCount == 0 ||$todayProductCount==0) { + $weeklyProductTotalGrowthRate = 0; + } else { + $weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100; + } + + $todayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time')->count(); + $yestertodayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time', 'yesterday')->count(); + if ($yestertodayProductCount == 0 ||$todayProductCount==0) { + $weeklyNewProductTotalGrowthRate = 0; + } else { + $weeklyNewProductTotalGrowthRate = ($todayNewProductCount - $yestertodayNewProductCount) / $yestertodayNewProductCount * 100; + } + $data = [ + "totalProductCounInfo" => [ + "todayProductCount" => $todayProductCount, + "yestertodayProductCount" => $yestertodayProductCount, + "weeklyProductTotalGrowthRate" => $weeklyProductTotalGrowthRate + ], + "newProductCountInfo" => [ + "todayNewProductCount" => 0, + "yestertodayNewProductCount" => 0, + "weeklyNewProductTotalGrowthRate" => $weeklyNewProductTotalGrowthRate + ], + "merchantCountInfo" => [ + "todayMerchantCount" => 1, + "yestertodayMerchantCount" => 1, + "weeklyMerchantGrowthRate" => 0 + ] + ]; + return $data; + } + + public static function sales($store_id){ + $select=StoreBranchProduct::where('store_id',$store_id)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select(); + return $select?->toArray(); + } +} diff --git a/app/statistics/logic/UserLogic.php b/app/statistics/logic/UserLogic.php new file mode 100644 index 000000000..5c34dc12f --- /dev/null +++ b/app/statistics/logic/UserLogic.php @@ -0,0 +1,33 @@ +$date) { + $data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); + $data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->group('uid')->count(); + $data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); + } + return $data; + } + public static function TradeCount($store_id,$dates) + { + $data = []; + foreach ($dates as $k=>$date) { + $data[$k]['date']=$date; + $data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count(); + $data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count(); + $data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count(); + } + return $data; + } +} diff --git a/app/store/controller/BaseAdminController.php b/app/store/controller/BaseAdminController.php index 4ccd24c80..b35b0d401 100644 --- a/app/store/controller/BaseAdminController.php +++ b/app/store/controller/BaseAdminController.php @@ -5,9 +5,7 @@ namespace app\store\controller; use app\common\controller\BaseLikeController; -use app\common\lists\BaseDataLists; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class BaseAdminController extends BaseLikeController { diff --git a/app/store/controller/ConfigController.php b/app/store/controller/ConfigController.php index c13dec726..a8220b243 100644 --- a/app/store/controller/ConfigController.php +++ b/app/store/controller/ConfigController.php @@ -19,7 +19,6 @@ use app\admin\logic\system_store\SystemStoreLogic; use app\common\controller\Definitions; use app\common\service\ConfigService; use app\common\service\FileService; -use hg\apidoc\annotation as ApiDoc; use think\facade\Db; /** @@ -27,27 +26,26 @@ use think\facade\Db; * Class ConfigController * @package app\admin\controller */ -#[ApiDoc\title('站点配置')] class ConfigController extends BaseAdminController { public $notNeedLogin = ['getConfig', 'dict']; - #[ - ApiDoc\Title('站点配置'), - ApiDoc\url('/store/config/getConfig'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'oss_domain', 'desc' => 'oss域名', 'type' => 'string'], - ['name' => 'web_name', 'desc' => '站点名称', 'type' => 'string'], - ['name' => 'web_favicon', 'desc' => '站点图标', 'type' => 'string'], - ['name' => 'web_logo', 'desc' => '站点logo', 'type' => 'string'], - ['name' => 'login_image', 'desc' => '登录页背景图', 'type' => 'string'], - ['name' => 'copyright_config', 'desc' => '版权信息', 'type' => 'array'], - ]), - ] + // #[ + // ApiDoc\Title('站点配置'), + // ApiDoc\url('/store/config/getConfig'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'oss_domain', 'desc' => 'oss域名', 'type' => 'string'], + // ['name' => 'web_name', 'desc' => '站点名称', 'type' => 'string'], + // ['name' => 'web_favicon', 'desc' => '站点图标', 'type' => 'string'], + // ['name' => 'web_logo', 'desc' => '站点logo', 'type' => 'string'], + // ['name' => 'login_image', 'desc' => '登录页背景图', 'type' => 'string'], + // ['name' => 'copyright_config', 'desc' => '版权信息', 'type' => 'array'], + // ]), + // ] public function getConfig() { // $data = ConfigLogic::getConfig(); @@ -70,15 +68,15 @@ class ConfigController extends BaseAdminController return $this->data($data); } - #[ - ApiDoc\Title('门店配置'), - ApiDoc\url('/store/config/store'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('门店配置'), + // ApiDoc\url('/store/config/store'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function store() { $params['id'] = $this->request->adminInfo['store_id']; @@ -86,15 +84,15 @@ class ConfigController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('保存门店配置'), - ApiDoc\url('/store/config/saveStore'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('保存门店配置'), + // ApiDoc\url('/store/config/saveStore'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function saveStore() { $params = $this->request->post(); @@ -103,31 +101,31 @@ class ConfigController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('省列表'), - ApiDoc\url('/store/config/province'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('省列表'), + // ApiDoc\url('/store/config/province'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function province() { $list = Db::name('geo_province')->select()->toArray(); return $this->success('ok', $list); } - #[ - ApiDoc\Title('市列表'), - ApiDoc\url('/store/config/city'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '省份代码'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('市列表'), + // ApiDoc\url('/store/config/city'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '省份代码'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function city() { $province_code = $this->request->get('code'); @@ -135,16 +133,16 @@ class ConfigController extends BaseAdminController return $this->success('ok', $list); } - #[ - ApiDoc\Title('区列表'), - ApiDoc\url('/store/config/area'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '城市代码'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('区列表'), + // ApiDoc\url('/store/config/area'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'code', type: 'int', require: true, desc: '城市代码'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function area() { $city_code = $this->request->get('code'); diff --git a/app/store/controller/DeliveryController.php b/app/store/controller/DeliveryController.php index 0811d69f0..d0a747e67 100644 --- a/app/store/controller/DeliveryController.php +++ b/app/store/controller/DeliveryController.php @@ -5,41 +5,39 @@ namespace app\store\controller; use app\common\controller\Definitions; use app\common\lists\DeliveryServiceLists; use app\common\logic\DeliveryServiceLogic; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('配送员管理')] class DeliveryController extends BaseAdminController { - #[ - ApiDoc\Title('列表'), - ApiDoc\url('/store/delivery/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '名称/手机号'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('列表'), + // ApiDoc\url('/store/delivery/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '名称/手机号'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function lists() { return $this->dataLists(new DeliveryServiceLists()); } - #[ - ApiDoc\Title('添加'), - ApiDoc\url('/store/delivery/add'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), - ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'), - ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), - ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('添加'), + // ApiDoc\url('/store/delivery/add'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), + // ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'), + // ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), + // ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function add(DeliveryServiceLogic $logic) { $params = $this->request->post(); @@ -47,20 +45,20 @@ class DeliveryController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('编辑'), - ApiDoc\url('/store/delivery/edit'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), - ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'), - ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), - ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('编辑'), + // ApiDoc\url('/store/delivery/edit'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), + // ApiDoc\Param(name: 'nickname', type: 'string', require: true, desc: '店员名称'), + // ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), + // ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function edit(DeliveryServiceLogic $logic) { $id = $this->request->post('id'); @@ -69,16 +67,16 @@ class DeliveryController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('删除'), - ApiDoc\url('/store/delivery/delete'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('删除'), + // ApiDoc\url('/store/delivery/delete'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delete(DeliveryServiceLogic $logic) { $id = $this->request->post('id'); @@ -86,27 +84,27 @@ class DeliveryController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('详情'), - ApiDoc\url('/store/delivery/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'account', 'desc' => '账号', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], - ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], - ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], - ['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'], - ['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'], - ['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'], - ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], - ['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'], - ]), - ] + // #[ + // ApiDoc\Title('详情'), + // ApiDoc\url('/store/delivery/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'account', 'desc' => '账号', 'type' => 'string'], + // ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], + // ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], + // ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], + // ['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'], + // ['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'], + // ['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'], + // ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], + // ['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'], + // ]), + // ] public function detail(DeliveryServiceLogic $logic) { $id = $this->request->get('id'); @@ -114,16 +112,16 @@ class DeliveryController extends BaseAdminController return $this->data($data); } - #[ - ApiDoc\Title('开启/关闭'), - ApiDoc\url('/store/delivery/status'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('开启/关闭'), + // ApiDoc\url('/store/delivery/status'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function status(DeliveryServiceLogic $logic) { $id = $this->request->post('id'); diff --git a/app/store/controller/DownloadController.php b/app/store/controller/DownloadController.php index faf1a11ed..93ce7f38b 100644 --- a/app/store/controller/DownloadController.php +++ b/app/store/controller/DownloadController.php @@ -7,8 +7,7 @@ namespace app\store\controller; use app\common\cache\ExportCache; use app\common\service\JsonService; use support\Cache; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class DownloadController extends BaseAdminController { diff --git a/app/store/controller/FileController.php b/app/store/controller/FileController.php index d1a50d9a4..e531cd65b 100644 --- a/app/store/controller/FileController.php +++ b/app/store/controller/FileController.php @@ -7,33 +7,32 @@ use app\admin\lists\file\FileLists; use app\admin\logic\FileLogic; use app\admin\validate\FileValidate; use app\common\controller\Definitions; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('文件管理')] +// #[ApiDoc\title('文件管理')] class FileController extends BaseAdminController { - #[ - ApiDoc\Title('列表'), - ApiDoc\url('/store/file/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('列表'), + // ApiDoc\url('/store/file/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function lists() { return $this->dataLists(new FileLists()); } - #[ - ApiDoc\Title('移动'), - ApiDoc\url('/store/file/move'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('移动'), + // ApiDoc\url('/store/file/move'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function move() { $params = (new FileValidate())->post()->goCheck('move'); @@ -41,13 +40,13 @@ class FileController extends BaseAdminController return $this->success('移动成功', [], 1, 1); } - #[ - ApiDoc\Title('重命名'), - ApiDoc\url('/store/file/rename'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('重命名'), + // ApiDoc\url('/store/file/rename'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function rename() { $params = (new FileValidate())->post()->goCheck('rename'); @@ -55,13 +54,13 @@ class FileController extends BaseAdminController return $this->success('重命名成功', [], 1, 1); } - #[ - ApiDoc\Title('删除'), - ApiDoc\url('/store/file/delete'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('删除'), + // ApiDoc\url('/store/file/delete'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delete() { $params = (new FileValidate())->post()->goCheck('delete'); @@ -69,25 +68,25 @@ class FileController extends BaseAdminController return $this->success('删除成功', [], 1, 1); } - #[ - ApiDoc\Title('分类列表'), - ApiDoc\url('/store/file/listCate'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('分类列表'), + // ApiDoc\url('/store/file/listCate'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function listCate() { return $this->dataLists(new FileCateLists()); } - #[ - ApiDoc\Title('添加文件分类'), - ApiDoc\url('/store/file/addCate'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('添加文件分类'), + // ApiDoc\url('/store/file/addCate'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function addCate() { $params = (new FileValidate())->post()->goCheck('addCate'); @@ -95,13 +94,13 @@ class FileController extends BaseAdminController return $this->success('添加成功', [], 1, 1); } - #[ - ApiDoc\Title('编辑文件分类'), - ApiDoc\url('/store/file/editCate'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('编辑文件分类'), + // ApiDoc\url('/store/file/editCate'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function editCate() { $params = (new FileValidate())->post()->goCheck('editCate'); @@ -109,13 +108,13 @@ class FileController extends BaseAdminController return $this->success('编辑成功', [], 1, 1); } - #[ - ApiDoc\Title('删除文件分类'), - ApiDoc\url('/store/file/delCate'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('删除文件分类'), + // ApiDoc\url('/store/file/delCate'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delCate() { $params = (new FileValidate())->post()->goCheck('id'); diff --git a/app/store/controller/LoginController.php b/app/store/controller/LoginController.php index 151e52bbe..b35adac66 100644 --- a/app/store/controller/LoginController.php +++ b/app/store/controller/LoginController.php @@ -17,34 +17,33 @@ namespace app\store\controller; use app\store\logic\LoginLogic; use app\store\validate\LoginValidate; use think\facade\Cache; -use hg\apidoc\annotation as ApiDoc; /** * 管理员登录控制器 * Class LoginController * @package app\store\controller */ -#[ApiDoc\title('登入登出')] +// #[ApiDoc\title('登入登出')] class LoginController extends BaseAdminController { public $notNeedLogin = ['account']; - #[ - ApiDoc\Title('账号登录'), - ApiDoc\url('/store/login/account'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "account", type: "string", require: true, desc: "账号"), - ApiDoc\Param(name: "password", type: "string", require: true, desc: "密码"), - ApiDoc\Param(name: "terminal", type: "integer", require: true, default: 1, desc: "终端类型:1-PC,2-H5"), - ApiDoc\NotHeaders(), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'name', 'desc' => '用户名', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], - ['name' => 'token', 'desc' => 'token', 'type' => 'string'], - ['name' => 'role_name', 'desc' => '角色名称', 'type' => 'integer'], - ]), - ] + // #[ + // ApiDoc\Title('账号登录'), + // ApiDoc\url('/store/login/account'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "account", type: "string", require: true, desc: "账号"), + // ApiDoc\Param(name: "password", type: "string", require: true, desc: "密码"), + // ApiDoc\Param(name: "terminal", type: "integer", require: true, default: 1, desc: "终端类型:1-PC,2-H5"), + // ApiDoc\NotHeaders(), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'name', 'desc' => '用户名', 'type' => 'string'], + // ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], + // ['name' => 'token', 'desc' => 'token', 'type' => 'string'], + // ['name' => 'role_name', 'desc' => '角色名称', 'type' => 'integer'], + // ]), + // ] public function account() { $params = (new LoginValidate())->post()->goCheck(); @@ -52,14 +51,14 @@ class LoginController extends BaseAdminController return $this->data((new LoginLogic())->login($params)); } - #[ - ApiDoc\Title('退出登录'), - ApiDoc\url('/store/login/logout'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('退出登录'), + // ApiDoc\url('/store/login/logout'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function logout() { //退出登录情况特殊,只有成功的情况,也不需要token验证 diff --git a/app/store/controller/StaffController.php b/app/store/controller/StaffController.php index 60e604c45..8dc4d3a0b 100644 --- a/app/store/controller/StaffController.php +++ b/app/store/controller/StaffController.php @@ -5,53 +5,52 @@ namespace app\store\controller; use app\common\controller\Definitions; use app\common\lists\StoreStaffLists; use app\common\logic\SystemStoreStaffLogic; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('店员管理')] +// #[ApiDoc\title('店员管理')] class StaffController extends BaseAdminController { - #[ - ApiDoc\Title('列表'), - ApiDoc\url('/store/staff/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '店员名称/手机号/账号'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'id', 'type' => 'int'], - ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], - ['name' => 'account', 'desc' => '账号', 'type' => 'string'], - ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], - ['name' => 'is_admin', 'desc' => '是否是管理员,1是,0不是', 'type' => 'int'], - ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], - ]), - ] + // #[ + // ApiDoc\Title('列表'), + // ApiDoc\url('/store/staff/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '店员名称/手机号/账号'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'id', 'type' => 'int'], + // ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], + // ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], + // ['name' => 'account', 'desc' => '账号', 'type' => 'string'], + // ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], + // ['name' => 'is_admin', 'desc' => '是否是管理员,1是,0不是', 'type' => 'int'], + // ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], + // ]), + // ] public function lists() { return $this->dataLists(new StoreStaffLists()); } - #[ - ApiDoc\Title('添加'), - ApiDoc\url('/store/staff/add'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'), - ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'), - ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), - ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'), - ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), - ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'), - ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'), - ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'), - ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('添加'), + // ApiDoc\url('/store/staff/add'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'), + // ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'), + // ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), + // ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'), + // ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), + // ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'), + // ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'), + // ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'), + // ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function add(SystemStoreStaffLogic $staffLogic) { $params = $this->request->post(); @@ -59,24 +58,24 @@ class StaffController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('编辑'), - ApiDoc\url('/store/staff/edit'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'), - ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'), - ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), - ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'), - ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), - ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'), - ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'), - ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'), - ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('编辑'), + // ApiDoc\url('/store/staff/edit'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\Param(name: 'account', type: 'string', require: true, desc: '账号'), + // ApiDoc\Param(name: 'pwd', type: 'string', require: true, desc: '密码'), + // ApiDoc\Param(name: 'avatar', type: 'string', require: true, desc: '头像'), + // ApiDoc\Param(name: 'staff_name', type: 'string', require: true, desc: '店员名称'), + // ApiDoc\Param(name: 'phone', type: 'string', require: true, desc: '手机号'), + // ApiDoc\Param(name: 'verify_status', type: 'string', require: true, desc: '核销开关,1开启,0关闭'), + // ApiDoc\Param(name: 'order_status', type: 'string', require: true, desc: '订单状态,1开启,0关闭'), + // ApiDoc\Param(name: 'is_manager', type: 'string', require: true, desc: '是否是店长,1是,0不是'), + // ApiDoc\Param(name: 'status', type: 'string', require: true, desc: '状态,1启用,0禁用'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function edit(SystemStoreStaffLogic $staffLogic) { $id = $this->request->post('id'); @@ -85,15 +84,15 @@ class StaffController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('删除'), - ApiDoc\url('/store/staff/delete'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('删除'), + // ApiDoc\url('/store/staff/delete'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delete(SystemStoreStaffLogic $staffLogic) { $id = $this->request->post('id'); @@ -101,26 +100,26 @@ class StaffController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('详情'), - ApiDoc\url('/store/staff/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'account', 'desc' => '账号', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], - ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], - ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], - ['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'], - ['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'], - ['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'], - ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], - ['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'], - ]), - ] + // #[ + // ApiDoc\Title('详情'), + // ApiDoc\url('/store/staff/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'account', 'desc' => '账号', 'type' => 'string'], + // ['name' => 'avatar', 'desc' => '头像', 'type' => 'string'], + // ['name' => 'staff_name', 'desc' => '店员名称', 'type' => 'string'], + // ['name' => 'phone', 'desc' => '手机号', 'type' => 'string'], + // ['name' => 'verify_status', 'desc' => '核销开关,1开启,0关闭', 'type' => 'int'], + // ['name' => 'order_status', 'desc' => '订单状态,1开启,0关闭', 'type' => 'int'], + // ['name' => 'is_admin', 'desc' => '是否管理员,1是,0不是', 'type' => 'int'], + // ['name' => 'is_manager', 'desc' => '是否是店长,1是,0不是', 'type' => 'int'], + // ['name' => 'status', 'desc' => '状态,1启用,0禁用', 'type' => 'int'], + // ]), + // ] public function detail(SystemStoreStaffLogic $staffLogic) { $id = $this->request->get('id'); @@ -128,15 +127,15 @@ class StaffController extends BaseAdminController return $this->data($data); } - #[ - ApiDoc\Title('开启/关闭'), - ApiDoc\url('/store/staff/status'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('开启/关闭'), + // ApiDoc\url('/store/staff/status'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function status(SystemStoreStaffLogic $logic) { $id = $this->request->post('id'); diff --git a/app/store/controller/UploadController.php b/app/store/controller/UploadController.php index 2cfc92110..cd00fde5a 100644 --- a/app/store/controller/UploadController.php +++ b/app/store/controller/UploadController.php @@ -6,9 +6,7 @@ namespace app\store\controller; use app\common\service\UploadService; use Exception; -use Tinywan\Storage\Storage; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class UploadController extends BaseAdminController { diff --git a/app/store/controller/WorkbenchController.php b/app/store/controller/WorkbenchController.php index 267a13ecc..6617466ca 100644 --- a/app/store/controller/WorkbenchController.php +++ b/app/store/controller/WorkbenchController.php @@ -3,25 +3,26 @@ namespace app\store\controller; use app\common\controller\Definitions; +use app\common\model\dict\DictType; use app\store\lists\store_order\StoreOrderLists; use app\store\logic\WorkbenchLogic; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\Title('工作台')] +// #[ApiDoc\Title('工作台')] class WorkbenchController extends BaseAdminController { + public $notNeedLogin = ['recharge_statistics']; - #[ - ApiDoc\Title('交易统计'), - ApiDoc\url('/store/workbench/index'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('交易统计'), + // ApiDoc\url('/store/workbench/index'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function index() { $params = $this->request->get(); @@ -30,17 +31,17 @@ class WorkbenchController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('商品统计(暂时不用)'), - ApiDoc\url('/store/workbench/product'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品统计(暂时不用)'), + // ApiDoc\url('/store/workbench/product'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function product() { $params = $this->request->get(); @@ -49,17 +50,17 @@ class WorkbenchController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('配送统计'), - ApiDoc\url('/store/workbench/delivery'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('配送统计'), + // ApiDoc\url('/store/workbench/delivery'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delivery() { $params = $this->request->get(); @@ -68,18 +69,18 @@ class WorkbenchController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('配送订单统计'), - ApiDoc\url('/store/workbench/deliveryOrder'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('配送订单统计'), + // ApiDoc\url('/store/workbench/deliveryOrder'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function deliveryOrder() { $params = $this->request->get(); @@ -88,17 +89,17 @@ class WorkbenchController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('商品统计-概况'), - ApiDoc\url('/store/workbench/get_basic'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品统计-概况'), + // ApiDoc\url('/store/workbench/get_basic'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function get_basic(\app\admin\controller\WorkbenchController $workbench) { $params = $this->request->get(); @@ -106,17 +107,17 @@ class WorkbenchController extends BaseAdminController return $workbench->get_basic(); } - #[ - ApiDoc\Title('商品统计-图表'), - ApiDoc\url('/store/workbench/get_trend'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品统计-图表'), + // ApiDoc\url('/store/workbench/get_trend'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function get_trend(\app\admin\controller\WorkbenchController $workbench) { $params = $this->request->get(); @@ -124,17 +125,17 @@ class WorkbenchController extends BaseAdminController return $workbench->get_trend(); } - #[ - ApiDoc\Title('商品统计-排行'), - ApiDoc\url('/store/workbench/get_product_ranking'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品统计-排行'), + // ApiDoc\url('/store/workbench/get_product_ranking'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function get_product_ranking(\app\admin\controller\WorkbenchController $workbench) { $params = $this->request->get(); @@ -142,4 +143,31 @@ class WorkbenchController extends BaseAdminController return $workbench->get_product_ranking(); } + + // #[ + // ApiDoc\Title('收银台数据统计'), + // ApiDoc\url('/store/workbench/business_statistics'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] + public function business_statistics() + { + $params = $this->request->get(); + $params['store_id'] = $this->request->adminInfo['store_id']; + $result = WorkbenchLogic::revenueStatistics($params); + return $this->data($result); + } + + + public function recharge_statistics() + { + $params['store_id'] = DictType::where('type','store')->value('remark')??5; + $result = WorkbenchLogic::rechargeData($params); + return $this->data($result); + + } } diff --git a/app/store/controller/auth/AdminController.php b/app/store/controller/auth/AdminController.php index 50c75f336..0ec1f6cbf 100644 --- a/app/store/controller/auth/AdminController.php +++ b/app/store/controller/auth/AdminController.php @@ -19,38 +19,37 @@ use app\store\lists\auth\AdminLists; use app\store\validate\auth\AdminValidate; use app\store\logic\auth\AdminLogic; use app\store\validate\auth\editSelfValidate; -use hg\apidoc\annotation as ApiDoc; /** * 管理员控制器 * Class AdminController * @package app\store\controller\auth */ -#[ApiDoc\title('管理员信息')] +// #[ApiDoc\title('管理员信息')] class AdminController extends BaseAdminController { - #[ - ApiDoc\Title("查看管理员列表"), - ApiDoc\url('/store/auth/admin/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("查看管理员列表"), + // ApiDoc\url('/store/auth/admin/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function lists() { return $this->dataLists(new AdminLists()); } - #[ - ApiDoc\Title("添加管理员"), - ApiDoc\url('/store/auth/admin/add'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("添加管理员"), + // ApiDoc\url('/store/auth/admin/add'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function add() { $params = (new AdminValidate())->post()->goCheck('add'); @@ -61,14 +60,14 @@ class AdminController extends BaseAdminController return $this->fail(AdminLogic::getError()); } - #[ - ApiDoc\Title("编辑管理员"), - ApiDoc\url('/store/auth/admin/edit'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("编辑管理员"), + // ApiDoc\url('/store/auth/admin/edit'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function edit() { $params = (new AdminValidate())->post()->goCheck('edit'); @@ -79,14 +78,14 @@ class AdminController extends BaseAdminController return $this->fail(AdminLogic::getError()); } - #[ - ApiDoc\Title("删除管理员"), - ApiDoc\url('/store/auth/admin/delete'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("删除管理员"), + // ApiDoc\url('/store/auth/admin/delete'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function delete() { $params = (new AdminValidate())->post()->goCheck('delete'); @@ -97,14 +96,14 @@ class AdminController extends BaseAdminController return $this->fail(AdminLogic::getError()); } - #[ - ApiDoc\Title("查看管理员详情"), - ApiDoc\url('/store/auth/admin/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("查看管理员详情"), + // ApiDoc\url('/store/auth/admin/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function detail() { $params = (new AdminValidate())->goCheck('detail'); @@ -112,28 +111,28 @@ class AdminController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title("获取当前管理员信息"), - ApiDoc\url('/store/auth/admin/mySelf'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("获取当前管理员信息"), + // ApiDoc\url('/store/auth/admin/mySelf'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function mySelf() { $result = AdminLogic::detail(['id' => $this->adminId], 'auth'); return $this->data($result); } - #[ - ApiDoc\Title("编辑超级管理员信息"), - ApiDoc\url('/store/auth/admin/editSelf'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title("编辑超级管理员信息"), + // ApiDoc\url('/store/auth/admin/editSelf'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function editSelf() { $params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]); diff --git a/app/store/controller/auth/MenuController.php b/app/store/controller/auth/MenuController.php index 0dd8ff82b..caa58acf6 100644 --- a/app/store/controller/auth/MenuController.php +++ b/app/store/controller/auth/MenuController.php @@ -19,7 +19,6 @@ use app\store\controller\BaseAdminController; use app\store\lists\auth\MenuLists; use app\store\logic\auth\MenuLogic; use app\store\validate\auth\MenuValidate; -use hg\apidoc\annotation as ApiDoc; /** @@ -27,7 +26,7 @@ use hg\apidoc\annotation as ApiDoc; * Class MenuController * @package app\store\controller\setting\system */ -#[ApiDoc\NotParse()] + class MenuController extends BaseAdminController { diff --git a/app/store/controller/auth/RoleController.php b/app/store/controller/auth/RoleController.php index 8cd0ee800..02557bb03 100644 --- a/app/store/controller/auth/RoleController.php +++ b/app/store/controller/auth/RoleController.php @@ -20,14 +20,12 @@ use app\store\{ validate\auth\RoleValidate, controller\BaseAdminController }; -use hg\apidoc\annotation as ApiDoc; - /** * 角色控制器 * Class RoleController * @package app\store\controller\auth */ -#[ApiDoc\NotParse()] + class RoleController extends BaseAdminController { diff --git a/app/store/controller/cart/CartController.php b/app/store/controller/cart/CartController.php index 6f3e640d8..1e3ae32f1 100644 --- a/app/store/controller/cart/CartController.php +++ b/app/store/controller/cart/CartController.php @@ -8,9 +8,8 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\store\lists\cart\CartList; use app\common\model\order\Cart; use app\store\controller\BaseAdminController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\NotParse()] + class CartController extends BaseAdminController { public function list() @@ -25,7 +24,7 @@ class CartController extends BaseAdminController { $params = (new CartValidate())->post()->goCheck('StoreAdd'); $adminInfo = $this->adminInfo; - $params['uid'] = 0; + $params['uid'] = $this->request->post('uid')??0; $params['staff_id'] = $adminInfo['admin_id']; $params['store_id'] = $adminInfo['store_id']; $result = Cart::where(['uid' => 0,'staff_id'=>$adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find(); diff --git a/app/store/controller/cate/CateController.php b/app/store/controller/cate/CateController.php new file mode 100644 index 000000000..d44b62da3 --- /dev/null +++ b/app/store/controller/cate/CateController.php @@ -0,0 +1,30 @@ +dataLists(new CateLists()); + } + + +} diff --git a/app/store/controller/finance/FinanceController.php b/app/store/controller/finance/FinanceController.php index 2ed913b22..fb0e2f2ef 100644 --- a/app/store/controller/finance/FinanceController.php +++ b/app/store/controller/finance/FinanceController.php @@ -6,54 +6,53 @@ use app\admin\lists\store_finance_flow\StoreFinanceFlowLists; use app\common\controller\Definitions; use app\common\logic\StoreFinanceFlowLogic; use app\store\controller\BaseAdminController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('财务')] +// #[ApiDoc\title('财务')] class FinanceController extends BaseAdminController { - #[ - ApiDoc\Title('财务流水'), - ApiDoc\url('/store/finance/finance/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '订单编号'), - ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), - ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'financial_record_sn', 'desc' => '流水号', 'type' => 'string'], - ['name' => 'order_sn', 'desc' => '订单号', 'type' => 'string'], - ['name' => 'number', 'desc' => '金额', 'type' => 'float'], - ['name' => 'create_time', 'desc' => '创建时间', 'type' => 'string'], - ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], - ['name' => 'staff_name', 'desc' => '店员', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '店铺名称', 'type' => 'string'], - ['name' => 'pay_type_name', 'desc' => '支付方式', 'type' => 'string'], - ['name' => 'financial_type_name', 'desc' => '流水类型', 'type' => 'string'], - ['name' => 'remark', 'desc' => '备注', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('财务流水'), + // ApiDoc\url('/store/finance/finance/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '订单编号'), + // ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'financial_record_sn', 'desc' => '流水号', 'type' => 'string'], + // ['name' => 'order_sn', 'desc' => '订单号', 'type' => 'string'], + // ['name' => 'number', 'desc' => '金额', 'type' => 'float'], + // ['name' => 'create_time', 'desc' => '创建时间', 'type' => 'string'], + // ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], + // ['name' => 'staff_name', 'desc' => '店员', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '店铺名称', 'type' => 'string'], + // ['name' => 'pay_type_name', 'desc' => '支付方式', 'type' => 'string'], + // ['name' => 'financial_type_name', 'desc' => '流水类型', 'type' => 'string'], + // ['name' => 'remark', 'desc' => '备注', 'type' => 'string'], + // ]), + // ] public function lists() { return $this->dataLists(new StoreFinanceFlowLists()); } - #[ - ApiDoc\Title('备注'), - ApiDoc\url('/store/finance/finance/remark'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\Param(name: 'remark', type: 'string', require: true, desc: '备注'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('备注'), + // ApiDoc\url('/store/finance/finance/remark'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\Param(name: 'remark', type: 'string', require: true, desc: '备注'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function remark(StoreFinanceFlowLogic $logic) { $id = $this->request->post('id'); diff --git a/app/store/controller/finance/FinancialTransfersController.php b/app/store/controller/finance/FinancialTransfersController.php new file mode 100644 index 000000000..0f103d94f --- /dev/null +++ b/app/store/controller/finance/FinancialTransfersController.php @@ -0,0 +1,74 @@ +dataLists(new FinancialTransfersLists()); + } + + + #[ + ApiDoc\Title('店铺确认'), + ApiDoc\url('/store/finance/financialTransfers/confirmation'), + ApiDoc\Method('POST'), + ApiDoc\NotHeaders(), + ApiDoc\Author('中国队长'), + ApiDoc\Query(name: 'status', type: 'int', require: true, desc: '状态1确认 0不确认'), + ApiDoc\Query(name: 'id', type: 'int', require: true, desc: '数据id'), + ApiDoc\Query(name: 'mark', type: 'string', require: false, desc: '原因/备注'), + ApiDoc\Header(ref: [Definitions::class, "token"]), + ApiDoc\Query(ref: [Definitions::class, "page"]), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function confirmation() + { + $params = (new FinancialTransfersValidate())->post()->goCheck('confirm'); + + $staff_id = $this->request->adminInfo['admin_id']??5; + $data = [ + 'store_staff_id' => $staff_id, + 'mark' => $params['mark']??'', + ]; + $status = -2; + if ($params['status']) { + $status = 2; + $data['confirmation_time'] = time(); + } + $data['status'] = $status; + $result = FinancialTransfersLogic::dealchange($data,$params['id']); + + if (true === $result) { + return $this->success('操作成功',[],1,1 ); + } + return $this->fail(FinancialTransfersLogic::getError()); + + + + } + + +} \ No newline at end of file diff --git a/app/store/controller/finance/StoreBillController.php b/app/store/controller/finance/StoreBillController.php index 426f7cddd..cbd7bc6be 100644 --- a/app/store/controller/finance/StoreBillController.php +++ b/app/store/controller/finance/StoreBillController.php @@ -2,50 +2,60 @@ namespace app\store\controller\finance; +use app\admin\lists\store_finance_flow\StoreFinanceFlowDayLists; use app\admin\lists\store_finance_flow\StoreFinanceFlowLists; +use app\admin\lists\store_finance_flow\StoreFinanceFlowMonthLists; +use app\admin\lists\store_finance_flow\StoreFinanceFlowWeekLists; use app\common\controller\Definitions; use app\common\lists\StoreBillLists; use app\store\controller\BaseAdminController; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('账单记录')] +// #[ApiDoc\title('账单记录')] class StoreBillController extends BaseAdminController { - #[ - ApiDoc\Title('列表'), - ApiDoc\url('/store/finance/storeBill/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'type', type: 'int', require: false, desc: '类型:1日账单,2周账单,3月账单'), - ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), - ApiDoc\Query(name: 'export', type: 'int', require: false, desc: '是否导出:2是'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('列表'), + // ApiDoc\url('/store/finance/storeBill/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'type', type: 'int', require: false, desc: '类型:1日账单,2周账单,3月账单'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), + // ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), + // ApiDoc\Query(name: 'export', type: 'int', require: false, desc: '是否导出:2是'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function lists() { - return $this->dataLists(new StoreBillLists()); + $type = $this->request->get('type'); + if($type == 1){ + return $this->dataLists(new StoreFinanceFlowDayLists()); + }else if($type == 2){ + return $this->dataLists(new StoreFinanceFlowWeekLists()); + }else{ + return $this->dataLists(new StoreFinanceFlowMonthLists()); + } +// return $this->dataLists(new StoreBillLists()); } - #[ - ApiDoc\Title('详情'), - ApiDoc\url('/store/finance/storeBill/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\Query(name: 'date_type', type: 'int', require: false, desc: '日期类型:1日账单,2周账单,3月账单'), - ApiDoc\Query(name: 'date', type: 'string', require: false, desc: '日期,日账单:2021-01-01,周账单:2024-W23,月账单:2021-01'), - ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), - ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '流水号/用户昵称'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('详情'), + // ApiDoc\url('/store/finance/storeBill/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\Query(name: 'date_type', type: 'int', require: false, desc: '日期类型:1日账单,2周账单,3月账单'), + // ApiDoc\Query(name: 'date', type: 'string', require: false, desc: '日期,日账单:2021-01-01,周账单:2024-W23,月账单:2021-01'), + // ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), + // ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '流水号/用户昵称'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function detail() { return $this->dataLists(new StoreFinanceFlowLists()); diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 0dda0ad55..e69c4f048 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -2,8 +2,11 @@ namespace app\store\controller\store_order; +use app\admin\logic\user\UserLogic; use app\api\logic\order\OrderLogic; use app\api\validate\OrderValidate; +use app\common\model\order\Cart; +use app\common\model\user\User; use app\store\lists\store_order\StoreOrderLists; use app\common\controller\Definitions; use app\common\enum\PayEnum; @@ -12,9 +15,14 @@ use app\common\logic\PayNotifyLogic; use app\common\logic\SystemStoreStaffLogic; use app\store\controller\BaseAdminController; use app\common\logic\store_order\StoreOrderLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\system_store\SystemStore; +use app\common\model\system_store\SystemStoreStaff; +use app\common\model\user_recharge\UserRecharge; use app\store\validate\store_order\StoreOrderValidate; -use hg\apidoc\annotation as ApiDoc; use support\Log; use Webman\RedisQueue\Redis; @@ -23,59 +31,25 @@ use Webman\RedisQueue\Redis; * Class StoreOrderController * @package app\store\controller\store_order */ -#[ApiDoc\title('订单')] +// #[ApiDoc\title('订单')] class StoreOrderController extends BaseAdminController { - #[ - ApiDoc\Title('订单列表'), - ApiDoc\url('/store/store_order/storeOrder/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'), - ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), - ApiDoc\Query(name: 'delivery_phone', type: 'int', require: false, desc: '配送员手机号'), - ApiDoc\Query(name: 'shipping_type', type: 'int', require: false, desc: '订单配送方式:1配送订单,2核销订单,3收银台订单'), - ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), - ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), - ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:-1待支付,0待发货,1待收货,2已完成'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'order_id', 'desc' => '订单编号', 'type' => 'string'], - ['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'], - ['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'], - ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'], - ['name' => 'status_name', 'desc' => '状态', 'type' => 'int'], - ['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'], - ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'], - ['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - ['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - ['name' => 'name', 'desc' => '商品名称', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'], - ['name' => 'price', 'desc' => '单价', 'type' => 'string'], - ]], - ]], - ]), - ] + /**订单列表 */ public function lists() { return $this->dataLists(new StoreOrderLists()); } - #[ - ApiDoc\Title('订单统计'), - ApiDoc\url('/store/store_order/storeOrder/title'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单统计'), + // ApiDoc\url('/store/store_order/storeOrder/title'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function title(SystemStoreStaffLogic $staffLogic, StoreOrderLogic $orderLogic) { return $this->data([ @@ -90,17 +64,9 @@ class StoreOrderController extends BaseAdminController ]); } - #[ - ApiDoc\Title('订单详情'), - ApiDoc\url('/store/store_order/storeOrder/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(name: 'id', type: 'int', require: false, desc: '订单id'), - ApiDoc\Query(name: 'verify_code', type: 'string', require: false, desc: '核销码'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + /** + * 订单详情 + */ public function detail(StoreOrderLogic $orderLogic) { $params = (new StoreOrderValidate())->goCheck('detail'); @@ -108,12 +74,16 @@ class StoreOrderController extends BaseAdminController return $this->data($result); } + /** + * 订单检查 + */ public function checkOrder() { $cartId = (array)$this->request->post('cart_id', []); $params = $this->request->post(); - $params['store_id']=$this->adminInfo['store_id']; - $res = StoreOrderLogic::cartIdByOrderInfo($cartId, null, null, $params); + $params['store_id'] = $this->adminInfo['store_id']; + $user=User::where('id',$params['uid'])->find(); + $res = StoreOrderLogic::cartIdByOrderInfo($cartId, null, $user, $params); if ($res == false) { $msg = StoreOrderLogic::getError(); if ($msg == '购物车为空') { @@ -124,28 +94,68 @@ class StoreOrderController extends BaseAdminController return $this->data($res); } + + public function checkSms() + { + $params = (new StoreOrderValidate())->post()->goCheck('check'); + $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 + $user = User::where('id', $params['uid'])->find(); + if (empty($user)) { + return $this->fail('无该用户请检查'); + } + $order = StoreOrderLogic::cartIdByOrderInfo($params['cart_id'], null, $user, $params); + if (!$order) { + return $this->fail(StoreOrderLogic::getError()); + } + if ($order['order']['pay_price'] > $user['purchase_funds']) { + return $this->fail('当前用户采购款不足支付'); + } + $res = (new StoreOrderLogic())->dealSendSms($params); + if ($res) { + return $this->success('发送成功', [], 1, 0); + } else { + return $this->fail('发送失败'); + } + } + + + /** + * 创建订单 + */ public function createOrder() { $cartId = (array)$this->request->post('cart_id', []); $pay_type = (int)$this->request->post('pay_type'); $addressId = (int)$this->request->post('address_id'); $auth_code = $this->request->post('auth_code'); //微信支付条码 + $uid=$this->request->post('uid'); $params = $this->request->post(); - if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) { + if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS) { return $this->fail('支付条码不能为空'); } if (count($cartId) > 100) { return $this->fail('购物车商品不能超过100个'); } + $user = null; + if ($uid) { + $user = User::where('id', $uid)->find(); + } $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 - $order = StoreOrderLogic::createOrder($cartId, $addressId, null, $params); + $order = StoreOrderLogic::createOrder($cartId, $addressId, $user, $params); if ($order != false) { switch ($pay_type) { + case PayEnum::PURCHASE_FUNDS: + //采购款支付 + PayNotifyLogic::handle('purchase_funds', $order['order_id'], [ + 'uid' => $uid,'store_id'=>$this->request->adminInfo['store_id'], + 'staff_id'=>$this->request->adminInfo['admin_id'] + ]); + return $this->success('采购款支付成功', ['id' => $order['id']]); case PayEnum::CASH_PAY: //现金支付 PayNotifyLogic::handle('cash_pay', $order['order_id']); - return $this->success('现金支付成功'); + return $this->success('现金支付成功', ['id' => $order['id']]); case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 @@ -160,7 +170,7 @@ class StoreOrderController extends BaseAdminController Redis::send('send-code-pay', ['order_id' => $order['order_id']]); return $this->success('用户支付中'); } - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]); case PayEnum::ALIPAY_BARCODE: //支付宝条码支付 $result = PaymentLogic::ali_auth_code($auth_code, $order); @@ -172,7 +182,7 @@ class StoreOrderController extends BaseAdminController } PayNotifyLogic::handle('alipay_cashier', $result['out_trade_no'], $result); $result['create_time'] = $order['create_time']; - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'], 'id' => $order['id']]); default: return $this->fail('支付方式错误'); } @@ -181,6 +191,9 @@ class StoreOrderController extends BaseAdminController } } + /** + * 重新支付 + */ public function pay() { $order_id = $this->request->post('order_id'); @@ -198,13 +211,15 @@ class StoreOrderController extends BaseAdminController if (!$order) { return $this->fail('订单不存在或已支付'); } - switch ($pay_type) { - + case PayEnum::PURCHASE_FUNDS: + //采购款支付 + PayNotifyLogic::handle('purchase_funds', $order['order_id'], ['uid' => $order['uid']]); + return $this->success('采购款支付成功', ['id' => $order['id']]); case PayEnum::CASH_PAY: //现金支付 PayNotifyLogic::handle('cash_pay', $order['order_id']); - return $this->success('现金支付成功'); + return $this->success('现金支付成功', ['id' => $order['id']]); break; case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 @@ -218,7 +233,7 @@ class StoreOrderController extends BaseAdminController Redis::send('send-code-pay', ['order_id' => $order['order_id']]); return $this->success('用户支付中'); } - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]); case PayEnum::ALIPAY_BARCODE: //支付宝条码支付 $result = PaymentLogic::ali_auth_code($auth_code, $order); @@ -231,13 +246,16 @@ class StoreOrderController extends BaseAdminController PayNotifyLogic::handle('alipay_cashier', $result['out_trade_no'], $result); $result['create_time'] = $order['create_time']; - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'], 'id' => $order['id']]); default: return $this->fail('支付方式错误'); } return $this->fail('支付失败'); } + /** + * 订单核销 + */ public function writeoff_order() { $params = (new OrderValidate())->post()->goCheck('check'); @@ -245,6 +263,8 @@ class StoreOrderController extends BaseAdminController if (empty($count)) { return $this->fail('无该核销码请检查'); } + $params['store_id'] = $this->adminInfo['store_id']; + $params['staff_id'] = $this->adminId; $res = OrderLogic::writeOff($params); if ($res) { return $this->success('核销成功'); @@ -253,17 +273,17 @@ class StoreOrderController extends BaseAdminController } - #[ - ApiDoc\Title('订单已核销列表'), - ApiDoc\url('/store/store_order/storeOrder/writeoff_list'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(name: 'page_no', type: 'int', require: false, desc: '页数 默认1'), - ApiDoc\Query(name: 'page_size', type: 'int', require: false, desc: '每页条数 默认15'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单已核销列表'), + // ApiDoc\url('/store/store_order/storeOrder/writeoff_list'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(name: 'page_no', type: 'int', require: false, desc: '页数 默认1'), + // ApiDoc\Query(name: 'page_size', type: 'int', require: false, desc: '每页条数 默认15'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function writeoff_list(StoreOrderLogic $orderLogic) { $page_no = (int)$this->request->post('page_no', 1); @@ -275,18 +295,109 @@ class StoreOrderController extends BaseAdminController $params['page_no'] = 1; $params['page_size'] = 15; } - $params['store_id'] =$this->request->adminInfo['store_id']; + $params['store_id'] = $this->request->adminInfo['store_id']; $result = $orderLogic->writeList($params); $data = [ 'lists' => $result, 'count' => count($result), 'page_no' => $params['page_no'], - 'page_size' =>$params['page_size'], + 'page_size' => $params['page_size'], ]; - return $this->success('ok',$data); - + return $this->success('ok', $data); + } + /** + * vip充值 + */ + public function rechange_amount() + { + $pay_type = $this->request->post('pay_type'); + $auth_code = $this->request->post('auth_code'); //微信支付条码 + if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) { + return $this->fail('支付条码不能为空'); + } + $params = $this->request->post(); + $data = [ + 'store_id' => $this->adminInfo['store_id'], + 'uid' => $params['uid'], + 'staff_id' => $this->adminId, + 'order_id' => getNewOrderId('CZ'), + 'price' => $params['price'], + 'recharge_type' => 'INDUSTRYMEMBERS', + ]; + $order = UserRecharge::create($data); + $order['pay_price'] = $order['price']; + switch ($pay_type) { + case PayEnum::WECHAT_PAY_BARCODE: + //微信条码支付 + $result = PaymentLogic::codepay($auth_code, $order); + if (PaymentLogic::hasError()) { + return $this->fail(PaymentLogic::getError(), $params); + } + if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { + PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result); + } else { + Redis::send('send-code-pay', ['order_id' => $order['order_id'], 'pay_type' => 'recharge']); + return $this->success('用户支付中'); + } + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); + case PayEnum::ALIPAY_BARCODE: + //支付宝条码支付 + $result = PaymentLogic::ali_auth_code($auth_code, $order); + if (PaymentLogic::hasError()) { + return $this->fail(PaymentLogic::getError(), $params); + } + if ($result['msg'] !== 'Success') { + return $this->success('用户支付中'); + } + PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result, 'ali'); + + $result['create_time'] = $order['create_time']; + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]); + default: + return $this->fail('支付方式错误'); + } + return $this->fail('支付失败'); + } + + public function stocking() + { + $uid = $this->request->post('uid'); + $res = (new StoreOrderLogic())->dealSendSms(['uid' => $uid], 1); + if ($res) { + return $this->success('发送成功', [], 0, 1); + } else { + return $this->fail('发送失败'); + } + } + + /** + * 订单打印 + */ + public function print() + { + $id = $this->request->get('id'); + $find = StoreOrder::where('id', $id)->find(); + if ($find) { + $merchant = SystemStore::where('id', $find['store_id'])->field('name,phone')->find(); + $mer_user_info = SystemStoreStaff::where('store_id', $find['store_id'])->where('is_admin', 1)->field('staff_name,phone')->find(); + $user = User::where('id', $find['uid'])->field('nickname,mobile')->find(); + $find['system_store_name'] = $merchant['name']; + $find['pay_type_name'] = PayEnum::getPaySceneDesc($find['pay_type']); + $find['system_store_phone'] = $merchant['phone']; + $find['staff_name'] = $mer_user_info['staff_name']; + $find['staff_phone'] = $mer_user_info['phone']; + $find['nickname'] = $user['nickname'] ?? ''; + $find['user_mobile'] = $user['mobile'] ?? ''; + $find['info'] = StoreOrderCartInfo::where('oid', $find['id'])->field('store_id,product_id,cart_num,cart_info')->select()->each(function ($item) { + $goods = StoreBranchProduct::where(['store_id' => $item['store_id'], 'product_id' => $item['product_id']])->field('store_name,unit')->find(); + $item['unit_name'] = StoreProductUnit::where('id', $goods['unit'])->value('name'); + $item['store_name'] = $goods['store_name']; + $item['total_price'] = $item['cart_info']['total_price']; + $item['price'] = $item['cart_info']['price']; + return $item; + }); + } + return $this->success('获取成功', $find?->toArray()); } - - } diff --git a/app/store/controller/store_order/StoreRefundOrderController.php b/app/store/controller/store_order/StoreRefundOrderController.php index 14ffbb3ec..5857b772c 100644 --- a/app/store/controller/store_order/StoreRefundOrderController.php +++ b/app/store/controller/store_order/StoreRefundOrderController.php @@ -7,66 +7,65 @@ use app\common\lists\order\StoreRefundOrderLists; use app\store\controller\BaseAdminController; use app\common\logic\store_order\StoreOrderLogic; use app\store\validate\store_order\StoreOrderValidate; -use hg\apidoc\annotation as ApiDoc; /** * 订单列表控制器 * Class StoreOrderController * @package app\store\controller\store_order */ -#[ApiDoc\title('退款订单')] +// #[ApiDoc\title('退款订单')] class StoreRefundOrderController extends BaseAdminController { - #[ - ApiDoc\Title('订单列表'), - ApiDoc\url('/store/store_order/storeRefundOrder/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'), - ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间', mock: "@datetime('yyyy-MM-dd')"), - ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间', mock: "@datetime('yyyy-MM-dd')"), - ApiDoc\Query(name: 'refund_type', type: 'int', require: false, desc: '状态:1仅退款,2退款退货,3拒绝退款,4商品待退货,5退货待收货,6已退款', mock: "@integer(1, 6)"), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'order_id', 'desc' => '订单编号', 'type' => 'string'], - ['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'], - ['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'], - ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'], - ['name' => 'status_name', 'desc' => '状态', 'type' => 'int'], - ['name' => 'refund_status_name', 'desc' => '退款状态', 'type' => 'string'], - ['name' => 'refund_type_name', 'desc' => '退款类型', 'type' => 'string'], - ['name' => 'refund_reason_time', 'desc' => '退款时间', 'type' => 'int'], - ['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'], - ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], - ['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'], - ['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - ['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - ['name' => 'name', 'desc' => '商品名称', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'], - ['name' => 'price', 'desc' => '单价', 'type' => 'string'], - ]], - ]], - ]), - ] + // #[ + // ApiDoc\Title('订单列表'), + // ApiDoc\url('/store/store_order/storeRefundOrder/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'), + // ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间', mock: "@datetime('yyyy-MM-dd')"), + // ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间', mock: "@datetime('yyyy-MM-dd')"), + // ApiDoc\Query(name: 'refund_type', type: 'int', require: false, desc: '状态:1仅退款,2退款退货,3拒绝退款,4商品待退货,5退货待收货,6已退款', mock: "@integer(1, 6)"), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'order_id', 'desc' => '订单编号', 'type' => 'string'], + // ['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'], + // ['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'], + // ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'], + // ['name' => 'status_name', 'desc' => '状态', 'type' => 'int'], + // ['name' => 'refund_status_name', 'desc' => '退款状态', 'type' => 'string'], + // ['name' => 'refund_type_name', 'desc' => '退款类型', 'type' => 'string'], + // ['name' => 'refund_reason_time', 'desc' => '退款时间', 'type' => 'int'], + // ['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'], + // ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], + // ['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'], + // ['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [ + // ['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [ + // ['name' => 'name', 'desc' => '商品名称', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'], + // ['name' => 'price', 'desc' => '单价', 'type' => 'string'], + // ]], + // ]], + // ]), + // ] public function lists() { return $this->dataLists(new StoreRefundOrderLists()); } - #[ - ApiDoc\Title('编辑订单'), - ApiDoc\url('/store/store_order/storeRefundOrder/edit'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('编辑订单'), + // ApiDoc\url('/store/store_order/storeRefundOrder/edit'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function edit() { $params = (new StoreOrderValidate())->post()->goCheck('edit'); @@ -77,16 +76,16 @@ class StoreRefundOrderController extends BaseAdminController return $this->fail(StoreOrderLogic::getError()); } - #[ - ApiDoc\Title('订单详情'), - ApiDoc\url('/store/store_order/storeRefundOrder/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Author('中国队长'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(name: 'id', type: 'int', require: true, desc: '订单id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('订单详情'), + // ApiDoc\url('/store/store_order/storeRefundOrder/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Author('中国队长'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(name: 'id', type: 'int', require: true, desc: '订单id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function detail(StoreOrderLogic $orderLogic) { $params = (new StoreOrderValidate())->goCheck('detail'); diff --git a/app/store/controller/store_product/StoreProductController.php b/app/store/controller/store_product/StoreProductController.php index c1aa3e16e..780430b60 100644 --- a/app/store/controller/store_product/StoreProductController.php +++ b/app/store/controller/store_product/StoreProductController.php @@ -9,7 +9,6 @@ use app\store\controller\BaseAdminController; use app\store\logic\store_branch_product\StoreBranchProductLogic; use app\store\logic\store_product\StoreProductLogic; use app\store\validate\store_product\StoreProductValidate; -use hg\apidoc\annotation as ApiDoc; /** @@ -17,57 +16,57 @@ use hg\apidoc\annotation as ApiDoc; * Class StoreProductController * @package app\store\controller\store_product */ -#[ApiDoc\title('商品列表')] +// #[ApiDoc\title('商品列表')] class StoreProductController extends BaseAdminController { - #[ - ApiDoc\Title('商品列表'), - ApiDoc\url('/store/store_product/storeProduct/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Query(name: 'cate_id', type: 'int', require: false, desc: '分类id'), - ApiDoc\Query(name: 'store_name', type: 'string', require: false, desc: '商品名称'), - ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:1上架,2下架,3售罄,4库存告警'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'product_id', 'desc' => '商品ID', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], - ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], - ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], - ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], - ['name' => 'status', 'desc' => '状态:1上架,0下架', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('商品列表'), + // ApiDoc\url('/store/store_product/storeProduct/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Query(name: 'cate_id', type: 'int', require: false, desc: '分类id'), + // ApiDoc\Query(name: 'store_name', type: 'string', require: false, desc: '商品名称'), + // ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:1上架,2下架,3售罄,4库存告警'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'product_id', 'desc' => '商品ID', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], + // ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], + // ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], + // ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], + // ['name' => 'status', 'desc' => '状态:1上架,0下架', 'type' => 'string'], + // ]), + // ] public function lists() { return $this->dataLists(new StoreBranchProductLists()); } - #[ - ApiDoc\Title('添加商品'), - ApiDoc\url('/store/store_product/storeProduct/add'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], - ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], - ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], - ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('添加商品'), + // ApiDoc\url('/store/store_product/storeProduct/add'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], + // ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], + // ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], + // ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], + // ]), + // ] public function add() { $params = (new StoreProductValidate())->post()->goCheck('add'); @@ -78,25 +77,25 @@ class StoreProductController extends BaseAdminController return $this->fail(StoreProductLogic::getError()); } - #[ - ApiDoc\Title('编辑商品'), - ApiDoc\url('/store/store_product/storeProduct/edit'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], - ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], - ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], - ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('编辑商品'), + // ApiDoc\url('/store/store_product/storeProduct/edit'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], + // ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], + // ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], + // ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], + // ]), + // ] public function edit() { $params = (new StoreProductValidate())->post()->goCheck('edit'); @@ -107,25 +106,25 @@ class StoreProductController extends BaseAdminController return $this->fail(StoreProductLogic::getError()); } - #[ - ApiDoc\Title('删除商品'), - ApiDoc\url('/store/store_product/storeProduct/delete'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], - ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], - ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], - ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('删除商品'), + // ApiDoc\url('/store/store_product/storeProduct/delete'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], + // ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], + // ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], + // ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], + // ]), + // ] public function delete() { $params = (new StoreProductValidate())->post()->goCheck('delete'); @@ -133,25 +132,25 @@ class StoreProductController extends BaseAdminController return $this->success('删除成功', [], 1, 1); } - #[ - ApiDoc\Title('商品详情'), - ApiDoc\url('/store/store_product/storeProduct/detail'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], - ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], - ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], - ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], - ]), - ] + // #[ + // ApiDoc\Title('商品详情'), + // ApiDoc\url('/store/store_product/storeProduct/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Query(name: "id", type: "int", require: true, desc: "id"), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], + // ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'], + // ['name' => 'price', 'desc' => '零售价', 'type' => 'float'], + // ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'], + // ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'], + // ]), + // ] public function detail() { $params = (new StoreProductValidate())->goCheck('detail'); @@ -159,15 +158,15 @@ class StoreProductController extends BaseAdminController return $this->data($result); } - #[ - ApiDoc\Title('商品上下架'), - ApiDoc\url('/store/store_product/storeProduct/status'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品上下架'), + // ApiDoc\url('/store/store_product/storeProduct/status'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Param(name: "id", type: "int", require: true, desc: "id"), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function status() { $params = (new StoreProductValidate())->post()->goCheck('detail'); @@ -175,19 +174,19 @@ class StoreProductController extends BaseAdminController return $this->success('操作成功', [], 1, 1); } - #[ - ApiDoc\Title('商品库存增减'), - ApiDoc\url('/store/store_product/storeProduct/stock'), - ApiDoc\Method('POST'), - ApiDoc\Param(name: "attrs", type: "array", require: true, desc: "id", children: [ - ['name' => 'unique', 'desc' => '唯一值', 'type' => 'string'], - ['name' => 'type', 'desc' => '类型:1增加,2减少', 'type' => 'int'], - ['name' => 'number', 'desc' => '数量', 'type' => 'int'], - ]), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('商品库存增减'), + // ApiDoc\url('/store/store_product/storeProduct/stock'), + // ApiDoc\Method('POST'), + // ApiDoc\Param(name: "attrs", type: "array", require: true, desc: "id", children: [ + // ['name' => 'unique', 'desc' => '唯一值', 'type' => 'string'], + // ['name' => 'type', 'desc' => '类型:1增加,2减少', 'type' => 'int'], + // ['name' => 'number', 'desc' => '数量', 'type' => 'int'], + // ]), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function stock() { $params = (new StoreProductValidate())->post()->goCheck('stock'); diff --git a/app/store/controller/store_product/StoreStorageController.php b/app/store/controller/store_product/StoreStorageController.php index 0fc5a2509..77ade604c 100644 --- a/app/store/controller/store_product/StoreStorageController.php +++ b/app/store/controller/store_product/StoreStorageController.php @@ -7,38 +7,37 @@ use app\store\controller\BaseAdminController; use app\admin\lists\system_store_storage\SystemStoreStorageLists; use app\admin\logic\system_store_storage\SystemStoreStorageLogic; use app\admin\validate\system_store_storage\SystemStoreStorageValidate; -use hg\apidoc\annotation as ApiDoc; -#[ApiDoc\title('入库管理')] +// #[ApiDoc\title('入库管理')] class StoreStorageController extends BaseAdminController { - #[ - ApiDoc\Title('入库记录'), - ApiDoc\url('/store/store_product/storeStorage/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Query(name: 'store_id', type: 'int', require: false, desc: '门店id'), - ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), - ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:0-待确认,1-已确认'), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('入库记录'), + // ApiDoc\url('/store/store_product/storeStorage/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Query(name: 'store_id', type: 'int', require: false, desc: '门店id'), + // ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), + // ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:0-待确认,1-已确认'), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function lists() { return $this->dataLists(new SystemStoreStorageLists()); } - #[ - ApiDoc\Title('确认入库'), - ApiDoc\url('/store/store_product/storeStorage/confirm'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), - ApiDoc\ResponseSuccess("data", type: "array"), - ] + // #[ + // ApiDoc\Title('确认入库'), + // ApiDoc\url('/store/store_product/storeStorage/confirm'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'), + // ApiDoc\ResponseSuccess("data", type: "array"), + // ] public function confirm() { $params = (new SystemStoreStorageValidate())->post()->goCheck('edit'); diff --git a/app/store/controller/store_product_attr_value/StoreProductAttrValueController.php b/app/store/controller/store_product_attr_value/StoreProductAttrValueController.php index ae7c08238..9b99546ac 100644 --- a/app/store/controller/store_product_attr_value/StoreProductAttrValueController.php +++ b/app/store/controller/store_product_attr_value/StoreProductAttrValueController.php @@ -8,7 +8,6 @@ use app\store\controller\BaseAdminController; use app\store\lists\store_product_attr_value\StoreProductAttrValueLists; use app\store\logic\store_product_attr_value\StoreProductAttrValueLogic; use app\store\validate\store_product_attr_value\StoreProductAttrValueValidate; -use hg\apidoc\annotation as ApiDoc; /** @@ -16,47 +15,47 @@ use hg\apidoc\annotation as ApiDoc; * Class StoreProductAttrValueController * @package app\store\controller\store_product_attr_value */ -#[ApiDoc\title('商品属性值')] +// #[ApiDoc\title('商品属性值')] class StoreProductAttrValueController extends BaseAdminController { - #[ - ApiDoc\Title('商品属性值列表'), - ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ApiDoc\Query(ref: [Definitions::class, "page"]), - ApiDoc\Query(name: 'product_id', type: 'int', require: true, desc: '商品ID'), - ApiDoc\Query(name: 'store_id', type: 'int', require: true, desc: '门店ID'), - ApiDoc\ResponseSuccess("data", type: "array", children: [ - ['name' => 'count', 'desc' => '总数', 'type' => 'int'], - ['name' => 'page_no', 'desc' => '页码', 'type' => 'int'], - ['name' => 'page_size', 'desc' => '每页数量', 'type' => 'int'], - ['name' => 'extend', 'desc' => '扩展数据', 'type' => 'array'], - ['name' => 'lists', 'desc' => '列表数据', 'type' => 'array', 'children' => [ - ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - ['name' => 'product_id', 'desc' => '商品ID', 'type' => 'int'], - ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], - ['name' => 'unique', 'desc' => '唯一值', 'type' => 'string'], - ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], - ['name' => 'bar_code', 'desc' => '条码', 'type' => 'string'], - ['name' => 'image', 'desc' => '规格图片', 'type' => 'string'], - ]], - ]), - ] + // #[ + // ApiDoc\Title('商品属性值列表'), + // ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ApiDoc\Query(ref: [Definitions::class, "page"]), + // ApiDoc\Query(name: 'product_id', type: 'int', require: true, desc: '商品ID'), + // ApiDoc\Query(name: 'store_id', type: 'int', require: true, desc: '门店ID'), + // ApiDoc\ResponseSuccess("data", type: "array", children: [ + // ['name' => 'count', 'desc' => '总数', 'type' => 'int'], + // ['name' => 'page_no', 'desc' => '页码', 'type' => 'int'], + // ['name' => 'page_size', 'desc' => '每页数量', 'type' => 'int'], + // ['name' => 'extend', 'desc' => '扩展数据', 'type' => 'array'], + // ['name' => 'lists', 'desc' => '列表数据', 'type' => 'array', 'children' => [ + // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], + // ['name' => 'product_id', 'desc' => '商品ID', 'type' => 'int'], + // ['name' => 'stock', 'desc' => '库存', 'type' => 'int'], + // ['name' => 'unique', 'desc' => '唯一值', 'type' => 'string'], + // ['name' => 'sales', 'desc' => '销量', 'type' => 'int'], + // ['name' => 'bar_code', 'desc' => '条码', 'type' => 'string'], + // ['name' => 'image', 'desc' => '规格图片', 'type' => 'string'], + // ]], + // ]), + // ] public function lists() { return $this->dataLists(new StoreProductAttrValueLists()); } - #[ - ApiDoc\Title('添加商品属性值'), - ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/add'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ] + // #[ + // ApiDoc\Title('添加商品属性值'), + // ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/add'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ] public function add() { $params = (new StoreProductAttrValueValidate())->post()->goCheck('add'); @@ -67,13 +66,13 @@ class StoreProductAttrValueController extends BaseAdminController return $this->fail(StoreProductAttrValueLogic::getError()); } - #[ - ApiDoc\Title('编辑商品属性值'), - ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/edit'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ] + // #[ + // ApiDoc\Title('编辑商品属性值'), + // ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/edit'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ] public function edit() { $params = (new StoreProductAttrValueValidate())->post()->goCheck('edit'); @@ -84,13 +83,13 @@ class StoreProductAttrValueController extends BaseAdminController return $this->fail(StoreProductAttrValueLogic::getError()); } - #[ - ApiDoc\Title('删除商品属性值'), - ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/delete'), - ApiDoc\Method('POST'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ] + // #[ + // ApiDoc\Title('删除商品属性值'), + // ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/delete'), + // ApiDoc\Method('POST'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ] public function delete() { $params = (new StoreProductAttrValueValidate())->post()->goCheck('delete'); @@ -98,14 +97,14 @@ class StoreProductAttrValueController extends BaseAdminController return $this->success('删除成功', [], 1, 1); } - #[ - ApiDoc\Title('获取商品属性值详情'), - ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/detail'), - ApiDoc\Method('GET'), - ApiDoc\Author('中国队长'), - ApiDoc\NotHeaders(), - ApiDoc\Header(ref: [Definitions::class, "token"]), - ] + // #[ + // ApiDoc\Title('获取商品属性值详情'), + // ApiDoc\url('/store/store_product_attr_value/storeProductAttrValue/detail'), + // ApiDoc\Method('GET'), + // ApiDoc\Author('中国队长'), + // ApiDoc\NotHeaders(), + // ApiDoc\Header(ref: [Definitions::class, "token"]), + // ] public function detail() { $params = (new StoreProductAttrValueValidate())->goCheck('detail'); diff --git a/app/store/controller/system_store_storage/SystemStoreStorageController.php b/app/store/controller/system_store_storage/SystemStoreStorageController.php index 11389cf74..b910e9a4e 100644 --- a/app/store/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/store/controller/system_store_storage/SystemStoreStorageController.php @@ -9,7 +9,6 @@ use app\admin\logic\system_store_storage\SystemStoreStorageLogic; use app\admin\validate\system_store_storage\SystemStoreStorageValidate; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\system_store_storage\SystemStoreStorage; -use hg\apidoc\annotation as ApiDoc; /** @@ -17,16 +16,16 @@ use hg\apidoc\annotation as ApiDoc; * Class SystemStoreStorageController * @package app\admin\controller\system_store_storage */ -#[ApiDoc\title('门店入库记录')] +// #[ApiDoc\title('门店入库记录')] class SystemStoreStorageController extends BaseAdminController { - #[ - ApiDoc\Title('列表'), - ApiDoc\url('/store/system_store_storage/systemstorestorage/lists'), - ApiDoc\Method('GET'), - ApiDoc\NotHeaders(), - ] + // #[ + // ApiDoc\Title('列表'), + // ApiDoc\url('/store/system_store_storage/systemstorestorage/lists'), + // ApiDoc\Method('GET'), + // ApiDoc\NotHeaders(), + // ] public function lists() { return $this->dataLists(new SystemStoreStorageLists()); diff --git a/app/store/controller/user/AddressController.php b/app/store/controller/user/AddressController.php new file mode 100644 index 000000000..b3a74cf8b --- /dev/null +++ b/app/store/controller/user/AddressController.php @@ -0,0 +1,49 @@ +dataLists(new UserAddressList()); + } + /** + * @notes 编辑地址 + * @return \support\Response + * @author likeadmin + * @date 2024/4/24 10:37 + */ + public function edit() + { + $params = (new UserAddressValidate())->post()->goCheck('edit'); + if(AddressLogic::edit($params)){ + return $this->success('编辑成功'); + }else{ + return $this->fail(AddressLogic::getError()); + } + } + /** + * @notes 获取地址详情 + * @return \support\Response + * @author likeadmin + * @date 2024/4/24 10:37 + */ + public function detail() + { + $id = $this->request->get('id'); + $uid = $this->request->get('uid'); + if($id){ + $params = ['id' => $id]; + } + if($uid){ + $params = ['uid' => $uid]; + } + return $this->success('获取成功',AddressLogic::detail($params)); + } +} diff --git a/app/store/controller/user/UserController.php b/app/store/controller/user/UserController.php new file mode 100644 index 000000000..5e45e7786 --- /dev/null +++ b/app/store/controller/user/UserController.php @@ -0,0 +1,58 @@ +dataLists(new UserLists()); + } + + + public function add() + { + $params = (new UserValidate())->post()->goCheck('storeAdd'); + UserLogic::StoreAdd($params); + if (UserLogic::hasError() ) { + return $this->fail(UserLogic::getError()); + } + return $this->success('添加成功', [], 1, 1); + + } + + public function detail() + { + $params = (new UserValidate())->goCheck('detail'); + $detail = UserLogic::detail($params['id']); + return $this->success('', $detail); + } + + public function user_ship(){ + $user_ship=$this->request->post('user_ship',0); + $id=$this->request->post('id',0); + if($user_ship==1){ + return $this->fail('充值会员不能前端设置'); + } + User::where('id',$id)->update(['user_ship'=>$user_ship]); + return $this->success('设置成功'); + } + + public function user_label(){ + $label_id=$this->request->post('label_id',0); + $id=$this->request->post('id',0); + + User::where('id',$id)->update(['label_id'=>$label_id]); + return $this->success('设置成功'); + } + +} \ No newline at end of file diff --git a/app/store/controller/user/UserLabelController.php b/app/store/controller/user/UserLabelController.php new file mode 100644 index 000000000..abae0d92b --- /dev/null +++ b/app/store/controller/user/UserLabelController.php @@ -0,0 +1,30 @@ +dataLists(new UserLabelLists()); + } + +} \ No newline at end of file diff --git a/app/store/controller/user/UserShipController.php b/app/store/controller/user/UserShipController.php new file mode 100644 index 000000000..e6bd8cdca --- /dev/null +++ b/app/store/controller/user/UserShipController.php @@ -0,0 +1,18 @@ +dataLists(new UserShipLists()); + } +} \ No newline at end of file diff --git a/app/store/lists/financial_transfers/FinancialTransfersLists.php b/app/store/lists/financial_transfers/FinancialTransfersLists.php new file mode 100644 index 000000000..7c5f68a21 --- /dev/null +++ b/app/store/lists/financial_transfers/FinancialTransfersLists.php @@ -0,0 +1,65 @@ + [ 'admin_id', 'uid', 'status', 'initiation_time', 'confirmation_time', 'mark', 'money', 'remark_time'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/06/14 10:10 + */ + public function lists(): array + { + $this->searchWhere[] = ['store_id','=',$this->adminInfo['store_id']]; + return FinancialTransfers::with(['store','staff','admin'])->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author admin + * @date 2024/06/14 10:10 + */ + public function count(): int + { + return FinancialTransfers::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/store/lists/store_order/StoreOrderLists.php b/app/store/lists/store_order/StoreOrderLists.php index 12f7c7208..3c86ba983 100644 --- a/app/store/lists/store_order/StoreOrderLists.php +++ b/app/store/lists/store_order/StoreOrderLists.php @@ -46,13 +46,13 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - $store_id = $this->adminInfo['store_id']; + $store_id = $this->adminInfo['store_id']??5; $this->searchWhere[] = ['store_id' ,'=',$store_id]; $is_sashier=$this->request->get('is_sashier'); if($is_sashier==1){//收银台订单 - $this->searchWhere[] = ['pay_type','in',[17,9,13]]; + $this->searchWhere[] = ['pay_type','in',[17,9,13,18]]; }elseif($is_sashier==2){//小程序订单 - $this->searchWhere[] = ['pay_type','in',[7,3]]; + $this->searchWhere[] = ['pay_type','in',[7,3,18]]; } return StoreOrder::where($this->searchWhere) ->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status','paid']) diff --git a/app/store/lists/system_store_storage/SystemStoreStorageLists.php b/app/store/lists/system_store_storage/SystemStoreStorageLists.php index e2e94148c..c31918b02 100644 --- a/app/store/lists/system_store_storage/SystemStoreStorageLists.php +++ b/app/store/lists/system_store_storage/SystemStoreStorageLists.php @@ -29,7 +29,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['admin_id', 'staff_id', 'status'], + '=' => ['admin_id', 'staff_id', 'status','type'], ]; } diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php new file mode 100644 index 000000000..0a888bef6 --- /dev/null +++ b/app/store/lists/user/UserLists.php @@ -0,0 +1,69 @@ + ['id','user_ship'], + '%like%' => ['mobile'], + ]; + } + + /** + * @notes 获取用户列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 乔峰 + * @date 2022/9/22 15:50 + */ + public function lists(): array + { + + $field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral"; + $lists = User::where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->field($field) + ->order('id desc') + ->select()->each(function($data){ + $data['sex_text'] = $data->sex_text; + $data['mobile'] = substr_replace($data['mobile'], '****', 3, 4); + $data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title'); + $data['return_money'] = StoreFinanceFlow:: + where(['user_id'=>$data['id'],'status'=>0,'financial_pm'=>0]) + ->sum('number'); + + })->toArray(); + return $lists; + } + + + /** + * @notes 获取数量 + * @return int + * @author 乔峰 + * @date 2022/9/22 15:51 + */ + public function count(): int + { + return User::where($this->searchWhere)->count(); + } +} \ No newline at end of file diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 01fb12a11..ea4e9de58 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -15,14 +15,21 @@ namespace app\store\logic; +use app\common\enum\OrderEnum; use app\common\enum\PayEnum; +use app\common\enum\YesNoEnum; use app\common\logic\BaseLogic; use app\common\logic\store_order\StoreOrderLogic; +use app\common\logic\StoreFinanceFlowLogic; +use app\common\model\finance\CapitalFlow; use app\common\model\order\Cart; use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; +use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_visit\StoreVisit; +use app\common\model\system_store\SystemStore; +use app\common\model\user_recharge\UserRecharge; use app\common\service\ConfigService; use app\common\service\FileService; @@ -38,29 +45,37 @@ class WorkbenchLogic extends BaseLogic public static function index($params) { $data = []; + $startTimeDefault = date('Y-m-d',time()); + $endTimeDefault =date('Y-m-d', strtotime($startTimeDefault) + 86400); + $orderLogic = new StoreOrderLogic(); + //订单总金额 + $data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault); + //余额支付总金额 + $data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['pay_type' => PayEnum::BALANCE_PAY]); + //线下收银总金额 + $data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 3]); + //现金收银总金额 + $data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTimeDefault, $endTimeDefault)->sum('cash_price'); + //核销订单金额 + $data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 2]); + //门店收益金额 + $data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, [], 'profit'); + //门店收款金额 + $data['receipt_amount'] = UserRecharge::where([ + 'store_id'=>$params['store_id'], + 'paid'=>YesNoEnum::YES + ])->sum('price'); + //门店成交用户数 + $data['user_number'] = StoreOrder::where('store_id', $params['store_id']) + ->where('paid', 1) + ->whereBetweenTime('pay_time', $startTimeDefault, $endTimeDefault) + ->group('uid') + ->count(); + $startTime = $params['start_time']; $endTime = $params['end_time']; $endTime = date('Y-m-d', strtotime($endTime) + 86400); $dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime)); - $orderLogic = new StoreOrderLogic(); - //订单总金额 - $data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime); - //余额支付总金额 - $data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]); - //线下收银总金额 - $data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]); - //现金收银总金额 - $data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price'); - //核销订单金额 - $data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]); - //门店收益金额 - $data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, [], 'profit'); - //门店成交用户数 - $data['user_number'] = StoreOrder::where('store_id', $params['store_id']) - ->where('paid', 1) - ->whereBetweenTime('pay_time', $startTime, $endTime) - ->group('uid') - ->count(); if ($dateDiff->days == 1) { $group = 'HOUR(pay_time)'; $i = 0; @@ -77,7 +92,8 @@ class WorkbenchLogic extends BaseLogic $i++; } $field = 'from_unixtime(pay_time,"%m-%d") as pay_time,sum(pay_price) as pay_price'; - } else { + } + else { $group = 'MONTH(pay_time)'; $i = 0; $month = 0; @@ -529,4 +545,187 @@ class WorkbenchLogic extends BaseLogic return $data; } + + public static function revenueStatistics($params) + { + + //当日营业额的统计 + $today = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']]); + $turnover_today = $today + ->whereDay('create_time') + ->sum('pay_price'); + //当日利润的统计 + $profit_today = $today + ->whereDay('create_time') + ->sum('profit'); + //当日成本合集的统计 + $cost_today = $today + ->whereDay('create_time') + ->sum('cost'); + + //当日加到保证金的 + $deposit = StoreFinanceFlow::where(['store_id'=>$params['store_id'],'status'=>YesNoEnum::YES]) + ->where('financial_type',OrderEnum::ORDER_MARGIN); + $deposit_today =$deposit + ->whereDay('create_time') + ->sum('number'); + //当日的现金收银 + $cash_today = StoreCashFinanceFlow::where('store_id',$params['store_id']) + ->whereDay('create_time') + ->where('status',YesNoEnum::YES) + ->sum('receivable'); + + //总的营业额的统计 总的利润的统计 总的成本合集的统计 总的加到保证金的 + $all = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']]); + + $deposit_all = StoreFinanceFlow::where(['store_id'=>$params['store_id'],'status'=>YesNoEnum::YES]) + ->sum('number'); + + $cash_all = StoreCashFinanceFlow::where('store_id',$params['store_id']) + ->where('status',YesNoEnum::YES) + ->sum('receivable'); + if(isset($params['month']) && $params['month']){ + $all = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$params['store_id']]) + ->whereMonth('create_time', $params['month']) + ; + $deposit_all = SystemStore::where('id',$params['store_id']) + ->whereMonth('create_time', $params['month']) + ->value('paid_deposit'); + $cash_all = StoreCashFinanceFlow::where('store_id',$params['store_id']) + ->where('status',YesNoEnum::YES) + ->whereMonth('create_time', $params['month']) + ->sum('receivable'); + } + $turnover_all = $all + ->sum('pay_price'); + $profit_all = $all + ->sum('profit'); + //消耗余额 V2.0 + $cost_all = CapitalFlow:: + where(['category'=>'user_order_balance_pay','store_id'=>$params['store_id']]) + ->sum('amount'); + + $time = self::getLastSevenDays(); + $newArr = []; + foreach ($time as $value){ + $data = self::dealSearch($params['store_id'],$value); + $newArr[$value] = $data; + } + return [ + 'today'=>[ + 'turnover_today'=>$turnover_today, + 'profit_today'=>$profit_today, + 'cost_today'=>$cost_today, + 'deposit_today'=>$deposit_today, + 'cash_today'=>$cash_today, + ], + 'all'=>[ + 'turnover_all'=>$turnover_all, + 'profit_all'=>$profit_all, + 'cost_all'=>$cost_all, + 'deposit_all'=>$deposit_all, + 'cash_all'=>$cash_all, + ], + 'time'=>$newArr + ]; + + + // 可以选时间 当日订单数 本月订单数 拆分线上和线下的方式 ---v.01 + /* if($params['start_time'] && $params['end_time']){ + $startTime = $params['start_time']; + $endTime = $params['end_time']; + $endTime = date('Y-m-d', strtotime($endTime) + 86400); + }else{ + $startTime = date('Y-m-d',time()); + $endTime = date('Y-m-d', strtotime($startTime) + 86400); + } + + //当日订单和当月订单 + $base = StoreOrder::where('paid',YesNoEnum::YES); + $offline_order_today_num =$base + ->whereIn('shipping_type',OrderEnum::OFFLINE) + ->whereDay('create_time') + ->count(); + + $offline_order_today_month = $base + ->whereIn('shipping_type',OrderEnum::OFFLINE) + ->whereMonth('create_time') + ->count(); + //条码收银的-->微信和支付宝的没那个 + + //线下现金收银 + whereIn('pay_type',[OrderEnum::CASHIER_ORDER_PAY, + OrderEnum::CASHIER_ORDER_ALI_PAY,OrderEnum::CASHIER_FACE_PAY]) + $cash = StoreCashFinanceFlow::where('store_id',$params['store_id']) + ->whereBetweenTime('create_time', $startTime, $endTime) + ->where('status',YesNoEnum::YES); + $cash_count = $cash->count(); + $cash_receipt = $cash->sum('receipts');*/ + + } + + + public static function getLastSevenDays() + { + $dates = []; + $today = new \DateTime(); // 获取当前日期 + + for ($i = 0; $i < 30; $i++) { + $date = clone $today; // 克隆当前日期对象,以避免修改原始对象 + $date->modify("-$i day"); // 减去相应的天数 + $dates[] = $date->format('Y-m-d'); // 格式化日期并添加到数组中 + } + + return $dates; + } + + + public static function dealSearch($store_id,$startTime) + { + $endTime = date('Y-m-d', strtotime($startTime) + 86400); + //当日营业额的统计 当日利润的统计 当日成本合集的统计 当日加到保证金的 当日的现金收银 + $today = StoreOrder::where(['paid'=>YesNoEnum::YES,'store_id'=>$store_id]); + $turnover_today = $today + ->whereBetweenTime('create_time', $startTime, $endTime) + ->sum('pay_price'); + $profit_today = $today + ->whereBetweenTime('create_time', $startTime, $endTime) + ->sum('profit'); + $cost_today = $today + ->whereBetweenTime('create_time', $startTime, $endTime) + ->sum('cost'); + + $deposit = StoreFinanceFlow::where(['store_id'=>$store_id]) + ->where('financial_type',OrderEnum::ORDER_MARGIN); + $deposit_today =$deposit + ->whereBetweenTime('create_time', $startTime, $endTime) + ->sum('number'); + + $cash_today = StoreCashFinanceFlow::where('store_id',$store_id) + ->whereBetweenTime('create_time', $startTime, $endTime) + ->where('status',YesNoEnum::YES) + ->sum('receipts'); + return [ + 'turnover_today'=>$turnover_today, + 'profit_today'=>$profit_today, + 'cost_today'=>$cost_today, + 'deposit_today'=>$deposit_today, + 'cash_today'=>$cash_today, + ]; + + } + + public static function rechargeData($params) + { + $data['receipt_amount'] = UserRecharge::where([ + 'store_id'=>$params['store_id'], + 'paid'=>YesNoEnum::YES + ])->sum('price'); + return $data??[]; + } + + + + + } diff --git a/app/store/logic/store_branch_product/StoreBranchProductLogic.php b/app/store/logic/store_branch_product/StoreBranchProductLogic.php index ad7a331ce..b08da5d3b 100644 --- a/app/store/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/store/logic/store_branch_product/StoreBranchProductLogic.php @@ -127,29 +127,6 @@ class StoreBranchProductLogic extends BaseLogic return StoreProduct::findOrEmpty($params['id'])->toArray(); } - /** - * 更新商品分类 - */ - public static function updateGoodsclass($id, $type = 0) - { - $pid = StoreCategory::where('id', $id)->value('pid'); - if ($pid) { - $goodsclass = StoreCategory::where('id', $pid)->field('pid,children')->find(); - if ($goodsclass) { - if (count($goodsclass['children']) >= 1) { - if (!in_array($id, $goodsclass['children'])) { - $arr = $goodsclass['children']; - array_push($arr, $id); - StoreCategory::where('id', $pid)->update(['children' => $arr]); - if ($goodsclass['pid'] != 0 && $type == 0) { - self::updateGoodsclass($pid, 1); - } - } - } - } - } - } - /** * @notes 商品上下架 * @param array $params diff --git a/app/store/logic/store_product/StoreProductLogic.php b/app/store/logic/store_product/StoreProductLogic.php index 1dd27998d..150040c2f 100644 --- a/app/store/logic/store_product/StoreProductLogic.php +++ b/app/store/logic/store_product/StoreProductLogic.php @@ -122,27 +122,4 @@ class StoreProductLogic extends BaseLogic { return StoreProduct::findOrEmpty($params['id'])->toArray(); } - - /** - * 更新商品分类 - */ - public static function updateGoodsclass($id, $type = 0) - { - $pid = StoreCategory::where('id', $id)->value('pid'); - if ($pid) { - $goodsclass = StoreCategory::where('id', $pid)->field('pid,children')->find(); - if ($goodsclass) { - if (count($goodsclass['children']) >= 1) { - if (!in_array($id, $goodsclass['children'])) { - $arr = $goodsclass['children']; - array_push($arr, $id); - StoreCategory::where('id', $pid)->update(['children' => $arr]); - if ($goodsclass['pid'] != 0 && $type == 0) { - self::updateGoodsclass($pid, 1); - } - } - } - } - } - } } diff --git a/app/store/validate/store_order/StoreOrderValidate.php b/app/store/validate/store_order/StoreOrderValidate.php index f7b4eeb81..928c46581 100644 --- a/app/store/validate/store_order/StoreOrderValidate.php +++ b/app/store/validate/store_order/StoreOrderValidate.php @@ -21,6 +21,8 @@ class StoreOrderValidate extends BaseValidate protected $rule = [ 'id' => 'requireWithout:verify_code', 'verify_code' => 'requireWithout:id', + 'uid' => 'require|number', + 'cart_id' => 'require|array', ]; @@ -81,4 +83,9 @@ class StoreOrderValidate extends BaseValidate return $this->only(['id','verify_code']); } + public function sceneCheck() + { + return $this->only(['uid','cart_id']); + } + } diff --git a/composer.json b/composer.json index 7ed7add65..5a665d605 100644 --- a/composer.json +++ b/composer.json @@ -54,9 +54,9 @@ "ext-bcmath": "*", "jpush/jpush": "^3.6", "workerman/crontab": "^1.0", - "hg/apidoc": "^5.2", "intervention/image": "^3.6", - "picqer/php-barcode-generator": "^2.4" + "picqer/php-barcode-generator": "^2.4", + "overtrue/easy-sms": "^2.6" }, "suggest": { "ext-event": "For better performance. " diff --git a/composer.lock b/composer.lock index 2b148506f..02626c932 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8c97deb23217033cd0ab2cb6e5b5d195", + "content-hash": "54acb0fe3bc70f1e94406e7b79e84b8a", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -1240,75 +1240,6 @@ ], "time": "2023-12-03T19:50:20+00:00" }, - { - "name": "hg/apidoc", - "version": "v5.2.3", - "source": { - "type": "git", - "url": "https://github.com/HGthecode/apidoc-php.git", - "reference": "328aa4fe177ed7393f680724bf3eeb485052c2fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/HGthecode/apidoc-php/zipball/328aa4fe177ed7393f680724bf3eeb485052c2fe", - "reference": "328aa4fe177ed7393f680724bf3eeb485052c2fe", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1 || ^2", - "php": "^7.1 || ^8.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "hg\\apidoc\\providers\\LaravelService" - ] - }, - "think": { - "services": [ - "hg\\apidoc\\providers\\ThinkPHPService" - ], - "config": { - "apidoc": "src/config.php" - } - }, - "hyperf": { - "config": "hg\\apidoc\\ConfigProvider" - } - }, - "autoload": { - "psr-4": { - "hg\\apidoc\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "hg-code", - "email": "376401263@qq.com" - } - ], - "description": "根据注解生成API文档,兼容Laravel、ThinkPHP、Hyperf、Webman等框架;在线调试、Markdown文档、多应用/多版本、Mock数据、授权访问、接口生成器、代码生成器等众多实用功能", - "keywords": [ - "apidoc", - "api文档", - "markdown", - "php接口文档", - "接口文档", - "注解", - "注释生成", - "自动生成api" - ], - "support": { - "issues": "https://github.com/HGthecode/apidoc-php/issues", - "source": "https://github.com/HGthecode/apidoc-php/tree/v5.2.3" - }, - "time": "2024-03-22T02:25:31+00:00" - }, { "name": "hyperf/context", "version": "v3.1.15", @@ -2848,6 +2779,78 @@ ], "time": "2023-11-08T09:30:43+00:00" }, + { + "name": "overtrue/easy-sms", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/easy-sms.git", + "reference": "bb88b244f0de8d1f74bc50c4c08414f4c5f30281" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/easy-sms/zipball/bb88b244f0de8d1f74bc50c4c08414f4c5f30281", + "reference": "bb88b244f0de8d1f74bc50c4c08414f4c5f30281", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "php": ">=5.6" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "jetbrains/phpstorm-attributes": "^1.0", + "mockery/mockery": "~1.3.3 || ^1.4.2", + "phpunit/phpunit": "^5.7 || ^7.5 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "extra": { + "hooks": { + "pre-commit": [ + "composer check-style", + "composer psalm", + "composer test" + ], + "pre-push": [ + "composer check-style" + ] + } + }, + "autoload": { + "psr-4": { + "Overtrue\\EasySms\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "i@overtrue.me" + } + ], + "description": "The easiest way to send short message.", + "support": { + "issues": "https://github.com/overtrue/easy-sms/issues", + "source": "https://github.com/overtrue/easy-sms/tree/2.6.0" + }, + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "time": "2024-03-08T06:36:45+00:00" + }, { "name": "overtrue/socialite", "version": "4.10.1", diff --git a/config/middleware.php b/config/middleware.php index 6bc9bfc97..f2a5297fd 100644 --- a/config/middleware.php +++ b/config/middleware.php @@ -38,5 +38,10 @@ return [ app\store\middleware\InitMiddleware::class, app\store\middleware\LoginMiddleware::class, // app\store\middleware\AuthMiddleware::class, - ] + ], + 'statistics' => [ + // 跨域中间件 + app\common\http\middleware\AdminAllowMiddleware::class, + + ], ]; diff --git a/config/plugin/hg/apidoc/app.php b/config/plugin/hg/apidoc/app.php deleted file mode 100644 index 6af1865fc..000000000 --- a/config/plugin/hg/apidoc/app.php +++ /dev/null @@ -1,105 +0,0 @@ - true, - 'apidoc' => [ - // (选配)文档标题,显示在左上角与首页 - 'title' => '接口文档', - // (选配)文档描述,显示在首页 - 'desc' => '', - // (必须)设置文档的应用/版本 - 'apps' => [ - [ - // (必须)标题 - 'title' => 'store接口', - // (必须)控制器目录地址 - 'path' => 'app\store\controller', - // (必须)唯一的key - 'key' => 'storeApi', - ], - [ - // (必须)标题 - 'title' => 'api接口', - // (必须)控制器目录地址 - 'path' => 'app\api\controller', - // (必须)唯一的key - 'key' => 'apiApi', - ] - ], - // (必须)指定通用注释定义的文件地址 - 'definitions' => "app\common\controller\Definitions", - // (必须)自动生成url规则,当接口不添加@Apidoc\Url ("xxx")注解时,使用以下规则自动生成 - 'auto_url' => [ - // 字母规则,lcfirst=首字母小写;ucfirst=首字母大写; - 'letter_rule' => "lcfirst", - // url前缀 - 'prefix' => "", - ], - // (选配)是否自动注册路由 - 'auto_register_routes' => true, - // (必须)缓存配置 - 'cache' => [ - // 是否开启缓存 - 'enable' => false, - ], - // (必须)权限认证配置 - 'auth' => [ - // 是否启用密码验证 - 'enable' => true, - // 全局访问密码 - 'password' => "qwe123", - // 密码加密盐 - 'secret_key' => "qwe123", - // 授权访问后的有效期 - 'expire' => 86400 * 7 - ], - // 全局参数 - 'params' => [ - // (选配)全局的请求Header - 'header' => [ - // name=字段名,type=字段类型,require=是否必须,default=默认值,desc=字段描述 - ['name' => 'Authorization', 'type' => 'string', 'require' => true, 'desc' => '身份令牌Token'], - ], - // (选配)全局的请求Query - 'query' => [ - // 同上 header - ], - // (选配)全局的请求Body - 'body' => [ - // 同上 header - ], - ], - // 全局响应体 - 'responses' => [ - // 成功响应体 - 'success' => [ - ['name' => 'code', 'desc' => '业务代码', 'type' => 'int', 'require' => 1], - ['name' => 'message', 'desc' => '业务信息', 'type' => 'string', 'require' => 1], - //参数同上 headers;main=true来指定接口Returned参数挂载节点 - ['name' => 'data', 'desc' => '业务数据', 'main' => true, 'type' => 'object', 'require' => 1], - ], - // 异常响应体 - 'error' => [ - ['name' => 'code', 'desc' => '业务代码', 'type' => 'int', 'require' => 1, 'md' => '/docs/HttpError.md'], - ['name' => 'message', 'desc' => '业务信息', 'type' => 'string', 'require' => 1], - ] - ], - //(选配)默认作者 - 'default_author' => '', - //(选配)默认请求类型 - 'default_method' => 'GET', - //(选配)Apidoc允许跨域访问 - 'allowCrossDomain' => false, - /** - * (选配)解析时忽略带@注解的关键词,当注解中存在带@字符并且非Apidoc注解,如 @key test,此时Apidoc页面报类似以下错误时: - * [Semantical Error] The annotation "@key" in method xxx() was never imported. Did you maybe forget to add a "use" statement for this annotation? - */ - 'ignored_annitation' => [], - - // (选配)数据库配置 - 'database' => [], - // (选配)Markdown文档 - 'docs' => [], - // (选配)接口生成器配置 注意:是一个二维数组 - 'generator' => [] - ] -]; diff --git a/config/plugin/hg/apidoc/route.php b/config/plugin/hg/apidoc/route.php deleted file mode 100644 index 1b03a1f35..000000000 --- a/config/plugin/hg/apidoc/route.php +++ /dev/null @@ -1,3 +0,0 @@ - [ + 'handler' => process\Task::class + ], ]; diff --git a/process/Task.php b/process/Task.php new file mode 100644 index 000000000..fa0e66504 --- /dev/null +++ b/process/Task.php @@ -0,0 +1,22 @@ +0]; + $where[]=['create_time','<',time() - 600];// 10分钟前创建的订单 + // 删除10分钟未支付的订单 + StoreOrder::where($where)->update(['delete_time'=>time()]); // 删除时间设置为当前时间,即删除 + }); + + + } +} \ No newline at end of file diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 2dcede840..348204ddb 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -10,7 +10,6 @@ return array( 'think\\' => array($vendorDir . '/topthink/think-container/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src'), 'taoser\\' => array($vendorDir . '/taoser/webman-validate/src'), 'support\\' => array($vendorDir . '/workerman/webman-framework/src/support'), - 'hg\\apidoc\\' => array($vendorDir . '/hg/apidoc/src'), 'app\\View\\Components\\' => array($baseDir . '/app/view/components'), 'app\\' => array($baseDir . '/app'), 'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'), @@ -73,6 +72,7 @@ return array( 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), 'PhpDocReader\\' => array($vendorDir . '/php-di/phpdoc-reader/src/PhpDocReader'), 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), + 'Overtrue\\EasySms\\' => array($vendorDir . '/overtrue/easy-sms/src'), 'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'), 'Nyholm\\Psr7\\' => array($vendorDir . '/nyholm/psr7/src'), 'Nyholm\\Psr7Server\\' => array($vendorDir . '/nyholm/psr7-server/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index b4a008779..a6ee17994 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -57,10 +57,6 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc array ( 'support\\' => 8, ), - 'h' => - array ( - 'hg\\apidoc\\' => 10, - ), 'a' => array ( 'app\\View\\Components\\' => 20, @@ -149,6 +145,7 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc 'O' => array ( 'Overtrue\\Socialite\\' => 19, + 'Overtrue\\EasySms\\' => 17, 'OSS\\' => 4, ), 'N' => @@ -247,10 +244,6 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc array ( 0 => __DIR__ . '/..' . '/workerman/webman-framework/src/support', ), - 'hg\\apidoc\\' => - array ( - 0 => __DIR__ . '/..' . '/hg/apidoc/src', - ), 'app\\View\\Components\\' => array ( 0 => __DIR__ . '/../..' . '/app/view/components', @@ -500,6 +493,10 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc array ( 0 => __DIR__ . '/..' . '/overtrue/socialite/src', ), + 'Overtrue\\EasySms\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/easy-sms/src', + ), 'OSS\\' => array ( 0 => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7c04a8972..9dfcf3b4e 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1282,78 +1282,6 @@ ], "install-path": "../guzzlehttp/uri-template" }, - { - "name": "hg/apidoc", - "version": "v5.2.3", - "version_normalized": "5.2.3.0", - "source": { - "type": "git", - "url": "https://github.com/HGthecode/apidoc-php.git", - "reference": "328aa4fe177ed7393f680724bf3eeb485052c2fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/HGthecode/apidoc-php/zipball/328aa4fe177ed7393f680724bf3eeb485052c2fe", - "reference": "328aa4fe177ed7393f680724bf3eeb485052c2fe", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1 || ^2", - "php": "^7.1 || ^8.0" - }, - "time": "2024-03-22T02:25:31+00:00", - "type": "library", - "extra": { - "laravel": { - "providers": [ - "hg\\apidoc\\providers\\LaravelService" - ] - }, - "think": { - "services": [ - "hg\\apidoc\\providers\\ThinkPHPService" - ], - "config": { - "apidoc": "src/config.php" - } - }, - "hyperf": { - "config": "hg\\apidoc\\ConfigProvider" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "hg\\apidoc\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "hg-code", - "email": "376401263@qq.com" - } - ], - "description": "根据注解生成API文档,兼容Laravel、ThinkPHP、Hyperf、Webman等框架;在线调试、Markdown文档、多应用/多版本、Mock数据、授权访问、接口生成器、代码生成器等众多实用功能", - "keywords": [ - "apidoc", - "api文档", - "markdown", - "php接口文档", - "接口文档", - "注解", - "注释生成", - "自动生成api" - ], - "support": { - "issues": "https://github.com/HGthecode/apidoc-php/issues", - "source": "https://github.com/HGthecode/apidoc-php/tree/v5.2.3" - }, - "install-path": "../hg/apidoc" - }, { "name": "hyperf/context", "version": "v3.1.15", @@ -2965,6 +2893,81 @@ ], "install-path": "../nyholm/psr7-server" }, + { + "name": "overtrue/easy-sms", + "version": "2.6.0", + "version_normalized": "2.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/easy-sms.git", + "reference": "bb88b244f0de8d1f74bc50c4c08414f4c5f30281" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/easy-sms/zipball/bb88b244f0de8d1f74bc50c4c08414f4c5f30281", + "reference": "bb88b244f0de8d1f74bc50c4c08414f4c5f30281", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "php": ">=5.6" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "jetbrains/phpstorm-attributes": "^1.0", + "mockery/mockery": "~1.3.3 || ^1.4.2", + "phpunit/phpunit": "^5.7 || ^7.5 || ^8.5.19 || ^9.5.8" + }, + "time": "2024-03-08T06:36:45+00:00", + "type": "library", + "extra": { + "hooks": { + "pre-commit": [ + "composer check-style", + "composer psalm", + "composer test" + ], + "pre-push": [ + "composer check-style" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Overtrue\\EasySms\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "i@overtrue.me" + } + ], + "description": "The easiest way to send short message.", + "support": { + "issues": "https://github.com/overtrue/easy-sms/issues", + "source": "https://github.com/overtrue/easy-sms/tree/2.6.0" + }, + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "install-path": "../overtrue/easy-sms" + }, { "name": "overtrue/socialite", "version": "4.10.1", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 43e1d6ee2..b1b2bed46 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'workerman/webman', - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '4b5122f1ac239cde50650106617717ac4ed3db2b', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -154,15 +154,6 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'hg/apidoc' => array( - 'pretty_version' => 'v5.2.3', - 'version' => '5.2.3.0', - 'reference' => '328aa4fe177ed7393f680724bf3eeb485052c2fe', - 'type' => 'library', - 'install_path' => __DIR__ . '/../hg/apidoc', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'hyperf/context' => array( 'pretty_version' => 'v3.1.15', 'version' => '3.1.15.0', @@ -385,6 +376,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'overtrue/easy-sms' => array( + 'pretty_version' => '2.6.0', + 'version' => '2.6.0.0', + 'reference' => 'bb88b244f0de8d1f74bc50c4c08414f4c5f30281', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/easy-sms', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'overtrue/socialite' => array( 'pretty_version' => '4.10.1', 'version' => '4.10.1.0', @@ -1038,9 +1038,9 @@ 'dev_requirement' => false, ), 'workerman/webman' => array( - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '4b5122f1ac239cde50650106617717ac4ed3db2b', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/hg/apidoc/.gitignore b/vendor/hg/apidoc/.gitignore deleted file mode 100644 index 485dee64b..000000000 --- a/vendor/hg/apidoc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/vendor/hg/apidoc/README.md b/vendor/hg/apidoc/README.md deleted file mode 100644 index 0f8ace596..000000000 --- a/vendor/hg/apidoc/README.md +++ /dev/null @@ -1,88 +0,0 @@ -
:calling: 一款满足你的多种发送需求的短信发送组件
+ + + + + + +## 特点 + +1. 支持目前市面多家服务商 +1. 一套写法兼容所有平台 +1. 简单配置即可灵活增减服务商 +1. 内置多种服务商轮询策略、支持自定义轮询策略 +1. 统一的返回值格式,便于日志与监控 +1. 自动轮询选择可用的服务商 +1. 更多等你去发现与改进... + +## 平台支持 + +- [腾讯云 SMS](https://cloud.tencent.com/product/sms) +- [Ucloud](https://www.ucloud.cn) +- [七牛云](https://www.qiniu.com/) +- [SendCloud](http://www.sendcloud.net/) +- [阿里云](https://www.aliyun.com/) +- [云片](https://www.yunpian.com) +- [Submail](https://www.mysubmail.com) +- [螺丝帽](https://luosimao.com/) +- [容联云通讯](http://www.yuntongxun.com) +- [互亿无线](http://www.ihuyi.com) +- [聚合数据](https://www.juhe.cn) +- [百度云](https://cloud.baidu.com/) +- [华信短信平台](http://www.ipyy.com/) +- [253云通讯(创蓝)](https://www.253.com/) +- [创蓝云智](https://www.chuanglan.com/) +- [融云](http://www.rongcloud.cn) +- [天毅无线](http://www.85hu.com/) +- [阿凡达数据](http://www.avatardata.cn/) +- [华为云](https://www.huaweicloud.com/product/msgsms.html) +- [网易云信](https://yunxin.163.com/sms) +- [云之讯](https://www.ucpaas.com/index.html) +- [凯信通](http://www.kingtto.cn/) +- [UE35.net](http://uesms.ue35.cn/) +- [短信宝](http://www.smsbao.com/) +- [Tiniyo](https://tiniyo.com/) +- [摩杜云](https://www.moduyun.com/) +- [融合云(助通)](https://www.ztinfo.cn/products/sms) +- [蜘蛛云](https://zzyun.com/) +- [融合云信](https://maap.wo.cn/) +- [天瑞云](http://cms.tinree.com/) +- [时代互联](https://www.now.cn/) +- [火山引擎](https://console.volcengine.com/sms/) + +## 环境需求 + +- PHP >= 5.6 + +## 安装 + +```shell +$ composer require "overtrue/easy-sms" +``` + +**For Laravel notification** + +如果你喜欢使用 [Laravel Notification](https://laravel.com/docs/5.8/notifications), 可以考虑直接使用朋友封装的拓展包: + +https://github.com/yl/easysms-notification-channel + +## 使用 + +```php +use Overtrue\EasySms\EasySms; + +$config = [ + // HTTP 请求的超时时间(秒) + 'timeout' => 5.0, + + // 默认发送配置 + 'default' => [ + // 网关调用策略,默认:顺序调用 + 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, + + // 默认可用的发送网关 + 'gateways' => [ + 'yunpian', 'aliyun', + ], + ], + // 可用的网关配置 + 'gateways' => [ + 'errorlog' => [ + 'file' => '/tmp/easy-sms.log', + ], + 'yunpian' => [ + 'api_key' => '824f0ff2f71cab52936axxxxxxxxxx', + ], + 'aliyun' => [ + 'access_key_id' => '', + 'access_key_secret' => '', + 'sign_name' => '', + ], + //... + ], +]; + +$easySms = new EasySms($config); + +$easySms->send(13188888888, [ + 'content' => '您的验证码为: 6379', + 'template' => 'SMS_001', + 'data' => [ + 'code' => 6379 + ], +]); +``` + +## 短信内容 + +由于使用多网关发送,所以一条短信要支持多平台发送,每家的发送方式不一样,但是我们抽象定义了以下公用属性: + +- `content` 文字内容,使用在像云片类似的以文字内容发送的平台 +- `template` 模板 ID,使用在以模板ID来发送短信的平台 +- `data` 模板变量,使用在以模板ID来发送短信的平台 + +所以,在使用过程中你可以根据所要使用的平台定义发送的内容。 + +```php +$easySms->send(13188888888, [ + 'content' => '您的验证码为: 6379', + 'template' => 'SMS_001', + 'data' => [ + 'code' => 6379 + ], +]); +``` + +你也可以使用闭包来返回对应的值: + +```php +$easySms->send(13188888888, [ + 'content' => function($gateway){ + return '您的验证码为: 6379'; + }, + 'template' => function($gateway){ + return 'SMS_001'; + }, + 'data' => function($gateway){ + return [ + 'code' => 6379 + ]; + }, +]); +``` + +你可以根据 `$gateway` 参数类型来判断返回值,例如: + +```php +$easySms->send(13188888888, [ + 'content' => function($gateway){ + if ($gateway->getName() == 'yunpian') { + return '云片专用验证码:1235'; + } + return '您的验证码为: 6379'; + }, + 'template' => function($gateway){ + if ($gateway->getName() == 'aliyun') { + return 'TP2818'; + } + return 'SMS_001'; + }, + 'data' => function($gateway){ + return [ + 'code' => 6379 + ]; + }, +]); +``` + +## 发送网关 + +默认使用 `default` 中的设置来发送,如果某一条短信你想要覆盖默认的设置。在 `send` 方法中使用第三个参数即可: + +```php +$easySms->send(13188888888, [ + 'content' => '您的验证码为: 6379', + 'template' => 'SMS_001', + 'data' => [ + 'code' => 6379 + ], + ], ['yunpian', 'juhe']); // 这里的网关配置将会覆盖全局默认值 +``` + +## 返回值 + +由于使用多网关发送,所以返回值为一个数组,结构如下: +```php +[ + 'yunpian' => [ + 'gateway' => 'yunpian', + 'status' => 'success', + 'result' => [...] // 平台返回值 + ], + 'juhe' => [ + 'gateway' => 'juhe', + 'status' => 'failure', + 'exception' => \Overtrue\EasySms\Exceptions\GatewayErrorException 对象 + ], + //... +] +``` + +如果所选网关列表均发送失败时,将会抛出 `Overtrue\EasySms\Exceptions\NoGatewayAvailableException` 异常,你可以使用 `$e->results` 获取发送结果。 + +你也可以使用 `$e` 提供的更多便捷方法: + +```php +$e->getResults(); // 返回所有 API 的结果,结构同上 +$e->getExceptions(); // 返回所有调用异常列表 +$e->getException($gateway); // 返回指定网关名称的异常对象 +$e->getLastException(); // 获取最后一个失败的异常对象 +``` + +## 自定义网关 + +本拓展已经支持用户自定义网关,你可以很方便的配置即可当成与其它拓展一样的使用: + +```php +$config = [ + ... + 'default' => [ + 'gateways' => [ + 'mygateway', // 配置你的网站到可用的网关列表 + ], + ], + 'gateways' => [ + 'mygateway' => [...], // 你网关所需要的参数,如果没有可以不配置 + ], +]; + +$easySms = new EasySms($config); + +// 注册 +$easySms->extend('mygateway', function($gatewayConfig){ + // $gatewayConfig 来自配置文件里的 `gateways.mygateway` + return new MyGateway($gatewayConfig); +}); + +$easySms->send(13188888888, [ + 'content' => '您的验证码为: 6379', + 'template' => 'SMS_001', + 'data' => [ + 'code' => 6379 + ], +]); +``` + +## 国际短信 + +国际短信与国内短信的区别是号码前面需要加国际码,但是由于各平台对国际号码的写法不一致,所以在发送国际短信的时候有一点区别: + +```php +use Overtrue\EasySms\PhoneNumber; + +// 发送到国际码为 31 的国际号码 +$number = new PhoneNumber(13188888888, 31); + +$easySms->send($number, [ + 'content' => '您的验证码为: 6379', + 'template' => 'SMS_001', + 'data' => [ + 'code' => 6379 + ], +]); +``` + +## 定义短信 + +你可以根据发送场景的不同,定义不同的短信类,从而实现一处定义多处调用,你可以继承 `Overtrue\EasySms\Message` 来定义短信模型: + +```php +order = $order; + } + + // 定义直接使用内容发送平台的内容 + public function getContent(GatewayInterface $gateway = null) + { + return sprintf('您的订单:%s, 已经完成付款', $this->order->no); + } + + // 定义使用模板发送方式平台所需要的模板 ID + public function getTemplate(GatewayInterface $gateway = null) + { + return 'SMS_003'; + } + + // 模板参数 + public function getData(GatewayInterface $gateway = null) + { + return [ + 'order_no' => $this->order->no + ]; + } +} +``` + +> 更多自定义方式请参考:[`Overtrue\EasySms\Message`](Overtrue\EasySms\Message;) + +发送自定义短信: + +```php +$order = ...; +$message = new OrderPaidMessage($order); + +$easySms->send(13188888888, $message); +``` + +## 各平台配置说明 + +### [阿里云](https://www.aliyun.com/) + +短信内容使用 `template` + `data` + +```php + 'aliyun' => [ + 'access_key_id' => '', + 'access_key_secret' => '', + 'sign_name' => '', + ], +``` + +### [阿里云Rest](https://www.aliyun.com/) + +短信内容使用 `template` + `data` + +```php + 'aliyunrest' => [ + 'app_key' => '', + 'app_secret_key' => '', + 'sign_name' => '', + ], +``` + +### [阿里云国际](https://www.alibabacloud.com/help/zh/doc-detail/160524.html) + +短信内容使用 `template` + `data` + +```php + 'aliyunintl' => [ + 'access_key_id' => '', + 'access_key_secret' => '', + 'sign_name' => '', + ], +``` + +发送示例: + +```php +use Overtrue\EasySms\PhoneNumber; + +$easySms = new EasySms($config); +$phone_number = new PhoneNumber(18888888888, 86); + +$easySms->send($phone_number, [ + 'content' => '您好:先生/女士!您的验证码为${code},有效时间是5分钟,请及时验证。', + 'template' => 'SMS_00000001', // 模板ID + 'data' => [ + "code" => 521410, + ], +]); +``` + +### [云片](https://www.yunpian.com) + +短信内容使用 `content` + +```php + 'yunpian' => [ + 'api_key' => '', + 'signature' => '【默认签名】', // 内容中无签名时使用 + ], +``` + +### [Submail](https://www.mysubmail.com) + +短信内容使用 `data` + +```php + 'submail' => [ + 'app_id' => '', + 'app_key' => '', + 'project' => '', // 默认 project,可在发送时 data 中指定 + ], +``` + +### [螺丝帽](https://luosimao.com/) + +短信内容使用 `content` + +```php + 'luosimao' => [ + 'api_key' => '', + ], +``` + +### [容联云通讯](http://www.yuntongxun.com) + +短信内容使用 `template` + `data` + +```php + 'yuntongxun' => [ + 'app_id' => '', + 'account_sid' => '', + 'account_token' => '', + 'is_sub_account' => false, + ], +``` + +### [互亿无线](http://www.ihuyi.com) + +短信内容使用 `content` + +```php + 'huyi' => [ + 'api_id' => '', + 'api_key' => '', + 'signature' => '', + ], +``` + +### [聚合数据](https://www.juhe.cn) + +短信内容使用 `template` + `data` + +```php + 'juhe' => [ + 'app_key' => '', + ], +``` + +### [SendCloud](http://www.sendcloud.net/) + +短信内容使用 `template` + `data` + +```php + 'sendcloud' => [ + 'sms_user' => '', + 'sms_key' => '', + 'timestamp' => false, // 是否启用时间戳 + ], +``` +### [百度云](https://cloud.baidu.com/) + +短信内容使用 `template` + `data` + +```php + 'baidu' => [ + 'ak' => '', + 'sk' => '', + 'invoke_id' => '', + 'domain' => '', + ], +``` + +### [华信短信平台](http://www.ipyy.com/) + +短信内容使用 `content` + +```php + 'huaxin' => [ + 'user_id' => '', + 'password' => '', + 'account' => '', + 'ip' => '', + 'ext_no' => '', + ], +``` + +### [253云通讯(创蓝)](https://www.253.com/) + +短信内容使用 `content` + +```php + 'chuanglan' => [ + 'account' => '', + 'password' => '', + + // 国际短信时必填 + 'intel_account' => '', + 'intel_password' => '', + + // \Overtrue\EasySms\Gateways\ChuanglanGateway::CHANNEL_VALIDATE_CODE => 验证码通道(默认) + // \Overtrue\EasySms\Gateways\ChuanglanGateway::CHANNEL_PROMOTION_CODE => 会员营销通道 + 'channel' => \Overtrue\EasySms\Gateways\ChuanglanGateway::CHANNEL_VALIDATE_CODE, + + // 会员营销通道 特定参数。创蓝规定:api提交营销短信的时候,需要自己加短信的签名及退订信息 + 'sign' => '【通讯云】', + 'unsubscribe' => '回TD退订', + ], +``` + +### [创蓝云智](https://www.chuanglan.com/) + +普通短信发送内容使用 `content` + +```php + 'chuanglanv1' => [ + 'account' => '', + 'password' => '', + 'needstatus' => false, + 'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_NORMAL_CODE, + ], +``` +发送示例: + +```php +$easySms->send(18888888888, [ + 'content' => xxxxxxx +]); +``` + +变量短信发送内容使用 `template` + `data` + +```php + 'chuanglanv1' => [ + 'account' => '', + 'password' => '', + 'needstatus' => false, + 'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_VARIABLE_CODE, + ], +``` +发送示例: + +```php +$easySms->send(18888888888, [ + 'template' => xxxxxx, // 模板内容 + 'data' => 'phone":"15800000000,1234;15300000000,4321', +]); +``` + +### [融云](http://www.rongcloud.cn) + +短信分为两大类,验证类和通知类短信。 发送验证类短信使用 `template` + `data` + +```php + 'rongcloud' => [ + 'app_key' => '', + 'app_secret' => '', + ] +``` + +### [天毅无线](http://www.85hu.com/) + +短信内容使用 `content` + +```php + 'tianyiwuxian' => [ + 'username' => '', //用户名 + 'password' => '', //密码 + 'gwid' => '', //网关ID + ] +``` + +### [twilio](https://www.twilio.com) + +短信使用 `content` +发送对象需要 使用`+`添加区号 + +```php + 'twilio' => [ + 'account_sid' => '', // sid + 'from' => '', // 发送的号码 可以在控制台购买 + 'token' => '', // apitoken + ], +``` + +### [tiniyo](https://www.tiniyo.com) + +短信使用 `content` +发送对象需要 使用`+`添加区号 + +```php + 'tiniyo' => [ + 'account_sid' => '', // auth_id from https://tiniyo.com + 'from' => '', // 发送的号码 可以在控制台购买 + 'token' => '', // auth_secret from https://tiniyo.com + ], +``` + + +### [腾讯云 SMS](https://cloud.tencent.com/product/sms) + +短信内容使用 `template` + `data` + +```php + 'qcloud' => [ + 'sdk_app_id' => '', // 短信应用的 SDK APP ID + 'secret_id' => '', // SECRET ID + 'secret_key' => '', // SECRET KEY + 'sign_name' => '腾讯CoDesign', // 短信签名 + ], +``` + +发送示例: + +```php +$easySms->send(18888888888, [ + 'template' => 101234, // 模板ID + 'data' => [ + "a", 'b', 'c', 'd', //按占位顺序给值 + ], +]); +``` + +### [阿凡达数据](http://www.avatardata.cn/) + +短信内容使用 `template` + `data` + +```php + 'avatardata' => [ + 'app_key' => '', // APP KEY + ], +``` + +### [华为云 SMS](https://www.huaweicloud.com/product/msgsms.html) + +短信内容使用 `template` + `data` + +```php + 'huawei' => [ + 'endpoint' => '', // APP接入地址 + 'app_key' => '', // APP KEY + 'app_secret' => '', // APP SECRET + 'from' => [ + 'default' => '1069012345', // 默认使用签名通道号 + 'custom' => 'csms12345', // 其他签名通道号 可以在 data 中定义 from 来指定 + 'abc' => 'csms67890', // 其他签名通道号 + ... + ], + 'callback' => '' // 短信状态回调地址 + ], +``` + +使用默认签名通道 `default` + +```php +$easySms->send(13188888888, [ + 'template' => 'SMS_001', + 'data' => [ + 6379 + ], +]); +``` + +使用指定签名通道 + +```php +$easySms->send(13188888888, [ + 'template' => 'SMS_001', + 'data' => [ + 6379, + 'from' => 'custom' // 对应 config 中的 from 数组中 custom + ], +]); +``` + +### [网易云信](https://yunxin.163.com/sms) + +短信内容使用 `template` + `data` + +```php + 'yunxin' => [ + 'app_key' => '', + 'app_secret' => '', + 'code_length' => 4, // 随机验证码长度,范围 4~10,默认为 4 + 'need_up' => false, // 是否需要支持短信上行 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => 'SMS_001', // 不填则使用默认模板 + 'data' => [ + 'code' => 8946, // 如果设置了该参数,则 code_length 参数无效 + 'action' => 'sendCode', // 默认为 `sendCode`,校验短信验证码使用 `verifyCode` + ], +]); +``` +通知模板短信 + +```php +$easySms->send(18888888888, [ + 'template' => 'templateid', // 模板编号(由客户顾问配置之后告知开发者) + 'data' => [ + 'action' => 'sendTemplate', // 默认为 `sendCode`,校验短信验证码使用 `verifyCode` + 'params' => [1,2,3], //短信参数列表,用于依次填充模板 + ], +]); +``` + + +### [云之讯](https://www.ucpaas.com/index.html) + +短信内容使用 `template` + `data` + +```php + 'yunzhixun' => [ + 'sid' => '', + 'token' => '', + 'app_id' => '', + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => 'SMS_001', + 'data' => [ + 'params' => '8946,3', // 模板参数,多个参数使用 `,` 分割,模板无参数时可为空 + 'uid' => 'hexianghui', // 用户 ID,随状态报告返回,可为空 + 'mobiles' => '18888888888,188888888889', // 批量发送短信,手机号使用 `,` 分割,不使用批量发送请不要设置该参数 + ], +]); +``` + +### [凯信通](http://www.kingtto.cn/) + +短信内容使用 `content` + +```php + 'kingtto' => [ + 'userid' => '', + 'account' => '', + 'password' => '', + ], +``` + +```php +$easySms->send(18888888888, [ + 'content' => '您的验证码为: 6379', +]); +``` + +### [七牛云](https://www.qiniu.com/) + +短信内容使用 `template` + `data` + +```php + 'qiniu' => [ + 'secret_key' => '', + 'access_key' => '', + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => '1231234123412341234', + 'data' => [ + 'code' => 1234, + ], +]); +``` +### [Ucloud](https://www.ucloud.cn/) +短信使用 `template` + `data` + +```php + 'ucloud' => [ + 'private_key' => '', //私钥 + 'public_key' => '', //公钥 + 'sig_content' => '', // 短信签名, + 'project_id' => '', //项目ID,子账号才需要该参数 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => 'UTAXXXXX', //短信模板 + 'data' => [ + 'code' => 1234, //模板参数,模板没有参数不用则填写,有多个参数请用数组,[1111,1111] + 'mobiles' =>'', //同时发送多个手机短信,请用数组[xxx,xxx] + ], +]); + +``` + + +### [短信宝](http://www.smsbao.com/) +短信使用 `content` + +```php + 'smsbao' => [ + 'user' => '', //账号 + 'password' => '' //密码 + ], +``` + +```php +$easySms->send(18888888888, [ + 'content' => '您的验证码为: 6379', //短信模板 +]); + +``` + +### [摩杜云](https://www.moduyun.com/) +短信使用 `template` + `data` + +```php + 'moduyun' => [ + 'accesskey' => '', //必填 ACCESS KEY + 'secretkey' => '', //必填 SECRET KEY + 'signId' => '', //选填 短信签名,如果使用默认签名,该字段可缺省 + 'type' => 0, //选填 0:普通短信;1:营销短信 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => '5a95****b953', //短信模板 + 'data' => [ + 1234, //模板参数,对应模板的{1} + 30 //模板参数,对应模板的{2} + //... + ], +]); + +``` + +### [融合云(助通)](https://www.ztinfo.cn/products/sms) + +短信使用 `template` + `data` + +```php + 'rongheyun' => [ + 'username' => '', //必填 用户名 + 'password' => '', //必填 密码 + 'signature'=> '', //必填 已报备的签名 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => '31874', //短信模板 + 'data' => [ + 'valid_code' => '888888', //模板参数,对应模板的{valid_code} + //... + ], +]); + +``` + +### [蜘蛛云](https://zzyun.com/) + +短信使用 `template` + `data` + +```php + 'zzyun' => [ + 'user_id' => '', //必填 会员ID + 'secret' => '', //必填 接口密钥 + 'sign_name'=> '', //必填 短信签名 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => 'SMS_210317****', //短信模板 + 'data' => [ + 'code' => '888888', //模板参数,对应模板的{code} + //... + ], +]); + +``` + +### [融合云信](https://maap.wo.cn/) + +短信使用 `template` + `data` + +```php + 'maap' => [ + 'cpcode' => '', //必填 商户编码 + 'key' => '', //必填 接口密钥 + 'excode'=> '', //选填 扩展名 + ], +``` + +```php +$easySms->send(18888888888, [ + 'template' => '356120', //短信模板 + 'data' => [ + '123465' + ],//模板参数 +]); + +``` + +### [天瑞云](http://cms.tinree.com/) + +短信内容使用 `template` + `data` + +```php + 'tinree' => [ + 'accesskey' => '', // 平台分配给用户的accesskey + 'secret' => '', // 平台分配给用户的secret + 'sign' => '', // 平台上申请的接口短信签名或者签名ID + ], +``` + +发送示例: + +```php +$easySms->send(18888888888, [ + 'template' => '123456', // 模板ID + 'data' => [ + "a", 'b', 'c', //按模板变量占位顺序 + ], +]); +``` + +### [时代互联](https://www.now.cn/) + +短信使用 `content` + +```php + 'nowcn' => [ + 'key' => '', //用户ID + 'secret' => '', //开发密钥 + 'api_type' => '', // 短信通道, + ], +``` + +发送示例: +```php +$easySms->send(18888888888, [ + 'content' => '您的验证码为: 6379', +]); +``` + +### [火山引擎](https://console.volcengine.com/sms/) + +短信内容使用 `template` + `data` + +```php + 'volcengine' => [ + 'access_key_id' => '', // 平台分配给用户的access_key_id + 'access_key_secret' => '', // 平台分配给用户的access_key_secret + 'region_id' => 'cn-north-1', // 国内节点 cn-north-1,国外节点 ap-singapore-1,不填或填错,默认使用国内节点 + 'sign_name' => '', // 平台上申请的接口短信签名或者签名ID,可不填,发送短信时data中指定 + 'sms_account' => '', // 消息组帐号,火山短信页面右上角,短信应用括号中的字符串,可不填,发送短信时data中指定 + ], +``` + +发送示例1: + +```php +$easySms->send(18888888888, [ + 'template' => 'SMS_123456', // 模板ID + 'data' => [ + "code" => 1234 // 模板变量 + ], +]); +``` + +发送示例2: +```php +$easySms->send(18888888888, [ + 'template' => 'SMS_123456', // 模板ID + 'data' => [ + "template_param" => ["code" => 1234], // 模板变量参数 + "sign_name" => "yoursignname", // 签名,覆盖配置文件中的sign_name + "sms_account" => "yoursmsaccount", // 消息组帐号,覆盖配置文件中的sms_account + "phone_numbers" => "18888888888,18888888889", // 手机号,批量发送,英文的逗号连接多个手机号,覆盖发送方法中的填入的手机号 + ], +]); +``` + +## :heart: 支持我 + +[](https://github.com/sponsors/overtrue) + +如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) + +## Project supported by JetBrains + +Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects. + +[](https://www.jetbrains.com/?from=https://github.com/overtrue) + + +## PHP 扩展包开发 + +> 想知道如何从零开始构建 PHP 扩展包? +> +> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package) + +## License + +MIT diff --git a/vendor/overtrue/easy-sms/composer.json b/vendor/overtrue/easy-sms/composer.json new file mode 100644 index 000000000..716c51636 --- /dev/null +++ b/vendor/overtrue/easy-sms/composer.json @@ -0,0 +1,62 @@ +{ + "name": "overtrue/easy-sms", + "description": "The easiest way to send short message.", + "type": "library", + "require": { + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "php": ">=5.6", + "ext-json": "*" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^7.5 || ^8.5.19 || ^9.5.8", + "mockery/mockery": "~1.3.3 || ^1.4.2", + "brainmaestro/composer-git-hooks": "^2.8", + "jetbrains/phpstorm-attributes": "^1.0" + }, + "autoload": { + "psr-4": { + "Overtrue\\EasySms\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Overtrue\\EasySms\\Tests\\": "tests" + } + }, + "license": "MIT", + "authors": [{ + "name": "overtrue", + "email": "i@overtrue.me" + }], + "extra": { + "hooks": { + "pre-commit": [ + "composer check-style", + "composer psalm", + "composer test" + ], + "pre-push": [ + "composer check-style" + ] + } + }, + "scripts": { + "post-update-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" + ], + "post-merge": "composer install", + "post-install-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" + ], + "phpstan": "phpstan analyse", + "check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php-cs-fixer.dist.php --dry-run --allow-risky=yes --ansi", + "fix-style": "php-cs-fixer fix --using-cache=no --config=.php-cs-fixer.dist.php --allow-risky=yes --ansi", + "test": "phpunit --colors", + "psalm": "psalm --show-info=true --no-cache", + "psalm-fix": "psalm --no-cache --alter --issues=MissingReturnType,MissingParamType" + } +} diff --git a/vendor/overtrue/easy-sms/psalm.xml b/vendor/overtrue/easy-sms/psalm.xml new file mode 100644 index 000000000..f8edfd3ae --- /dev/null +++ b/vendor/overtrue/easy-sms/psalm.xml @@ -0,0 +1,15 @@ + ++ * An offset to check for. + *
+ * + * @return bool true on success or false on failure. + * + *+ * The return value will be casted to boolean if non-boolean was returned + * + * @since 5.0.0 + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return array_key_exists($offset, $this->config); + } + + /** + * Offset to retrieve. + * + * @see http://php.net/manual/en/arrayaccess.offsetget.php + * + * @param mixed $offset
+ * The offset to retrieve. + *
+ * + * @return mixed Can return all value types + * + * @since 5.0.0 + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->get($offset); + } + + /** + * Offset to set. + * + * @see http://php.net/manual/en/arrayaccess.offsetset.php + * + * @param mixed $offset+ * The offset to assign the value to. + *
+ * @param mixed $value+ * The value to set. + *
+ * + * @since 5.0.0 + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (isset($this->config[$offset])) { + $this->config[$offset] = $value; + } + } + + /** + * Offset to unset. + * + * @see http://php.net/manual/en/arrayaccess.offsetunset.php + * + * @param mixed $offset+ * The offset to unset. + *
+ * + * @since 5.0.0 + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + if (isset($this->config[$offset])) { + unset($this->config[$offset]); + } + } +} diff --git a/vendor/overtrue/easy-sms/src/Traits/HasHttpRequest.php b/vendor/overtrue/easy-sms/src/Traits/HasHttpRequest.php new file mode 100644 index 000000000..d861dedfc --- /dev/null +++ b/vendor/overtrue/easy-sms/src/Traits/HasHttpRequest.php @@ -0,0 +1,136 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Overtrue\EasySms\Traits; + +use GuzzleHttp\Client; +use Psr\Http\Message\ResponseInterface; + +/** + * Trait HasHttpRequest. + */ +trait HasHttpRequest +{ + /** + * Make a get request. + * + * @param string $endpoint + * @param array $query + * @param array $headers + * + * @return ResponseInterface|array|string + */ + protected function get($endpoint, $query = [], $headers = []) + { + return $this->request('get', $endpoint, [ + 'headers' => $headers, + 'query' => $query, + ]); + } + + /** + * Make a post request. + * + * @param string $endpoint + * @param array $params + * @param array $headers + * + * @return ResponseInterface|array|string + */ + protected function post($endpoint, $params = [], $headers = []) + { + return $this->request('post', $endpoint, [ + 'headers' => $headers, + 'form_params' => $params, + ]); + } + + /** + * Make a post request with json params. + * + * @param $endpoint + * @param array $params + * @param array $headers + * + * @return ResponseInterface|array|string + */ + protected function postJson($endpoint, $params = [], $headers = []) + { + return $this->request('post', $endpoint, [ + 'headers' => $headers, + 'json' => $params, + ]); + } + + /** + * Make a http request. + * + * @param string $method + * @param string $endpoint + * @param array $options http://docs.guzzlephp.org/en/latest/request-options.html + * + * @return ResponseInterface|array|string + */ + protected function request($method, $endpoint, $options = []) + { + return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options)); + } + + /** + * Return base Guzzle options. + * + * @return array + */ + protected function getBaseOptions() + { + $options = method_exists($this, 'getGuzzleOptions') ? $this->getGuzzleOptions() : []; + + return \array_merge($options, [ + 'base_uri' => method_exists($this, 'getBaseUri') ? $this->getBaseUri() : '', + 'timeout' => method_exists($this, 'getTimeout') ? $this->getTimeout() : 5.0, + ]); + } + + /** + * Return http client. + * + * @param array $options + * + * @return \GuzzleHttp\Client + * + * @codeCoverageIgnore + */ + protected function getHttpClient(array $options = []) + { + return new Client($options); + } + + /** + * Convert response contents to json. + * + * @param \Psr\Http\Message\ResponseInterface $response + * + * @return ResponseInterface|array|string + */ + protected function unwrapResponse(ResponseInterface $response) + { + $contentType = $response->getHeaderLine('Content-Type'); + $contents = $response->getBody()->getContents(); + + if (false !== stripos($contentType, 'json') || stripos($contentType, 'javascript')) { + return json_decode($contents, true); + } elseif (false !== stripos($contentType, 'xml')) { + return json_decode(json_encode(simplexml_load_string($contents)), true); + } + + return $contents; + } +}