| | |
| | | package cc.mrbird.febs.pay.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.properties.XcxProperties; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextHolder; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.WechatConfigure; |
| | | import cc.mrbird.febs.pay.util.WeixinServiceUtil; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; |
| | | import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import cn.hutool.log.Log; |
| | | import com.alibaba.fastjson.JSON; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | MallMemberMapper mallMemberMapper; |
| | | @Autowired |
| | | WeixinServiceUtil weixinServiceUtil; |
| | | @Autowired |
| | | DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | @Autowired |
| | |
| | | OrderStateMsgVo orderStateMsgVo = new OrderStateMsgVo(); |
| | | orderStateMsgVo.setToUser(info.getOpenId());//用户的openId |
| | | orderStateMsgVo.setTemplateId(info.getTemplateId());//订阅消息模板id |
| | | // wxMssVo.setPage("pages/appointment/line_up?"+"shopId="+info.getShopId()); |
| | | |
| | | Map<String, WxTemplateData> m = new HashMap<>(5); |
| | | m.put("character_string1", new WxTemplateData(info.getOrderNo())); |
| | | m.put("thing9", new WxTemplateData(info.getGoodsName())); |
| | |
| | | m.put("thing13", new WxTemplateData(info.getAddressArea())); |
| | | m.put("thing16", new WxTemplateData(info.getTakeCode())); |
| | | orderStateMsgVo.setData(m); |
| | | String s = JSONUtil.toJsonStr(orderStateMsgVo); |
| | | log.info(s); |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, orderStateMsgVo, String.class); |
| | | log.info(responseEntity.getBody()); |
| | | } |
| | | |
| | | private static final String WXAPPLETURl="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="; |
| | | |
| | | @Override |
| | | public void uniformMessageSend(OrderStateDto info) { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String url = WXAPPLETURl + redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY); |
| | | //拼接推送的模版 |
| | | OrderStateMsgVo orderStateMsgVo = new OrderStateMsgVo(); |
| | | orderStateMsgVo.setToUser(info.getOpenId());//用户的openId |
| | | orderStateMsgVo.setTemplateId(info.getTemplateId());//订阅消息模板id |
| | | Map<String, WxTemplateData> m = new HashMap<>(5); |
| | | m.put("character_string1", new WxTemplateData(info.getOrderNo())); |
| | | m.put("thing9", new WxTemplateData(info.getGoodsName())); |
| | | m.put("phrase2", new WxTemplateData(info.getOrderState())); |
| | | m.put("thing13", new WxTemplateData(info.getAddressArea())); |
| | | m.put("thing16", new WxTemplateData(info.getTakeCode())); |
| | | orderStateMsgVo.setData(m); |
| | | String s = JSONUtil.toJsonStr(orderStateMsgVo); |
| | | log.info(s); |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, orderStateMsgVo, String.class); |
| | | log.info(responseEntity.getBody()); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getTemplateId() { |
| | | List<String> wxTemplates = new ArrayList<>(); |
| | | List<DataDictionaryCustom> wxTemplateList = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.WX_TEMPLATE_ID_ONE.getType()); |
| | | if(CollUtil.isNotEmpty(wxTemplateList)){ |
| | | for(DataDictionaryCustom dic : wxTemplateList){ |
| | | wxTemplates.add(dic.getValue()); |
| | | } |
| | | } |
| | | return wxTemplates; |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和订单ID获取所购买商品名称 |
| | | * @return 所含商品名称(多个以","隔开) |