From 1200f624d72939917ea75166fbab6d23ce839fec Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 6 Mar 2024 11:37:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Open.php | 51 ++++++++++++++++++++------------ app/controller/api/user/User.php | 3 +- route/api.php | 1 + 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/app/controller/api/Open.php b/app/controller/api/Open.php index 03f757eb..913e6851 100755 --- a/app/controller/api/Open.php +++ b/app/controller/api/Open.php @@ -3,7 +3,9 @@ namespace app\controller\api; use app\common\dao\store\consumption\CommissionDao; +use app\common\model\store\order\StoreOrder; use crmeb\basic\BaseController; +use think\exception\ValidateException; use think\facade\Log; class Open extends BaseController @@ -18,19 +20,12 @@ class Open extends BaseController */ public function activityCommission() { - $timestamp = $this->request->post('timestamp'); - $data = $this->request->post('data'); - $aes = new \AES(); - $iv = !empty($timestamp) ? $aes->buildIv($timestamp) : ''; - $decrypted = $aes->decrypt($data, $iv); + $decrypted = $this->decrypt(); Log::error('供销平台佣金回调:' . var_export($decrypted, true)); - if (!empty($decrypted)) { - $storeConsumptionUserDao = new CommissionDao(); - // "惠农供销,谱写数字新篇章"活动首单分润 - $result = $storeConsumptionUserDao->firstOrderCommissionCallback($decrypted); - return app('json')->success($result); - } - return app('json')->fail('解密失败'); + $storeConsumptionUserDao = new CommissionDao(); + // "惠农供销,谱写数字新篇章"活动首单分润 + $result = $storeConsumptionUserDao->firstOrderCommissionCallback($decrypted); + return app('json')->success($result); } @@ -42,19 +37,37 @@ class Open extends BaseController * @throws \think\db\exception\ModelNotFoundException */ public function refundCommission() + { + $decrypted = $this->decrypt(); + Log::error('供销平台退佣金回调:' . var_export($decrypted, true)); + $storeConsumptionUserDao = new CommissionDao(); + $result = $storeConsumptionUserDao->refundByCallback($decrypted); + return app('json')->success($result); + } + + public function orderList() + { + $pageIndex = $this->request->get('page', 1); + $pageSize = $this->request->get('page_size', 15); + $order = StoreOrder::whereIn('status', [0, 1, 2, 3]) + ->field('order_id,order_sn') + ->limit($pageIndex, $pageSize) + ->order('order_id', 'desc') + ->select()->toArray(); + return app('json')->success($order); + } + + public function decrypt() { $timestamp = $this->request->post('timestamp'); $data = $this->request->post('data'); $aes = new \AES(); $iv = !empty($timestamp) ? $aes->buildIv($timestamp) : ''; $decrypted = $aes->decrypt($data, $iv); - Log::error('供销平台退佣金回调:' . var_export($decrypted, true)); - if (!empty($decrypted)) { - $storeConsumptionUserDao = new CommissionDao(); - $result = $storeConsumptionUserDao->refundByCallback($decrypted); - return app('json')->success($result); + if (empty($decrypted)) { + throw new ValidateException('解密失败'); } - return app('json')->fail('解密失败'); + return $decrypted; } -} \ No newline at end of file +} diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index 2becc0ca..a20c44c6 100755 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -566,7 +566,6 @@ class User extends BaseController [$page, $limit] = $this->getPage(); $userIds = UserModel::where('spread_uid', $this->user->uid)->column('uid'); $query = Merchant::whereIn('uid', $userIds)->where('is_del', 0); - $count = $query->count(); $merchants = $query->page($page, $limit) ->field('mer_id,mer_name,uid,real_name') ->select()->toArray(); @@ -591,7 +590,7 @@ class User extends BaseController $result[] = ['mer_id' => '', 'mer_name' => '', 'uid' => $userId, 'real_name' => '', 'sale_amount' => '0.00', 'buy_amount' => '0.00', 'status' => 0]; } } - return app('json')->success(['count' => $count, 'list' => $result]); + return app('json')->success(['count' => count($userIds), 'list' => $result]); } } diff --git a/route/api.php b/route/api.php index b44642de..5eb990c1 100755 --- a/route/api.php +++ b/route/api.php @@ -660,6 +660,7 @@ Route::group('api/', function () { Route::get('storeActivity/consumption', 'api.store.StoreActivity/consumption'); //消费金列表 Route::post('open/activityCommission', 'api.open/activityCommission'); //活动佣金回调 Route::post('open/refundCommission', 'api.open/refundCommission'); //活动佣金退款回调 + Route::get('open/orderList', 'api.open/orderList'); //订单列表 })->middleware(UserTokenMiddleware::class, false); //微信支付回调