* master: 修改配置星巴克 肯德基 会员充值 话费 微信商户号 修改配置星巴克 肯德基 会员充值 话费 微信商户号 # Conflicts: # hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java # hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.javadev-discount
parent
20ba3e7a89
commit
3da4b9061e
@ -1,33 +0,0 @@ |
|||||||
package com.cweb.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(SysConst.getSysConfig().getWxAppId()); |
|
||||||
config.setSecret(SysConst.getSysConfig().getWxAppSecret()); |
|
||||||
|
|
||||||
maService = new WxMaServiceImpl(); |
|
||||||
maService.setWxMaConfig(config); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,120 +0,0 @@ |
|||||||
package com.cweb.config; |
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaMsgService; |
|
||||||
import cn.binarywang.wx.miniapp.api.WxMaService; |
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; |
|
||||||
import com.hai.common.utils.DateUtil; |
|
||||||
import org.slf4j.Logger; |
|
||||||
import org.slf4j.LoggerFactory; |
|
||||||
|
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
public class WxMsgConfig { |
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(WxMsgConfig.class); |
|
||||||
|
|
||||||
public static void pushOneUser(String orderName , String price , String orderNo , Date payTime , String remark , Long orderId , String openId) { |
|
||||||
|
|
||||||
try { |
|
||||||
List<WxMaSubscribeMessage.Data> list = new ArrayList<>(); |
|
||||||
|
|
||||||
Map<String, String> m = new HashMap<>(); |
|
||||||
|
|
||||||
m.put("thing1", orderName); |
|
||||||
m.put("amount2", price + "元"); |
|
||||||
m.put("character_string3", orderNo); |
|
||||||
m.put("time4", DateUtil.date2String(payTime , "yyyy年MM月dd日 HH:mm:ss")); |
|
||||||
m.put("thing6", remark); |
|
||||||
|
|
||||||
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(openId); // 小程序openId
|
|
||||||
subscribeMessage.setTemplateId("oUvaCPeeOg4wH6HTvCcSabU6FnzXUXOBXsqBYAPOV-U"); |
|
||||||
subscribeMessage.setData(list); |
|
||||||
subscribeMessage.setPage("pages/user/order_details/order_details?id=" + orderId); |
|
||||||
subscribeMessage.setMiniprogramState("developer"); |
|
||||||
|
|
||||||
final WxMaService wxService = WxMaConfiguration.getMaService(); |
|
||||||
WxMaMsgService maMsgService = wxService.getMsgService(); |
|
||||||
maMsgService.sendSubscribeMsg(subscribeMessage); |
|
||||||
} catch (Exception e) { |
|
||||||
log.error(String.valueOf(e)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public static void rechargedSuccess(String orderName , String price , String orderNo , Date payTime , String payType , String openId) { |
|
||||||
|
|
||||||
try { |
|
||||||
List<WxMaSubscribeMessage.Data> list = new ArrayList<>(); |
|
||||||
|
|
||||||
Map<String, String> m = new HashMap<>(); |
|
||||||
|
|
||||||
m.put("character_string1", orderNo); // 订单号
|
|
||||||
m.put("thing11", orderName); // 充值项目
|
|
||||||
m.put("thing10", payType); // 支付方式
|
|
||||||
m.put("amount8", price); // 支付金额
|
|
||||||
m.put("date5", DateUtil.date2String(payTime , "yyyy年MM月dd日 HH:mm:ss")); |
|
||||||
|
|
||||||
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(openId); // 小程序openId
|
|
||||||
subscribeMessage.setTemplateId("ZO6kC3oJv0zj9QzL0htsF-mM9vAElcgPZEcUGglxsoU"); |
|
||||||
subscribeMessage.setData(list); |
|
||||||
|
|
||||||
final WxMaService wxService = WxMaConfiguration.getMaService(); |
|
||||||
WxMaMsgService maMsgService = wxService.getMsgService(); |
|
||||||
maMsgService.sendSubscribeMsg(subscribeMessage); |
|
||||||
} catch (Exception e) { |
|
||||||
log.error(String.valueOf(e)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public static void rechargedFail(String orderName , String price , String openId) { |
|
||||||
|
|
||||||
try { |
|
||||||
List<WxMaSubscribeMessage.Data> list = new ArrayList<>(); |
|
||||||
|
|
||||||
Map<String, String> m = new HashMap<>(); |
|
||||||
|
|
||||||
m.put("thing1", orderName); // 订单内容
|
|
||||||
m.put("thing2", "充值通道爆满!"); // 失败原因
|
|
||||||
m.put("amount3", price); // 退款金额
|
|
||||||
m.put("thing4", "退款将在1-3日内原路退回"); // 温馨提示
|
|
||||||
|
|
||||||
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(openId); // 小程序openId
|
|
||||||
subscribeMessage.setTemplateId("xjacmzuWSRdiKGz4IJVeuvyGE0vOhoy0JVQPgOr-PuI"); |
|
||||||
subscribeMessage.setData(list); |
|
||||||
|
|
||||||
final WxMaService wxService = WxMaConfiguration.getMaService(); |
|
||||||
WxMaMsgService maMsgService = wxService.getMsgService(); |
|
||||||
maMsgService.sendSubscribeMsg(subscribeMessage); |
|
||||||
} catch (Exception e) { |
|
||||||
log.error(String.valueOf(e)); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,31 +0,0 @@ |
|||||||
package com.web.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(SysConst.getSysConfig().getWxMiniAppId()); |
|
||||||
config.setSecret(SysConst.getSysConfig().getWxMiniAppSecret()); |
|
||||||
maService = new WxMaServiceImpl(); |
|
||||||
maService.setWxMaConfig(config); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue