| @@ -72,10 +72,6 @@ public class WxMsgController extends BaseController { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | ||||
| if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | ||||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | wxTemplateMsg.updateTenantInfo(getTenantInfo()); | ||||
| List<Integer> types = new ArrayList<>(); | |||||
| 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.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -90,12 +86,6 @@ public class WxMsgController extends BaseController { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | logger.debug("[" + getIpAddr() + "] WxMsgController::list"); | ||||
| if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | if (null == wxTemplateMsg) wxTemplateMsg = new WxTemplateMsg(); | ||||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | 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); | final PageInfo<WxTemplateMsg> page = wxTemplateMsgService.listAsPageForMiniApp(wxTemplateMsg, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -116,21 +106,6 @@ public class WxMsgController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("推送模板") | |||||
| @PostMapping("pushTemp") | |||||
| @SystemControllerLog(description = "moban tuisong") | |||||
| public ResultData pushTemp(@RequestBody WxTemplateMsg wxTemplateMsg) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgController::tuisong"); | |||||
| if(wxTemplateMsg.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | |||||
| // if(null == wxTemplateMsg.getOnOff()){ | |||||
| // wxTemplateMsg.setOnOff(1); | |||||
| // } | |||||
| return wxTemplateMsgService.pushTemp(wxTemplateMsg); | |||||
| } | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| @SystemControllerLog(description = "标签短信-新增") | @SystemControllerLog(description = "标签短信-新增") | ||||
| @@ -189,6 +189,8 @@ public class CallbackSmController extends BaseController { | |||||
| imgList.add(data.get("img_2")); | imgList.add(data.get("img_2")); | ||||
| imgList.add(data.get("img_3")); | imgList.add(data.get("img_3")); | ||||
| userDigitalAvatarPhotoService.handlePhoto(userDigitalAvatarOrder,imgList); | userDigitalAvatarPhotoService.handlePhoto(userDigitalAvatarOrder,imgList); | ||||
| userDigitalAvatarOrderService.sendPhotoSuccess(userDigitalAvatarOrder); | |||||
| }else{ | }else{ | ||||
| UserDigitalAvatarOrder updOrder = new UserDigitalAvatarOrder(); | UserDigitalAvatarOrder updOrder = new UserDigitalAvatarOrder(); | ||||
| updOrder.setId(userDigitalAvatarOrder.getId()); | updOrder.setId(userDigitalAvatarOrder.getId()); | ||||
| @@ -1,27 +1,17 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.Product; | |||||
| import com.iformall.domain.po.ProductOrder; | |||||
| import com.iformall.domain.po.UserBasicImage; | import com.iformall.domain.po.UserBasicImage; | ||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import com.iformall.enums.EnumVideoStatus; | |||||
| import com.iformall.service.ProductService; | |||||
| import com.iformall.service.UserBasicImageService; | import com.iformall.service.UserBasicImageService; | ||||
| import com.iformall.sm.AiCheckPhotoParam; | import com.iformall.sm.AiCheckPhotoParam; | ||||
| import com.iformall.sm.AiCheckPhotoResult; | import com.iformall.sm.AiCheckPhotoResult; | ||||
| import com.iformall.sm.AiDigitalAvatarHelper; | import com.iformall.sm.AiDigitalAvatarHelper; | ||||
| import com.iformall.sm.AiVideoHelper; | |||||
| import com.iformall.utils.Base64Util; | import com.iformall.utils.Base64Util; | ||||
| 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.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -47,7 +37,6 @@ public class UserBasicImageController extends BaseController { | |||||
| logger.debug("[" + getIpAddr() + "] UserBasicImageController::findImage"); | logger.debug("[" + getIpAddr() + "] UserBasicImageController::findImage"); | ||||
| UserBasicImage userBasicImage = userBasicImageService.findById(getMemberId()); | UserBasicImage userBasicImage = userBasicImageService.findById(getMemberId()); | ||||
| return new ResultData(userBasicImage); | return new ResultData(userBasicImage); | ||||
| } | } | ||||
| @@ -0,0 +1,45 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxTemplateMsg; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.service.WxTemplateMsgService; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/api/templateMsg") | |||||
| public class WxTemplateMsgController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxTemplateMsgService wxTemplateMsgService; | |||||
| @ApiOperation("模板列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({}) | |||||
| public ResultData templateList(@ModelAttribute WxTemplateMsg wxTemplateMsg) { | |||||
| logger.debug("[" + getIpAddr() + "] WxTemplateMsgController::list"); | |||||
| if(wxTemplateMsg.getProjectType() == null || wxTemplateMsg.getPlat() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| wxTemplateMsg.updateTenantInfo(getTenantInfo()); | |||||
| wxTemplateMsg.setOnOff(EnumYesOrNo.YES.getCode()); | |||||
| List<WxTemplateMsg> list = wxTemplateMsgService.findList(wxTemplateMsg); | |||||
| //todo 微信订阅消息一次只支持3个 | |||||
| return new ResultData(list); | |||||
| } | |||||
| } | |||||
| @@ -18,7 +18,7 @@ public class WxTemplateMsg extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | ||||
| private String templateId; | private String templateId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息, 101:公众号审核结果消息, 102:公众号卡券核销消息",name="type") | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumTemplateType",name="type") | |||||
| private Integer type; | private Integer type; | ||||
| @io.swagger.annotations.ApiModelProperty(value="自定义参数",name="customParam") | @io.swagger.annotations.ApiModelProperty(value="自定义参数",name="customParam") | ||||
| private String customParam; | private String customParam; | ||||
| @@ -29,14 +29,15 @@ public class WxTemplateMsg extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="消息开关(0/1)",name="onOff") | @io.swagger.annotations.ApiModelProperty(value="消息开关(0/1)",name="onOff") | ||||
| private Integer onOff; | private Integer onOff; | ||||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息, 101:公众号审核结果消息, 102:公众号卡券核销消息",name="type") | |||||
| private Integer projectType; | |||||
| private Integer plat; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String typeName; | private String typeName; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Integer> types; | private List<Integer> types; | ||||
| public String getTypeName(){ | public String getTypeName(){ | ||||
| if(this.getType() != null) { | if(this.getType() != null) { | ||||
| this.typeName = EnumTemplateType.getEnum(this.getType()).getMessage(); | this.typeName = EnumTemplateType.getEnum(this.getType()).getMessage(); | ||||
| @@ -5,25 +5,9 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumTemplateType { | 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"), // 小程序 | |||||
| TT_SEND_COUPON_REMIND(60, "优惠券到账提醒",""), // 抖音小程序 | |||||
| AUDIT_MESSAGE(101, "公众号审核结果通知",""), // 公众号 | |||||
| VERIFY_RESULT(102, "公众号卡券核销通知",""), // 公众号 | |||||
| GIFT_MESSAGE(103, "公众号购票成功通知",""), // 公众号 | |||||
| PHOTO_SUCCESS(1, "AI写真完成通知",""), | |||||
| ; | ; | ||||
| public static EnumTemplateType getEnum(Integer code) { | public static EnumTemplateType getEnum(Integer code) { | ||||
| @@ -40,7 +40,7 @@ public interface TtCUserMapper extends CommonMapper<TtCUser, Long> { | |||||
| // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | ||||
| List<String> findOpenIdList(@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||||
| String findOpenId(@Param("userId")Long userId); | |||||
| List<String> findTokenList(@Param("id")Long id,@Param("userId")Long userId, @Param("tenantId")String tenantId); | List<String> findTokenList(@Param("id")Long id,@Param("userId")Long userId, @Param("tenantId")String tenantId); | ||||
| @@ -40,7 +40,7 @@ public interface WxCUserMapper extends CommonMapper<WxCUser, Long> { | |||||
| // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | // void updateMsgCountDown(@Param("tenantId")String tenantId, @Param("openId")String openId); | ||||
| String findOpenId(@Param("userId")Long userId, @Param("tenantId")String tenantId); | |||||
| String findOpenId(@Param("userId")Long userId); | |||||
| Long findCuserId(@Param("userId")Long userId, @Param("tenantId")String tenantId); | Long findCuserId(@Param("userId")Long userId, @Param("tenantId")String tenantId); | ||||
| @@ -3,6 +3,7 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxTemplateMsg; | import com.iformall.domain.po.WxTemplateMsg; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxTemplateMsgMapper extends CommonMapper<WxTemplateMsg, Long> { | public interface WxTemplateMsgMapper extends CommonMapper<WxTemplateMsg, Long> { | ||||
| @@ -29,4 +29,5 @@ public interface UserBasicPropertyService { | |||||
| void updUserGlod(Long userId, Integer projectType,Integer propertyLogType, Long extraId, Integer glod, Date now); | void updUserGlod(Long userId, Integer projectType,Integer propertyLogType, Long extraId, Integer glod, Date now); | ||||
| UserBasicProperty findById(Long id); | UserBasicProperty findById(Long id); | ||||
| } | } | ||||
| @@ -41,7 +41,7 @@ public interface WxMsgService { | |||||
| void addMsgCallback(WxMsg wxmsg, String batchNo); | void addMsgCallback(WxMsg wxmsg, String batchNo); | ||||
| void batchSendAppinfo(WxMsg wxMsg); | void batchSendAppinfo(WxMsg wxMsg); | ||||
| void batchSendTtAppinfo(WxMsg msg); | |||||
| // void batchSendTtAppinfo(WxMsg msg); | |||||
| void batchSendMsg(WxMsg wxMsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject); | void batchSendMsg(WxMsg wxMsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject); | ||||
| @@ -2,9 +2,11 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxTemplateMsg; | import com.iformall.domain.po.WxTemplateMsg; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface WxTemplateMsgService { | public interface WxTemplateMsgService { | ||||
| @@ -59,7 +61,7 @@ public interface WxTemplateMsgService { | |||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| ResultData pushTemp(WxTemplateMsg wxTemplateMsg); | |||||
| PageInfo<WxTemplateMsg> listAsPageForMiniApp(WxTemplateMsg wxTemplateMsg, Integer pageNum, Integer pageSize); | PageInfo<WxTemplateMsg> listAsPageForMiniApp(WxTemplateMsg wxTemplateMsg, Integer pageNum, Integer pageSize); | ||||
| void sendTemplateMsg(WxAppinfo appinfo, Long userId, String toPage, Map<String, String> param); | |||||
| } | } | ||||
| @@ -50,4 +50,6 @@ public interface CUserServiceApapter { | |||||
| String updateQrCode(CUser user); | String updateQrCode(CUser user); | ||||
| List<UserStructureVo> findCountData(WxCUserBasicInfoDto dto); | List<UserStructureVo> findCountData(WxCUserBasicInfoDto dto); | ||||
| String getOpenId(Long userId); | |||||
| } | } | ||||
| @@ -350,6 +350,11 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| return ttCUserMapper.findCountData(dto); | return ttCUserMapper.findCountData(dto); | ||||
| } | } | ||||
| @Override | |||||
| public String getOpenId(Long userId) { | |||||
| return ttCUserMapper.findOpenId(userId); | |||||
| } | |||||
| private void delForUserIdOnly(Long id, Long userId, String tenantId) { | private void delForUserIdOnly(Long id, Long userId, String tenantId) { | ||||
| List<String> tokenList = ttCUserMapper.findTokenList(id,userId, tenantId); | List<String> tokenList = ttCUserMapper.findTokenList(id,userId, tenantId); | ||||
| @@ -361,6 +361,11 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| return wxCUserMapper.findCountData(dto); | return wxCUserMapper.findCountData(dto); | ||||
| } | } | ||||
| @Override | |||||
| public String getOpenId(Long userId) { | |||||
| return wxCUserMapper.findOpenId(userId); | |||||
| } | |||||
| private WxMaService getWxMaService(WxAppinfo wxAppinfo, Boolean isFmOpen) { | private WxMaService getWxMaService(WxAppinfo wxAppinfo, Boolean isFmOpen) { | ||||
| WxMaService wxMaService = null; | WxMaService wxMaService = null; | ||||
| if (isFmOpen) { | if (isFmOpen) { | ||||
| @@ -56,7 +56,12 @@ public class UserBasicImageServiceImpl implements UserBasicImageService { | |||||
| @Override | @Override | ||||
| public UserBasicImage findById(Long userId) { | public UserBasicImage findById(Long userId) { | ||||
| return userBasicImageMapper.selectById(userId); | |||||
| UserBasicImage userBasicImage = userBasicImageMapper.selectById(userId); | |||||
| if(userBasicImage == null){ | |||||
| userBasicImage = new UserBasicImage(); | |||||
| userBasicImage.setId(userId); | |||||
| } | |||||
| return userBasicImage; | |||||
| } | } | ||||
| @@ -103,7 +103,12 @@ public class UserBasicPropertyServiceImpl implements UserBasicPropertyService { | |||||
| @Override | @Override | ||||
| public UserBasicProperty findById(Long id) { | public UserBasicProperty findById(Long id) { | ||||
| return userBasicPropertyMapper.selectById(id); | |||||
| UserBasicProperty userBasicProperty = userBasicPropertyMapper.selectById(id); | |||||
| if(userBasicProperty == null){ | |||||
| userBasicProperty = new UserBasicProperty(); | |||||
| userBasicProperty.setId(id); | |||||
| } | |||||
| return userBasicProperty; | |||||
| } | } | ||||
| private Integer handGlodNum(Integer projectType, Integer propertyLogType, Integer glod){ | private Integer handGlodNum(Integer projectType, Integer propertyLogType, Integer glod){ | ||||
| @@ -2122,131 +2122,58 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| * 核销时间:{{keyword3.DATA}} | * 核销时间:{{keyword3.DATA}} | ||||
| * {{remark.DATA}} | * {{remark.DATA}} | ||||
| */ | */ | ||||
| MpAppMsg mpAppMsg = new MpAppMsg(); | |||||
| mpAppMsg.setMsgType(EnumMsgRecordType.PUBLIC.getCode()); | |||||
| mpAppMsg.setAppId(user.getMpAppId()); | |||||
| mpAppMsg.setTo(user.getMpOpenId()); | |||||
| mpAppMsg.setMiniAppId(user.getAppId()); | |||||
| mpAppMsg.setMiniPagePath(gotopage); | |||||
| mpAppMsg.updateTenantInfo(couponOrder); | |||||
| mpAppMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||||
| mpAppMsg.setDataList(Lists.newArrayList( | |||||
| merchant.getName(), | |||||
| EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||||
| couponOrder.getId().toString(), | |||||
| dateFormat.format(new Date()), | |||||
| user.getNickName() | |||||
| )); | |||||
| try { | |||||
| mqBaseProducer.sendMessage(mpAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } catch (Exception e) { | |||||
| logger.error("核销-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.MP_TEMPLATE_SEND_FAILED); | |||||
| } | |||||
| // MpAppMsg mpAppMsg = new MpAppMsg(); | |||||
| // mpAppMsg.setMsgType(EnumMsgRecordType.PUBLIC.getCode()); | |||||
| // mpAppMsg.setAppId(user.getMpAppId()); | |||||
| // mpAppMsg.setTo(user.getMpOpenId()); | |||||
| // mpAppMsg.setMiniAppId(user.getAppId()); | |||||
| // mpAppMsg.setMiniPagePath(gotopage); | |||||
| // mpAppMsg.updateTenantInfo(couponOrder); | |||||
| // mpAppMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||||
| // mpAppMsg.setDataList(Lists.newArrayList( | |||||
| // merchant.getName(), | |||||
| // EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||||
| // couponOrder.getId().toString(), | |||||
| // dateFormat.format(new Date()), | |||||
| // user.getNickName() | |||||
| // )); | |||||
| // | |||||
| // try { | |||||
| // mqBaseProducer.sendMessage(mpAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("核销-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| // throw new MallinkException(ErrorCode.MP_TEMPLATE_SEND_FAILED); | |||||
| // } | |||||
| } | } | ||||
| private void doVerifyAppUniformMsg(WxCouponOrder couponOrder, WxCoupon coupon, WxMerchant merchant, WxCUser user, SimpleDateFormat dateFormat, String gotopage) { | private void doVerifyAppUniformMsg(WxCouponOrder couponOrder, WxCoupon coupon, WxMerchant merchant, WxCUser user, SimpleDateFormat dateFormat, String gotopage) { | ||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| authQ.setAuthorizerAppid(user.getAppId()); | |||||
| authQ.updateTenantInfo(couponOrder); | |||||
| WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | |||||
| if (weappInfo != null) { | |||||
| AppUniformMsg appUniformMsg = new AppUniformMsg(); | |||||
| appUniformMsg.setTenantId(coupon.getTenantId()); | |||||
| appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | |||||
| appUniformMsg.setAppId(user.getAppId()); | |||||
| appUniformMsg.setTo(user.getOpenId()); | |||||
| appUniformMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||||
| appUniformMsg.setPagePath(gotopage); | |||||
| appUniformMsg.setMpAppId(weappInfo.getAuthorizerAppid()); | |||||
| appUniformMsg.setDataList(Lists.newArrayList( | |||||
| merchant.getName(), | |||||
| EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||||
| couponOrder.getId().toString(), | |||||
| dateFormat.format(new Date()), | |||||
| user.getNickName() | |||||
| )); | |||||
| try { | |||||
| mqBaseProducer.sendMessage(appUniformMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } catch (Exception e) { | |||||
| logger.error("核销-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.UNIFORM_SEND_FAILED); | |||||
| } | |||||
| } | |||||
| } | |||||
| 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); | |||||
| } | |||||
| // WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| // authQ.setAuthorizerAppid(user.getAppId()); | |||||
| // authQ.updateTenantInfo(couponOrder); | |||||
| // WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | |||||
| // if (weappInfo != null) { | |||||
| // AppUniformMsg appUniformMsg = new AppUniformMsg(); | |||||
| // appUniformMsg.setTenantId(coupon.getTenantId()); | |||||
| // appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | |||||
| // appUniformMsg.setAppId(user.getAppId()); | |||||
| // appUniformMsg.setTo(user.getOpenId()); | |||||
| // appUniformMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||||
| // appUniformMsg.setPagePath(gotopage); | |||||
| // appUniformMsg.setMpAppId(weappInfo.getAuthorizerAppid()); | |||||
| // appUniformMsg.setDataList(Lists.newArrayList( | |||||
| // merchant.getName(), | |||||
| // EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||||
| // couponOrder.getId().toString(), | |||||
| // dateFormat.format(new Date()), | |||||
| // user.getNickName() | |||||
| // )); | |||||
| // try { | |||||
| // mqBaseProducer.sendMessage(appUniformMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("核销-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| // throw new MallinkException(ErrorCode.UNIFORM_SEND_FAILED); | |||||
| // } | |||||
| // } | |||||
| } | } | ||||
| @@ -657,42 +657,42 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| } | } | ||||
| private void sendCreditUpdRemind(WxCUserBasicInfo wxCUserBasicInfo,WxCreditHistory record,String tenantId){ | private void sendCreditUpdRemind(WxCUserBasicInfo wxCUserBasicInfo,WxCreditHistory record,String tenantId){ | ||||
| try { | |||||
| WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| // temp.updateTenantInfo(record); | |||||
| temp.setTenantId(tenantId); | |||||
| temp.setType(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||||
| temp = wxTemplateMsgService.getByObj(temp); | |||||
| if(temp.getId() != null){ | |||||
| String openId = wxCUserMapper.findOpenId(wxCUserBasicInfo.getId(),tenantId); | |||||
| if(StringUtils.isNotBlank(openId)){ | |||||
| WxMsg msg = new WxMsg(); | |||||
| // msg.updateTenantInfo(record); | |||||
| msg.setTenantId(tenantId); | |||||
| // msg.setWay(EnumSendWay.APPINFOR.getCode()); | |||||
| // msg.setIsright(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode()); | |||||
| // msg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); | |||||
| msg.setPhones(openId); | |||||
| msg.setModelId(temp.getId()); | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("character_string1",record.getCreditNum().toString()); | |||||
| map.put("character_string2",record.getCreditAmount().toString()); | |||||
| map.put("time4",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(record.getCreateDate())); | |||||
| map.put("thing3",EnumScoreType.getEnum(record.getCreditType()).getMessage()); | |||||
| map.put("goToPage","pages/index/index?type=jf"); | |||||
| msg.setMsg(JSONObject.toJSONString(map)); | |||||
| // msg.setName(EnumTemplateType.CREDIT_UPD_REMIND.name()); | |||||
| // msg.setSignature(EnumTemplateType.CREDIT_UPD_REMIND.name()); | |||||
| // wxMsgService.add(msg); | |||||
| wxMsgService.batchSendAppinfo(msg); | |||||
| }else{ | |||||
| logger.error("找不到微信用户"); | |||||
| } | |||||
| } | |||||
| } catch (Exception e) { | |||||
| // e.printStackTrace(); | |||||
| logger.error("积分消息发送异常"); | |||||
| } | |||||
| // try { | |||||
| // WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| //// temp.updateTenantInfo(record); | |||||
| // temp.setTenantId(tenantId); | |||||
| // temp.setType(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||||
| // temp = wxTemplateMsgService.getByObj(temp); | |||||
| // if(temp.getId() != null){ | |||||
| // String openId = wxCUserMapper.findOpenId(wxCUserBasicInfo.getId(),tenantId); | |||||
| // if(StringUtils.isNotBlank(openId)){ | |||||
| // WxMsg msg = new WxMsg(); | |||||
| //// msg.updateTenantInfo(record); | |||||
| // msg.setTenantId(tenantId); | |||||
| //// msg.setWay(EnumSendWay.APPINFOR.getCode()); | |||||
| //// msg.setIsright(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode()); | |||||
| //// msg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); | |||||
| // msg.setPhones(openId); | |||||
| // msg.setModelId(temp.getId()); | |||||
| // Map<String,String> map = new HashMap<>(); | |||||
| // map.put("character_string1",record.getCreditNum().toString()); | |||||
| // map.put("character_string2",record.getCreditAmount().toString()); | |||||
| // map.put("time4",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(record.getCreateDate())); | |||||
| // map.put("thing3",EnumScoreType.getEnum(record.getCreditType()).getMessage()); | |||||
| // map.put("goToPage","pages/index/index?type=jf"); | |||||
| // msg.setMsg(JSONObject.toJSONString(map)); | |||||
| //// msg.setName(EnumTemplateType.CREDIT_UPD_REMIND.name()); | |||||
| //// msg.setSignature(EnumTemplateType.CREDIT_UPD_REMIND.name()); | |||||
| //// wxMsgService.add(msg); | |||||
| // wxMsgService.batchSendAppinfo(msg); | |||||
| // }else{ | |||||
| // logger.error("找不到微信用户"); | |||||
| // } | |||||
| // } | |||||
| // } catch (Exception e) { | |||||
| //// e.printStackTrace(); | |||||
| // logger.error("积分消息发送异常"); | |||||
| // } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -404,59 +404,16 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| goToPage = "pages/index/index?type=in";//默认首页 | goToPage = "pages/index/index?type=in";//默认首页 | ||||
| } | } | ||||
| smartAppMsg.setGotopage(goToPage); | smartAppMsg.setGotopage(goToPage); | ||||
| if(wxTemplateMsg.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | |||||
| if(wxTemplateMsg.getType() == EnumTemplateType.PHOTO_SUCCESS.getCode()){ | |||||
| /** | /** | ||||
| * 活动名称:{{thing13.DATA}} | |||||
| * 活动时间:{{date5.DATA}} | |||||
| * 商户名称:{{thing12.DATA}} | |||||
| * 活动内容:{{thing1.DATA}} | |||||
| * 温馨提示:{{thing11.DATA}}" | |||||
| * {{thing1.DATA}} | |||||
| * {{character_string3.DATA}} | |||||
| * {{time4.DATA}} | |||||
| */ | */ | ||||
| smartAppMsg.setDataList(Lists.newArrayList( | smartAppMsg.setDataList(Lists.newArrayList( | ||||
| customParam.getString("thing13"), | |||||
| customParam.getString("date5"), | |||||
| customParam.getString("thing12"), | |||||
| customParam.getString("thing1"), | customParam.getString("thing1"), | ||||
| customParam.getString("thing11") | |||||
| )); | |||||
| }else if(wxTemplateMsg.getType() == EnumTemplateType.LIVE_REMIND.getCode()){ | |||||
| /** | |||||
| * 直播标题:{{thing1.DATA}} | |||||
| * 开播时间:{{date3.DATA}} | |||||
| * 主播昵称:{{thing4.DATA}} | |||||
| * 温馨提示:{{thing5.DATA}} | |||||
| */ | |||||
| smartAppMsg.setDataList(Lists.newArrayList( | |||||
| customParam.getString("thing1"), | |||||
| customParam.getString("date3"), | |||||
| customParam.getString("thing4"), | |||||
| customParam.getString("thing5") | |||||
| )); | |||||
| }else if(wxTemplateMsg.getType() == EnumTemplateType.CREDIT_UPD_REMIND.getCode()){ | |||||
| /** | |||||
| * 变更数量{{character_string1.DATA}} | |||||
| * 积分余额{{character_string2.DATA}} | |||||
| * 变动时间{{time4.DATA}} | |||||
| * 变更原因{{thing3.DATA}} | |||||
| */ | |||||
| smartAppMsg.setDataList(Lists.newArrayList( | |||||
| customParam.getString("character_string1"), | |||||
| customParam.getString("character_string2"), | |||||
| customParam.getString("time4"), | |||||
| customParam.getString("thing3") | |||||
| )); | |||||
| }else if(wxTemplateMsg.getType() == EnumTemplateType.SEND_COUPON_REMIND.getCode()){ | |||||
| /** | |||||
| * 券名称{{thing1.DATA}} | |||||
| * 获取时间{{time3.DATA}} | |||||
| * 过期日期{{time4.DATA}} | |||||
| * 备注{{thing5.DATA}} | |||||
| */ | |||||
| smartAppMsg.setDataList(Lists.newArrayList( | |||||
| customParam.getString("thing1"), | |||||
| customParam.getString("time3"), | |||||
| customParam.getString("time4"), | |||||
| customParam.getString("thing5") | |||||
| customParam.getString("character_string3"), | |||||
| customParam.getString("time4") | |||||
| )); | )); | ||||
| }else{ | }else{ | ||||
| return; | return; | ||||
| @@ -509,81 +466,81 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| } | } | ||||
| @Override | |||||
| public void batchSendTtAppinfo(WxMsg msg) { | |||||
| TenantEntity tenantEntity = new TenantEntity(); | |||||
| tenantEntity.setTenantId(msg.getTenantId()); | |||||
| tenantEntity.setParentTenantId(msg.getParentTenantId()); | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(tenantEntity, EnumAppPlat.TOUTIAO); | |||||
| SmartAppMsg smartAppMsg = new SmartAppMsg(); | |||||
| smartAppMsg.updateTenantInfo(tenantEntity); | |||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||||
| smartAppMsg.setAppId(cAppInfo.getAppId()); | |||||
| WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(msg.getModelId()); | |||||
| // if(1 == wxTemplateMsg.getOnOff().intValue()){ | |||||
| // logger.error("订阅消息模板关闭。"); | |||||
| // @Override | |||||
| // public void batchSendTtAppinfo(WxMsg msg) { | |||||
| // TenantEntity tenantEntity = new TenantEntity(); | |||||
| // tenantEntity.setTenantId(msg.getTenantId()); | |||||
| // tenantEntity.setParentTenantId(msg.getParentTenantId()); | |||||
| // WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(tenantEntity, EnumAppPlat.TOUTIAO); | |||||
| // SmartAppMsg smartAppMsg = new SmartAppMsg(); | |||||
| // smartAppMsg.updateTenantInfo(tenantEntity); | |||||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||||
| // smartAppMsg.setAppId(cAppInfo.getAppId()); | |||||
| // | |||||
| // WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectById(msg.getModelId()); | |||||
| //// if(1 == wxTemplateMsg.getOnOff().intValue()){ | |||||
| //// logger.error("订阅消息模板关闭。"); | |||||
| //// return; | |||||
| //// } | |||||
| // | |||||
| // smartAppMsg.setTemplateType(wxTemplateMsg.getType()); | |||||
| // JSONObject customParam = JSON.parseObject(msg.getMsg()); | |||||
| // String goToPage = customParam.getString("goToPage"); | |||||
| // if(StringUtils.isBlank(goToPage)){ | |||||
| // goToPage = "pages/index/index?type=in";//默认首页 | |||||
| // } | |||||
| // smartAppMsg.setGotopage(goToPage); | |||||
| // if(wxTemplateMsg.getType() == EnumTemplateType.TT_SEND_COUPON_REMIND.getCode()){ | |||||
| // smartAppMsg.setDataJson(msg.getMsg()); | |||||
| // }else{ | |||||
| // return; | // return; | ||||
| // } | // } | ||||
| smartAppMsg.setTemplateType(wxTemplateMsg.getType()); | |||||
| JSONObject customParam = JSON.parseObject(msg.getMsg()); | |||||
| String goToPage = customParam.getString("goToPage"); | |||||
| if(StringUtils.isBlank(goToPage)){ | |||||
| goToPage = "pages/index/index?type=in";//默认首页 | |||||
| } | |||||
| smartAppMsg.setGotopage(goToPage); | |||||
| if(wxTemplateMsg.getType() == EnumTemplateType.TT_SEND_COUPON_REMIND.getCode()){ | |||||
| smartAppMsg.setDataJson(msg.getMsg()); | |||||
| }else{ | |||||
| return; | |||||
| } | |||||
| if(StringUtils.isNotBlank(msg.getPhones())){ | |||||
| smartAppMsg.setTo(msg.getPhones()); | |||||
| mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // String[] split = wxMsg.getPhones().split(","); | |||||
| // int length = split.length; | |||||
| // int extra = length % 1000; | |||||
| // int extracount = extra > 0 ? (length / 1000 + 1) : (length / 1000); | |||||
| // int index = extracount - 1; | |||||
| // for (int i = 0; i < extracount; i++) { | |||||
| // if (extra > 0 && i == index) { | |||||
| // List<String> phoneList = Arrays.asList(split).subList(i * 1000, length); | |||||
| // String phones = StringUtils.join(phoneList, ","); | |||||
| // smartAppMsg.setTo(phones); | |||||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // } else { | |||||
| // List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i + 1) * 1000); | |||||
| // String phones = StringUtils.join(phoneList, ","); | |||||
| // | |||||
| // if(StringUtils.isNotBlank(msg.getPhones())){ | |||||
| // | |||||
| // smartAppMsg.setTo(msg.getPhones()); | |||||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // | |||||
| //// String[] split = wxMsg.getPhones().split(","); | |||||
| //// int length = split.length; | |||||
| //// int extra = length % 1000; | |||||
| //// int extracount = extra > 0 ? (length / 1000 + 1) : (length / 1000); | |||||
| //// int index = extracount - 1; | |||||
| //// for (int i = 0; i < extracount; i++) { | |||||
| //// if (extra > 0 && i == index) { | |||||
| //// List<String> phoneList = Arrays.asList(split).subList(i * 1000, length); | |||||
| //// String phones = StringUtils.join(phoneList, ","); | |||||
| //// smartAppMsg.setTo(phones); | |||||
| //// mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| //// } else { | |||||
| //// List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i + 1) * 1000); | |||||
| //// String phones = StringUtils.join(phoneList, ","); | |||||
| //// smartAppMsg.setTo(phones); | |||||
| //// mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| //// } | |||||
| //// } | |||||
| // }else{ | |||||
| // TtCUser ttCUserQ = new TtCUser(); | |||||
| // ttCUserQ.updateTenantInfo(tenantEntity); | |||||
| // PageInfo<String> openIdPage = ttCUserService.listOpenIdAsPage(ttCUserQ, 1, 1000); | |||||
| // msg.setExpectSendNumber((int) openIdPage.getTotal()); | |||||
| // if(openIdPage.getTotal() == 0){ | |||||
| // return; | |||||
| // } | |||||
| // String phones = StringUtils.join(openIdPage.getList(), ","); | |||||
| // smartAppMsg.setTo(phones); | |||||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // if(openIdPage.getPages() > 1){ | |||||
| // for(int i=2;i<=openIdPage.getPages();i++){ | |||||
| // openIdPage = ttCUserService.listOpenIdAsPage(ttCUserQ, i, 1000); | |||||
| // phones = StringUtils.join(openIdPage.getList(), ","); | |||||
| // smartAppMsg.setTo(phones); | // smartAppMsg.setTo(phones); | ||||
| // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | // mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| // } | // } | ||||
| // } | // } | ||||
| }else{ | |||||
| TtCUser ttCUserQ = new TtCUser(); | |||||
| ttCUserQ.updateTenantInfo(tenantEntity); | |||||
| PageInfo<String> openIdPage = ttCUserService.listOpenIdAsPage(ttCUserQ, 1, 1000); | |||||
| msg.setExpectSendNumber((int) openIdPage.getTotal()); | |||||
| if(openIdPage.getTotal() == 0){ | |||||
| return; | |||||
| } | |||||
| String phones = StringUtils.join(openIdPage.getList(), ","); | |||||
| smartAppMsg.setTo(phones); | |||||
| mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| if(openIdPage.getPages() > 1){ | |||||
| for(int i=2;i<=openIdPage.getPages();i++){ | |||||
| openIdPage = ttCUserService.listOpenIdAsPage(ttCUserQ, i, 1000); | |||||
| phones = StringUtils.join(openIdPage.getList(), ","); | |||||
| smartAppMsg.setTo(phones); | |||||
| mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| // | |||||
| // } | |||||
| // } | |||||
| @Override | @Override | ||||
| @@ -208,48 +208,6 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { | |||||
| // // mq发送小程序消息 - 核销成功消息 | // // mq发送小程序消息 - 核销成功消息 | ||||
| // doPressSuccessMsg(coupon, user, formId, gotopage); | // 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); | |||||
| } | |||||
| } | |||||
| @@ -1665,170 +1665,70 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } | } | ||||
| private void sendCouponRemind(WxCouponOrder couponOrder,WxCoupon coupon,WxCUser cuser){ | private void sendCouponRemind(WxCouponOrder couponOrder,WxCoupon coupon,WxCUser cuser){ | ||||
| try { | |||||
| WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| temp.updateTenantInfo(coupon); | |||||
| temp.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||||
| temp = wxTemplateMsgService.getByObj(temp); | |||||
| if(temp.getId() != null){ | |||||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| WxMsg msg = new WxMsg(); | |||||
| msg.updateTenantInfo(coupon); | |||||
| msg.setPhones(cuser.getOpenId()); | |||||
| msg.setModelId(temp.getId()); | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("thing1",coupon.getTitle()); | |||||
| map.put("time3",dateFormat.format(couponOrder.getCreateDate())); | |||||
| map.put("time4",dateFormat.format(couponOrder.getExpiredTime())); | |||||
| map.put("thing5","你的优惠券已到账!请立即使用"); | |||||
| if(EnumCouponType.COUPON_TINGCHE.getCode().equals(couponOrder.getCouponType()) | |||||
| || EnumCouponType.COUPON_CREDIT_PARK.getCode().equals(couponOrder.getCouponType())){ | |||||
| map.put("goToPage","pages/index/index?type=pc"); | |||||
| }else{ | |||||
| map.put("goToPage","pages/index/index?type=mc"); | |||||
| } | |||||
| msg.setMsg(JSONObject.toJSONString(map)); | |||||
| wxMsgService.batchSendAppinfo(msg); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| // e.printStackTrace(); | |||||
| logger.error("发卷消息发送异常"); | |||||
| } | |||||
| // try { | |||||
| // WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| // temp.updateTenantInfo(coupon); | |||||
| // temp.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||||
| // temp = wxTemplateMsgService.getByObj(temp); | |||||
| // if(temp.getId() != null){ | |||||
| // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| // WxMsg msg = new WxMsg(); | |||||
| // msg.updateTenantInfo(coupon); | |||||
| // msg.setPhones(cuser.getOpenId()); | |||||
| // msg.setModelId(temp.getId()); | |||||
| // Map<String,String> map = new HashMap<>(); | |||||
| // map.put("thing1",coupon.getTitle()); | |||||
| // map.put("time3",dateFormat.format(couponOrder.getCreateDate())); | |||||
| // map.put("time4",dateFormat.format(couponOrder.getExpiredTime())); | |||||
| // map.put("thing5","你的优惠券已到账!请立即使用"); | |||||
| // if(EnumCouponType.COUPON_TINGCHE.getCode().equals(couponOrder.getCouponType()) | |||||
| // || EnumCouponType.COUPON_CREDIT_PARK.getCode().equals(couponOrder.getCouponType())){ | |||||
| // map.put("goToPage","pages/index/index?type=pc"); | |||||
| // }else{ | |||||
| // map.put("goToPage","pages/index/index?type=mc"); | |||||
| // } | |||||
| // | |||||
| // msg.setMsg(JSONObject.toJSONString(map)); | |||||
| // wxMsgService.batchSendAppinfo(msg); | |||||
| // } | |||||
| // } catch (Exception e) { | |||||
| //// e.printStackTrace(); | |||||
| // logger.error("发卷消息发送异常"); | |||||
| // } | |||||
| } | } | ||||
| private void sendCouponRemind(WxCouponOrder couponOrder,WxCoupon coupon,TtCUser cuser){ | private void sendCouponRemind(WxCouponOrder couponOrder,WxCoupon coupon,TtCUser cuser){ | ||||
| try { | |||||
| WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| temp.updateTenantInfo(coupon); | |||||
| temp.setType(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode()); | |||||
| temp = wxTemplateMsgService.getByObj(temp); | |||||
| if(temp.getId() != null){ | |||||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| WxMsg msg = new WxMsg(); | |||||
| msg.updateTenantInfo(coupon); | |||||
| msg.setPhones(cuser.getOpenId()); | |||||
| msg.setModelId(temp.getId()); | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("优惠券名称",coupon.getTitle()); | |||||
| map.put("剩余时间","至"+ dateFormat.format(couponOrder.getExpiredTime())); | |||||
| map.put("备注","你的优惠券已到账!请立即使用"); | |||||
| if(EnumCouponType.COUPON_TINGCHE.getCode().equals(couponOrder.getCouponType()) | |||||
| || EnumCouponType.COUPON_CREDIT_PARK.getCode().equals(couponOrder.getCouponType())){ | |||||
| map.put("goToPage","pages/index/index?type=in"); | |||||
| }else{ | |||||
| map.put("goToPage","pages/index/index?type=mc"); | |||||
| } | |||||
| msg.setMsg(JSONObject.toJSONString(map)); | |||||
| wxMsgService.batchSendTtAppinfo(msg); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| // e.printStackTrace(); | |||||
| logger.error("发卷消息发送异常"); | |||||
| } | |||||
| } | |||||
| private boolean sendMpMsgForSendCoupon(WxCouponOrder couponOrder,WxCoupon coupon, WxCUser user) { | |||||
| // 发送 公众号 模板消息 | |||||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| String gotopage = Constant.mainPageUrl + "?type=mc"; | |||||
| // 7. 公众号消息 | |||||
| if (StringUtils.isNotBlank(user.getMpAppId()) && | |||||
| StringUtils.isNotBlank(user.getMpOpenId()) && | |||||
| user.getMpSubscribe().equals(EnumUserIsSubscribe.YES.getCode())) { | |||||
| // 检查是否超限 | |||||
| WxMsgLimit msgLimit = new WxMsgLimit(); | |||||
| msgLimit.updateTenantInfo(couponOrder); | |||||
| msgLimit.setType(EnumMsgLimitType.WXCHAT_OPENID_SEND.getCode()); | |||||
| msgLimit.setLimitId(user.getMpOpenId()); | |||||
| if (wxMsgLimitService.checkIsLimit(msgLimit)) { | |||||
| logger.error("用户公众号模板消息超限" + user.getId()); | |||||
| return true; | |||||
| } | |||||
| // 已关注公众号 | |||||
| /** | |||||
| * 购票成功通知 | |||||
| * {first.DATA}} | |||||
| * 订单号:{{keyword1.DATA}} | |||||
| * 兑换券:{{keyword2.DATA}} | |||||
| * 订单详情:{{keyword3.DATA}} | |||||
| * 有效期至:{{keyword4.DATA}} | |||||
| * 购买数量:{{keyword5.DATA}} | |||||
| * {{remark.DATA}} | |||||
| */ | |||||
| MpAppMsg mpAppMsg = new MpAppMsg(); | |||||
| mpAppMsg.setMsgType(EnumMsgRecordType.PUBLIC.getCode()); | |||||
| mpAppMsg.setAppId(user.getMpAppId()); | |||||
| mpAppMsg.setTo(user.getMpOpenId()); | |||||
| mpAppMsg.setMiniAppId(user.getAppId()); | |||||
| mpAppMsg.setMiniPagePath(gotopage); | |||||
| mpAppMsg.updateTenantInfo(couponOrder); | |||||
| mpAppMsg.setTemplateType(EnumTemplateType.GIFT_MESSAGE.getCode()); | |||||
| mpAppMsg.setDataList(Lists.newArrayList( | |||||
| user.getNickName(), | |||||
| String.valueOf(couponOrder.getOrderId()), | |||||
| couponOrder.getId().toString(), | |||||
| coupon.getTitle(), | |||||
| dateFormat.format(couponOrder.getExpiredTime()), | |||||
| "1", | |||||
| user.getNickName() | |||||
| )); | |||||
| try { | |||||
| mqBaseProducer.sendMessage(mpAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } catch (Exception e) { | |||||
| logger.error("购票成功-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| //throw new MallinkException(ErrorCode.MP_TEMPLATE_SEND_FAILED); | |||||
| } | |||||
| } else { | |||||
| // 可能未关注公众号, 用户可能收不到 | |||||
| // 8. 微信小程序-统一消息 | |||||
| // 检查是否超限 | |||||
| WxMsgLimit msgLimit = new WxMsgLimit(); | |||||
| msgLimit.updateTenantInfo(couponOrder); | |||||
| msgLimit.setType(EnumMsgLimitType.WEAPP_OPENID_SEND.getCode()); | |||||
| msgLimit.setLimitId(user.getOpenId()); | |||||
| if (wxMsgLimitService.checkIsLimit(msgLimit)) { | |||||
| logger.error("用户小程序统一模板消息超限:" + user.getId()); | |||||
| return true; | |||||
| } | |||||
| // 获取小程序关联的服务号 | |||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| authQ.setAuthorizerAppid(user.getAppId()); | |||||
| authQ.updateTenantInfo(couponOrder); | |||||
| WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | |||||
| if (weappInfo != null) { | |||||
| AppUniformMsg appUniformMsg = new AppUniformMsg(); | |||||
| appUniformMsg.setTenantId(coupon.getTenantId()); | |||||
| appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | |||||
| appUniformMsg.setAppId(user.getAppId()); | |||||
| appUniformMsg.setTo(user.getOpenId()); | |||||
| appUniformMsg.setTemplateType(EnumTemplateType.GIFT_MESSAGE.getCode()); | |||||
| appUniformMsg.setPagePath(gotopage); | |||||
| appUniformMsg.setMpAppId(weappInfo.getAuthorizerAppid()); | |||||
| appUniformMsg.setDataList(Lists.newArrayList( | |||||
| user.getNickName(), | |||||
| String.valueOf(couponOrder.getOrderId()), | |||||
| couponOrder.getId().toString(), | |||||
| coupon.getTitle(), | |||||
| dateFormat.format(couponOrder.getExpiredTime()), | |||||
| "1", | |||||
| user.getNickName() | |||||
| )); | |||||
| try { | |||||
| mqBaseProducer.sendMessage(appUniformMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } catch (Exception e) { | |||||
| logger.error("核销-公众号-模板消息发送失败: " + e.getMessage()); | |||||
| //throw new MallinkException(ErrorCode.UNIFORM_SEND_FAILED); | |||||
| } | |||||
| } | |||||
| } | |||||
| return false; | |||||
| // try { | |||||
| // WxTemplateMsg temp = new WxTemplateMsg(); | |||||
| // temp.updateTenantInfo(coupon); | |||||
| // temp.setType(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode()); | |||||
| // temp = wxTemplateMsgService.getByObj(temp); | |||||
| // if(temp.getId() != null){ | |||||
| // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| // WxMsg msg = new WxMsg(); | |||||
| // msg.updateTenantInfo(coupon); | |||||
| // msg.setPhones(cuser.getOpenId()); | |||||
| // msg.setModelId(temp.getId()); | |||||
| // Map<String,String> map = new HashMap<>(); | |||||
| // map.put("优惠券名称",coupon.getTitle()); | |||||
| // map.put("剩余时间","至"+ dateFormat.format(couponOrder.getExpiredTime())); | |||||
| // map.put("备注","你的优惠券已到账!请立即使用"); | |||||
| // if(EnumCouponType.COUPON_TINGCHE.getCode().equals(couponOrder.getCouponType()) | |||||
| // || EnumCouponType.COUPON_CREDIT_PARK.getCode().equals(couponOrder.getCouponType())){ | |||||
| // map.put("goToPage","pages/index/index?type=in"); | |||||
| // }else{ | |||||
| // map.put("goToPage","pages/index/index?type=mc"); | |||||
| // } | |||||
| // | |||||
| // msg.setMsg(JSONObject.toJSONString(map)); | |||||
| // wxMsgService.batchSendTtAppinfo(msg); | |||||
| // } | |||||
| // } catch (Exception e) { | |||||
| //// e.printStackTrace(); | |||||
| // logger.error("发卷消息发送异常"); | |||||
| // } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxCouponOrder sendFreeCouponToUser(Long userId,TenantEntity tenantinfo, Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay,EnumPayVersion payVersion,Long merchantId,Long bUserId) { | public WxCouponOrder sendFreeCouponToUser(Long userId,TenantEntity tenantinfo, Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay,EnumPayVersion payVersion,Long merchantId,Long bUserId) { | ||||
| @@ -13,9 +13,12 @@ import com.iformall.domain.po.WxTemplateMsg; | |||||
| import com.iformall.enums.EnumAppPlat; | import com.iformall.enums.EnumAppPlat; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.enums.EnumTemplateType; | import com.iformall.enums.EnumTemplateType; | ||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import com.iformall.mapper.WxTemplateMsgMapper; | import com.iformall.mapper.WxTemplateMsgMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxTemplateMsgService; | import com.iformall.service.WxTemplateMsgService; | ||||
| import com.iformall.service.cuser.CUserServiceFactory; | |||||
| import com.iformall.service.pay.PayServiceFactory; | |||||
| import com.iformall.service.wechat.FmOpenService; | import com.iformall.service.wechat.FmOpenService; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -27,6 +30,7 @@ import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @Service | @Service | ||||
| public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | ||||
| @@ -42,6 +46,12 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||||
| @Autowired | @Autowired | ||||
| private FmOpenService openService; | private FmOpenService openService; | ||||
| @Autowired | |||||
| private PayServiceFactory payServiceFactory; | |||||
| @Autowired | |||||
| private CUserServiceFactory cuserFactory; | |||||
| @Autowired | @Autowired | ||||
| MaUtil maUtil; | MaUtil maUtil; | ||||
| @@ -49,26 +59,26 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||||
| @Override | @Override | ||||
| public void wxTemplateMsgInit(String tenantId) { | public void wxTemplateMsgInit(String tenantId) { | ||||
| WxTemplateMsg wxTemplateMsg = new WxTemplateMsg(); | |||||
| wxTemplateMsg.setTenantId(tenantId); | |||||
| wxTemplateMsg.setTemplateId(""); | |||||
| wxTemplateMsg.setType(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||||
| wxTemplateMsg.setCustomParam("{\"index\": [\"thing13\", \"date5\", \"thing12\", \"thing1\", \"thing11\"], \"emphasis\": \"\"}"); | |||||
| wxTemplateMsg.setCreateDate(new Date()); | |||||
| wxTemplateMsg.setUpdateDate(new Date()); | |||||
| wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| // WxTemplateMsg wxTemplateMsg = new WxTemplateMsg(); | |||||
| // wxTemplateMsg.setTenantId(tenantId); | |||||
| // wxTemplateMsg.setTemplateId(""); | |||||
| // wxTemplateMsg.setType(EnumTemplateType.ACTIVITY_REMIND.getCode()); | |||||
| // wxTemplateMsg.setCustomParam("{\"index\": [\"thing13\", \"date5\", \"thing12\", \"thing1\", \"thing11\"], \"emphasis\": \"\"}"); | |||||
| // wxTemplateMsg.setCreateDate(new Date()); | |||||
| // wxTemplateMsg.setUpdateDate(new Date()); | |||||
| // wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| //// wxTemplateMsg.setId(null); | |||||
| //// wxTemplateMsg.setType(EnumTemplateType.LIVE_REMIND.getCode()); | |||||
| //// wxTemplateMsg.setCustomParam("{\"index\": [\"thing1\", \"date3\", \"thing4\", \"thing5\"], \"emphasis\": \"\"}"); | |||||
| //// wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| // wxTemplateMsg.setId(null); | // wxTemplateMsg.setId(null); | ||||
| // wxTemplateMsg.setType(EnumTemplateType.LIVE_REMIND.getCode()); | |||||
| // wxTemplateMsg.setCustomParam("{\"index\": [\"thing1\", \"date3\", \"thing4\", \"thing5\"], \"emphasis\": \"\"}"); | |||||
| // wxTemplateMsg.setType(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||||
| // wxTemplateMsg.setCustomParam("{\"index\": [\"character_string1\", \"character_string2\", \"time4\", \"thing3\"], \"emphasis\": \"\"}"); | |||||
| // wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| // wxTemplateMsg.setId(null); | |||||
| // wxTemplateMsg.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||||
| // wxTemplateMsg.setCustomParam("{\"index\": [\"thing1\", \"time3\", \"time4\", \"thing5\"], \"emphasis\": \"\"}"); | |||||
| // wxTemplateMsgMapper.insert(wxTemplateMsg); | // wxTemplateMsgMapper.insert(wxTemplateMsg); | ||||
| wxTemplateMsg.setId(null); | |||||
| wxTemplateMsg.setType(EnumTemplateType.CREDIT_UPD_REMIND.getCode()); | |||||
| wxTemplateMsg.setCustomParam("{\"index\": [\"character_string1\", \"character_string2\", \"time4\", \"thing3\"], \"emphasis\": \"\"}"); | |||||
| wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| wxTemplateMsg.setId(null); | |||||
| wxTemplateMsg.setType(EnumTemplateType.SEND_COUPON_REMIND.getCode()); | |||||
| wxTemplateMsg.setCustomParam("{\"index\": [\"thing1\", \"time3\", \"time4\", \"thing5\"], \"emphasis\": \"\"}"); | |||||
| wxTemplateMsgMapper.insert(wxTemplateMsg); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -114,63 +124,32 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData pushTemp(WxTemplateMsg wxTemplateMsg) { | |||||
| WxTemplateMsg byId = this.getById(wxTemplateMsg.getId()); | |||||
| 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); | |||||
| public PageInfo<WxTemplateMsg> listAsPageForMiniApp(WxTemplateMsg record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxTemplateMsgMapper.findListForMiniApp(record)); | |||||
| } | |||||
| @Override | |||||
| public void sendTemplateMsg(WxAppinfo appinfo, Long userId, String toPage, Map<String, String> param) { | |||||
| WxTemplateMsg templateMsgQ = new WxTemplateMsg(); | |||||
| templateMsgQ.setType(EnumTemplateType.PHOTO_SUCCESS.getCode()); | |||||
| templateMsgQ.setProjectType(appinfo.getProjectType()); | |||||
| templateMsgQ.setPlat(appinfo.getPlat()); | |||||
| templateMsgQ.setOnOff(EnumYesOrNo.YES.getCode()); | |||||
| WxTemplateMsg wxTemplateMsg = wxTemplateMsgMapper.selectOne(new QueryWrapper<>(templateMsgQ)); | |||||
| if(wxTemplateMsg == null){ | |||||
| return; | |||||
| } | } | ||||
| 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); | |||||
| } | |||||
| }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()); | |||||
| } catch (WxErrorException e) { | |||||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||||
| } | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.TEMPLATE_NOT_FOUND); | |||||
| String openId = cuserFactory.getCUserService(EnumAppPlat.getByCode(appinfo.getPlat())).getOpenId(userId); | |||||
| if(StringUtils.isBlank(openId)){ | |||||
| return; | |||||
| } | } | ||||
| if(StringUtils.isBlank(s)){ | |||||
| return new ResultData(ErrorCode.TEMPLATE_ADD_ERROR); | |||||
| try{ | |||||
| payServiceFactory.getMsgService(appinfo.getPlat()).sendSubscribeMsg(appinfo,wxTemplateMsg,openId,toPage,param); | |||||
| }catch(Exception e){ | |||||
| logger.error("发送订阅消息失败"+ e); | |||||
| return; | |||||
| } | } | ||||
| wxTemplateMsg.setTemplateId(s); | |||||
| 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)); | |||||
| } | } | ||||
| @@ -94,7 +94,7 @@ public class AfterCarInOutMsgServiceImpl implements MsgSendService { | |||||
| logger.error("车牌未找到用户{}"+plateNumber); | logger.error("车牌未找到用户{}"+plateNumber); | ||||
| return; | return; | ||||
| } | } | ||||
| String openId = wxCUserMapper.findOpenId(userCar.getCUserId(), tenantEntity.getTenantId()); | |||||
| String openId = wxCUserMapper.findOpenId(userCar.getCUserId()); | |||||
| if(StringUtils.isBlank(openId)){ | if(StringUtils.isBlank(openId)){ | ||||
| logger.error("车牌未找到用户{}"+plateNumber); | logger.error("车牌未找到用户{}"+plateNumber); | ||||
| return; | return; | ||||
| @@ -75,77 +75,77 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||||
| // throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | // throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | ||||
| return; | return; | ||||
| } | } | ||||
| if(0 == msg.getOnOff().intValue()){ | |||||
| 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(); | |||||
| 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())) | |||||
| { | |||||
| 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"); | |||||
| 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); | |||||
| } | |||||
| 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); | |||||
| // wxCUserMapper.updateMsgCountDown(tenantEntity.getTenantId(),to); | |||||
| } catch (Exception e) { | |||||
| logger.error("openId:"+to+"-----发送订阅消息失败"); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| // if(0 == msg.getOnOff().intValue()){ | |||||
| // 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(); | |||||
| // | |||||
| // 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())) | |||||
| // | |||||
| // { | |||||
| // 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"); | |||||
| // | |||||
| // 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); | |||||
| // } | |||||
| // | |||||
| // 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); | |||||
| //// wxCUserMapper.updateMsgCountDown(tenantEntity.getTenantId(),to); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("openId:"+to+"-----发送订阅消息失败"); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // | |||||
| // } | |||||
| } | } | ||||
| } | } | ||||
| @@ -50,6 +50,7 @@ public class PayServiceFactory { | |||||
| private Map<String,PayAdapterService> payVendorServiceMap = null; | private Map<String,PayAdapterService> payVendorServiceMap = null; | ||||
| private Map<String,PayShareAdapterService> payVendorShareMap = null; | private Map<String,PayShareAdapterService> payVendorShareMap = null; | ||||
| private Map<String,PayAdapterService> platQrcodeMap = null; | private Map<String,PayAdapterService> platQrcodeMap = null; | ||||
| private Map<String,PayAdapterService> platMsgMap = null; | |||||
| @Autowired | @Autowired | ||||
| WxMiniAppPayAdapterService wxMiniAppPayService; | WxMiniAppPayAdapterService wxMiniAppPayService; | ||||
| @@ -133,6 +134,15 @@ public class PayServiceFactory { | |||||
| return platQrcodeMap; | return platQrcodeMap; | ||||
| } | } | ||||
| private Map<String,PayAdapterService> getPlatMsgMap() { | |||||
| if (null == platMsgMap) { | |||||
| platMsgMap = new ConcurrentHashMap<String,PayAdapterService>(); | |||||
| platMsgMap.put(EnumAppPlat.WX.getCode()+"_", wxMiniAppPayV3AdapterService); | |||||
| platMsgMap.put(EnumAppPlat.TOUTIAO.getCode()+"_",ttMiniAppPayService); | |||||
| } | |||||
| return platMsgMap; | |||||
| } | |||||
| private Map<String,PayAdapterService> getPayVendorServiceMap() { | private Map<String,PayAdapterService> getPayVendorServiceMap() { | ||||
| if (null == payVendorServiceMap) { | if (null == payVendorServiceMap) { | ||||
| payVendorServiceMap = new ConcurrentHashMap<String,PayAdapterService>(); | payVendorServiceMap = new ConcurrentHashMap<String,PayAdapterService>(); | ||||
| @@ -259,7 +269,15 @@ public class PayServiceFactory { | |||||
| public PayAdapterService getQrcodeService(Integer type) throws MallinkException{ | public PayAdapterService getQrcodeService(Integer type) throws MallinkException{ | ||||
| PayAdapterService service = getPlatQrcodeMap().get(type+"_"); | PayAdapterService service = getPlatQrcodeMap().get(type+"_"); | ||||
| if (null == service) { | if (null == service) { | ||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"payWay["+type+"] 二维码service未找到"); | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"plat["+type+"] 二维码service未找到"); | |||||
| } | |||||
| return service; | |||||
| } | |||||
| public PayAdapterService getMsgService(Integer type) throws MallinkException{ | |||||
| PayAdapterService service = getPlatMsgMap().get(type+"_"); | |||||
| if (null == service) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"plat["+type+"] 消息service未找到"); | |||||
| } | } | ||||
| return service; | return service; | ||||
| } | } | ||||
| @@ -123,4 +123,15 @@ public interface PayAdapterService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders); | PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders); | ||||
| /** | |||||
| * 发小程序订阅消息 | |||||
| * @param appinfo | |||||
| * @param wxTemplateMsg | |||||
| * @param openId | |||||
| * @param toPage | |||||
| * @param param | |||||
| */ | |||||
| void sendSubscribeMsg(WxAppinfo appinfo, WxTemplateMsg wxTemplateMsg, String openId, String toPage, Map<String, String> param)throws Exception; | |||||
| } | } | ||||
| @@ -116,4 +116,5 @@ public class BaseTtPayAdapterService { | |||||
| final File codeFile = ttappService.getQrcodeService().createTtaCode("douyin", pathStr, QRCodeUtils.QR_WIDTH); | final File codeFile = ttappService.getQrcodeService().createTtaCode("douyin", pathStr, QRCodeUtils.QR_WIDTH); | ||||
| return codeFile; | return codeFile; | ||||
| } | } | ||||
| } | } | ||||
| @@ -3,12 +3,15 @@ package com.iformall.service.pay.service.pay.douyin.v1.miniApp; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.google.gson.Gson; | |||||
| import com.google.gson.JsonParser; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.domain.vo.WxOrderCouponVo; | import com.iformall.domain.vo.WxOrderCouponVo; | ||||
| import com.iformall.douyin.miniapp.api.TtMaService; | import com.iformall.douyin.miniapp.api.TtMaService; | ||||
| import com.iformall.douyin.miniapp.api.bean.TtMaSubscribeMessage; | |||||
| import com.iformall.douyin.pay.DouYinPayHelper; | import com.iformall.douyin.pay.DouYinPayHelper; | ||||
| import com.iformall.douyin.pay.TtPayService; | import com.iformall.douyin.pay.TtPayService; | ||||
| import com.iformall.douyin.pay.orderQuery.OrderQueryResult; | import com.iformall.douyin.pay.orderQuery.OrderQueryResult; | ||||
| @@ -526,4 +529,18 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| return par; | return par; | ||||
| } | } | ||||
| @Override | |||||
| public void sendSubscribeMsg(WxAppinfo appinfo, WxTemplateMsg wxTemplateMsg, String openId, String toPage, Map<String, String> param) throws Exception{ | |||||
| TtMaService ttappService = maUtil.getTtMaService(appinfo); | |||||
| TtMaSubscribeMessage subscribeMessage = TtMaSubscribeMessage.builder() | |||||
| .appId(appinfo.getAppId()) | |||||
| .tplId(wxTemplateMsg.getTemplateId()) | |||||
| .openId(openId) | |||||
| .page(toPage) | |||||
| .data(new Gson().toJsonTree(param).getAsJsonObject()) | |||||
| .build(); | |||||
| ttappService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||||
| } | |||||
| } | } | ||||
| @@ -1,11 +1,13 @@ | |||||
| package com.iformall.service.pay.service.pay.wx; | package com.iformall.service.pay.service.pay.wx; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import java.util.*; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; | |||||
| import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest; | import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest; | ||||
| import cn.binarywang.wx.miniapp.constant.WxMaConstants; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.iformall.domain.po.*; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -16,13 +18,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.PosCouponOrderVerify; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxBatchOrder; | |||||
| import com.iformall.domain.po.WxCouponOrder; | |||||
| import com.iformall.domain.po.WxOrder; | |||||
| import com.iformall.domain.po.WxPayAccount; | |||||
| import com.iformall.domain.po.WxPayOrder; | |||||
| import com.iformall.enums.EnumCouponOrderStatus; | import com.iformall.enums.EnumCouponOrderStatus; | ||||
| import com.iformall.enums.EnumOrderFrom; | import com.iformall.enums.EnumOrderFrom; | ||||
| import com.iformall.enums.EnumOrderStatus; | import com.iformall.enums.EnumOrderStatus; | ||||
| @@ -105,6 +100,35 @@ public class BaseWxPayAdapterService { | |||||
| } | } | ||||
| } | } | ||||
| protected void subscribeMsg(WxAppinfo appinfo, WxTemplateMsg wxTemplateMsg, String openId, String toPage, Map<String, String> param) throws WxErrorException { | |||||
| boolean isFmOpen = false; | |||||
| WxMaService wxMaService; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = maUtil.getWeappService(appinfo); | |||||
| } | |||||
| JSONObject customParam = JSON.parseObject(wxTemplateMsg.getCustomParam()); | |||||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||||
| List<WxMaSubscribeMessage.Data> dataTempList = new ArrayList<>(); | |||||
| for(int i=0;i<indexArr.size();i++) { | |||||
| String key = indexArr.getString(i); | |||||
| String value = param.get(key); | |||||
| WxMaSubscribeMessage.Data templateData = new WxMaSubscribeMessage.Data(key, value); | |||||
| dataTempList.add(templateData); | |||||
| } | |||||
| WxMaSubscribeMessage subscribeMessage = WxMaSubscribeMessage.builder() | |||||
| .templateId(wxTemplateMsg.getTemplateId()) | |||||
| .toUser(openId) | |||||
| .page(toPage) | |||||
| .lang(WxMaConstants.MiniprogramLang.ZH_CN) | |||||
| .miniprogramState(WxMaConstants.MiniprogramState.FORMAL) | |||||
| .data(dataTempList) | |||||
| .build(); | |||||
| wxMaService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||||
| } | |||||
| protected String generateScheme(WxAppinfo appinfo,String pageUrl,String sceneParam,Long expireTime) throws WxErrorException { | protected String generateScheme(WxAppinfo appinfo,String pageUrl,String sceneParam,Long expireTime) throws WxErrorException { | ||||
| boolean isFmOpen = false; | boolean isFmOpen = false; | ||||
| WxMaService wxMaService; | WxMaService wxMaService; | ||||
| @@ -460,4 +460,9 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } | } | ||||
| @Override | |||||
| public void sendSubscribeMsg(WxAppinfo appinfo, WxTemplateMsg wxTemplateMsg, String openId, String toPage, Map<String, String> param) throws Exception { | |||||
| super.subscribeMsg(appinfo,wxTemplateMsg,openId,toPage,param); | |||||
| } | |||||
| } | } | ||||
| @@ -60,5 +60,6 @@ public interface UserDigitalAvatarOrderService { | |||||
| void createPhoto(UserDigitalAvatarOrder record); | void createPhoto(UserDigitalAvatarOrder record); | ||||
| void sendPhotoSuccess(UserDigitalAvatarOrder record); | |||||
| } | } | ||||
| @@ -6,6 +6,8 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.UserBasicProperty; | import com.iformall.domain.po.UserBasicProperty; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.msg.WxMsg; | |||||
| import com.iformall.domain.po.sm.DigitalAvatarMould; | import com.iformall.domain.po.sm.DigitalAvatarMould; | ||||
| import com.iformall.domain.po.sm.UserDigitalAvatarOrder; | import com.iformall.domain.po.sm.UserDigitalAvatarOrder; | ||||
| import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | ||||
| @@ -14,11 +16,14 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | import com.iformall.file.aliyun.AliyunOSS; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.UserBasicPropertyService; | import com.iformall.service.UserBasicPropertyService; | ||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxTemplateMsgService; | |||||
| import com.iformall.service.impl.ProductOrderServiceImpl; | import com.iformall.service.impl.ProductOrderServiceImpl; | ||||
| import com.iformall.service.sm.UserDigitalAvatarOrderService; | import com.iformall.service.sm.UserDigitalAvatarOrderService; | ||||
| import com.iformall.service.sm.UserDigitalAvatarPhotoService; | import com.iformall.service.sm.UserDigitalAvatarPhotoService; | ||||
| import com.iformall.sm.*; | import com.iformall.sm.*; | ||||
| import com.iformall.utils.Base64Util; | import com.iformall.utils.Base64Util; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.RedisLock; | import com.iformall.utils.RedisLock; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -34,7 +39,9 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.concurrent.Future; | import java.util.concurrent.Future; | ||||
| @@ -60,6 +67,12 @@ public class UserDigitalAvatarOrderServiceImpl implements UserDigitalAvatarOrder | |||||
| @Autowired | @Autowired | ||||
| UserBasicPropertyService userBasicPropertyService; | UserBasicPropertyService userBasicPropertyService; | ||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @Autowired | |||||
| WxTemplateMsgService wxTemplateMsgService; | |||||
| @Autowired | @Autowired | ||||
| private AliyunOSS aliyunOSS; | private AliyunOSS aliyunOSS; | ||||
| @@ -290,4 +303,22 @@ public class UserDigitalAvatarOrderServiceImpl implements UserDigitalAvatarOrder | |||||
| } | } | ||||
| @Async | |||||
| @Override | |||||
| public void sendPhotoSuccess(UserDigitalAvatarOrder record) { | |||||
| UserDigitalAvatarOrder userDigitalAvatarOrder = userDigitalAvatarOrderMapper.selectById(record.getId()); | |||||
| if(!EnumDigitalAvatarOrderStatus.finish.getCode().equals(userDigitalAvatarOrder.getStatus())){ | |||||
| return; | |||||
| } | |||||
| //默认先发微信订阅消息 | |||||
| WxAppinfo appinfo = wxAppinfoService.getProjectCAppInfoFromRedis(EnumProject.PROJECT_5.getCode(), EnumAppPlat.WX.getCode()); | |||||
| String toPage = "/pages/lookPhoto/index?id="+record.getId(); | |||||
| Map<String,String> param = new HashMap<>(); | |||||
| param.put("thing1",record.getTitle()); | |||||
| param.put("character_string3",record.getId().toString()); | |||||
| param.put("time4", DateUtils.date2String(record.getUpdateDate())); | |||||
| wxTemplateMsgService.sendTemplateMsg(appinfo,record.getUserId(),toPage,param); | |||||
| } | |||||
| } | } | ||||
| @@ -441,7 +441,7 @@ | |||||
| <!-- union_id = IF(union_id is null ,null,CONCAT(union_id,"_del"))--> | <!-- union_id = IF(union_id is null ,null,CONCAT(union_id,"_del"))--> | ||||
| <select id="findOpenIdList" parameterType="hashmap" resultType="String" > | |||||
| select open_id from tt_c_user where user_id=#{userId} and tenant_id = #{tenantId} | |||||
| <select id="findOpenId" parameterType="hashmap" resultType="String" > | |||||
| select open_id from tt_c_user where user_id=#{userId} | |||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||
| @@ -446,7 +446,7 @@ | |||||
| <select id="findOpenId" parameterType="hashmap" resultType="String" > | <select id="findOpenId" parameterType="hashmap" resultType="String" > | ||||
| select open_id from wx_c_user where user_id=#{userId} and tenant_id = #{tenantId} | |||||
| select open_id from wx_c_user where user_id=#{userId} | |||||
| </select> | </select> | ||||
| <select id="findCuserId" parameterType="hashmap" resultType="Long" > | <select id="findCuserId" parameterType="hashmap" resultType="Long" > | ||||
| @@ -12,10 +12,12 @@ | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | ||||
| <result column="on_off" jdbcType="INTEGER" property="onOff"/> | <result column="on_off" jdbcType="INTEGER" property="onOff"/> | ||||
| <result column="project_type" jdbcType="INTEGER" property="projectType"/> | |||||
| <result column="plat" jdbcType="INTEGER" property="plat"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <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`,`project_type`,`plat` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -50,6 +52,12 @@ | |||||
| <if test=" null != onOff "> | <if test=" null != onOff "> | ||||
| and `on_off` = #{onOff} | and `on_off` = #{onOff} | ||||
| </if> | </if> | ||||
| <if test=" null != projectType "> | |||||
| and `project_type` = #{projectType} | |||||
| </if> | |||||
| <if test=" null != plat "> | |||||
| and `plat` = #{plat} | |||||
| </if> | |||||
| <if test=" isc "> | <if test=" isc "> | ||||
| and `template_id` is not null and `template_id` <> '' | and `template_id` is not null and `template_id` <> '' | ||||