|
|
|
@@ -0,0 +1,86 @@ |
|
|
|
package com.iformall.controller.sys; |
|
|
|
|
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxMall; |
|
|
|
import com.iformall.domain.po.WxMsgSignature; |
|
|
|
import com.iformall.domain.po.WxMsgValidationcodeModel; |
|
|
|
import com.iformall.enums.EnumMsgModel; |
|
|
|
import com.iformall.mapper.WxMallMapper; |
|
|
|
import com.iformall.mapper.WxMsgSignatureMapper; |
|
|
|
import com.iformall.mapper.WxMsgValidationcodeModelMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 数据初始化 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("sys") |
|
|
|
public class DataInitController { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
private WxMallMapper mallMapper; |
|
|
|
@Resource |
|
|
|
private WxMsgSignatureMapper signatureMapper; |
|
|
|
@Resource |
|
|
|
private WxMsgValidationcodeModelMapper modelMapper; |
|
|
|
|
|
|
|
@GetMapping("/init") |
|
|
|
public ResultData init() { |
|
|
|
|
|
|
|
try { |
|
|
|
addBirthDayMsgModel(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("DataInitController::init error ", e); |
|
|
|
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 增加会员生日短信模板 |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
public void addBirthDayMsgModel() { |
|
|
|
List<WxMsgSignature> list = signatureMapper.selectAll(); |
|
|
|
Map<String, String> tenantOfSignature = list.stream().collect(Collectors.toMap(WxMsgSignature::getTenantId, WxMsgSignature::getName)); |
|
|
|
|
|
|
|
List<WxMall> malls = mallMapper.selectAll(); |
|
|
|
IdWorker idWorker = IdWorker.get(); |
|
|
|
malls.forEach(wxMall -> { |
|
|
|
addBirthDayMsgModelItem(tenantOfSignature, idWorker, wxMall, EnumMsgModel.COUPON_BIRTHDAY_OPENED, "亲到的{userName},在您的生日到来之际,我们精心的为您准备了一份生日礼物,并在生日当天消费领取{creditScale}倍积分,赶快打开{mallName}微信小程序领取您的专属生日礼物吧!"); |
|
|
|
addBirthDayMsgModelItem(tenantOfSignature, idWorker, wxMall, EnumMsgModel.COUPON_BIRTHDAY_OPENED_NO, "会员生日券未开启', '富茂中心', '亲到的{userName},在您的生日到来之际,我们精心的为您准备了一份生日礼物,赶快打开{mallName}微信小程序领取您的专属生日礼物吧!"); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void addBirthDayMsgModelItem(Map<String, String> tenantOfSignature, IdWorker idWorker, WxMall wxMall, EnumMsgModel msgModel, String content) { |
|
|
|
WxMsgValidationcodeModel model = new WxMsgValidationcodeModel(); |
|
|
|
model.setTenantId(wxMall.getTenantId()); |
|
|
|
model.setId(idWorker.nextId()); |
|
|
|
model.setType(msgModel.getCode()); |
|
|
|
model.setName(msgModel.getMessage()); |
|
|
|
model.setSignature(tenantOfSignature.get(wxMall.getTenantId())); |
|
|
|
model.setContent(content); |
|
|
|
model.setCreatetime(new Date()); |
|
|
|
model.setStatus(0); |
|
|
|
model.setMinutes(0); |
|
|
|
model.setOpen(0); |
|
|
|
model.setMsgType(1); |
|
|
|
model.setRoleType(3); |
|
|
|
modelMapper.insertSelective(model); |
|
|
|
} |
|
|
|
} |