From 325014ee992d36c3fab7f66e58250b1ab2ab8f2a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 18 Jun 2024 15:01:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(user):=20=E6=B7=BB=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=A0=87=E7=AD=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/user/UserLogic.php | 4 ++- .../logic/store_order/StoreOrderLogic.php | 21 +++++-------- app/store/controller/user/UserController.php | 8 +++++ .../controller/user/UserLabelController.php | 30 +++++++++++++++++++ 4 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 app/store/controller/user/UserLabelController.php diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index 46b7033c4..ff86b002b 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -19,6 +19,7 @@ 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; @@ -148,7 +149,7 @@ class UserLogic extends BaseLogic public static function detail(int $userId): array { $field = [ - 'id', 'account', 'nickname', 'avatar', 'real_name','integral', + 'id', 'account', 'nickname', 'avatar', 'real_name','integral','label_id', 'sex', 'mobile', 'create_time', 'login_time', 'channel','now_money','purchase_funds' ]; @@ -158,6 +159,7 @@ 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/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index d0c11d7bf..bbb40ea62 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -62,11 +62,11 @@ class StoreOrderLogic extends BaseLogic $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'] == 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); -// } + if ($user && $user['user_ship'] == 4) { + $deduction_price_count=bcmul(bcsub($find['price'], $find['purchase'], 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]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 @@ -101,13 +101,9 @@ class StoreOrderLogic extends BaseLogic self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2);//门店零售价格 // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } - $preferential_amount = 0;//差价(用户为UserShipEnum::DISCOUNT_ARRAY 的时候的优惠差价) $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 - if($user && in_array($user['user_ship'],UserShipEnum::DISCOUNT_ARRAY)){ - $pay_price =bcsub(self::$store_price, self::$activity_price, 2); //减去活动优惠金额 - $preferential_amount = bcsub(self::$pay_price,self::$store_price,2); - } + $vipPrice = 0; //成本价 收益 $order = [ @@ -125,12 +121,11 @@ class StoreOrderLogic extends BaseLogic 'store_id' => $params['store_id'] ?? 0, 'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提 'activity' =>'减免', - 'activity_price' =>self::$activity_price, + '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, - 'preferential_amount' => $preferential_amount, + 'deduction_price' => self::$activity_price,//抵扣金额 ]; if($user && $user['user_ship']!=4){ $order['is_vip']=1; diff --git a/app/store/controller/user/UserController.php b/app/store/controller/user/UserController.php index 3ad486640..5e45e7786 100644 --- a/app/store/controller/user/UserController.php +++ b/app/store/controller/user/UserController.php @@ -47,4 +47,12 @@ class UserController extends BaseAdminController 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