|
@@ -998,19 +998,156 @@ public class PayController {
|
|
@RequestMapping(value = "/getYunPayCallback", consumes = "text/xml", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/getYunPayCallback", consumes = "text/xml", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@Transactional
|
|
@Transactional
|
|
- public net.sf.json.JSONObject getYunPayCallback(@RequestBody String params){
|
|
|
|
- logger.info(" =======================================云闪付(扫呗)** 开始 ** 调用回调接口===============================================");
|
|
|
|
|
|
+ public net.sf.json.JSONObject getYunPayCallback(@RequestBody String params) throws ParseException {
|
|
|
|
+ logger.info("=============================云闪付(扫呗)** 开始 ** 调用回调接口===============================================");
|
|
net.sf.json.JSONObject result = new net.sf.json.JSONObject(); //返回
|
|
net.sf.json.JSONObject result = new net.sf.json.JSONObject(); //返回
|
|
YunPayCallBack yunPayCallBack = JSON.parseObject(params, YunPayCallBack.class);
|
|
YunPayCallBack yunPayCallBack = JSON.parseObject(params, YunPayCallBack.class);
|
|
logger.info("云闪付扫呗调用回调接口返回参数:" + params);
|
|
logger.info("云闪付扫呗调用回调接口返回参数:" + params);
|
|
//logger.info("云闪付扫呗调用回调接口状态码:" + yunPayCallBack.getResult_code());
|
|
//logger.info("云闪付扫呗调用回调接口状态码:" + yunPayCallBack.getResult_code());
|
|
if(yunPayCallBack.getResult_code() !=null && yunPayCallBack.getResult_code().equals("01")){
|
|
if(yunPayCallBack.getResult_code() !=null && yunPayCallBack.getResult_code().equals("01")){
|
|
- logger.info(" -------------------------云闪付回调成功-------------------------- ");
|
|
|
|
- //业务逻辑
|
|
|
|
-
|
|
|
|
|
|
+ logger.info("-------------------------云闪付回调成功-------------------------- ");
|
|
//返给云闪付状态码
|
|
//返给云闪付状态码
|
|
result.put("return_code", "01");
|
|
result.put("return_code", "01");
|
|
result.put("return_msg", "success");
|
|
result.put("return_msg", "success");
|
|
|
|
+ //业务逻辑
|
|
|
|
+ String ordNo = yunPayCallBack.getTerminal_trace();
|
|
|
|
+ List<PayOrder> list = payOrderService.getPayOrderList(ordNo);
|
|
|
|
+ //logger.info("根据订单号,查询订单"+gson.toJson(list));
|
|
|
|
+ if (list != null && list.size() == 1) {
|
|
|
|
+ String status = list.get(0).getStatus();
|
|
|
|
+ if(status !=null && status.equals("0")){
|
|
|
|
+ PayOrder payOrder = new PayOrder();
|
|
|
|
+ payOrder.setOrderNo(ordNo);
|
|
|
|
+ payOrder.setStatus("1");
|
|
|
|
+ if(yunPayCallBack.getPay_type().equals("010")){ //WECHAT:微信,ALIPAY:支付宝,UNIONPAY:
|
|
|
|
+ payOrder.setPayType("wx");
|
|
|
|
+ }else if(yunPayCallBack.getPay_type().equals("020")){
|
|
|
|
+ payOrder.setPayType("zfb");
|
|
|
|
+ }
|
|
|
|
+ payOrder.setWxAmt(Double.valueOf(yunPayCallBack.getReceipt_fee()));
|
|
|
|
+ payOrder.setDzkAmt(Double.valueOf("0"));
|
|
|
|
+ payOrder.setPayDate(new Timestamp(new Date().getTime())); //支付时间
|
|
|
|
+ payOrder.setReceivedAmt(Double.valueOf(yunPayCallBack.getReceipt_fee())); //settleAmt商家入账金额
|
|
|
|
+ //修改订单状态
|
|
|
|
+ int count = payOrderService.getUpdatePayOrder(payOrder);
|
|
|
|
+ if(count == 1){
|
|
|
|
+ Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder); //获取该订单手机号、加油升数、实收金额、油站名称
|
|
|
|
+ logger.info("根据订单查询用户手机号等订单信息"+ infoMap.toString());
|
|
|
|
+ //手机号必须有
|
|
|
|
+ if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
|
|
|
|
+ int integral =0;
|
|
|
|
+ StationInfo stationInfo = new StationInfo();
|
|
|
|
+ stationInfo.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
|
+ StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
|
+ if(stationInfos.getIsLngFlagGroup() !=null && stationInfos.getIsLngFlagGroup().equals("1")){
|
|
|
|
+ //等于1表示次要业务:LNG集团平台加气(可能会出现); 插入油站余额记录
|
|
|
|
+ StationBalanceChange stationBalanceChange = new StationBalanceChange();
|
|
|
|
+ stationBalanceChange.setStationId(stationInfos.getStationId());
|
|
|
|
+ stationBalanceChange.setAmt(Double.valueOf(infoMap.get("sellAmt").toString()));
|
|
|
|
+ stationBalanceChange.setCreateTime(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(infoMap.get("payDate").toString()));
|
|
|
|
+ stationBalanceChange.setType("-");
|
|
|
|
+ stationBalanceChange.setOrderNo(ordNo);
|
|
|
|
+ //生成记录
|
|
|
|
+ payOrderService.insertStationBalanceExchange(stationBalanceChange);
|
|
|
|
+ StationInfo s = new StationInfo();
|
|
|
|
+ BigDecimal subtract = new BigDecimal(String.valueOf(stationInfos.getBalance())).subtract(new BigDecimal(infoMap.get("sellAmt").toString()));
|
|
|
|
+ s.setBalance(subtract.doubleValue());
|
|
|
|
+ s.setStationId(stationInfos.getStationId());
|
|
|
|
+ //更新油站余额
|
|
|
|
+ stationService.updateStationBalance(s);
|
|
|
|
+ logger.info("LNG加气平台支付更新余额完成!");
|
|
|
|
+ }else {
|
|
|
|
+ //当前系统主要业务逻辑
|
|
|
|
+ CustomerManage customerManage = this.insertCustomerManage(infoMap); //插入客户积分返回要插入客户的信息
|
|
|
|
+ CalculateIntegral calculateIntegral = new CalculateIntegral();
|
|
|
|
+ calculateIntegral.setOrderNo(ordNo);
|
|
|
|
+ if(infoMap.containsKey("consumer") && infoMap.get("consumer") !=null){
|
|
|
|
+ calculateIntegral.setNickName(infoMap.get("consumer").toString());
|
|
|
|
+ }else {
|
|
|
|
+ calculateIntegral.setNickName("");
|
|
|
|
+ }
|
|
|
|
+ calculateIntegral.setGroupId(Integer.valueOf(infoMap.get("groupId").toString())); //集团ID
|
|
|
|
+ calculateIntegral.setCustomerGrade(customerManage.getGrade()); //客户等级
|
|
|
|
+ calculateIntegral.setIntegralRuleFlag(stationInfos.getIntegralRuleFlagGroup()); //是否共享积分规则
|
|
|
|
+ calculateIntegral.setOpenId(infoMap.get("minaOpenid").toString()); //客户小程序ID
|
|
|
|
+ if(infoMap.containsKey("blogOpenid") && StringUtils.isNotBlank(infoMap.get("blogOpenid").toString())){
|
|
|
|
+ calculateIntegral.setBlogOpenid(infoMap.get("blogOpenid").toString());
|
|
|
|
+ }
|
|
|
|
+ calculateIntegral.setStationId(Integer.valueOf(infoMap.get("stationId").toString())); //油站ID
|
|
|
|
+ calculateIntegral.setStationName(infoMap.get("stationName").toString()); //油站名称
|
|
|
|
+ calculateIntegral.setAmt(new BigDecimal(infoMap.get("amt").toString())); //实收金额
|
|
|
|
+ calculateIntegral.setOilType(infoMap.get("oilType").toString()); //订单类型
|
|
|
|
+ calculateIntegral.setOilName(infoMap.get("oilName").toString()); //油品名称
|
|
|
|
+ calculateIntegral.setOilLiters(new BigDecimal(infoMap.get("orderLiters").toString())); //加油升数
|
|
|
|
+ calculateIntegral.setUnionId(infoMap.get("unionId").toString()); //客户unionId
|
|
|
|
+ calculateIntegral.setNickName(infoMap.get("consumer").toString()); //客户昵称
|
|
|
|
+ calculateIntegral.setMobilePhone(infoMap.get("mobilePhone").toString()); //客户手机号
|
|
|
|
+ calculateIntegral.setReceivableAmt(new BigDecimal(infoMap.get("receivableAmt").toString())); //应收金额
|
|
|
|
+
|
|
|
|
+ CustomerPoints customerPoints;
|
|
|
|
+ //计算积分
|
|
|
|
+ CalculateIntegral calculateIntegralInfos;
|
|
|
|
+ if(stationInfos.getIntegralRuleFlagGroup().equals("1")){ //表示积分共享
|
|
|
|
+ if(stationInfos.getIntegralFlagGroup().equals("1")){ //集团开启积分功能
|
|
|
|
+ //calculateIntegral.setGroupId(stationInfos.getGroupId());
|
|
|
|
+ calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
|
|
|
|
+ //插入客户所得积分
|
|
|
|
+ customerPoints = this.insertUserIntegral(calculateIntegralInfos);
|
|
|
|
+ integral =calculateIntegralInfos.getIntegral();
|
|
|
|
+ //推送积分
|
|
|
|
+ this.pushIntegral(customerPoints, calculateIntegral);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if(stationInfos.getIntegralFlag().equals("1")){
|
|
|
|
+ //calculateIntegral.setStationId(stationInfos.getStationId());
|
|
|
|
+ calculateIntegralInfos = this.calculateIntegral(calculateIntegral);
|
|
|
|
+ //插入客户所得积分
|
|
|
|
+ customerPoints = this.insertUserIntegral(calculateIntegralInfos);
|
|
|
|
+ //推送积分
|
|
|
|
+ integral =calculateIntegralInfos.getIntegral();
|
|
|
|
+ this.pushIntegral(customerPoints, calculateIntegral);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取油枪绑定的POS机信息
|
|
|
|
+ StationDeviceManager stationDeviceManager = new StationDeviceManager();
|
|
|
|
+ stationDeviceManager.setGunNo(infoMap.get("oilGun").toString());
|
|
|
|
+ stationDeviceManager.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
|
|
|
|
+ List<StationDeviceManager> stationDeviceManagerList = stationService.getStationDeviceManagerList(stationDeviceManager);
|
|
|
|
+ if(stationDeviceManagerList !=null && stationDeviceManagerList.size() >0){
|
|
|
|
+ if(stationDeviceManagerList.get(0).getDeviceType() !=null && stationDeviceManagerList.get(0).getDeviceType() !=""){
|
|
|
|
+ switch (stationDeviceManagerList.get(0).getDeviceType()){
|
|
|
|
+ case "1":
|
|
|
|
+ logger.info("小票机打印方式");
|
|
|
|
+ infoMap.put("sn", stationDeviceManagerList.get(0).getDeviceNo());
|
|
|
|
+ infoMap.put("printSetting", stationInfos.getPrintSetting());
|
|
|
|
+ infoMap.put("isLngFlagGroup", stationInfos.getIsLngFlagGroup());
|
|
|
|
+ this.printReceipt(infoMap);
|
|
|
|
+ break;
|
|
|
|
+ case "2":
|
|
|
|
+ logger.info("POS机打印方式");
|
|
|
|
+ payOrder.setIntegral(String.valueOf(integral));
|
|
|
|
+ payOrder.setPrintSetting(stationInfos.getPrintSetting());
|
|
|
|
+ payOrder.setIsLngFlagGroup(stationInfos.getIsLngFlagGroup());
|
|
|
|
+ if(stationInfos.getIsLngFlagGroup() !=null && stationInfos.getIsLngFlagGroup().equals("1")){
|
|
|
|
+ payOrder.setSellAmt(Double.valueOf(infoMap.get("sellAmt").toString()));
|
|
|
|
+ }
|
|
|
|
+ if(stationDeviceManagerList.get(0).getPosFanoutExchange() !=null && stationDeviceManagerList.get(0).getPosQueue() !=null){
|
|
|
|
+ logger.info("POS设备交换机信息:" + stationDeviceManagerList.get(0).getPosFanoutExchange());
|
|
|
|
+ payOrder.setPosFanoutExchange(stationDeviceManagerList.get(0).getPosFanoutExchange());
|
|
|
|
+ payOrder.setPosQueue(stationDeviceManagerList.get(0).getPosQueue());
|
|
|
|
+ payOrder.setDeviceNo(stationDeviceManagerList.get(0).getDeviceNo());
|
|
|
|
+ this.posPrintReceipt(payOrder);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
result.put("return_code", "02");
|
|
result.put("return_code", "02");
|
|
result.put("return_msg", "fail");
|
|
result.put("return_msg", "fail");
|