From 526e08cbd49b1bf781620de335b52675cf720fdd Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sun, 24 Mar 2024 16:11:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E9=A2=86=E5=8F=96=E7=8A=B6=E6=80=81=E5=92=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Coupon.php | 24 +++++++++++++- addons/shopro/controller/Index.php | 7 ++-- addons/shopro/controller/user/WalletLog.php | 8 ++--- addons/shopro/service/CommissionScoreLog.php | 34 ++++++++++++++++++++ addons/shopro/service/commission/Agent.php | 9 ++++++ addons/shopro/service/order/OrderCreate.php | 2 +- 6 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 addons/shopro/service/CommissionScoreLog.php diff --git a/addons/shopro/controller/Coupon.php b/addons/shopro/controller/Coupon.php index f9252a4..69dd7f5 100755 --- a/addons/shopro/controller/Coupon.php +++ b/addons/shopro/controller/Coupon.php @@ -7,6 +7,7 @@ use app\admin\model\shopro\commission\Level; use app\admin\model\shopro\Coupon as CouponModel; use addons\shopro\traits\CouponSend; use app\admin\model\shopro\goods\Goods as GoodsModel; +use app\admin\model\shopro\user\Coupon as UserCouponModel; use app\common\model\User; class Coupon extends Common @@ -110,7 +111,28 @@ class Coupon extends Common public function commissionCouponList() { $user = auth_user(); $userInfo = (new \app\admin\model\shopro\commission\Agent())->where('user_id', $user->id)->find(); - $data = Level::get(['level' => $userInfo['level']]); + $data = Level::get(['level' => $userInfo['level']])->toArray(); + + //添加优惠券领取标识 + $is_get = 0; + $coupon_ids = []; + $user_id = $user->id; + if($data['coupon_rules']['programme_1']) { + $coupon_ids = array_merge($coupon_ids, array_column($data['coupon_rules']['programme_1'], 'id')); + } + if ($data['coupon_rules']['programme_2']) { + $coupon_ids = array_merge($coupon_ids, array_column($data['coupon_rules']['programme_2'], 'id')); + } + $coupon_ids = array_values(array_unique($coupon_ids)); + + $coupon_list = UserCouponModel::with('coupon') + ->where('user_id', $user_id) + ->whereIn('coupon_id', $coupon_ids) + ->select(); + if ($coupon_list) { + $is_get = 1; + } + $data['coupon_rules']['is_get'] = $is_get; $this->success('success',$data['coupon_rules']); } } diff --git a/addons/shopro/controller/Index.php b/addons/shopro/controller/Index.php index 321d835..59aa898 100755 --- a/addons/shopro/controller/Index.php +++ b/addons/shopro/controller/Index.php @@ -4,6 +4,7 @@ namespace addons\shopro\controller; use addons\shopro\controller\traits\Util; use addons\shopro\library\easywechatPlus\WechatMiniProgramShop; +use addons\shopro\service\user\UserAuth; use app\admin\model\shopro\decorate\Decorate; use app\admin\model\shopro\decorate\Page; use app\common\library\Sms as Smslib; @@ -171,8 +172,10 @@ class Index extends Common //被占用 $this->error(__('手机号已经被占用')); } elseif (in_array($event, ['changepwd', 'resetpwd', 'mobilelogin']) && !$userinfo) { - //未注册 - $this->error(__('手机号未注册')); + //未注册 注册手机号 + $this->auth->register($mobile, $mobile, '', $mobile, ''); +// set_token_in_header($auth->getToken()); +// $this->error(__('手机号未注册')); } } if (!Hook::get('sms_send')) { diff --git a/addons/shopro/controller/user/WalletLog.php b/addons/shopro/controller/user/WalletLog.php index d378c6e..468cc51 100755 --- a/addons/shopro/controller/user/WalletLog.php +++ b/addons/shopro/controller/user/WalletLog.php @@ -52,7 +52,7 @@ class WalletLog extends Common $user = auth_user(); $user_id = $user->id; $result = Db::transaction(function () use ($params, $user_id) { - return WalletService::change($user_id, $params['type'], $params['amount'], 'admin_recharge', [], '积分充值'); + return WalletService::change($user_id, $params['type'], $params['amount'], 'user_recharge', [], '积分充值'); }); if ($result) { $this->success('充值成功'); @@ -71,13 +71,13 @@ class WalletLog extends Common $user = auth_user(); $user_id = $user->id; - if (!Sms::check($params['exchange_phone'], $params['code'], 'mobilelogin')) { - $this->error(__('Captcha is incorrect')); + if (!Sms::check($params['exchange_phone'], $params['code'], 'score')) { + $this->error('验证码不正确'); } $exchange_user = UserModel::getByMobile($params['exchange_phone']); if ($user) { if ($user->status != 'normal') { - $this->error(__('Account is locked')); + $this->error(__('账户已经被锁定')); } }else { $this->error('该手机号暂未注册'); diff --git a/addons/shopro/service/CommissionScoreLog.php b/addons/shopro/service/CommissionScoreLog.php new file mode 100644 index 0000000..ba3d460 --- /dev/null +++ b/addons/shopro/service/CommissionScoreLog.php @@ -0,0 +1,34 @@ +user = is_numeric($user) ? User::get($user) : $user; + $this->user = $this->user ?: auth_user(); + } + + /** + * 计算用户积分 + * @return + */ + public function addLog() { + + } + + /** + * 获取用户等级 + */ + public function getUserLevel() { + + } +} \ No newline at end of file diff --git a/addons/shopro/service/commission/Agent.php b/addons/shopro/service/commission/Agent.php index 9aa2010..ee3f283 100755 --- a/addons/shopro/service/commission/Agent.php +++ b/addons/shopro/service/commission/Agent.php @@ -538,4 +538,13 @@ class Agent // 循环完所有的 如果是①的情况则代表都不符合条件,如果是②则代表都符合条件 返回对应状态即可 return boolval($level->upgrade_type); } + + /** + * 计算分销用户用户积分 + * @return + */ + public function calcScore() { + $comission_score = 0; + + } } diff --git a/addons/shopro/service/order/OrderCreate.php b/addons/shopro/service/order/OrderCreate.php index 06d4bdc..9b870e4 100755 --- a/addons/shopro/service/order/OrderCreate.php +++ b/addons/shopro/service/order/OrderCreate.php @@ -614,7 +614,7 @@ class OrderCreate * * @return array */ - public function getCoupons($calc_type = 'coupons') + public function xgetCoupons($calc_type = 'coupons') { $this->calc_type = $calc_type; // 检查是否可下单 From 58180865335e8b1e0dc9b0eb9c9ec0961df9e80b Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sun, 24 Mar 2024 16:31:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/shopro/controller/Index.php b/addons/shopro/controller/Index.php index 59aa898..09423c3 100755 --- a/addons/shopro/controller/Index.php +++ b/addons/shopro/controller/Index.php @@ -173,7 +173,9 @@ class Index extends Common $this->error(__('手机号已经被占用')); } elseif (in_array($event, ['changepwd', 'resetpwd', 'mobilelogin']) && !$userinfo) { //未注册 注册手机号 - $this->auth->register($mobile, $mobile, '', $mobile, ''); + $userAuth = new UserAuth(); + $auth = $userAuth->register(['mobile' => $mobile]); + set_token_in_header($auth->getToken()); // set_token_in_header($auth->getToken()); // $this->error(__('手机号未注册')); }