|
@@ -322,7 +322,7 @@ public class ElectronicMembershipCardController {
|
|
|
@RequestMapping(value = "/dzkPaySet", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@Transactional
|
|
|
- public String dzkPaySet(@RequestParam String ordNo, Integer id) throws ParseException {
|
|
|
+ public String dzkPaySet(@RequestParam String ordNo, String id) throws ParseException {
|
|
|
Gson gson =new Gson();
|
|
|
ResultData resultData =null;
|
|
|
if(ordNo !=null){
|
|
@@ -422,9 +422,9 @@ public class ElectronicMembershipCardController {
|
|
|
BigDecimal amtNew = new BigDecimal(dzkAmt);
|
|
|
BigDecimal discountAmtNew = new BigDecimal(discountAmt);
|
|
|
//获取该优惠券
|
|
|
- if(id !=null){
|
|
|
+ if(StringUtils.isNotBlank(id) && !id.equals("undefined")){
|
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
|
- userCoupon.setId(id);
|
|
|
+ userCoupon.setId(Integer.valueOf(id));
|
|
|
UserCoupon ucResult = couponService.selectUserCouponInfo(userCoupon);
|
|
|
if(ucResult !=null){
|
|
|
payOrder.setDiscountCoupon(ucResult.getId().toString());
|
|
@@ -468,9 +468,19 @@ public class ElectronicMembershipCardController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ UserCoupon userCoupon_p = new UserCoupon();
|
|
|
+ userCoupon_p.setCouponIsUsed("1");
|
|
|
+ //String discountCoupon = infoMap.get("discountCoupon").toString();
|
|
|
+ userCoupon_p.setId(Integer.valueOf(id));
|
|
|
+ userCoupon_p.setCreateTime(new Date());
|
|
|
+ userCoupon_p.setVerificationTime(new Date());
|
|
|
+ userCoupon_p.setMobilePhone(mobilePhone);
|
|
|
+ couponService.updateCouponUserInfo(userCoupon_p);
|
|
|
+
|
|
|
+
|
|
|
//更新该优惠券的使用数量
|
|
|
UserCoupon u = new UserCoupon();
|
|
|
- u.setId(id);
|
|
|
+ u.setId(Integer.valueOf(id));
|
|
|
UserCoupon userCouponInfo = couponService.selectUserCouponInfo(u);
|
|
|
Coupon coupon_up = new Coupon();
|
|
|
coupon_up.setCouponId(userCouponInfo.getCouponId());
|
|
@@ -485,6 +495,11 @@ public class ElectronicMembershipCardController {
|
|
|
//BigDecimal discountAmt = new BigDecimal(receivableAmt).subtract(new BigDecimal(dzkAmt));
|
|
|
//payOrder.setDiscountAmt(Double.valueOf(discountAmt));
|
|
|
payOrderService.getUpdatePayOrder(payOrder);
|
|
|
+
|
|
|
+ if(stationInfos.getCouponEnabledFlag() !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
+ this.drawCoupon(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
//插入集团客户信息
|
|
|
//insertCustomerGroup(resultMap);
|
|
|
//更新客户表
|
|
@@ -689,6 +704,77 @@ public class ElectronicMembershipCardController {
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
+ //主动领取
|
|
|
+ public void drawCoupon(Map infoMap){
|
|
|
+ //按照应付来主动发放
|
|
|
+ //查询该油站是否有主动发放
|
|
|
+ BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());
|
|
|
+ Integer stationId = Integer.valueOf(infoMap.get("stationId").toString());
|
|
|
+ String unionId = infoMap.get("unionId").toString();
|
|
|
+ Coupon coupon = new Coupon();
|
|
|
+ coupon.setStationId(stationId);
|
|
|
+ coupon.setIssueType("1");
|
|
|
+ List<Coupon> couponList = couponService.selectStaGrantCouponList(coupon);;
|
|
|
+ if(couponList !=null && couponList.size()>0){
|
|
|
+ //获取该油站已主动发放的优惠券
|
|
|
+ for(Coupon c: couponList){
|
|
|
+ if(!(receivableAmt.compareTo(c.getDiscountThresholdAmt()) == -1)){
|
|
|
+ Integer couponHoldNum = c.getCouponHoldNum(); //持有张数
|
|
|
+ Integer couponReceiveNum = c.getCouponReceiveNum(); //最多领取张数
|
|
|
+ Integer couponNum = c.getCouponNum(); //改模板最大数量
|
|
|
+ String couponIssueId = c.getCouponIssueId(); //领取方式的ID
|
|
|
+ Integer couponId = c.getCouponId(); //优惠券模板ID
|
|
|
+ Integer couponCumulativeNum = c.getCouponCumulativeNum(); //当前优惠券已领取的数量
|
|
|
+ UserCoupon u = new UserCoupon();
|
|
|
+ u.setUnionId(unionId);
|
|
|
+ u.setStationId(stationId);
|
|
|
+ u.setCouponIsUsed("0");
|
|
|
+ int userCouponCount = couponService.selectUserCouponCount(u);
|
|
|
+ u.setCouponIsUsed("1");
|
|
|
+ int userCouponCountUsed = couponService.selectUserCouponCount(u);
|
|
|
+ if(couponNum >0){
|
|
|
+ if(userCouponCount < couponHoldNum){
|
|
|
+ if(userCouponCountUsed < couponReceiveNum){
|
|
|
+ UserCoupon userCouponParam = new UserCoupon();
|
|
|
+ userCouponParam.setCouponIsUsed("0"); //是否使用:0、未使用;1、已使用;
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
+ String s = stationId + Long.toString(currentTimeMillis) + Math.round((Math.random() + 1) * 1000);
|
|
|
+ String s1 = CryptUtil.useMD5(s);
|
|
|
+ userCouponParam.setCouponNo(s1); //优惠券编码
|
|
|
+ userCouponParam.setUnionId(unionId); //用户unionId
|
|
|
+ userCouponParam.setIssueId(couponIssueId); //领取方式ID
|
|
|
+ userCouponParam.setCouponId(c.getCouponId()); //优惠券模板ID
|
|
|
+ userCouponParam.setStationId(stationId); //油站ID
|
|
|
+ userCouponParam.setCouponIsEffective("1"); //优惠券是否有效
|
|
|
+ userCouponParam.setGetCouponTime(new Date()); //优惠券领取时间
|
|
|
+ String effectiveTimeType = c.getEffectiveTimeType();
|
|
|
+ //'有效时间类型: 1,固定时间;2,领取后x天内有效'
|
|
|
+ switch (effectiveTimeType) {
|
|
|
+ case "1":
|
|
|
+ userCouponParam.setCouponEffectiveTime(c.getEffectiveTimeEnd()); //优惠券有效期截止时间
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(userCouponParam.getGetCouponTime());
|
|
|
+ calendar.add(Calendar.DATE, c.getEffectiveDayNum()); //领取后多少天有效
|
|
|
+ userCouponParam.setCouponEffectiveTime(calendar.getTime()); //优惠券有效期截止时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ couponService.addUserCoupon(userCouponParam);
|
|
|
+ //更新该优惠券的领取数量
|
|
|
+ Coupon coupon_up = new Coupon();
|
|
|
+ coupon_up.setCouponId(couponId);
|
|
|
+ couponCumulativeNum = couponCumulativeNum + 1;
|
|
|
+ coupon_up.setCouponCumulativeNum(couponCumulativeNum);
|
|
|
+ couponService.updateCouponInfo(coupon_up);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//POS机打印小票
|
|
|
public void posPrintReceipt(PayOrder payOrder){
|
|
|
Map<String, Object> infoMap = payOrderService.getOrderInfoAndUserInfoByOrderNo(payOrder);
|