Browse Source

[优化]积分处理逻辑

release_toaliyun_real
Burce 6 years ago
parent
commit
8f86884580
6 changed files with 22 additions and 25 deletions
  1. +1
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java
  2. +1
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java
  3. +11
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java
  4. +0
    -15
      mallinkCApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java
  5. +4
    -3
      mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java
  6. +5
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java

+ 1
- 0
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java View File

@@ -78,6 +78,7 @@ public class WxCreditHistoryController extends BaseController {
wxCreditHistory.setTenantId(user.getTenantId());
wxCreditHistory.setOperatorId(user.getId());
try {
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId()) ;
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {


+ 1
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java View File

@@ -92,6 +92,7 @@ public class WxCUserController extends BaseController {
wxCUser.setOpenId(wxCUserFromBDto.getOpenid());
wxCUser = wxCUserService.getByOpenId(wxCUser);
if (wxCUserFromB == null) {
//TODO phone可能为空
String phone = wxCUser.getPhone();
String tenantId = wxCUser.getTenantId();
//查询会员信息


+ 11
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java View File

@@ -15,6 +15,7 @@ import com.iformall.exception.MallinkException;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCreditHistoryService;
import com.iformall.service.WxMerchantService;
import com.iformall.utils.UserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -25,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@@ -61,7 +63,14 @@ public class WxCreditHistoryController extends BaseController {
if(Objects.isNull(merchantId)|| StringUtils.isEmpty(spendStr)||Objects.isNull(userId)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ;
}
return new ResultData(wxCreditHistoryService.findByMerchantIdAndSpend(merchantId,spendStr,userId,getTenantId()));
try {
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId, getTenantId());
return new ResultData(result);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, e.getMessage());
}
}

@ApiOperation("根据手机号查询接口")
@@ -104,7 +113,7 @@ public class WxCreditHistoryController extends BaseController {
//B端操作用户
wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode());
try {
wxCreditHistoryService.check(wxCreditHistory.getCUserId());
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId());
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {


+ 0
- 15
mallinkCApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java View File

@@ -25,21 +25,6 @@ public class WxCreditHistoryController extends BaseController{
@Autowired
private WxCreditHistoryService wxCreditHistoryService;

@ApiOperation("新增接口")
@PostMapping("/add")
public ResultData add(@RequestBody WxCreditHistory wxCreditHistory) {
log.debug("[" + getIpAddr() + "] WxCreditHistoryController::add");
wxCreditHistory.setTenantId(getTenantId());
wxCreditHistory.setOperatorId(getUser().getId());
try {
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {
log.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}
}

@ApiOperation("用户积分列表")
@GetMapping("list")
@ApiImplicitParams({


+ 4
- 3
mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java View File

@@ -40,11 +40,12 @@ public interface WxCreditHistoryService {
WxCreditHistory getById(Long id);

/**
* 校验用户是否存在
* 添加积分时,需要校验用户以及手机号是否存在
* 规则:有手机号增加积分,无手机号提示授权手机号
* @param cUserId
*/
void check(Long cUserId) ;
void creditUsercheck(Long cUserId);
/**
* 保存或更新实体
*


+ 5
- 5
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java View File

@@ -19,6 +19,7 @@ import com.iformall.service.WxCreditHistoryService;
import com.iformall.service.WxScoreRulesService;
import com.iformall.utils.CreditUtil;
import com.iformall.utils.RedisLock;
import com.iformall.utils.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -195,11 +196,10 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
}

@Override
public void check(Long cUserId) {
public void creditUsercheck(Long cUserId) {
WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(cUserId);
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(cUserId);
if (wxCUserBasicInfo == null) {
throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE);
}
UserUtil.creditUsercheck(wxCUser, wxCUserBasicInfo);
}

@Override
@@ -352,7 +352,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
if (Objects.nonNull(userId)) {
WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(userId);
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(userId);
Integer birthdayScale = wxLevelConfigMapper.getScale(wxCUser.getTenantId(), wxCUser.getScore());
Integer birthdayScale = (wxCUser == null ? null : wxLevelConfigMapper.getScale(tenantId, wxCUser.getScore()));
creditNew = CreditUtil.calUserCredit(credit, wxCUser, birthdayScale, wxCUserBasicInfo, wxScoreRulesService);
} else {
creditNew = credit;


Loading…
Cancel
Save