diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java index c0ae1f0d..7964a4d3 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java @@ -46,11 +46,13 @@ public class HighGoldRecController { @ResponseBody @ApiOperation(value = "获取金币情况") public ResponseData getGoldRecList(@RequestParam(name = "goldType", required = false) Integer goldType, + @RequestParam(name = "resType", required = false) Integer resType, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { Map map = new HashMap<>(); map.put("goldType", goldType); + map.put("resType", resType); PageHelper.startPage(pageNum,pageSize); return ResponseMsgUtil.success(new PageInfo<>(highGoldRecService.getGoldRec(map))); diff --git a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java index 7172b4c8..1f46bedc 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java @@ -11,6 +11,7 @@ import com.hai.common.utils.*; import com.hai.config.CommonSysConst; import com.hai.config.QianZhuConfig; import com.hai.config.TelConfig; +import com.hai.config.WxMsgConfig; import com.hai.entity.HighDiscount; import com.hai.entity.HighTelOrder; import com.hai.entity.HighUser; @@ -182,4 +183,16 @@ public class TelApiController { } } + @RequestMapping(value = "/getTest", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "测试接口") + public ResponseData getTest() { + try { + + return ResponseMsgUtil.success(WxMsgConfig.pushOneUser(668L)); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 6cd33b97..3e035bea 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -39,6 +39,11 @@ public class CommonSysConfig { private String telUrl; private String czOrderNotify; + private String apiKey; + private String apiSecret; + private String MpApiSecret; + private String tokenUrl; + public String getHuiLianTongUnionCardUrl() { return HuiLianTongUnionCardUrl; } @@ -230,4 +235,36 @@ public class CommonSysConfig { public void setTelUrl(String telUrl) { this.telUrl = telUrl; } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiSecret() { + return apiSecret; + } + + public void setApiSecret(String apiSecret) { + this.apiSecret = apiSecret; + } + + public String getMpApiSecret() { + return MpApiSecret; + } + + public void setMpApiSecret(String mpApiSecret) { + MpApiSecret = mpApiSecret; + } + + public String getTokenUrl() { + return tokenUrl; + } + + public void setTokenUrl(String tokenUrl) { + this.tokenUrl = tokenUrl; + } } diff --git a/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java b/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java new file mode 100644 index 00000000..9c819990 --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java @@ -0,0 +1,33 @@ +package com.hai.config; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; + +@Configuration +public class WxMaConfiguration { + + private static WxMaService maService; + + public static WxMaService getMaService() { + if (maService == null) { + throw new IllegalArgumentException(String.format("未找到对应的配置,请核实!")); + } + + return maService; + } + + @PostConstruct + public void init() { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(CommonSysConst.getSysConfig().getApiKey()); + config.setSecret(CommonSysConst.getSysConfig().getApiSecret()); + + maService = new WxMaServiceImpl(); + maService.setWxMaConfig(config); + } + +} diff --git a/hai-service/src/main/java/com/hai/config/WxMsgConfig.java b/hai-service/src/main/java/com/hai/config/WxMsgConfig.java new file mode 100644 index 00000000..cfd6dec6 --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/WxMsgConfig.java @@ -0,0 +1,90 @@ +package com.hai.config; + +import cn.binarywang.wx.miniapp.api.WxMaMsgService; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; +import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.HttpsUtils; + +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighOrder; +import com.hai.model.ResponseData; +import com.hai.service.HighOrderService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class WxMsgConfig { + + private static Logger log = LoggerFactory.getLogger(WxMsgConfig.class); + + @Resource + private static HighOrderService highOrderService; + + + public static ResponseData pushOneUser(Long orderId) { + + try { + List list = new ArrayList<>(); + + HighChildOrder highChildOrder = highOrderService.getChildOrderByPresentation(orderId); + + HighOrder highOrder = highOrderService.getOrderById(orderId); + + + + Map m = new HashMap<>(); + m.put("thing1", highChildOrder.getGoodsName()); + m.put("amount2", highChildOrder.getGoodsActualPrice() + "元"); + m.put("character_string3", highOrder.getOrderNo()); + m.put("time4", DateUtil.date2String(highOrder.getPayTime() , "yyyy年MM月dd天 HH分mm秒")); + m.put("thing6", "微信支付"); + + for (String key: m.keySet()) { + WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data(); + msgElement.setName(key); + msgElement.setValue(m.get(key)); + list.add(msgElement); + } + + + WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage(); + subscribeMessage.setToUser("oUGn_4lkgegcjTc9oR1qBGjtAm3A"); // 小程序openId + subscribeMessage.setTemplateId("oUvaCPeeOg4wH6HTvCcSabU6FnzXUXOBXsqBYAPOV-U"); + subscribeMessage.setData(list); + subscribeMessage.setPage("pages/user/order_details/order_details?id=666"); + subscribeMessage.setMiniprogramState("developer"); + + final WxMaService wxService = WxMaConfiguration.getMaService(); + WxMaMsgService maMsgService = wxService.getMsgService(); + maMsgService.sendSubscribeMsg(subscribeMessage); + return ResponseMsgUtil.success("发送成功"); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + + } + + public static JSONObject getWxMsgToken() { + + Map map = new HashMap<>(); + + map.put("appid", CommonSysConst.getSysConfig().getApiKey()); + map.put("secret", CommonSysConst.getSysConfig().getApiSecret()); + map.put("grant_type", "client_credential"); + + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTokenUrl() + "/cgi-bin/token", map); + } + + +} diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 4c59b4ba..109e7f6c 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -84,6 +84,16 @@ public interface HighOrderService { */ List getChildOrderByOrder(Long orderId); + /** + * @Author Sum1Dream + * @name getChildOrderByPresentation.java + * @Description // 根据是否赠品查询子订单 + * @Date 16:20 2021/9/7 + * @Param [orderId, isGiveAway] + * @return com.hai.entity.HighChildOrder + **/ + HighChildOrder getChildOrderByPresentation(Long orderId); + /** * @Author 胡锐 * @Description 查询子商品列表 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java index 418c1fcd..bfe843a6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java @@ -44,6 +44,10 @@ public class HighGoldRecServiceImpl implements HighGoldRecService { criteria.andGoldTypeEqualTo(MapUtils.getLong(map, "goldType")); } + if (MapUtils.getLong(map, "resType") != null) { + criteria.andResTypeEqualTo(MapUtils.getInteger(map, "resType")); + } + example.setOrderByClause("create_time desc"); List list = highGoldRecMapper.selectByExample(example); for (HighGoldRec highGoldRec : list) { diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 9108ca36..38e861ec 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -872,4 +872,12 @@ public class HighOrderServiceImpl implements HighOrderService { public List> getFinishGasOrder() { return highOrderMapper.selectFinishGasOrder(); } + + @Override + public HighChildOrder getChildOrderByPresentation(Long orderId) { + HighChildOrderExample example = new HighChildOrderExample(); + HighChildOrderExample.Criteria criteria = example.createCriteria(); + example.createCriteria().andOrderIdEqualTo(orderId).andGiveawayTypeEqualTo(false); + return highChildOrderMapper.selectByExample(example).get(0); + } } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 681a182f..cf850c43 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -23,4 +23,8 @@ wx_cert=/home/project/wx_cert/ TelApiKey=2d01f6b520254b1a80f6b167832cea18 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 -TelMemberId=d13091df65d64aafbf0f35d2093157b7 \ No newline at end of file +TelMemberId=d13091df65d64aafbf0f35d2093157b7 + +apiKey=wx8d49e2f83025229d +apiSecret=d8d6dcaef77d3b659258a01b5ddba5df +tokenUrl=https://api.weixin.qq.com