From 0b3fc8a7b6705adc6a08ab993c3ae6d4adb43983 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 2 Jul 2024 14:30:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E9=80=BB=E8=BE=91=E5=92=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 21 ++-- app/api/lists/user_sign/UserSignLists.php | 79 ++++++++++++++ .../lists/user_sign_log/UserSignLogLists.php | 78 ++++++++++++++ app/api/logic/user/UserLogic.php | 3 +- app/common/logic/PayNotifyLogic.php | 33 ------ app/common/logic/UserSignLogic.php | 101 ++++++++++++++---- 6 files changed, 249 insertions(+), 66 deletions(-) create mode 100644 app/api/lists/user_sign/UserSignLists.php create mode 100644 app/api/lists/user_sign_log/UserSignLogLists.php diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index a1b0142b5..e66171fde 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -3,6 +3,8 @@ namespace app\api\controller\user; use app\api\controller\BaseApiController; +use app\api\lists\user_sign\UserSignLists; +use app\api\lists\user_sign_log\UserSignLogLists; use app\api\logic\user\UserLogic; use app\api\service\UserTokenService; use app\api\validate\UserValidate; @@ -246,18 +248,19 @@ class UserController extends BaseApiController } + /** + * 礼品券/冻结券 + */ public function userSing() { (new UserValidate())->get()->goCheck('fund'); - $page_no = (int)$this->request->get('page_no', 1); - $page_size = (int)$this->request->get('page_size', 15); - $params = $this->request->get(); - $params['page_no'] = $page_no > 0 ? $page_no : 1; - $params['page_size'] = $page_size > 0 ? $page_size : 15; - $res = UserLogic::userSingList($params,$this->userId); - $res['page_no'] = $params['page_no']; - $res['page_size'] = $params['page_size']; - return $this->success('ok', $res); + $type = (int)$this->request->get('type', 1); + if($type==1){ + return $this->dataLists(new UserSignLists()); + }else{ + return $this->dataLists(new UserSignLogLists()); + } + } /** diff --git a/app/api/lists/user_sign/UserSignLists.php b/app/api/lists/user_sign/UserSignLists.php new file mode 100644 index 000000000..af18f8785 --- /dev/null +++ b/app/api/lists/user_sign/UserSignLists.php @@ -0,0 +1,79 @@ +request->get('type',1); + $mark=$this->request->get('mark',''); + if($type==1){ + $this->searchWhere[]=['type','in',[4,9,8,2]]; + $this->searchWhere[]=['status','=',1]; + } + if($mark==1){ + $this->searchWhere[]=['financial_pm','=',1]; + }elseif($mark==2){ + $this->searchWhere[]=['financial_pm','=',0]; + } + $list=UserSign::where($this->searchWhere)->order('id desc') + ->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + return $item; + }); + return $list?->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/api/lists/user_sign_log/UserSignLogLists.php b/app/api/lists/user_sign_log/UserSignLogLists.php new file mode 100644 index 000000000..a5f5834da --- /dev/null +++ b/app/api/lists/user_sign_log/UserSignLogLists.php @@ -0,0 +1,78 @@ +request->get('type',1); + $mark=$this->request->get('mark',''); + if($type==1){ + $this->searchWhere[]=['type','in',[1,7,3]]; + $this->searchWhere[]=['status','=',1]; + } + if($mark==1){ + $this->searchWhere[]=['financial_pm','=',1]; + }elseif($mark==2){ + $this->searchWhere[]=['financial_pm','=',0]; + } + $list=UserSignLog::where($this->searchWhere)->order('id desc') + ->limit($this->limitOffset, $this->limitLength) + ->select()->each(function ($item){ + $item['title']=UserSignLogic::getTitle($item['type'],$item['number']); + return $item; + }); + return $list?->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/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 6a5d2b628..3088e7392 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -21,6 +21,7 @@ use app\common\{logic\BaseLogic, model\vip_flow\VipFlow, service\SmsService, service\wechat\WeChatMnpService}; +use app\common\logic\UserSignLogic; use app\common\model\user_label\UserLabel; use support\Cache; use think\facade\Db; @@ -287,7 +288,7 @@ class UserLogic extends BaseLogic } foreach ($data as &$value){ if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){ - $value['title'] = PayNotifyLogic::getTitle($value['title'],$value['number']); + $value['title'] = UserSignLogic::getTitle($value['title'],$value['number']); } } return [ diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 484f0b79f..c2b36788c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -1130,37 +1130,4 @@ class PayNotifyLogic extends BaseLogic return 0.1; } } - - - - //礼品券相关对应文本 - public static function getTitle($category, $amount) - { - switch ($category) { - /**冻结券**/ - //收入 - case 1: - return "购买商品{$amount}元获得冻结卷"; - case 7: - return "充值{$amount}元获得冻结卷"; - //支出 - case 2: - return "核销商品{$amount}元解冻冻结卷"; - case 3: - return "退款{$amount}元扣除冻结卷"; - /**礼品券**/ - //收入 - case 4: - return "核销金额{$amount}元获得礼品卷"; - //支出 - case 5: - return "兑换{$amount}元商品扣除礼品卷"; - case 6: - return "退款{$amount}元扣除礼品卷"; - case 8: - return "收银台支付{$amount}元增加礼品卷"; - default: - return "订单支付{$amount}元"; - } - } } diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index dfcbf4c76..dfaf79ea2 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -23,12 +23,13 @@ class UserSignLogic extends BaseLogic $total_vip = bcmul($order['price'], 0.1, 2); $count = UserSign::where('uid', $order->uid)->count(); if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { - $write = self::write($order, $total_vip, 0, 1); - self::write_log($write, $total_vip, 0); + //首充 + $write = self::write($order, $total_vip, 0, 1,9); + self::write_log($write, $total_vip, 0,9); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } else { - $write = self::write($order, $total_vip, 0, 0); - self::write_log($write, $total_vip, 0); + $write = self::write($order, $total_vip, 0, 0,7); + self::write_log($write, $total_vip, 0,7); } return true; } @@ -40,12 +41,12 @@ class UserSignLogic extends BaseLogic { $total_vip = bcmul($order['pay_price'], 0.1, 2); - //非收银台订单冻结里礼品卷 if ($order['source'] == 0) { - $write = self::write($order, $total_vip, 1, 0); + //非收银台订单冻结礼品卷 + self::write($order, $total_vip, 1, 0,1); } else { - $write = self::write($order, $total_vip, 1, 1); - self::write_log($write, $total_vip, 1); + $write = self::write($order, $total_vip, 1, 1,4); + self::write_log($write, $total_vip, 1,4); User::where('id', $order->uid)->inc('integral', $total_vip)->update(); } } @@ -53,22 +54,23 @@ class UserSignLogic extends BaseLogic /** * 核销 */ - public static function WriteOff($order){ - $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); - if($find){ - $find->status=1; + public static function WriteOff($order) + { + $find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); + if ($find) { + $find->status = 1; $find->save(); User::where('id', $order->uid)->inc('integral', $find['number'])->update(); - self::write_log($find,$find['number'], 1); - + self::write_log($find, $find['number'], 1,4); } } /** * 储存商品积分结算 */ - public static function storage($order){ - $find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find(); - if($find){ + public static function storage($order) + { + $find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find(); + if ($find) { // if($or) // $find->status=1; // $find->save(); @@ -78,14 +80,24 @@ class UserSignLogic extends BaseLogic } } - - public static function write($order, $total_vip, $order_type = 0, $status = 0, $title = 4, $pm = 1) + /** + * @param type 1:购买商品冻结 + * @param type 2:核销商品解冻 + * @param type 3:退款扣除冻结 + * @param type 4:核销金额获得 + * @param type 5:兑换商品扣除 + * @param type 6:退款扣除礼品 + * @param type 7:充值冻结 + * @param type 8:收银台支付增加 + * @param type 9:首充获得 + */ + public static function write($order, $total_vip, $order_type = 0, $status = 0, $type = 4, $pm = 1) { //礼品券得 $sing = [ 'uid' => $order['uid'], 'order_id' => $order['order_id'], - 'title' => $title, + 'type' => $type, 'financial_pm' => $pm, 'store_id' => $order['store_id'], 'status' => $status, @@ -96,14 +108,25 @@ class UserSignLogic extends BaseLogic ]; return UserSign::create($sing); } - public static function write_log($write, $total_vip, $order_type = 0, $title = 4, $pm = 1) + /** + * @param type 1:购买商品冻结 + * @param type 2:核销商品解冻 + * @param type 3:退款扣除冻结 + * @param type 4:核销金额获得 + * @param type 5:兑换商品扣除 + * @param type 6:退款扣除礼品 + * @param type 7:充值冻结 + * @param type 8:收银台支付增加 + * @param type 9:首充获得 + */ + public static function write_log($write, $total_vip, $order_type = 0, $type = 4, $pm = 1) { //礼品券日志记录 $sing = [ 'uid' => $write['uid'], 'sid' => $write['id'], 'order_id' => $write['order_id'], - 'title' => $title, + 'type' => $type, 'financial_pm' => $pm, 'order_type' => $order_type, 'status' => 1, @@ -111,5 +134,37 @@ class UserSignLogic extends BaseLogic ]; UserSignLog::create($sing); } - + + //礼品券相关对应文本 + public static function getTitle($type, $amount) + { + switch ($type) { + /**冻结券**/ + //收入 + case 1: + return "购买商品{$amount}元获得冻结券"; + case 7: + return "充值{$amount}元获得冻结券"; + //支出 + case 2: + return "核销商品{$amount}元解冻冻结券"; + case 3: + return "退款{$amount}元扣除冻结券"; + /**礼品券**/ + //收入 + case 4: + return "核销金额{$amount}元获得礼品券"; + //支出 + case 5: + return "兑换{$amount}元商品扣除礼品券"; + case 6: + return "退款{$amount}元扣除礼品券"; + case 8: + return "收银台支付{$amount}元增加礼品券"; + case 9: + return "首充{$amount}元获得礼品券"; + default: + return "订单支付{$amount}元"; + } + } }