| @@ -13,6 +13,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.WxMsg; | |||
| import com.iformall.enums.EnumSendWay; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxMsgService; | |||
| import com.iformall.service.WxTemplateMsgService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -62,6 +63,13 @@ public class WxMsgController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| /** | |||
| * 可以主动推消息的订阅模板 | |||
| * @param wxTemplateMsg | |||
| * @param pageNum | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| @ApiOperation("模板分页列表接口") | |||
| @GetMapping("templateList") | |||
| @ApiImplicitParams({ | |||
| @@ -76,10 +84,18 @@ public class WxMsgController extends BaseController { | |||
| types.add(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||
| types.add(EnumTemplateType.LIVE_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| wxTemplateMsg.setOnOff(EnumYesOrNo.YES.getCode()); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPage(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| /** | |||
| * 获取所有的微信订阅模板 | |||
| * @param wxTemplateMsg | |||
| * @param pageNum | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| @ApiOperation("模板分页列表接口") | |||
| @GetMapping("templateListV1") | |||
| @ApiImplicitParams({ | |||
| @@ -90,18 +106,13 @@ public class WxMsgController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | |||
| if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | |||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | |||
| List<Integer> types = new ArrayList<>(); | |||
| types.add(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||
| types.add(EnumTemplateType.LIVE_REMIND.getCode()); | |||
| types.add(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||
| types.add(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| wxTemplateMsg.setTypes(EnumTemplateType.getWxList()); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPage(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("修改模板接口") | |||
| @PostMapping("tempUpd") | |||
| @PostMapping("tempUpdStatus") | |||
| @SystemControllerLog(description = "moban xiugai") | |||
| public ResultData tempUpd(@RequestBody WxTemplateMsg wxTemplateMsg) { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgController::tempUpd"); | |||
| @@ -112,7 +123,7 @@ public class WxMsgController extends BaseController { | |||
| // if(null == wxTemplateMsg.getOnOff()){ | |||
| // wxTemplateMsg.setOnOff(1); | |||
| // } | |||
| wxTemplateMsgService.saveOrUpdate(wxTemplateMsg); | |||
| wxTemplateMsgService.tempUpdStatus(wxTemplateMsg); | |||
| return new ResultData(); | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| delete from wx_template_msg where type in (1,2,3); | |||
| ALTER TABLE `mallink`.`wx_template_msg` | |||
| MODIFY COLUMN `on_off` smallint(2) NOT NULL DEFAULT 0 COMMENT '是否打开' AFTER `update_date`, | |||
| ADD COLUMN `sync_status` smallint(2) NOT NULL DEFAULT 0 COMMENT '是否同步' AFTER `on_off`; | |||
| update wx_template_msg set on_off = 1 where template_id is not null and template_id != ''; | |||
| update wx_template_msg set sync_status = 1 where template_id is not null and template_id != ''; | |||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxTemplateMsg; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxTemplateMsgService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -14,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -37,15 +40,12 @@ public class WxMsgController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | |||
| if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | |||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | |||
| List<Integer> types = new ArrayList<>(); | |||
| types.add(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||
| types.add(EnumTemplateType.LIVE_REMIND.getCode()); | |||
| types.add(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||
| types.add(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| wxTemplateMsg.setIsc(true); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| wxTemplateMsg.setTypes(EnumTemplateType.getWxList()); | |||
| wxTemplateMsg.setOnOff(EnumYesOrNo.YES.getCode()); | |||
| List<WxTemplateMsg> list = wxTemplateMsgService.findList(wxTemplateMsg); | |||
| //微信订阅消息一次只支持3个 | |||
| return new ResultData(createRandomList(list,3)); | |||
| } | |||
| @ApiOperation("模板分页列表接口") | |||
| @@ -60,9 +60,26 @@ public class WxMsgController extends BaseController { | |||
| List<Integer> types = new ArrayList<>(); | |||
| types.add(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| wxTemplateMsg.setIsc(true); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| wxTemplateMsg.setOnOff(EnumYesOrNo.YES.getCode()); | |||
| List<WxTemplateMsg> list = wxTemplateMsgService.findList(wxTemplateMsg); | |||
| return new ResultData(list); | |||
| } | |||
| private static List createRandomList(List list, int n) { | |||
| Map map = new HashMap(); | |||
| List listNew = new ArrayList(); | |||
| if (list.size() <= n) { | |||
| return list; | |||
| } else { | |||
| while (map.size() < n) { | |||
| int random = (int) (Math.random() * list.size()); | |||
| if (!map.containsKey(random)) { | |||
| map.put(random, ""); | |||
| listNew.add(list.get(random)); | |||
| } | |||
| } | |||
| return listNew; | |||
| } | |||
| } | |||
| } | |||
| @@ -784,8 +784,6 @@ public class WxUserGrantController extends BaseController { | |||
| @PostMapping("/updateMsg") | |||
| @ApiOperation(value = "updateMsg", notes = "{\"id\":\"string\"}") | |||
| public ResultData updateMsg() { | |||
| CUser user = getCUser(); | |||
| cuserFactory.getCUserService(user.getAppPlat()).updateMsgCount(user); | |||
| return new ResultData(); | |||
| } | |||
| @@ -91,7 +91,7 @@ public class CouponOrderNoticeSchedule { | |||
| temp.updateTenantInfo(mall); | |||
| temp.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||
| temp = wxTemplateMsgService.getByObj(temp); | |||
| if(temp.getId() != null){ | |||
| if(temp != null){ | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| WxMsg msg = new WxMsg(); | |||
| msg.updateTenantInfo(mall); | |||
| @@ -408,6 +408,8 @@ public enum ErrorCode{ | |||
| TEMPLATE_FORMID_NOT_FOUND(12091, "formId不存在"), | |||
| TEMPLATE_DATA_ERROR(12092, "数据格式错误"), | |||
| TEMPLATE_ADD_ERROR(12093, "添加模板错误"), | |||
| TEMPLATE_IS_CREATE(12094, "模板已同步"), | |||
| TEMPLATE_NOT_CREATE(12095, "模板已同步"), | |||
| /** | |||
| * | |||
| @@ -26,9 +26,12 @@ public class WxTemplateMsg extends TenantEntity { | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="消息开关(0/1)",name="onOff") | |||
| @io.swagger.annotations.ApiModelProperty(value="是否打开",name="onOff") | |||
| private Integer onOff; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否同步",name="syncStatus") | |||
| private Integer syncStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息, 101:公众号审核结果消息, 102:公众号卡券核销消息",name="type") | |||
| @TableField(exist = false) | |||
| private String typeName; | |||
| @@ -36,9 +39,6 @@ public class WxTemplateMsg extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private List<Integer> types; | |||
| @TableField(exist = false) | |||
| private boolean isc; | |||
| public String getTypeName(){ | |||
| if(this.getType() != null) { | |||
| @@ -41,7 +41,7 @@ public class WxMsg extends BaseMsg { | |||
| private Integer errorNumber; | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "returnResult") | |||
| private String returnResult; | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "phones") | |||
| @io.swagger.annotations.ApiModelProperty(value = "兼容openIDS", name = "phones") | |||
| private String phones; | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "signature") | |||
| private String signature; | |||
| @@ -1,29 +1,35 @@ | |||
| package com.iformall.enums; | |||
| import com.google.common.collect.Lists; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumTemplateType { | |||
| // 1-核销成功消息, 2-核销失败消息 | |||
| VERIFY_SUCCESS(1, "核销成功消息",""), // 小程序(作废) | |||
| VERIFY_FAIL(2, "核销失败消息",""), // 小程序(作废) | |||
| PRESS_SUCCESS(3, "砍价成功消息",""), // 小程序(作废) | |||
| /** | |||
| * | |||
| * 微信小程序订阅消息 | |||
| */ | |||
| ACTIVITY_REMIND(4, "活动开始提醒","386"), // 小程序 | |||
| LIVE_REMIND(5, "直播开播提醒","8501"), // 小程序 | |||
| CREDIT_UPD_REMIND(50, "积分变更提醒","310"), // 小程序 | |||
| SEND_COUPON_REMIND(51, "优惠券到账提醒","3209"), // 小程序 | |||
| ACTIVITY_REMIND(4, "活动开始提醒","386", Lists.newArrayList(13, 5, 12, 1, 11)), // 小程序 | |||
| LIVE_REMIND(5, "直播开播提醒","8501",Lists.newArrayList(1, 3, 4, 5)), // 小程序 | |||
| CREDIT_UPD_REMIND(50, "积分变更提醒","310",Lists.newArrayList(1, 2, 4, 3)), // 小程序 | |||
| SEND_COUPON_REMIND(51, "优惠券到账提醒","3209",Lists.newArrayList(1, 3, 4, 5)), // 小程序 | |||
| CARD_BALANCE_CHANGE(52, "账户余额变动提醒","4148",Lists.newArrayList(7, 1, 2, 4, 6)), // 小程序 | |||
| TT_SEND_COUPON_REMIND(60, "优惠券到账提醒",""), // 抖音小程序 | |||
| /** | |||
| * 抖音小程序订阅消息 | |||
| */ | |||
| TT_SEND_COUPON_REMIND(60, "优惠券到账提醒","",null), // 抖音小程序 | |||
| AUDIT_MESSAGE(101, "公众号审核结果通知",""), // 公众号 | |||
| VERIFY_RESULT(102, "公众号卡券核销通知",""), // 公众号 | |||
| GIFT_MESSAGE(103, "公众号购票成功通知",""), // 公众号 | |||
| /** | |||
| * 公众号消息 | |||
| */ | |||
| AUDIT_MESSAGE(101, "公众号审核结果通知","",null), // 公众号 | |||
| VERIFY_RESULT(102, "公众号卡券核销通知","",null), // 公众号 | |||
| GIFT_MESSAGE(103, "公众号购票成功通知","",null), // 公众号 | |||
| ; | |||
| public static EnumTemplateType getEnum(Integer code) { | |||
| @@ -38,11 +44,13 @@ public enum EnumTemplateType { | |||
| private Integer code; | |||
| private String message; | |||
| private String tid; | |||
| private List<Integer> param; | |||
| EnumTemplateType(Integer code, String message, String tid) { | |||
| EnumTemplateType(Integer code, String message, String tid,List<Integer> param) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.tid = tid; | |||
| this.param = param; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -56,4 +64,26 @@ public enum EnumTemplateType { | |||
| public String getTid() { | |||
| return tid; | |||
| } | |||
| public List<Integer> getParam() { | |||
| return param; | |||
| } | |||
| public static List<Integer> getWxList(){ | |||
| List<Integer> wxList = new ArrayList<>(); | |||
| wxList.add(ACTIVITY_REMIND.getCode()); | |||
| wxList.add(LIVE_REMIND.getCode()); | |||
| wxList.add(CREDIT_UPD_REMIND.getCode()); | |||
| wxList.add(SEND_COUPON_REMIND.getCode()); | |||
| wxList.add(CARD_BALANCE_CHANGE.getCode()); | |||
| return wxList; | |||
| } | |||
| public static List<Integer> getWxOfficialList(){ | |||
| List<Integer> wxList = new ArrayList<>(); | |||
| wxList.add(AUDIT_MESSAGE.getCode()); | |||
| wxList.add(VERIFY_RESULT.getCode()); | |||
| wxList.add(GIFT_MESSAGE.getCode()); | |||
| return wxList; | |||
| } | |||
| } | |||
| @@ -36,10 +36,6 @@ public interface TtCUserMapper extends CommonMapper<TtCUser, Long> { | |||
| List<String> listOpenId(TtCUser record); | |||
| void updateMsgCount(TtCUser record); | |||
| // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | |||
| List<String> findOpenIdList(@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||
| List<String> findTokenList(@Param("id")Long id,@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||
| @@ -36,10 +36,6 @@ public interface WxCUserMapper extends CommonMapper<WxCUser, Long> { | |||
| List<String> listOpenId(WxCUser record); | |||
| void updateMsgCount(WxCUser user); | |||
| // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | |||
| String findOpenId(@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||
| Long findCuserId(@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||
| @@ -7,6 +7,4 @@ import com.iformall.domain.po.WxTemplateMsg; | |||
| public interface WxTemplateMsgMapper extends CommonMapper<WxTemplateMsg, Long> { | |||
| List<WxTemplateMsg> findList(WxTemplateMsg wxTemplateMsg); | |||
| List<WxTemplateMsg> findListForMiniApp(WxTemplateMsg record); | |||
| } | |||
| @@ -125,5 +125,4 @@ public interface TtCUserService { | |||
| void delForUserIdOnly(Long id, Long userId, String tenantId); | |||
| void updateMsgCount(TtCUser user); | |||
| } | |||
| @@ -135,7 +135,5 @@ public interface WxCUserService { | |||
| void delForUserIdOnly(Long id, Long userId, String tenantId); | |||
| void updateMsgCount(WxCUser user); | |||
| void updateAuthorizeStateByOpenId(WxCUser updCuser); | |||
| } | |||
| @@ -57,7 +57,5 @@ public interface WxOrderPressService { | |||
| int pressCouponStatus(WxOrder order, Long cUserId); | |||
| boolean checkCUserHasJoin(WxOrder order, Long cUserId); | |||
| void sendPressComplateMsg(WxOrder orderUpdatePress); | |||
| } | |||
| @@ -61,5 +61,5 @@ public interface WxTemplateMsgService { | |||
| ResultData pushTemp(WxTemplateMsg wxTemplateMsg); | |||
| PageInfo<WxTemplateMsg> listAsPageForMiniApp(WxTemplateMsg wxTemplateMsg, Integer pageNum, Integer pageSize); | |||
| ResultData tempUpdStatus(WxTemplateMsg wxTemplateMsg); | |||
| } | |||
| @@ -41,8 +41,6 @@ public interface CUserServiceApapter { | |||
| void updateExtInfo(CUser user); | |||
| void updateMsgCount(CUser user); | |||
| long findCount(WxCUserBasicInfoDto dto); | |||
| List<UserCountVo> findCountHistory(WxCUserBasicInfoDto dto); | |||
| @@ -246,11 +246,6 @@ public class TtBUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| cleanCuserToken(user.getToken()); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(CUser user) { | |||
| } | |||
| @Override | |||
| public long findCount(WxCUserBasicInfoDto dto) { | |||
| return 0l; | |||
| @@ -309,15 +309,6 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| cleanCuserToken(user.getToken()); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(CUser user) { | |||
| // TtCUser userL = new TtCUser(); | |||
| // userL.setId(user.getId()); | |||
| // userL.updateTenantInfo(user); | |||
| // ttCUserMapper.updateMsgCount(userL); | |||
| ttCUserMapper.updateMsgCount((TtCUser) user); | |||
| } | |||
| @Override | |||
| public long findCount(WxCUserBasicInfoDto dto) { | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| @@ -250,11 +250,6 @@ public class WxBUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| cleanCuserToken(user.getToken()); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(CUser user) { | |||
| } | |||
| @Override | |||
| public long findCount(WxCUserBasicInfoDto dto) { | |||
| return 0l; | |||
| @@ -322,15 +322,6 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| cleanCuserToken(user.getToken()); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(CUser user) { | |||
| // WxCUser userL = new WxCUser(); | |||
| // userL.setId(user.getId()); | |||
| // userL.updateTenantInfo(user); | |||
| // wxCUserMapper.updateMsgCount(userL); | |||
| wxCUserMapper.updateMsgCount((WxCUser) user); | |||
| } | |||
| @Override | |||
| public long findCount(WxCUserBasicInfoDto dto) { | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| @@ -259,9 +259,4 @@ public class TtCUserServiceImpl implements TtCUserService { | |||
| ttCUserMapper.delForUserIdOnly(id,userId,tenantId); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(TtCUser user) { | |||
| ttCUserMapper.updateMsgCount(user); | |||
| } | |||
| } | |||
| @@ -341,11 +341,6 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| wxCUserMapper.delForUserIdOnly(id,userId,tenantId); | |||
| } | |||
| @Override | |||
| public void updateMsgCount(WxCUser user) { | |||
| wxCUserMapper.updateMsgCount(user); | |||
| } | |||
| @Override | |||
| public void updateAuthorizeStateByOpenId(WxCUser updCuser) { | |||
| wxCUserMapper.updateAuthorizeStateByOpenId(updCuser); | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| @@ -11,6 +12,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxSharingOrderDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.WxMsg; | |||
| import com.iformall.domain.vo.PromotionCalc; | |||
| import com.iformall.domain.vo.WxCardSpendMerchantVo; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| @@ -37,6 +39,7 @@ import javax.servlet.http.HttpServletResponse; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.math.BigDecimal; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| @@ -98,12 +101,21 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| @Lazy | |||
| @Autowired | |||
| WxCashOutService wxCashOutService; | |||
| @Autowired | |||
| WxTemplateMsgService wxTemplateMsgService; | |||
| @Autowired | |||
| WxMsgService wxMsgService; | |||
| @Autowired | |||
| WxCouponChannelMapper wxCouponChannelMapper; | |||
| @Autowired | |||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @Autowired | |||
| WxCUserMapper wxCUserMapper; | |||
| @Override | |||
| public WxCouponMerchant checkMerchantInCoupon(WxCardInfo cardInfo, Long merchantId) { | |||
| @@ -302,6 +314,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| } | |||
| } | |||
| sendCardBalanceChange(coupon,record); | |||
| if (null != orderUpdate.getCUserId() && Constant.defaultCUserId != orderUpdate.getCUserId()) { | |||
| // 成长值 | |||
| try { | |||
| @@ -337,6 +351,51 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| return new ResultData(record); | |||
| } | |||
| /** | |||
| * 卡余额变动订阅消息 | |||
| */ | |||
| private void sendCardBalanceChange(WxCoupon coupon,WxCardSpend cardSpend){ | |||
| try { | |||
| if(cardSpend.getOwnerId() == null){ | |||
| return; | |||
| } | |||
| WxCUser wcuQ = new WxCUser(); | |||
| wcuQ.updateTenantInfo(coupon); | |||
| wcuQ.setUserId(cardSpend.getOwnerId()); | |||
| String openId = wxCUserMapper.findOpenId(cardSpend.getOwnerId(), coupon.getTenantId()); | |||
| if(StringUtils.isBlank(openId)){ | |||
| return; | |||
| } | |||
| WxTemplateMsg temp = new WxTemplateMsg(); | |||
| temp.updateTenantInfo(coupon); | |||
| temp.setType(EnumTemplateType.CARD_BALANCE_CHANGE.getCode()); | |||
| temp = wxTemplateMsgService.getByObj(temp); | |||
| if(temp == null){ | |||
| return; | |||
| } | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| WxMsg msg = new WxMsg(); | |||
| msg.updateTenantInfo(coupon); | |||
| msg.setPhones(openId); | |||
| msg.setModelId(temp.getId()); | |||
| Map<String,String> map = new HashMap<>(); | |||
| map.put("thing7",coupon.getTitle()); | |||
| map.put("amount1",cardSpend.getPaymentStr()); | |||
| map.put("amount2",cardSpend.getCardRemainAmountStr()); | |||
| map.put("date4",dateFormat.format(cardSpend.getCreateDate())); | |||
| WxMerchant merchant = wxMerchantMapper.selectById(cardSpend.getMerchantId()); | |||
| map.put("thing6","商户【"+merchant.getName()+"】消费"); | |||
| map.put("goToPage","pages/index/index?type=ca"); | |||
| msg.setMsg(JSONObject.toJSONString(map)); | |||
| wxMsgService.batchSendAppinfo(msg); | |||
| } catch (Exception e) { | |||
| // e.printStackTrace(); | |||
| logger.error("卡余额变动消息发送异常"); | |||
| } | |||
| } | |||
| public void creteMerchantSubsidy(WxCardSpend record, Date curDate, IdWorker idWorker, WxCoupon coupon, Integer payment) { | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| merchantSubsidy.setId(idWorker.nextId()); | |||
| @@ -2272,79 +2272,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| } | |||
| private void doVerifySuccessMsg(WxCouponOrder couponOrder, String formId, WxCoupon coupon, WxMerchant merchant, WxCUser user, SimpleDateFormat dateFormat, String couponDetail, String gotopage) { | |||
| SmartAppMsg smartAppMsg; | |||
| /** | |||
| * 核销成功消息 | |||
| * 核销金额 {{keyword1.DATA}} | |||
| * 商家名称 {{keyword2.DATA}} | |||
| * 商品 {{keyword3.DATA}} | |||
| * 商品描述 {{keyword4.DATA}} | |||
| * 订单金额 {{keyword5.DATA}} | |||
| * 核销时间 {{keyword6.DATA}} | |||
| * 温馨提示 {{keyword7.DATA}} | |||
| */ | |||
| smartAppMsg = new SmartAppMsg(); | |||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||
| smartAppMsg.setAppId(user.getAppId()); | |||
| smartAppMsg.updateTenantInfo(couponOrder); | |||
| smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_SUCCESS.getCode()); | |||
| smartAppMsg.setGotopage(gotopage); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| coupon.getPriceStr(), | |||
| merchant.getName(), | |||
| coupon.getTitle(), | |||
| couponDetail, | |||
| coupon.getSalePriceStr(), | |||
| dateFormat.format(new Date()), | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| //mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| } catch (Exception e) { | |||
| logger.error("支付通知发送失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||
| } | |||
| } | |||
| private void doVerifyFailMsg(WxCouponOrder couponOrder, String formId, WxCoupon coupon, WxCUser user, SimpleDateFormat dateFormat, String couponDetail, String gotopage) { | |||
| SmartAppMsg smartAppMsg; /** | |||
| * 核销失败消息 | |||
| * 商品名称 {{keyword1.DATA}} | |||
| * 核销时间 {{keyword2.DATA}} | |||
| * 失败原因 {{keyword3.DATA}} | |||
| * 备注 {{keyword4.DATA}} | |||
| */ | |||
| smartAppMsg = new SmartAppMsg(); | |||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||
| smartAppMsg.setAppId(user.getAppId()); | |||
| smartAppMsg.updateTenantInfo(couponOrder); | |||
| smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_FAIL.getCode()); | |||
| smartAppMsg.setGotopage(gotopage); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setReceiver(user.getOpenId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| coupon.getTitle(), | |||
| dateFormat.format(new Date()), | |||
| "核销失败", | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| } catch (Exception e) { | |||
| logger.error("支付通知发送失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||
| } | |||
| } | |||
| @Override | |||
| public List<CUserDateAmountVo> queryPriceTotalGroup(TenantEntity tenantEntity, Date startTime, Date endTime) { | |||
| @@ -670,7 +670,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| temp.setTenantId(tenantId); | |||
| temp.setType(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||
| temp = wxTemplateMsgService.getByObj(temp); | |||
| if(temp.getId() != null){ | |||
| if(temp != null){ | |||
| String openId = wxCUserMapper.findOpenId(wxCUserBasicInfo.getId(),tenantId); | |||
| if(StringUtils.isNotBlank(openId)){ | |||
| WxMsg msg = new WxMsg(); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| @@ -392,10 +393,10 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| smartAppMsg.setAppId(cAppInfo.getAppId()); | |||
| WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(wxMsg.getModelId()); | |||
| // if(1 == wxTemplateMsg.getOnOff().intValue()){ | |||
| // logger.error("订阅消息模板关闭。"); | |||
| // return; | |||
| // } | |||
| if(wxTemplateMsg == null || !EnumYesOrNo.YES.getCode().equals(wxTemplateMsg.getOnOff())){ | |||
| logger.error("未找到订阅消息模板或模板未启用。"); | |||
| return; | |||
| } | |||
| smartAppMsg.setTemplateType(wxTemplateMsg.getType()); | |||
| JSONObject customParam = JSON.parseObject(wxMsg.getMsg()); | |||
| @@ -404,6 +405,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| goToPage = "pages/index/index?type=in";//默认首页 | |||
| } | |||
| smartAppMsg.setGotopage(goToPage); | |||
| if(wxTemplateMsg.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | |||
| /** | |||
| * 活动名称:{{thing13.DATA}} | |||
| @@ -458,6 +460,21 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| customParam.getString("time4"), | |||
| customParam.getString("thing5") | |||
| )); | |||
| }else if(wxTemplateMsg.getType() == EnumTemplateType.CARD_BALANCE_CHANGE.getCode()){ | |||
| /** | |||
| * 账户名称{{thing7.DATA}} | |||
| * 变动金额{{amount1.DATA}} | |||
| * 账户余额{{amount2.DATA}} | |||
| * 时间{{date4.DATA}} | |||
| * 变动原因{{thing6.DATA}} | |||
| */ | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| customParam.getString("thing7"), | |||
| customParam.getString("amount1"), | |||
| customParam.getString("amount2"), | |||
| customParam.getString("date4"), | |||
| customParam.getString("thing6") | |||
| )); | |||
| }else{ | |||
| return; | |||
| } | |||
| @@ -141,118 +141,6 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { | |||
| } | |||
| return EnumOrderPressStatus.NOT_JOIN.getCode(); | |||
| } | |||
| /** | |||
| * 微信模板消息 | |||
| * | |||
| * @param | |||
| */ | |||
| @Override | |||
| public void sendPressComplateMsg(WxOrder orderUpdatePress) { | |||
| // 1. get order info | |||
| WxOrder order = wxOrderMapper.selectById(orderUpdatePress.getId(),orderUpdatePress.getTenantId()); | |||
| if (order == null) { | |||
| logger.error("找不到订单信息"); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| // 2. get coupon info | |||
| WxCoupon coupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId()); | |||
| if (order == null) { | |||
| logger.error("找不到券信息"); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| // 3. get user info | |||
| WxCUser user = null; | |||
| WxCUser wcuQ = new WxCUser(); | |||
| wcuQ.updateTenantInfo(order); | |||
| wcuQ.setUserId(order.getCUserId()); | |||
| List<WxCUser> list = userMapper.findList(wcuQ); | |||
| if(list != null && list.size() > 0){ | |||
| user = list.get(0); | |||
| } | |||
| if (user == null) { | |||
| logger.error("找不到C端用户"); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| String gotopage = Constant.mainPageUrl + "?type=mb"; | |||
| // 小程序 消息 | |||
| String formId = null; | |||
| Date curDate = new Date(); | |||
| Date dateAfter7Day = DateUtils.getHourTimeAfter(7, order.getCreateDate()); | |||
| if(StringUtils.isNotBlank(order.getFormId()) && curDate.before(dateAfter7Day) | |||
| && !order.getFormId().equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| formId = order.getFormId(); | |||
| } | |||
| int formType = EnumMsgLimitType.WEAPP_FORMID.getCode(); | |||
| if(StringUtils.isBlank(formId)) { | |||
| logger.error("无可用formId, 不能发小程序模板消息"); | |||
| return; | |||
| } | |||
| // 9. 微信小程序-模板消息 | |||
| /** | |||
| * 检查 小程序模板消息是否超限 | |||
| */ | |||
| // WxMsgLimit msgLimit = new WxMsgLimit(); | |||
| // msgLimit.updateTenantInfo(user); | |||
| // msgLimit.setType(formType); | |||
| // msgLimit.setLimitId(formId); | |||
| // if(wxMsgLimitService.checkIsLimit(msgLimit)) { | |||
| // // 已达到限制条件,不发消息了 | |||
| // logger.error("已达到限制条件,不发小程序模板消息了: " + user.getId()); | |||
| // return; | |||
| // } | |||
| // // mq发送小程序消息 - 核销成功消息 | |||
| // doPressSuccessMsg(coupon, user, formId, gotopage); | |||
| } | |||
| private void doPressSuccessMsg(WxCoupon coupon, WxCUser user, String formId, String gotopage) { | |||
| SmartAppMsg smartAppMsg; | |||
| /** | |||
| * 砍价成功消息 | |||
| * 商品名称 {{keyword1.DATA}} | |||
| * 商品原价 {{keyword2.DATA}} | |||
| * 付款剩余时间 {{keyword3.DATA}} | |||
| * 支付截止时间 {{keyword4.DATA}} | |||
| * 支付金额 {{keyword5.DATA}} | |||
| * 温馨提示 {{keyword6.DATA}} | |||
| */ | |||
| Calendar calendar = Calendar.getInstance(); | |||
| calendar.setTime(new Date()); | |||
| calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) +1);// 让日期加1h | |||
| System.out.println(calendar.get(Calendar.DATE));// 加1之后的日期Top | |||
| System.out.println(); | |||
| smartAppMsg = new SmartAppMsg(); | |||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||
| smartAppMsg.setAppId(user.getAppId()); | |||
| smartAppMsg.setTenantId(user.getTenantId()); | |||
| smartAppMsg.setTemplateType(EnumTemplateType.PRESS_SUCCESS.getCode()); | |||
| smartAppMsg.setGotopage(gotopage); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| coupon.getTitle(), | |||
| coupon.getPriceStr(), | |||
| "1小时", | |||
| new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()), | |||
| coupon.getSalePriceStr(), | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| } catch (Exception e) { | |||
| logger.error("砍价成功通知发送失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | |||
| } | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ import com.iformall.domain.po.WxTemplateMsg; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.mapper.WxTemplateMsgMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxTemplateMsgService; | |||
| @@ -69,6 +70,11 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| wxTemplateMsg.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||
| wxTemplateMsg.setCustomParam("{\"index\": [\"thing1\", \"time3\", \"time4\", \"thing5\"], \"emphasis\": \"\"}"); | |||
| wxTemplateMsgMapper.insert(wxTemplateMsg); | |||
| // wxTemplateMsg.setId(null); | |||
| // wxTemplateMsg.setType(EnumTemplateType.CARD_BALANCE_CHANGE.getCode()); | |||
| // wxTemplateMsg.setCustomParam("{\"index\": [\"thing7\", \"amount1\", \"amount2\", \"amount4\", \"thing6\"], \"emphasis\": \"\"}"); | |||
| // wxTemplateMsgMapper.insert(wxTemplateMsg); | |||
| } | |||
| @Override | |||
| @@ -119,40 +125,21 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(wxTemplateMsg, EnumAppPlat.WX); | |||
| WxMaService wxMaService = null; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appinfo); | |||
| if(EnumYesOrNo.YES.getCode().equals(byId.getSyncStatus())){ | |||
| return new ResultData(ErrorCode.TEMPLATE_IS_CREATE); | |||
| } | |||
| String s = ""; | |||
| if(byId.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.ACTIVITY_REMIND.getTid(), | |||
| Lists.newArrayList(13, 5, 12, 1, 11), EnumTemplateType.ACTIVITY_REMIND.getMessage()); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| }else if(byId.getType() == EnumTemplateType.LIVE_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.LIVE_REMIND.getTid(), | |||
| Lists.newArrayList(1, 3, 4, 5),EnumTemplateType.LIVE_REMIND.getMessage()); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| }else if(byId.getType() == EnumTemplateType.CREDIT_UPD_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.CREDIT_UPD_REMIND.getTid(), | |||
| Lists.newArrayList(1, 2, 4, 3),EnumTemplateType.CREDIT_UPD_REMIND.getMessage()); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| if(EnumTemplateType.getWxList().contains(byId.getType())){ | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(wxTemplateMsg, EnumAppPlat.WX); | |||
| WxMaService wxMaService = null; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appinfo); | |||
| } | |||
| }else if(byId.getType() == EnumTemplateType.SEND_COUPON_REMIND.getCode()){ | |||
| try { | |||
| s = wxMaService.getSubscribeService().addTemplate(EnumTemplateType.SEND_COUPON_REMIND.getTid(), | |||
| Lists.newArrayList(1, 3, 4, 5),EnumTemplateType.SEND_COUPON_REMIND.getMessage()); | |||
| EnumTemplateType typeEnum = EnumTemplateType.getEnum(byId.getType()); | |||
| s = wxMaService.getSubscribeService().addTemplate(typeEnum.getTid(),typeEnum.getParam(),typeEnum.getMessage()); | |||
| } catch (WxErrorException e) { | |||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||
| } | |||
| @@ -164,13 +151,26 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||
| } | |||
| wxTemplateMsg.setTemplateId(s); | |||
| wxTemplateMsg.setSyncStatus(EnumYesOrNo.YES.getCode()); | |||
| this.saveOrUpdate(wxTemplateMsg); | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public PageInfo<WxTemplateMsg> listAsPageForMiniApp(WxTemplateMsg record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxTemplateMsgMapper.findListForMiniApp(record)); | |||
| public ResultData tempUpdStatus(WxTemplateMsg wxTemplateMsg) { | |||
| WxTemplateMsg byId = this.getById(wxTemplateMsg.getId()); | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| if(!EnumYesOrNo.YES.getCode().equals(byId.getSyncStatus())){ | |||
| return new ResultData(ErrorCode.TEMPLATE_NOT_CREATE); | |||
| } | |||
| WxTemplateMsg updStatus = new WxTemplateMsg(); | |||
| updStatus.setId(wxTemplateMsg.getId()); | |||
| updStatus.updateTenantInfo(wxTemplateMsg); | |||
| updStatus.setOnOff(wxTemplateMsg.getOnOff()); | |||
| this.saveOrUpdate(updStatus); | |||
| return new ResultData(); | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.iformall.service.msg.impl; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; | |||
| import cn.binarywang.wx.miniapp.constant.WxMaConstants; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| @@ -8,6 +10,8 @@ import com.iformall.domain.po.WxTemplateMsg; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| import com.iformall.domain.po.msg.MpAppMsg; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.mapper.WxTemplateMsgMapper; | |||
| import com.iformall.service.msg.MsgSendService; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| @@ -39,53 +43,62 @@ public class SendMpMsgServiceImpl implements MsgSendService { | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception{ | |||
| MpAppMsg mpAppMsg = (MpAppMsg)baseMsg; | |||
| WxTemplateMsg msg = null; | |||
| TenantEntity tenantEntity = mpAppMsg.getTenantInfo(); | |||
| WxMpService wxMpService = openService.getWxOpenComponentService().getWxMpServiceByAppid(mpAppMsg.getAppId()); | |||
| // 查询信息模板 | |||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||
| msgQ.updateTenantInfo(tenantEntity); | |||
| msgQ.setType(mpAppMsg.getTemplateType()); | |||
| try { | |||
| msg = wxTemplateMsgMapper.selectOne(new QueryWrapper(msgQ)); | |||
| } catch (Exception e) { | |||
| logger.error("公众号消息模板错误: " + e.getMessage()); | |||
| msgQ.setOnOff(EnumYesOrNo.YES.getCode()); | |||
| List<WxTemplateMsg> list = wxTemplateMsgMapper.findList(msgQ); | |||
| WxTemplateMsg msg = null; | |||
| if (list.size() > 0) { | |||
| msg = list.get(0); | |||
| } | |||
| if (msg == null) { | |||
| logger.error("找不到模板Id"); | |||
| //throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| return; | |||
| } | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| String url = customParam.getString("url"); | |||
| if(EnumTemplateType.getWxOfficialList().contains(msg.getType())){ | |||
| WxMpService wxMpService = openService.getWxOpenComponentService().getWxMpServiceByAppid(mpAppMsg.getAppId()); | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| String url = customParam.getString("url"); | |||
| // build template data list | |||
| List<WxMpTemplateData> dataTempList = new ArrayList<>(); | |||
| List<String> dataList = mpAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| for(int i=0;i<indexArr.size();i++) { | |||
| String key = indexArr.getString(i); | |||
| String value = customParam.getString(key); | |||
| value = value.replace("{"+key+"}", dataList.get(i)); | |||
| WxMpTemplateData templateData = new WxMpTemplateData(key, value); | |||
| dataTempList.add(templateData); | |||
| } | |||
| // build template data list | |||
| List<WxMpTemplateData> dataTempList = new ArrayList<>(); | |||
| List<String> dataList = mpAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| for(int i=0;i<indexArr.size();i++) { | |||
| String key = indexArr.getString(i); | |||
| String value = customParam.getString(key); | |||
| value = value.replace("{"+key+"}", dataList.get(i)); | |||
| WxMpTemplateData templateData = new WxMpTemplateData(key, value); | |||
| dataTempList.add(templateData); | |||
| } | |||
| WxMpTemplateMessage.MiniProgram miniprogram = new WxMpTemplateMessage.MiniProgram(); | |||
| miniprogram.setAppid(mpAppMsg.getMiniAppId()); | |||
| miniprogram.setPagePath(mpAppMsg.getMiniPagePath()); | |||
| WxMpTemplateMessage.MiniProgram miniprogram = new WxMpTemplateMessage.MiniProgram(); | |||
| miniprogram.setAppid(mpAppMsg.getMiniAppId()); | |||
| miniprogram.setPagePath(mpAppMsg.getMiniPagePath()); | |||
| String[] split = mpAppMsg.getTo().split(","); | |||
| for (String to:split) { | |||
| try { | |||
| WxMpTemplateMessage mpTemplateMessage = WxMpTemplateMessage.builder() | |||
| .toUser(to) | |||
| .templateId(msg.getTemplateId()) | |||
| .miniProgram(miniprogram) | |||
| .data(dataTempList) | |||
| .build(); | |||
| wxMpService.getTemplateMsgService().sendTemplateMsg(mpTemplateMessage); | |||
| } catch (Exception e) { | |||
| logger.error("openId:"+to+"-----发送公众号消息失败"); | |||
| } | |||
| } | |||
| }else{ | |||
| logger.error("-----模板类型错误"); | |||
| } | |||
| WxMpTemplateMessage mpTemplateMessage = WxMpTemplateMessage.builder() | |||
| .toUser(mpAppMsg.getTo()) | |||
| .templateId(msg.getTemplateId()) | |||
| .miniProgram(miniprogram) | |||
| .data(dataTempList) | |||
| .build(); | |||
| String retStr = wxMpService.getTemplateMsgService().sendTemplateMsg(mpTemplateMessage); | |||
| logger.info(retStr); | |||
| } | |||
| } | |||
| @@ -15,6 +15,7 @@ import com.iformall.domain.po.msg.SmartAppMsg; | |||
| import com.iformall.douyin.miniapp.api.TtMaService; | |||
| import com.iformall.douyin.miniapp.api.bean.TtMaSubscribeMessage; | |||
| import com.iformall.enums.EnumTemplateType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.mapper.WxCUserMapper; | |||
| import com.iformall.mapper.WxTemplateMsgMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| @@ -65,6 +66,7 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||
| msgQ.updateTenantInfo(tenantEntity); | |||
| msgQ.setType(smartAppMsg.getTemplateType()); | |||
| msgQ.setOnOff(EnumYesOrNo.YES.getCode()); | |||
| List<WxTemplateMsg> list = wxTemplateMsgMapper.findList(msgQ); | |||
| WxTemplateMsg msg = null; | |||
| if (list.size() > 0) { | |||
| @@ -72,79 +74,71 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||
| } | |||
| if (msg == null) { | |||
| logger.error("找不到模板Id"); | |||
| // throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| return; | |||
| } | |||
| if(0 == msg.getOnOff().intValue()){ | |||
| if(EnumTemplateType.getWxList().contains(msg.getType())){ | |||
| WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(smartAppMsg.getAppId()); | |||
| if(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode().equals(msg.getType())){ | |||
| //发抖音 | |||
| TtMaService ttappService = maUtil.getTtMaService(appInfo); | |||
| TtMaSubscribeMessage subscribeMessage; | |||
| String[] split = smartAppMsg.getTo().split(","); | |||
| for (String to:split) { | |||
| try { | |||
| subscribeMessage = TtMaSubscribeMessage.builder() | |||
| .appId(appInfo.getAppId()) | |||
| .tplId(msg.getTemplateId()) | |||
| .openId(to) | |||
| .page(smartAppMsg.getGotopage()) | |||
| .data(new JsonParser().parse(smartAppMsg.getDataJson()).getAsJsonObject()) | |||
| .build(); | |||
| WxMaService wxMaService = null; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(smartAppMsg.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appInfo); | |||
| } | |||
| //发微信 | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| List<String> dataList = smartAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| ttappService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||
| // wxCUserMapper.updateMsgCountDown(tenantEntity.getTenantId(),to); | |||
| } catch (Exception e) { | |||
| logger.error("openId:"+to+"-----发送订阅消息失败"); | |||
| } | |||
| } | |||
| }else | |||
| // if(EnumTemplateType.ACTIVITY_REMIND.getCode().equals(msg.getType()) | |||
| // || EnumTemplateType.LIVE_REMIND.getCode().equals(msg.getType()) | |||
| // || EnumTemplateType.CREDIT_UPD_REMIND.getCode().equals(msg.getType()) | |||
| // || EnumTemplateType.SEND_COUPON_REMIND.getCode().equals(msg.getType())) | |||
| List<WxMaSubscribeMessage.Data> dataTempList = new ArrayList<>(); | |||
| for(int i=0;i<indexArr.size();i++) { | |||
| String key = indexArr.getString(i); | |||
| String value = dataList.get(i); | |||
| WxMaSubscribeMessage.Data templateData = new WxMaSubscribeMessage.Data(key, value); | |||
| dataTempList.add(templateData); | |||
| } | |||
| { | |||
| WxMaService wxMaService = null; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(smartAppMsg.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appInfo); | |||
| } | |||
| //发微信 | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| List<String> dataList = smartAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| WxMaSubscribeMessage subscribeMessage; | |||
| String[] split = smartAppMsg.getTo().split(","); | |||
| for (String to:split) { | |||
| try { | |||
| subscribeMessage = WxMaSubscribeMessage.builder() | |||
| .templateId(msg.getTemplateId()) | |||
| .toUser(to) | |||
| .page(smartAppMsg.getGotopage()) | |||
| .lang(WxMaConstants.MiniprogramLang.ZH_CN) | |||
| .miniprogramState(WxMaConstants.MiniprogramState.FORMAL) | |||
| .data(dataTempList) | |||
| .build(); | |||
| List<WxMaSubscribeMessage.Data> dataTempList = new ArrayList<>(); | |||
| for(int i=0;i<indexArr.size();i++) { | |||
| String key = indexArr.getString(i); | |||
| String value = dataList.get(i); | |||
| WxMaSubscribeMessage.Data templateData = new WxMaSubscribeMessage.Data(key, value); | |||
| dataTempList.add(templateData); | |||
| wxMaService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||
| // wxCUserMapper.updateMsgCountDown(tenantEntity.getTenantId(),to); | |||
| } catch (Exception e) { | |||
| logger.error("openId:"+to+"-----发送订阅消息失败"); | |||
| } | |||
| } | |||
| }else if(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode().equals(msg.getType())){ | |||
| WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(smartAppMsg.getAppId()); | |||
| TtMaService ttappService = maUtil.getTtMaService(appInfo); | |||
| TtMaSubscribeMessage subscribeMessage; | |||
| String[] split = smartAppMsg.getTo().split(","); | |||
| for (String to:split) { | |||
| try { | |||
| subscribeMessage = TtMaSubscribeMessage.builder() | |||
| .appId(appInfo.getAppId()) | |||
| .tplId(msg.getTemplateId()) | |||
| .openId(to) | |||
| .page(smartAppMsg.getGotopage()) | |||
| .data(new JsonParser().parse(smartAppMsg.getDataJson()).getAsJsonObject()) | |||
| .build(); | |||
| WxMaSubscribeMessage subscribeMessage; | |||
| String[] split = smartAppMsg.getTo().split(","); | |||
| for (String to:split) { | |||
| try { | |||
| subscribeMessage = WxMaSubscribeMessage.builder() | |||
| .templateId(msg.getTemplateId()) | |||
| .toUser(to) | |||
| .page(smartAppMsg.getGotopage()) | |||
| .lang(WxMaConstants.MiniprogramLang.ZH_CN) | |||
| .miniprogramState(WxMaConstants.MiniprogramState.FORMAL) | |||
| .data(dataTempList) | |||
| .build(); | |||
| wxMaService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||
| ttappService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||
| // wxCUserMapper.updateMsgCountDown(tenantEntity.getTenantId(),to); | |||
| } catch (Exception e) { | |||
| logger.error("openId:"+to+"-----发送订阅消息失败"); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("openId:"+to+"-----发送订阅消息失败"); | |||
| } | |||
| } | |||
| }else{ | |||
| logger.error("-----模板类型错误"); | |||
| } | |||
| } | |||
| @@ -236,10 +236,7 @@ | |||
| <select id="listOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultType="String"> | |||
| select open_id | |||
| from tt_c_user | |||
| where msg_count >= 10 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| @@ -251,33 +248,6 @@ | |||
| </if> | |||
| </select> | |||
| <update id="updateMsgCount" parameterType="com.iformall.domain.po.tt.TtCUser"> | |||
| update tt_c_user | |||
| set msg_count = msg_count+2 | |||
| where msg_count < 10 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != openId "> | |||
| and `open_id` = #{openId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| <!-- <update id="updateMsgCountDown">--> | |||
| <!-- update tt_c_user set msg_count = msg_count-1--> | |||
| <!-- where msg_count > 0--> | |||
| <!-- <if test=" null != tenantId and '' != tenantId">--> | |||
| <!-- and `tenant_id` = #{tenantId}--> | |||
| <!-- </if>--> | |||
| <!-- and `open_id` = #{openId}--> | |||
| <!-- </update>--> | |||
| <select id="findByOpenId" parameterType="com.iformall.domain.po.tt.TtCUser" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> | |||
| from tt_c_user | |||
| @@ -244,10 +244,7 @@ | |||
| <select id="listOpenId" parameterType="com.iformall.domain.po.WxCUser" resultType="String"> | |||
| select open_id | |||
| from wx_c_user | |||
| where msg_count >= 10 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| @@ -259,33 +256,6 @@ | |||
| </if> | |||
| </select> | |||
| <update id="updateMsgCount" parameterType="com.iformall.domain.po.WxCUser"> | |||
| update wx_c_user | |||
| set msg_count = msg_count+2 | |||
| where msg_count < 10 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != openId "> | |||
| and `open_id` = #{openId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| <!-- <update id="updateMsgCountDown">--> | |||
| <!-- update wx_c_user set msg_count = msg_count-1--> | |||
| <!-- where msg_count > 0--> | |||
| <!-- <if test=" null != tenantId and '' != tenantId">--> | |||
| <!-- and `tenant_id` = #{tenantId}--> | |||
| <!-- </if>--> | |||
| <!-- and `open_id` = #{openId}--> | |||
| <!-- </update>--> | |||
| <select id="findByOpenId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> | |||
| from wx_c_user | |||
| @@ -12,10 +12,11 @@ | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="on_off" jdbcType="INTEGER" property="onOff"/> | |||
| <result column="sync_status" jdbcType="INTEGER" property="syncStatus"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`template_id`,`type`,`custom_param`,`create_date`,`update_date`,`on_off` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`template_id`,`type`,`custom_param`,`create_date`,`update_date`,`on_off`,`sync_status` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -50,10 +51,10 @@ | |||
| <if test=" null != onOff "> | |||
| and `on_off` = #{onOff} | |||
| </if> | |||
| <if test=" isc "> | |||
| and `template_id` is not null and `template_id` <> '' | |||
| <if test=" null != syncStatus "> | |||
| and `sync_status` = #{syncStatus} | |||
| </if> | |||
| <if test=" null != types "> | |||
| and `type` in | |||
| <foreach collection="types" index="index" item="item" open="(" separator="," close=")"> | |||
| @@ -76,12 +77,5 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findListForMiniApp" parameterType="com.iformall.domain.po.WxTemplateMsg" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_template_msg | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||
| @@ -76,7 +76,7 @@ public class WxMsgController extends BaseController { | |||
| types.add(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||
| types.add(EnumTemplateType.LIVE_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPage(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -96,7 +96,7 @@ public class WxMsgController extends BaseController { | |||
| types.add(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||
| types.add(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||
| wxTemplateMsg.setTypes(types); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | |||
| final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPage(wxTemplateMsg, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||