dev-discount
袁野 3 years ago
parent 9a4128c17f
commit ec305bc568
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighGoldRecController.java
  2. 13
      hai-bweb/src/main/java/com/bweb/controller/TelApiController.java
  3. 37
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  4. 33
      hai-service/src/main/java/com/hai/config/WxMaConfiguration.java
  5. 90
      hai-service/src/main/java/com/hai/config/WxMsgConfig.java
  6. 10
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  7. 4
      hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java
  8. 8
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  9. 6
      hai-service/src/main/resources/dev/commonConfig.properties

@ -46,11 +46,13 @@ public class HighGoldRecController {
@ResponseBody @ResponseBody
@ApiOperation(value = "获取金币情况") @ApiOperation(value = "获取金币情况")
public ResponseData getGoldRecList(@RequestParam(name = "goldType", required = false) Integer goldType, 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 = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) { @RequestParam(name = "pageSize", required = true) Integer pageSize) {
try { try {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("goldType", goldType); map.put("goldType", goldType);
map.put("resType", resType);
PageHelper.startPage(pageNum,pageSize); PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highGoldRecService.getGoldRec(map))); return ResponseMsgUtil.success(new PageInfo<>(highGoldRecService.getGoldRec(map)));

@ -11,6 +11,7 @@ import com.hai.common.utils.*;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.QianZhuConfig; import com.hai.config.QianZhuConfig;
import com.hai.config.TelConfig; import com.hai.config.TelConfig;
import com.hai.config.WxMsgConfig;
import com.hai.entity.HighDiscount; import com.hai.entity.HighDiscount;
import com.hai.entity.HighTelOrder; import com.hai.entity.HighTelOrder;
import com.hai.entity.HighUser; 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);
}
}
} }

@ -39,6 +39,11 @@ public class CommonSysConfig {
private String telUrl; private String telUrl;
private String czOrderNotify; private String czOrderNotify;
private String apiKey;
private String apiSecret;
private String MpApiSecret;
private String tokenUrl;
public String getHuiLianTongUnionCardUrl() { public String getHuiLianTongUnionCardUrl() {
return HuiLianTongUnionCardUrl; return HuiLianTongUnionCardUrl;
} }
@ -230,4 +235,36 @@ public class CommonSysConfig {
public void setTelUrl(String telUrl) { public void setTelUrl(String telUrl) {
this.telUrl = 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;
}
} }

@ -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);
}
}

@ -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<WxMaSubscribeMessage.Data> list = new ArrayList<>();
HighChildOrder highChildOrder = highOrderService.getChildOrderByPresentation(orderId);
HighOrder highOrder = highOrderService.getOrderById(orderId);
Map<String, String> 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<String, Object> 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);
}
}

@ -84,6 +84,16 @@ public interface HighOrderService {
*/ */
List<HighChildOrder> getChildOrderByOrder(Long orderId); List<HighChildOrder> 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 胡锐 * @Author 胡锐
* @Description 查询子商品列表 * @Description 查询子商品列表

@ -44,6 +44,10 @@ public class HighGoldRecServiceImpl implements HighGoldRecService {
criteria.andGoldTypeEqualTo(MapUtils.getLong(map, "goldType")); criteria.andGoldTypeEqualTo(MapUtils.getLong(map, "goldType"));
} }
if (MapUtils.getLong(map, "resType") != null) {
criteria.andResTypeEqualTo(MapUtils.getInteger(map, "resType"));
}
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
List<HighGoldRec> list = highGoldRecMapper.selectByExample(example); List<HighGoldRec> list = highGoldRecMapper.selectByExample(example);
for (HighGoldRec highGoldRec : list) { for (HighGoldRec highGoldRec : list) {

@ -872,4 +872,12 @@ public class HighOrderServiceImpl implements HighOrderService {
public List<Map<String, Object>> getFinishGasOrder() { public List<Map<String, Object>> getFinishGasOrder() {
return highOrderMapper.selectFinishGasOrder(); 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);
}
} }

@ -23,4 +23,8 @@ wx_cert=/home/project/wx_cert/
TelApiKey=2d01f6b520254b1a80f6b167832cea18 TelApiKey=2d01f6b520254b1a80f6b167832cea18
TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7 TelMemberId=d13091df65d64aafbf0f35d2093157b7
apiKey=wx8d49e2f83025229d
apiSecret=d8d6dcaef77d3b659258a01b5ddba5df
tokenUrl=https://api.weixin.qq.com

Loading…
Cancel
Save