false, 'msg' => '没有增加积分']; } //获取会员积分等级关系 $gradeList = xhMerchantExtendService::getGradeList($merchantExtend, 'desc'); if (empty($gradeList)) { return ['status' => false, 'msg' => '没有会员等级信息']; } $gainLevel = 0; $gainDiscount = 1; foreach ($gradeList as $key => $val) { $currentLevel = (int)$val['level']; $currentGrowth = (int)$val['growth']; $gradeDiscount = $val['discount']; if ($growth >= $currentGrowth && $preLevel < $currentLevel) { $gainLevel = $currentLevel; $gainDiscount = $gradeDiscount; break; } } if (empty($gainLevel)) {//会员积分达到新等级 return ['status' => false, 'msg' => '没有升级']; } xhUserAssetService::updateByUserId($userId, ['member' => $gainLevel,'discount'=>$gainDiscount]); UserService::updateById($userId, ['member' => $gainLevel]); $allTM = xhTMessageService::getList($sjId);//积分变动通知 $shortTempId = 'OPENTM205211943'; if (isset($allTM[$shortTempId]) == false) { return ['status' => false, 'msg' => '已升级未通知,没有找到消息系统']; } $merchant = MerchantService::getBYId($sjId); $user = UserService::getById($userId); $openId = isset($user['openId']) ? $user['openId'] : ''; if (empty($openId)) { return ['status' => false, 'msg' => '已升级未通知,客户信息不完整']; } $tempId = $allTM[$shortTempId]; $tmData = [ "touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['mallDomain'] . '/#/pages/home/user?account=' . $merchant['id'], "data" => [ "first" => ["value" => "恭喜,您已升为{$gainLevel}级会员。购物享{$gainDiscount}折优惠", "color" => "#173177"], "keyword1" => ["value" => $user['userName'], "color" => "#173177"], "keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"], "remark" => ["value" => "祝您生活愉快!", "color" => "#173177"], ], ]; wxUtil::sendTaskInform($tmData, $merchant); } }