parent
9ee95b7ddf
commit
1c6d1f3cc6
@ -0,0 +1,100 @@ |
|||||||
|
package com.order.controller.notify; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.utils.AESTool; |
||||||
|
import com.hfkj.common.utils.DateUtil; |
||||||
|
import com.hfkj.common.utils.MD5Util; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.hfkj.entity.BsOrderCoupon; |
||||||
|
import com.hfkj.entity.BsOrderCouponNo; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponNoService; |
||||||
|
import com.hfkj.service.coupon.channel.ChongQingCNPCCouponService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/cqNotify") |
||||||
|
@Api(value = "重庆业务通知") |
||||||
|
public class CqNotifyController { |
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CqNotifyController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsOrderCouponNoService orderCouponNoService; |
||||||
|
|
||||||
|
@RequestMapping(value = "/cqCnpcNotify", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "重庆中石油通知") |
||||||
|
public Object cqCnpcNotify(@RequestBody String paramsStr) { |
||||||
|
System.out.println(paramsStr); |
||||||
|
log.info("重庆中石油核销通知"); |
||||||
|
log.info("通知参数:" + paramsStr); |
||||||
|
try { |
||||||
|
if (StringUtils.isNotBlank(paramsStr)) { |
||||||
|
|
||||||
|
JSONObject sendMessage = JSONObject.parseObject(paramsStr).getJSONObject("sendMessage"); |
||||||
|
JSONObject body = ChongQingCNPCCouponService.decryptBody(sendMessage.getString("body")); |
||||||
|
|
||||||
|
// 查询卡密
|
||||||
|
BsOrderCouponNo coupon = orderCouponNoService.getDetailByCouNo(body.getString("couponNo")); |
||||||
|
if (coupon != null) { |
||||||
|
coupon.setFinishTime(DateUtil.format(body.getString("useTime"), "yyyyMMddHHmmss")); |
||||||
|
coupon.setStatus(40); |
||||||
|
orderCouponNoService.editData(coupon); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String, Object> param = new HashMap<>(); |
||||||
|
param.put("status", 1); |
||||||
|
param.put("msg", "成功"); |
||||||
|
String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); |
||||||
|
|
||||||
|
Map<String, Object> returnContent = new HashMap<>(); |
||||||
|
Map<String, Object> returnPostMessage = new HashMap<>(); |
||||||
|
|
||||||
|
Map<String, Object> returnHead = new HashMap<>(); |
||||||
|
returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); |
||||||
|
returnHead.put("requestType", "couponNotice"); |
||||||
|
returnPostMessage.put("head", returnHead); |
||||||
|
|
||||||
|
returnPostMessage.put("body", verifyCode); |
||||||
|
returnContent.put("postMessage", returnPostMessage); |
||||||
|
return returnContent; |
||||||
|
} else { |
||||||
|
Map<String, Object> param = new HashMap<>(); |
||||||
|
param.put("status", 0); |
||||||
|
param.put("msg", "解析参数错误"); |
||||||
|
String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); |
||||||
|
|
||||||
|
Map<String, Object> returnContent = new HashMap<>(); |
||||||
|
Map<String, Object> returnPostMessage = new HashMap<>(); |
||||||
|
|
||||||
|
Map<String, Object> returnHead = new HashMap<>(); |
||||||
|
returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); |
||||||
|
returnHead.put("requestType", "couponNotice"); |
||||||
|
returnPostMessage.put("head", returnHead); |
||||||
|
|
||||||
|
returnPostMessage.put("body", verifyCode); |
||||||
|
returnContent.put("postMessage", returnPostMessage); |
||||||
|
return returnContent; |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
log.info("重庆中石油核销通知业务出现异常", e); |
||||||
|
return null; |
||||||
|
// return ResponseMsgUtil.exception(e);
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,97 @@ |
|||||||
|
package com.hfkj.schedule; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.entity.BsOrderCoupon; |
||||||
|
import com.hfkj.entity.BsOrderCouponNo; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponNoService; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponService; |
||||||
|
import com.hfkj.service.coupon.channel.HuiLianTongCouponService; |
||||||
|
import com.hfkj.service.coupon.channel.PetroConfig; |
||||||
|
import com.hfkj.service.hlt.HuiLianTongUnionCardService; |
||||||
|
import com.hfkj.service.order.BsOrderChildService; |
||||||
|
import com.hfkj.service.order.BsOrderService; |
||||||
|
import com.hfkj.sysenum.GoodsVpdSourceEnum; |
||||||
|
import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: 卡卷定时任务 |
||||||
|
* @Date: 2021/3/27 15:39 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
public class CouponSchedule { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CouponSchedule.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsOrderChildService orderChildService; |
||||||
|
@Resource |
||||||
|
private BsOrderService orderService; |
||||||
|
@Resource |
||||||
|
BsOrderCouponService orderCouponService; |
||||||
|
@Resource |
||||||
|
private BsOrderCouponNoService orderCouponNoService; |
||||||
|
|
||||||
|
//每日凌晨12点5秒执行一次
|
||||||
|
@Scheduled(cron = "5 0 0 * * ?") |
||||||
|
public void expiredCoupon() { |
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
param.put("status", OrderCouponNoStatusEnum.status2.getCode()); |
||||||
|
param.put("expireStatus", false); |
||||||
|
param.put("exceptionStatus", false); |
||||||
|
// 查询卡密
|
||||||
|
List<BsOrderCouponNo> list = orderCouponNoService.getList(param); |
||||||
|
for (BsOrderCouponNo coupon : list) { |
||||||
|
try { |
||||||
|
if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type4.getCode())) { |
||||||
|
// 渠道查询
|
||||||
|
JSONObject jsonObject = HuiLianTongCouponService.getPayOrderByCouNo(coupon.getGoodsVpdSourceCouNo()); |
||||||
|
if (jsonObject.getString("respCode").equals("0000")) { |
||||||
|
// 解析数据
|
||||||
|
JSONObject data = HuiLianTongUnionCardService.resolveResponse(jsonObject.getString("data")); |
||||||
|
if (data.getString("respCode").equals("0000")) { |
||||||
|
JSONObject responseObject = JSONObject.parseObject(data.getString("data")); |
||||||
|
if (responseObject.getInteger("state") == 40) { |
||||||
|
coupon.setStatus(OrderCouponNoStatusEnum.status3.getCode()); |
||||||
|
coupon.setFinishTime(new Date()); |
||||||
|
orderCouponNoService.editData(coupon); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type5.getCode())) { |
||||||
|
|
||||||
|
} else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type7.getCode())) { |
||||||
|
|
||||||
|
} else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type10.getCode())) { |
||||||
|
// 查询卡券订单
|
||||||
|
BsOrderCoupon orderCoupon = orderCouponService.getDetail(coupon.getCouponOrderId()); |
||||||
|
if (orderCoupon != null) { |
||||||
|
JSONObject jsonObject = PetroConfig.couponDetail(coupon.getGoodsVpdSourceCouNo(), orderCoupon.getUserPhone()); |
||||||
|
if (jsonObject.getString("resultCode").equals("0000")) { |
||||||
|
String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); |
||||||
|
JSONObject jsonData = JSONObject.parseObject(data); |
||||||
|
if (jsonData.getInteger("state") == 40) { |
||||||
|
coupon.setStatus(OrderCouponNoStatusEnum.status3.getCode()); |
||||||
|
coupon.setFinishTime(jsonData.getDate("usedTime")); |
||||||
|
orderCouponNoService.editData(coupon); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue