feat(user): 添加用户标签功能

This commit is contained in:
mkm 2024-06-18 15:01:36 +08:00
parent 79e89fa22d
commit 325014ee99
4 changed files with 49 additions and 14 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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('设置成功');
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\store\controller\user;
use app\store\controller\BaseAdminController;
use app\admin\lists\user_label\UserLabelLists;
/**
* 用户标签控制器
* Class UserLabelController
* @package app\admin\controller\user_label
*/
class UserLabelController extends BaseAdminController
{
/**
* @notes 获取用户标签列表
* @return \think\response\Json
* @author admin
* @date 2024/06/17 17:02
*/
public function lists()
{
return $this->dataLists(new UserLabelLists());
}
}