| @@ -78,6 +78,7 @@ public class WxCreditHistoryController extends BaseController { | |||||
| wxCreditHistory.setTenantId(user.getTenantId()); | wxCreditHistory.setTenantId(user.getTenantId()); | ||||
| wxCreditHistory.setOperatorId(user.getId()); | wxCreditHistory.setOperatorId(user.getId()); | ||||
| try { | try { | ||||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId()) ; | |||||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | ||||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | return new ResultData(Result.SUCCESS, "操作成功", credit); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| @@ -92,6 +92,7 @@ public class WxCUserController extends BaseController { | |||||
| wxCUser.setOpenId(wxCUserFromBDto.getOpenid()); | wxCUser.setOpenId(wxCUserFromBDto.getOpenid()); | ||||
| wxCUser = wxCUserService.getByOpenId(wxCUser); | wxCUser = wxCUserService.getByOpenId(wxCUser); | ||||
| if (wxCUserFromB == null) { | if (wxCUserFromB == null) { | ||||
| //TODO phone可能为空 | |||||
| String phone = wxCUser.getPhone(); | String phone = wxCUser.getPhone(); | ||||
| String tenantId = wxCUser.getTenantId(); | String tenantId = wxCUser.getTenantId(); | ||||
| //查询会员信息 | //查询会员信息 | ||||
| @@ -15,6 +15,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxCreditHistoryService; | import com.iformall.service.WxCreditHistoryService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.utils.UserUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -25,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.Objects; | import java.util.Objects; | ||||
| @RestController | @RestController | ||||
| @@ -61,7 +63,14 @@ public class WxCreditHistoryController extends BaseController { | |||||
| if(Objects.isNull(merchantId)|| StringUtils.isEmpty(spendStr)||Objects.isNull(userId)) { | if(Objects.isNull(merchantId)|| StringUtils.isEmpty(spendStr)||Objects.isNull(userId)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | 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("根据手机号查询接口") | @ApiOperation("根据手机号查询接口") | ||||
| @@ -104,7 +113,7 @@ public class WxCreditHistoryController extends BaseController { | |||||
| //B端操作用户 | //B端操作用户 | ||||
| wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode()); | wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode()); | ||||
| try { | try { | ||||
| wxCreditHistoryService.check(wxCreditHistory.getCUserId()); | |||||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId()); | |||||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | ||||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | return new ResultData(Result.SUCCESS, "操作成功", credit); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| @@ -25,21 +25,6 @@ public class WxCreditHistoryController extends BaseController{ | |||||
| @Autowired | @Autowired | ||||
| private WxCreditHistoryService wxCreditHistoryService; | 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("用户积分列表") | @ApiOperation("用户积分列表") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -40,11 +40,12 @@ public interface WxCreditHistoryService { | |||||
| WxCreditHistory getById(Long id); | WxCreditHistory getById(Long id); | ||||
| /** | /** | ||||
| * 校验用户是否存在 | |||||
| * 添加积分时,需要校验用户以及手机号是否存在 | |||||
| * 规则:有手机号增加积分,无手机号提示授权手机号 | |||||
| * @param cUserId | * @param cUserId | ||||
| */ | */ | ||||
| void check(Long cUserId) ; | |||||
| void creditUsercheck(Long cUserId); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| @@ -19,6 +19,7 @@ import com.iformall.service.WxCreditHistoryService; | |||||
| import com.iformall.service.WxScoreRulesService; | import com.iformall.service.WxScoreRulesService; | ||||
| import com.iformall.utils.CreditUtil; | import com.iformall.utils.CreditUtil; | ||||
| import com.iformall.utils.RedisLock; | import com.iformall.utils.RedisLock; | ||||
| import com.iformall.utils.UserUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -195,11 +196,10 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void check(Long cUserId) { | |||||
| public void creditUsercheck(Long cUserId) { | |||||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(cUserId); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(cUserId); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(cUserId); | ||||
| if (wxCUserBasicInfo == null) { | |||||
| throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | |||||
| } | |||||
| UserUtil.creditUsercheck(wxCUser, wxCUserBasicInfo); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -352,7 +352,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| if (Objects.nonNull(userId)) { | if (Objects.nonNull(userId)) { | ||||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(userId); | WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(userId); | ||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.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); | creditNew = CreditUtil.calUserCredit(credit, wxCUser, birthdayScale, wxCUserBasicInfo, wxScoreRulesService); | ||||
| } else { | } else { | ||||
| creditNew = credit; | creditNew = credit; | ||||