|
|
@@ -128,130 +128,6 @@ class UserController extends BaseController
|
|
|
util::complete();
|
|
|
}
|
|
|
|
|
|
- //充值 ssh 2019.12.1
|
|
|
- public function actionRecharge()
|
|
|
- {
|
|
|
- util::fail('此功能已停用');
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $payPassword = isset($post['payPassword']) ? $post['payPassword'] : '';
|
|
|
- AdminService::verifyPayPassword($this->adminId, $payPassword);
|
|
|
-
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
|
|
|
- $user = UserService::getById($userId);
|
|
|
- if (empty($user)) {
|
|
|
- util::fail('找不到客户');
|
|
|
- }
|
|
|
- if ($user['sjId'] != $this->sjId) {
|
|
|
- util::fail('您无法操作');
|
|
|
- }
|
|
|
- $userAsset = UserAssetService::getByUserId($userId);
|
|
|
- $totalBalance = $userAsset['balance'] + $rechargeAmount;
|
|
|
- $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
|
|
|
- $upData['balance'] = $totalBalance;
|
|
|
- $upData['totalRecharge'] = $totalRecharge;
|
|
|
- $merchantAsset = MerchantAssetService::getBySjId($this->sjId);
|
|
|
- $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->sj->attributes, $this->sjExtend->attributes, $merchantAsset);
|
|
|
- if ($return['code'] == 'A0001') {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- util::fail();
|
|
|
- }
|
|
|
-
|
|
|
- //升级 ssh 2019.12.1
|
|
|
- public function actionUpgrade()
|
|
|
- {
|
|
|
- util::fail('此功能已停用');
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $member = isset($post['member']) ? $post['member'] : 0;
|
|
|
- $user = UserService::getById($userId);
|
|
|
- if (empty($user)) {
|
|
|
- util::fail('客户不存在');
|
|
|
- }
|
|
|
- //验证是否商家客户
|
|
|
- UserService::valid($user, $this->sjId);
|
|
|
- //验证确认密码
|
|
|
- $payPassword = $post['payPassword'];
|
|
|
- AdminService::verifyPayPassword($this->adminId, $payPassword);
|
|
|
-
|
|
|
- $grade = xhMerchantExtendService::getGradeList($this->sjExtend->attributes, 'desc');
|
|
|
- //升级后的成长值
|
|
|
- $newLevelGrowth = $grade[$member]['growth'];
|
|
|
- $newDiscount = $grade[$member]['discount'];
|
|
|
- $userAsset = UserAssetService::getByUserId($userId);
|
|
|
- if ($userAsset['member'] >= $member) {
|
|
|
- util::fail('客户已经达到此级别了');
|
|
|
- }
|
|
|
-
|
|
|
- $now = time();
|
|
|
- $date = date("Y-m-d H:i", $now);
|
|
|
-
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
-
|
|
|
- $addGrowth = $newLevelGrowth - $userAsset['growth'];
|
|
|
- $upData['growth'] = $newLevelGrowth;
|
|
|
- $upData['member'] = $member;
|
|
|
- $upData['discount'] = $newDiscount;
|
|
|
- UserAssetService::updateByUserId($userId, $upData);
|
|
|
- UserService::updateById($userId, ['member' => $member]);
|
|
|
-
|
|
|
- $upgradeData = [
|
|
|
- 'member' => $member,
|
|
|
- 'prevMember' => $userAsset['member'],
|
|
|
- 'sjId' => $this->sjId,
|
|
|
- 'gainType' => 0,
|
|
|
- 'addTime' => $now,
|
|
|
- 'userId' => $userId,
|
|
|
- ];
|
|
|
- $upgradeRespond = UserUpgradeService::add($upgradeData);
|
|
|
-
|
|
|
- $growthData = [
|
|
|
- 'userId' => $userId,
|
|
|
- 'userName' => $user['userName'],
|
|
|
- 'sjId' => $this->sjId,
|
|
|
- 'relateId' => $upgradeRespond['id'],
|
|
|
- 'growth' => $newLevelGrowth,
|
|
|
- 'num' => $addGrowth,
|
|
|
- 'io' => 1,
|
|
|
- 'payWay' => 4,
|
|
|
- 'alipayId' => '',
|
|
|
- 'event' => '管理员操作升到' . $member . '级增加成长值',
|
|
|
- 'operatorId' => $userId,
|
|
|
- 'createTime' => $date,
|
|
|
- 'gainType' => 0,
|
|
|
- 'addTime' => $now,
|
|
|
- ];
|
|
|
- UserGrowthService::add($growthData);
|
|
|
- $transaction->commit();
|
|
|
- } catch (Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- util::fail();
|
|
|
- }
|
|
|
- $allTM = xhTMessageService::getList($this->sjId);
|
|
|
- $openId = isset($user['openId']) ? $user['openId'] : '';
|
|
|
- if (empty($openId)) {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- $shortTempId = 'OPENTM205211943';//升级通知
|
|
|
- if (isset($allTM[$shortTempId]) == false) {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- $tempId = $allTM[$shortTempId];
|
|
|
- $data = [
|
|
|
- "touser" => $openId, "template_id" => $tempId, "url" => '',
|
|
|
- "data" => [
|
|
|
- "first" => ["value" => "恭喜,您已经升为{$member}级会员。", "color" => "#173177"],
|
|
|
- "keyword1" => ["value" => $user['userName'], "color" => "#173177"],
|
|
|
- "keyword2" => ["value" => $date, "color" => "#173177"],
|
|
|
- "remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
|
|
|
- ]];
|
|
|
- wxUtil::sendTaskInform($data, $this->sj);
|
|
|
- util::complete();
|
|
|
- }
|
|
|
-
|
|
|
//重置客户密码
|
|
|
public function actionResetPayPassword()
|
|
|
{
|