|
|
@@ -91,6 +91,7 @@ class User
|
|
|
/**
|
|
|
* 用户升级
|
|
|
* @param $user_id
|
|
|
+ * @param int $totalPrice
|
|
|
* @param int $wxapp_id
|
|
|
* @return bool
|
|
|
* @throws Exception
|
|
|
@@ -98,7 +99,7 @@ class User
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public static function upgrade($user_id, $wxapp_id=0)
|
|
|
+ public static function upgrade($user_id, $totalPrice, $wxapp_id=0)
|
|
|
{
|
|
|
$info = UserModel::alias('a')
|
|
|
->join('user_grade ug', 'ug.grade_id=a.grade_id','left')
|
|
|
@@ -110,8 +111,8 @@ class User
|
|
|
}
|
|
|
|
|
|
$gradeId = isset($info['grade_id'])? intval($info['grade_id']) : 0;
|
|
|
- $upgradeMoney = isset($info['expend_upgrade_money'])? floatval($info['expend_upgrade_money']) : 0;
|
|
|
- if($upgradeMoney>0){
|
|
|
+ //$upgradeMoney = isset($info['expend_upgrade_money'])? floatval($info['expend_upgrade_money']) : 0;
|
|
|
+ if($totalPrice>0){
|
|
|
$gradeList = Grade::where(['status'=> 1, 'is_delete'=> 0,'wxapp_id'=>$wxapp_id])
|
|
|
->where('grade_id','>', $gradeId)
|
|
|
->field('grade_id,name,upgrade')
|
|
|
@@ -124,7 +125,7 @@ class User
|
|
|
$id = isset($v['grade_id'])? $v['grade_id'] : 0;
|
|
|
$upgrade = isset($v['upgrade']) && $v['upgrade']? $v['upgrade'] : [];
|
|
|
$upgradeGradeMoney = isset($upgrade['expend_money'])? floatval($upgrade['expend_money']) : 0;
|
|
|
- if($id>$gradeId && $upgradeGradeMoney<=$upgradeMoney){
|
|
|
+ if($id>$gradeId && $upgradeGradeMoney<=$totalPrice){
|
|
|
$newGradeId = $id;
|
|
|
}
|
|
|
}
|
|
|
@@ -143,7 +144,7 @@ class User
|
|
|
'new_grade_id'=> $newGradeId,
|
|
|
'change_type'=> 20,
|
|
|
'wxapp_id'=> $wxapp_id,
|
|
|
- 'remark'=> "升级成功",
|
|
|
+ 'remark'=> "消费[¥{$totalPrice}]升级",
|
|
|
'create_time'=> time()
|
|
|
];
|
|
|
if(!GradeLog::insertgetId($log)){
|