|
|
@@ -0,0 +1,57 @@ |
|
|
|
|
|
package com.iformall.service.openapi.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
|
|
import com.iformall.domain.po.WxCreditHistory; |
|
|
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
|
|
import com.iformall.enums.EnumScoreType; |
|
|
|
|
|
import com.iformall.enums.EnumUserType; |
|
|
|
|
|
import com.iformall.mapper.WxCreditHistoryMapper; |
|
|
|
|
|
import com.iformall.service.WxCUserBasicInfoService; |
|
|
|
|
|
import com.iformall.service.WxCreditHistoryService; |
|
|
|
|
|
import com.iformall.service.openapi.OpenUserBasicInfoService; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 会员相关开放接口service |
|
|
|
|
|
* @author xmzhao71 |
|
|
|
|
|
* @date 2023-09-07 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Service |
|
|
|
|
|
public class OpenUserBasicInfoServiceImpl implements OpenUserBasicInfoService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WxCreditHistoryMapper wxCreditHistoryMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WxCUserBasicInfoService wxCUserBasicInfoService; |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public void pointChange(TenantEntity tenantEntity, Integer changePoints, String phone) { |
|
|
|
|
|
wxCUserBasicInfoService.updatePointsByPhone(tenantEntity, changePoints, phone); |
|
|
|
|
|
WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, phone); |
|
|
|
|
|
WxCreditHistory wxCreditHistory = buildWxCreditHistory(userBasicInfo, changePoints); |
|
|
|
|
|
wxCreditHistoryMapper.insert(wxCreditHistory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WxCreditHistory buildWxCreditHistory(WxCUserBasicInfo userBasicInfo, Integer changePoints) { |
|
|
|
|
|
WxCreditHistory creditHistory = new WxCreditHistory(); |
|
|
|
|
|
creditHistory.setTenantId(userBasicInfo.getFinalTenantId()); |
|
|
|
|
|
creditHistory.setCreateDate(new Date()); |
|
|
|
|
|
creditHistory.setCUserId(userBasicInfo.getId()); |
|
|
|
|
|
creditHistory.setOperatorId(Long.valueOf(userBasicInfo.getPhone())); |
|
|
|
|
|
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode()); |
|
|
|
|
|
creditHistory.setCreditAmount(userBasicInfo.getCredit()); |
|
|
|
|
|
creditHistory.setCreditNum(changePoints); |
|
|
|
|
|
creditHistory.setCreditType(EnumScoreType.POINT_CHANGE.getCode()); |
|
|
|
|
|
if(creditHistory.getCreditNum() > 0){ |
|
|
|
|
|
creditHistory.setChangePurpose("积分新增"); |
|
|
|
|
|
}else if(creditHistory.getCreditNum() < 0){ |
|
|
|
|
|
creditHistory.setChangePurpose("积分扣减"); |
|
|
|
|
|
} |
|
|
|
|
|
return creditHistory; |
|
|
|
|
|
} |
|
|
|
|
|
} |