设置价格 折扣
This commit is contained in:
@@ -6,6 +6,7 @@ use app\user\model\User as UserModel;
|
||||
use app\user\model\AgentUser as AgentUser;
|
||||
use app\user\model\UserScore as UserScore;
|
||||
use app\user\model\SellCouponUserOrgin;
|
||||
use app\user\model\ProductPriceScheme;
|
||||
use fastphp\base\Controller;
|
||||
|
||||
class User extends Controller
|
||||
@@ -23,8 +24,17 @@ class User extends Controller
|
||||
$where = "LoginCode like '%".$_GET['keyWord']."%' or Phone like '%".$_GET['keyWord']."%'";
|
||||
}
|
||||
$user_model = new UserModel;
|
||||
$discount_model = new ProductPriceScheme;
|
||||
$user_list = $user_model->getUserListPage($where, '*', 'id desc', "$page,50");
|
||||
|
||||
//折扣列表
|
||||
$discount_data = $discount_model->getList();
|
||||
$discount_list = [];
|
||||
$discount_list[0] = '原价';
|
||||
foreach($discount_data as $info) {
|
||||
$discount_list[$info['Id']] = $info['Name'];
|
||||
}
|
||||
|
||||
foreach ($user_list as &$info){
|
||||
$info['Password'] = '';
|
||||
if(empty($info['id_code'])){
|
||||
@@ -34,6 +44,8 @@ class User extends Controller
|
||||
$info['is_verify'] = $info['is_verify']?'认证成功':'认证失败';
|
||||
}
|
||||
|
||||
$info['discount'] = $discount_list[$info['discount_id']];
|
||||
|
||||
if($info['CreateType'] == 4){
|
||||
$agent = new AgentUser;
|
||||
$agent_info = $agent->getOne(['id'=>$info['agent_id']]);
|
||||
@@ -269,4 +281,52 @@ class User extends Controller
|
||||
];
|
||||
echo json_encode($info);
|
||||
}
|
||||
|
||||
//设置用户的折扣价
|
||||
public function setUserDiscount()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
// dump($data);
|
||||
|
||||
if(!isset($data['schemeId'])){
|
||||
die;
|
||||
}
|
||||
|
||||
$user_model = new UserModel;
|
||||
$discount_model = new ProductPriceScheme;
|
||||
|
||||
$user_info = $user_model->getOne(['Id'=>$data['userId']]);
|
||||
//原始折扣
|
||||
$discount_old = $discount_model->getList(['Id'=>['in',[$data['schemeId'],$user_info['discount_id']]]],'Id,discount');
|
||||
|
||||
$discount_list = [];
|
||||
foreach($discount_old as $info){
|
||||
$discount_list[$info['Id']] = $info["discount"];
|
||||
}
|
||||
|
||||
if($user_info['discount_id'] != 0){
|
||||
if($discount_list[$data['schemeId']]>$discount_list[$user_info['discount_id']]){
|
||||
$info = [
|
||||
'Code' => -10000,
|
||||
'Data' => '折扣无法调高!',
|
||||
'Message' => '折扣无法调高!',
|
||||
];
|
||||
echo json_encode($info);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$discount_data = [
|
||||
'discount_id' => $data['schemeId']
|
||||
];
|
||||
|
||||
$user_model->updateOne(['Id'=>$data['userId']],$discount_data);
|
||||
$info = [
|
||||
'Code' => 10000,
|
||||
'Data' => '',
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($info);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user