| | |
| | | import java.io.BufferedReader;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.security.SignatureException;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.crypto.Mac;
|
| | |
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg;
|
| | | import com.yeshi.fanli.dto.push.PushContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
|
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
|
| | | import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
|
| | | /**
|
| | | * 客服消息回调
|
| | |
| | | out.print("success");
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "banlishop/pay")
|
| | | public void banLiShopPay(HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | Map<String, String> map = WXUtil.parseXML(request);
|
| | | JSONObject json = JSONObject.fromObject(map);
|
| | | LogHelper.test("商城微信支付回调:" + json.toString());
|
| | | String sign = map.get("sign");
|
| | | map.remove("sign");
|
| | | boolean isSuccess = BanLiShopWXPayUtil.signIsRight(map, sign);
|
| | | if (isSuccess)
|
| | | if (map.get("return_code").equalsIgnoreCase("SUCCESS")
|
| | | && map.get("result_code").equalsIgnoreCase("SUCCESS")) {
|
| | | // 商户订单号
|
| | | String wxPayOrderNo = map.get("out_trade_no");
|
| | | // 订单号
|
| | | String orderNo = BanLiShopOrderUtil.getOrderNoFromWXPayOrderNo(wxPayOrderNo);
|
| | | if (!StringUtil.isNullOrEmpty(orderNo)) {
|
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo);
|
| | | if (order != null) {// 支付成功消息推送
|
| | | BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid(),
|
| | | new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
|
| | | Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
|
| | | OrderTopicTagEnum.banLiShopOrderPaid, msg);
|
| | | producer.send(message);
|
| | | Map<String, String> returnMap = new HashMap<>();
|
| | | returnMap.put("return_code", "SUCCESS");
|
| | | returnMap.put("return_msg", "OK");
|
| | | out.print(WXUtil.loadWXMessage(returnMap));
|
| | | out.close();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|