|
|
@@ -6,20 +6,20 @@ import com.iformall.common.ResultData; |
|
|
import com.iformall.controller.base.BaseController; |
|
|
import com.iformall.controller.base.BaseController; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.enums.EnumMsgModel; |
|
|
import com.iformall.enums.EnumMsgModel; |
|
|
|
|
|
import com.iformall.enums.EnumScoreType; |
|
|
|
|
|
import com.iformall.enums.EnumUserType; |
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.service.WxCreditHistoryService; |
|
|
import com.iformall.service.WxCreditHistoryService; |
|
|
import com.iformall.utils.DateUtils; |
|
|
import com.iformall.utils.DateUtils; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@@ -47,14 +47,25 @@ public class DataInitController extends BaseController { |
|
|
@Resource |
|
|
@Resource |
|
|
private WxCUserBasicInfoMapper cUserBasicInfoMapper; |
|
|
private WxCUserBasicInfoMapper cUserBasicInfoMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private WxCouponMapper couponMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private WxCouponOrderMapper couponOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private WxMerchantBUserMapper merchantBUserMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/init") |
|
|
@GetMapping("/init") |
|
|
public ResultData init() { |
|
|
public ResultData init() { |
|
|
try { |
|
|
try { |
|
|
MallUserInfo userInfo = getUser(); |
|
|
MallUserInfo userInfo = getUser(); |
|
|
if (userInfo.isFmSuperAdmin()) { |
|
|
if (userInfo.isFmSuperAdmin()) { |
|
|
|
|
|
addBirthDayMsgModel(); |
|
|
return new ResultData(); |
|
|
return new ResultData(); |
|
|
} |
|
|
} |
|
|
addBirthDayMsgModel(); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("DataInitController::init error ", e); |
|
|
log.error("DataInitController::init error ", e); |
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
@@ -73,9 +84,30 @@ public class DataInitController extends BaseController { |
|
|
try { |
|
|
try { |
|
|
MallUserInfo userInfo = getUser(); |
|
|
MallUserInfo userInfo = getUser(); |
|
|
if(userInfo.isFmSuperAdmin()) { |
|
|
if(userInfo.isFmSuperAdmin()) { |
|
|
|
|
|
doFixCredit(); |
|
|
|
|
|
return new ResultData(); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("DataInitController::fixCredit error ", e); |
|
|
|
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 核销积分数据修复 |
|
|
|
|
|
* |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
@GetMapping("/fixVerifyCredit") |
|
|
|
|
|
public ResultData fixVerifyCredit() { |
|
|
|
|
|
try { |
|
|
|
|
|
MallUserInfo userInfo = getUser(); |
|
|
|
|
|
if(userInfo.isFmSuperAdmin()) { |
|
|
|
|
|
doFixVerifyCredit(); |
|
|
return new ResultData(); |
|
|
return new ResultData(); |
|
|
} |
|
|
} |
|
|
doFixCredit(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("DataInitController::fixCredit error ", e); |
|
|
log.error("DataInitController::fixCredit error ", e); |
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
@@ -131,6 +163,61 @@ public class DataInitController extends BaseController { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void doFixVerifyCredit() { |
|
|
|
|
|
// 1 获取券码 |
|
|
|
|
|
Map dateMap = new HashMap(); |
|
|
|
|
|
dateMap.put("startDate", "2019-09-16 22:00:00"); |
|
|
|
|
|
List<WxCouponOrder> coList = couponOrderMapper.findListOfVerifiedByDate(dateMap); |
|
|
|
|
|
// 2 重新计算积分,比较是否需要修复 |
|
|
|
|
|
coList.forEach(co -> { |
|
|
|
|
|
WxCUser cuUser = cUserMapper.selectByPrimaryKey(co.getcUserId()); |
|
|
|
|
|
WxCUserBasicInfo userBasicInfo = cUserBasicInfoMapper.selectByPrimaryKey(co.getcUserId()); |
|
|
|
|
|
//排查不存在的用户 |
|
|
|
|
|
if (Objects.isNull(cuUser) && Objects.isNull(userBasicInfo)) { |
|
|
|
|
|
log.debug("用户不存在 id: {}", co.getId()); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WxCoupon coupon = couponMapper.selectByPrimaryKey(co.getCouponId()); |
|
|
|
|
|
|
|
|
|
|
|
WxMerchantBUser buUser = merchantBUserMapper.selectByPrimaryKey(co.getBUserId()); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Integer> result = creditHistoryService.findByMerchantIdAndSpend(buUser.getMerchantId(), String.valueOf(co.getCouponPriceStr()), co.getCUserId(), co.getTenantId()); |
|
|
|
|
|
Integer credit = result.get("credit"); |
|
|
|
|
|
|
|
|
|
|
|
WxCreditHistory creditHistory = new WxCreditHistory(); |
|
|
|
|
|
creditHistory.setOperatorType(EnumUserType.BUSER.getCode()); |
|
|
|
|
|
creditHistory.setOperatorId(buUser.getId()); |
|
|
|
|
|
creditHistory.setCUserId(co.getcUserId()); |
|
|
|
|
|
creditHistory.setCreateDate(co.getUpdateDate()); |
|
|
|
|
|
creditHistory.setTenantId(co.getTenantId()); |
|
|
|
|
|
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); |
|
|
|
|
|
creditHistory.setCouponId(coupon.getId()); |
|
|
|
|
|
creditHistory.setBusinessId(coupon.getBusiness()); |
|
|
|
|
|
creditHistory.setSpend(co.getCouponPrice()); |
|
|
|
|
|
//如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 |
|
|
|
|
|
creditHistory.setMerchantId(buUser.getMerchantId()); |
|
|
|
|
|
creditHistoryService.saveOrUpdate(creditHistory); |
|
|
|
|
|
|
|
|
|
|
|
//用户新积分 |
|
|
|
|
|
Integer newCredit = cuUser.getCredit() + credit; |
|
|
|
|
|
|
|
|
|
|
|
// 4 更新积分 |
|
|
|
|
|
WxCUser toUpdateCUser = new WxCUser(); |
|
|
|
|
|
toUpdateCUser.setId(co.getCUserId()); |
|
|
|
|
|
toUpdateCUser.setCredit(newCredit); |
|
|
|
|
|
toUpdateCUser.setUpdateDate(new Date()); |
|
|
|
|
|
cUserMapper.updateByPrimaryKeySelective(toUpdateCUser); |
|
|
|
|
|
|
|
|
|
|
|
WxCUserBasicInfo toUpdateBasicInfo = new WxCUserBasicInfo(); |
|
|
|
|
|
toUpdateBasicInfo.setId(co.getCUserId()); |
|
|
|
|
|
toUpdateBasicInfo.setCredit(newCredit); |
|
|
|
|
|
toUpdateBasicInfo.setUpdateDate(new Date()); |
|
|
|
|
|
cUserBasicInfoMapper.updateByPrimaryKeySelective(toUpdateBasicInfo); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 增加会员生日短信模板 |
|
|
* 增加会员生日短信模板 |
|
|
*/ |
|
|
*/ |
|
|
|