From f923dba16a241a23780c7334e31866dd052dbd89 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Wed, 21 Aug 2019 14:32:45 +0800 Subject: [PATCH 01/19] =?UTF-8?q?[=E7=94=B5=E8=A1=A8=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E6=9F=A5=E8=AF=A2=E5=95=86=E6=88=B7]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/KwMerchantMeterMapper.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml b/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml index 6914819b4..5860f896f 100644 --- a/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml +++ b/mallinkService/src/main/resources/mapper/KwMerchantMeterMapper.xml @@ -277,8 +277,8 @@ From 9259b0ad7bade1b5a6cfc205e220003cd31777a6 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 21 Aug 2019 14:51:48 +0800 Subject: [PATCH 02/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxBillRentServiceImpl.java | 14 +++++++------- .../service/impl/WxRentContractServiceImpl.java | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index 2faf2b87d..c7185de36 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -275,9 +275,10 @@ public class WxBillRentServiceImpl implements WxBillRentService { * @param record */ public Integer getPayRatio(WxBillRent record,WxRentContract wxRentContract,EnumMissTimeType timeType){ - if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() > 0){ - return wxRentContract.getPayRatio(); - } +// if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() > 0){ +// return wxRentContract.getPayRatio(); +// } + wxRentContract.setPayRatio(0); BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(wxRentContract.getBusDiscountRatio(), String.class); long dayCount = DateUtils.startToEnd(record.getStarttime(),record.getEndtime()); @@ -332,10 +333,10 @@ public class WxBillRentServiceImpl implements WxBillRentService { int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))); int months = getMonths(sdM.format(wxBillRent.getStarttime())+"-01",sdM.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))+"-01"); + wxBillRent.setRevenue(record.getRevenue()); + Integer ratio = 0; - if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() >0){ - ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); - }else if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ + if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ if(startInt == endInt && months == 12){ //刚好1年 @@ -364,7 +365,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { Long oldPrice = wxBillRent.getReceivePay(); Long newPrice = newReceivePay; - wxBillRent.setRevenue(record.getRevenue()); //wxBillRent.setReceivePay(oldPrice.equals(newPrice) ? oldPrice : newPrice); wxBillRent.setUpdatetime(new Date()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index fcb2af203..8fe9941c5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -250,13 +250,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { /** * 获取设置的跳点率 + * 合同这,不需要年份月份转换 * ["1000-1200:10",">3000:20"] * @param record */ public void getPayRatio(WxRentContract record){ - if(record.getPayRatio() != null && record.getPayRatio().intValue() >0){ - return; - } +// if(record.getPayRatio() != null && record.getPayRatio().intValue() >0){ +// return; +// } + record.setPayRatio(0); if(StringUtils.isBlank(record.getBusDiscountRatio())){ return; } From 8f8b8d0bdb17b79c0cb11db6e5be3a6d513924dc Mon Sep 17 00:00:00 2001 From: gongbiao Date: Wed, 21 Aug 2019 15:17:13 +0800 Subject: [PATCH 03/19] =?UTF-8?q?[=E7=94=B5=E8=A1=A8=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/schedule/PowerBillAutoBuildSchedule.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java index a0696da11..9b7e935ce 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java @@ -24,10 +24,7 @@ import java.time.LocalDate; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.temporal.TemporalAdjusters; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -59,7 +56,7 @@ public class PowerBillAutoBuildSchedule { /** * 每天5点执行 */ - @Scheduled(cron = "0 49 13 * * ?") + @Scheduled(cron = "0 0 5 * * ?") public void powerBillAutoConfigStart() { logger.info("自动生成电费账单开始...."); int dayOfMonth = LocalDate.now().getDayOfMonth(); @@ -143,7 +140,9 @@ public class PowerBillAutoBuildSchedule { kwMeterDataDto.setStartTime(startdate); kwMeterDataDto.setEndTime(lastdate); KwMeterDataVo power = kwMeterDataService.getPower(kwMeterDataDto); - usedPower += power.getUsedPower(); + if (power != null) { + usedPower += power.getUsedPower(); + } } } return usedPower; From 104679b2b8172130968ad15084c8303b024cb991 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 21 Aug 2019 16:45:28 +0800 Subject: [PATCH 04/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxBillRentServiceImpl.java | 3 -- .../impl/WxRentContractServiceImpl.java | 48 ++++++++++++++----- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index c7185de36..8fd47de1c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -275,9 +275,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { * @param record */ public Integer getPayRatio(WxBillRent record,WxRentContract wxRentContract,EnumMissTimeType timeType){ -// if(wxRentContract.getPayRatio() != null && wxRentContract.getPayRatio().intValue() > 0){ -// return wxRentContract.getPayRatio(); -// } wxRentContract.setPayRatio(0); BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(wxRentContract.getBusDiscountRatio(), String.class); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 8fe9941c5..1a06c2a6c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -254,18 +254,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { * ["1000-1200:10",">3000:20"] * @param record */ - public void getPayRatio(WxRentContract record){ -// if(record.getPayRatio() != null && record.getPayRatio().intValue() >0){ -// return; -// } + public BigDecimal getPayRatio(WxRentContract record){ record.setPayRatio(0); if(StringUtils.isBlank(record.getBusDiscountRatio())){ - return; + return null; } BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(record.getBusDiscountRatio(), String.class); - for (String e:ratioList) { + for (int i = 0; i < ratioList.size(); i++) { + String e = ratioList.get(i); String[] array = e.split(":"); Integer ratio = Integer.parseInt(array[1]); @@ -283,10 +281,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { BigDecimal end = new BigDecimal(revenueArray[1]); if (revenue.compareTo(end) >= 0){ record.setPayRatio(ratio); - break; + + //计算超出部分 + BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); + BigDecimal balance = new BigDecimal(record.getRevenue()).subtract(end.multiply(new BigDecimal(1000000))); + BigDecimal price = balance.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); + + array = ratioList.get(i-1).split(":"); + Integer frontatio = Integer.parseInt(array[1]); + BigDecimal frontRatio = new BigDecimal(frontatio).divide(new BigDecimal(10000)); + BigDecimal frontPrice = end.multiply(new BigDecimal(1000000).multiply(frontRatio).setScale(2, RoundingMode.HALF_EVEN)); + + return price.add(frontPrice); } } } + return null; } @Transactional(rollbackFor = {Exception.class}) @@ -312,13 +322,19 @@ public class WxRentContractServiceImpl implements WxRentContractService { } if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - getPayRatio(record); + BigDecimal balance = getPayRatio(record); //有超出部分 BigDecimal hundred = new BigDecimal(100); BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); - record.setPrice(price.multiply(hundred).longValue()); + BigDecimal price; + if(balance != null){ + //计算超出部分 + record.setPrice(balance.longValue()); + }else{ + price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); + record.setPrice(price.multiply(hundred).longValue()); + } } else { if (StringUtils.isNotEmpty(record.getPriceStr())) { record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).longValue()); @@ -542,12 +558,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(from != 1){ if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - getPayRatio(record); + BigDecimal balance = getPayRatio(record); BigDecimal hundred = new BigDecimal(100); BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); - record.setPrice(price.multiply(hundred).longValue()); + + BigDecimal price; + if(balance != null){ + record.setPrice(balance.longValue()); + }else { + price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); + record.setPrice(price.multiply(hundred).longValue()); + } } else { if (StringUtils.isNotEmpty(record.getPriceStr())) { record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).longValue()); From a579adea5b68c74bffe3a4a0a113756af1a640a5 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 21 Aug 2019 02:53:33 +0800 Subject: [PATCH 05/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:B=E7=AB=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0POS=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/controller/WxPosController.java | 323 +++++++++++++++++- 1 file changed, 322 insertions(+), 1 deletion(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java index a6716f324..906995c96 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java @@ -1,11 +1,18 @@ package com.iformall.controller; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxMerchantBUser; import com.iformall.exception.MallinkException; +import com.iformall.pay.WxPayConstant; +import com.iformall.pay.WxPayment; import com.iformall.utils.PosUtil; 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.beans.factory.annotation.Autowired; @@ -33,7 +40,7 @@ public class WxPosController extends BaseController { PosUtil posUtil = new PosUtil(); - @ApiOperation(value = "检查POSServer是否正常", notes = "") + @ApiOperation(value = "检查POS Server是否正常", notes = "") @GetMapping("checkAvaiable") public ResultData checkAvaiable() { try { @@ -50,7 +57,321 @@ public class WxPosController extends BaseController { logger.error(e.getMessage()); return new ResultData(Result.ERROR, e.getMessage()); } + } + + @ApiOperation(value = "商户POS用户/B端用户登录检查") + @PostMapping("checkUserPassword") + public ResultData checkUserPassword() { + WxMerchantBUser user = getUser(); + try { + String resStr = posUtil.checkUserPassword(posUrl, posDevId, posReqKey, + user.getTenantId(), user.getPhone(), user.getUserPwd()); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用") + @PostMapping("getPosMemConfig") + public ResultData getPosMemConfig() { + try { + String resStr = posUtil.getPosMemConfig(posUrl, posDevId, posReqKey, + getTenantId()); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "获取注册二维码及小票二维码规则") + @PostMapping("getQrCode") + public ResultData getQrCode() { + try { + String resStr = posUtil.getQrCode(posUrl, posDevId, posReqKey, + getTenantId()); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "会员识别") + @PostMapping("checkMem") + public ResultData checkMem(@RequestBody Map params) { + WxMerchantBUser user = getUser(); + String memIdStr = params.get(WxPayConstant.MEM_ID); // 会员ID + String memPhoneStr = params.get(WxPayConstant.MEM_PHONE); // 会员手机 + String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID + String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) + + if (StringUtils.isBlank(posOrderIdStr)) { + String errMessage = "request params[pos_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posAmountStr)) { + String errMessage = "request params[pos_amount] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + + if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { + String errMessage = "please give one value for mem_id or mem_phone"; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + try { + String resStr = posUtil.checkMem(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), + memIdStr, memPhoneStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "券核销检查") + @PostMapping("checkCouponOrderForVerify") + public ResultData checkCouponOrderForVerify(@RequestBody Map params) { + WxMerchantBUser user = getUser(); + String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID + String verifyType = params.get(WxPayConstant.VERIFY_TYPE); // 核销类型 + String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID + String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) + + if (StringUtils.isBlank(couponOrderIdStr)) { + String errMessage = "request params[coupon_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(verifyType)) { + String errMessage = "request params[verify_type] error."; + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posOrderIdStr)) { + String errMessage = "request params[pos_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posAmountStr)) { + String errMessage = "request params[pos_amount] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + try { + String resStr = posUtil.checkCouponOrderForVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, verifyType, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "券预核销") + @PostMapping("couponOrderPreVerify") + public ResultData couponOrderPreVerify(@RequestBody Map params) { + WxMerchantBUser user = getUser(); + String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID + String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID + String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) + + if (StringUtils.isBlank(couponOrderIdStr)) { + String errMessage = "request params[coupon_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posOrderIdStr)) { + String errMessage = "request params[pos_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posAmountStr)) { + String errMessage = "request params[pos_amount] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + try { + String resStr = posUtil.couponOrderPreVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + @ApiOperation(value = "券预核销取消") + @PostMapping("couponOrderPreVerifyCancel") + public ResultData couponOrderPreVerifyCancel(@RequestBody Map params) { + WxMerchantBUser user = getUser(); + String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID + String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID + String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) + + if (StringUtils.isBlank(couponOrderIdStr)) { + String errMessage = "request params[coupon_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posOrderIdStr)) { + String errMessage = "request params[pos_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posAmountStr)) { + String errMessage = "request params[pos_amount] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + try { + String resStr = posUtil.couponOrderPreVerifyCancel(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + @ApiOperation(value = "券独立核销") + @PostMapping("couponOrderIndependentVerify") + public ResultData couponOrderIndependentVerify(@RequestBody Map params) { + WxMerchantBUser user = getUser(); + String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID + String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID + + if (StringUtils.isBlank(couponOrderIdStr)) { + String errMessage = "request params[coupon_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (StringUtils.isBlank(posOrderIdStr)) { + String errMessage = "request params[pos_order_id] error."; + logger.error(errMessage); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + try { + String resStr = posUtil.couponOrderIndependentVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } } @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") From e5cd369e4aa14daec2577de960f9d0c503e51444 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 21 Aug 2019 17:31:52 +0800 Subject: [PATCH 06/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:B=E7=AB=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0POS=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/controller/WxPosController.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java index 906995c96..62c73fcb4 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java @@ -61,11 +61,20 @@ public class WxPosController extends BaseController { @ApiOperation(value = "商户POS用户/B端用户登录检查") @PostMapping("checkUserPassword") - public ResultData checkUserPassword() { + public ResultData checkUserPassword(@RequestBody Map params) { WxMerchantBUser user = getUser(); + String phone = params.get("phone"); + String password = params.get("password"); + //登录凭证不能为空 + if (StringUtils.isBlank(phone)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "手机号不能为空"); + } + if (StringUtils.isBlank(password)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); + } try { String resStr = posUtil.checkUserPassword(posUrl, posDevId, posReqKey, - user.getTenantId(), user.getPhone(), user.getUserPwd()); + user.getTenantId(), phone, password); if (resStr != null) { JSONObject retObj = JSON.parseObject(resStr); Map options = retObj; From 75ed4f7232f8aaf69ea88e861f91c4153062b704 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 22 Aug 2019 10:36:42 +0800 Subject: [PATCH 07/19] =?UTF-8?q?[=E7=94=B5=E8=A1=A8=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][B=E7=AB=AF=E6=98=BE=E7=A4=BA]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mallinkService/src/main/resources/mapper/WxBillAllMapper.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml index ac9346ffa..c74eaefb2 100644 --- a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml @@ -71,8 +71,8 @@ select id,merchant_id,shop_id,tenant_id,case when type=1 then '水费' when type=2 then '电费' else '空调费' end name, case when type=1 then 5 when type=2 then 6 else 9 end bill_type_value, case when type=1 then '水费' when type=2 then '电费' else '空调费' end bill_type,0 as - need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime, - rent_shop_type,'[]' shop_info,NULL comments + need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime, + rent_shop_type,'[]' shop_info,price_detail as comments from wx_bill_daily where tenant_id=#{tenantId} union all select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as From 5c27fe8745c29adcb86c110872ce9e10fc6bd218 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 22 Aug 2019 10:53:12 +0800 Subject: [PATCH 08/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:POS=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=8APOS=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V201908221020__POS_ORDER.sql | 39 ++++++ .../controller/PosOrderController.java | 71 ++++++++++ .../controller/PosPayOrderController.java | 73 +++++++++++ .../iformall/controller/WxPosController.java | 2 +- .../java/com/iformall/domain/po/PosOrder.java | 39 ++++++ .../com/iformall/domain/po/PosPayOrder.java | 69 ++++++++++ .../com/iformall/mapper/PosOrderMapper.java | 17 +++ .../iformall/mapper/PosPayOrderMapper.java | 17 +++ .../com/iformall/service/PosOrderService.java | 48 +++++++ .../iformall/service/PosPayOrderService.java | 48 +++++++ .../service/impl/PosOrderServiceImpl.java | 54 ++++++++ .../service/impl/PosPayOrderServiceImpl.java | 54 ++++++++ .../main/resources/mapper/PosOrderMapper.xml | 64 +++++++++ .../resources/mapper/PosPayOrderMapper.xml | 124 ++++++++++++++++++ 14 files changed, 718 insertions(+), 1 deletion(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql create mode 100644 mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java create mode 100644 mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/PosOrderMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/PosPayOrderMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/service/PosOrderService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/PosPayOrderService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/PosPayOrderServiceImpl.java create mode 100644 mallinkService/src/main/resources/mapper/PosOrderMapper.xml create mode 100644 mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml diff --git a/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql b/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql new file mode 100644 index 000000000..d85becbaa --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql @@ -0,0 +1,39 @@ +create table `pos_order` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', + `pos_order_no` varchar(20) NULL COMMENT 'POS订单ID', + `type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付类型(1: 独立核销, 2:支付)', + `order_status` tinyint(6) NOT NULL DEFAULT '0' COMMENT '订单状态:0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败', + `bu_user_id` bigint(20) DEFAULT NULL COMMENT 'b端用户', + `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='POS订单'; + +CREATE TABLE `pos_pay_order` ( + `id` bigint(20) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_time` datetime NOT NULL COMMENT '更新时间', + `order_id` bigint(20) NOT NULL COMMENT '订单ID', + `bu_user_id` bigint(20) DEFAULT NULL COMMENT 'b端用户', + `type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付类型(1:独立核销 2:支付核销 3:现金支付)', + `pay_from` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付来源(0: 现金, 1:微信 2:支付核销 3:现金支付)', + `pay_amount` int(11) NOT NULL COMMENT '支付金额(分)', + `pay_time_start` datetime NOT NULL COMMENT '支付发起时间', + `pay_time_end` datetime NOT NULL COMMENT '支付结束时间', + `prepay_id` varchar(64) DEFAULT NULL COMMENT '微信预支付交易会话标识-发模板信息使用', + `transaction_id` varchar(36) DEFAULT NULL COMMENT '微信生成的订单号', + `pay_vendor` int(11) NOT NULL DEFAULT 0 COMMENT '支付渠道: 0-微信 1-支付宝 2-银联 ', + `pay_order_no` varchar(36) DEFAULT '' COMMENT '支付订单号', + `pay_order_status` int(11) NOT NULL DEFAULT 0 COMMENT '支付状态: 0-支付中;1-支付成功;2-支付失败', + `share` smallint(2) DEFAULT NULL COMMENT '是否支持分账(0:不支持,1:支持)', + `share_amount` int(11) DEFAULT NULL COMMENT '分账金额(总金额扣掉手续费后的金额)', + `rate_amount` int(11) DEFAULT NULL COMMENT '分账实际通道费', + `fail_reason` varchar(50) DEFAULT '' COMMENT '支付失败原因', + `auth_code` varchar(128) DEFAULT NULL COMMENT '扫码支付授权码', + `open_id` varchar(128) DEFAULT NULL COMMENT '微信支付后获取的open_id', + `pay_end_from` smallint(2) DEFAULT NULL COMMENT '支付后结果来源(0:callback, 1:query)', + PRIMARY KEY (`id`), + UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' +) ENGINE=`InnoDB` DEFAULT CHARSET=utf8mb4 COMMENT='POS支付订单'; \ No newline at end of file diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java new file mode 100644 index 000000000..5b6695529 --- /dev/null +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java @@ -0,0 +1,71 @@ +package com.iformall.controller; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.Result; +import com.iformall.common.ResultData; + +import com.iformall.domain.po.PosOrder; +import com.iformall.service.PosOrderService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + + +@RestController +@RequestMapping("/api/posOrder") +@AllArgsConstructor +@Api(description = "POS订单接口") +public class PosOrderController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final PosOrderService posOrderService; + + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData list(@ModelAttribute PosOrder posOrder,Integer pageNum, Integer pageSize) { + if (null == posOrder) posOrder = new PosOrder(); + final PageInfo page = posOrderService.listAsPage(posOrder, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增POS订单接口") + @PostMapping("add") + public ResultData add(@RequestBody PosOrder posOrder) { + posOrderService.saveOrUpdate(posOrder); + return new ResultData(); + } + + @ApiOperation("根据id更新接口") + @PostMapping("update") + public ResultData update(@RequestBody PosOrder posOrder) { + posOrderService.saveOrUpdate(posOrder); + return new ResultData(); + } + + @ApiOperation("根据id删除接口") + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + posOrderService.deleteById(id); + return new ResultData(Result.SUCCESS, "删除成功", null); + } + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData findById(Long id) { + return new ResultData(Result.SUCCESS,"查询成功",posOrderService.getById(id)); + } + + + +} diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java new file mode 100644 index 000000000..cd7805928 --- /dev/null +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java @@ -0,0 +1,73 @@ +package com.iformall.controller; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.Result; +import com.iformall.common.ResultData; + +import com.iformall.domain.po.PosPayOrder; +import com.iformall.service.PosPayOrderService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("/api/posPayOrder") +@AllArgsConstructor +@Api(description = "POS支付订单接口") +public class PosPayOrderController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final PosPayOrderService posPayOrderService; + + + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData list(@ModelAttribute PosPayOrder posPayOrder,Integer pageNum, Integer pageSize) { + if (null == posPayOrder) posPayOrder = new PosPayOrder(); + final PageInfo page = posPayOrderService.listAsPage(posPayOrder, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("新增POS订单接口") + @PostMapping("add") + public ResultData add(@RequestBody PosPayOrder posPayOrder) { + //Assert.notNull(posPayOrder.getName(), "角色名不能为空"); + //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); + posPayOrderService.saveOrUpdate(posPayOrder); + return new ResultData(); + } + + @ApiOperation("根据id更新接口") + @PostMapping("update") + public ResultData update(@RequestBody PosPayOrder posPayOrder) { + posPayOrderService.saveOrUpdate(posPayOrder); + return new ResultData(); + } + + @ApiOperation("根据id删除接口") + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + posPayOrderService.deleteById(id); + return new ResultData(Result.SUCCESS, "删除成功", null); + } + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData findById(Long id) { + return new ResultData(Result.SUCCESS,"查询成功",posPayOrderService.getById(id)); + } + + + +} diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java index 62c73fcb4..ee5072ee7 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java @@ -22,7 +22,7 @@ import java.util.Map; @RestController @RequestMapping("/api/pos") -@Api(description = "卡券相关接口") +@Api(description = "POS服务相关接口") public class WxPosController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java new file mode 100644 index 000000000..31bdcc489 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java @@ -0,0 +1,39 @@ +package com.iformall.domain.po; + +import lombok.Data; +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "pos_order") +@Data +public class PosOrder implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="POS订单ID",name="posOrderNo") + private String posOrderNo; + @io.swagger.annotations.ApiModelProperty(value="支付类型(1: 独立核销, 2:支付)",name="type") + private Integer type; + @io.swagger.annotations.ApiModelProperty(value="订单状态:0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败",name="orderStatus") + private Integer orderStatus; + @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") + private Long buUserId; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java new file mode 100644 index 000000000..afe44f95f --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java @@ -0,0 +1,69 @@ +package com.iformall.domain.po; + +import lombok.Data; +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "pos_pay_order") +@Data +public class PosPayOrder implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") + private Date createTime; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") + private Date updateTime; + @io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId") + private Long orderId; + @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") + private Long buUserId; + @io.swagger.annotations.ApiModelProperty(value="支付类型(1:独立核销 2:支付核销 3:现金支付)",name="type") + private Integer type; + @io.swagger.annotations.ApiModelProperty(value="支付来源(0: 现金, 1:微信 2:支付核销 3:现金支付)",name="payFrom") + private Integer payFrom; + @io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payAmount") + private Integer payAmount; + @io.swagger.annotations.ApiModelProperty(value="支付发起时间",name="payTimeStart") + private Date payTimeStart; + @io.swagger.annotations.ApiModelProperty(value="支付结束时间",name="payTimeEnd") + private Date payTimeEnd; + @io.swagger.annotations.ApiModelProperty(value="微信预支付交易会话标识-发模板信息使用",name="prepayId") + private String prepayId; + @io.swagger.annotations.ApiModelProperty(value="微信生成的订单号",name="transactionId") + private String transactionId; + @io.swagger.annotations.ApiModelProperty(value="支付渠道: 0-微信 1-支付宝 2-银联 ",name="payVendor") + private Integer payVendor; + @io.swagger.annotations.ApiModelProperty(value="支付订单号",name="payOrderNo") + private String payOrderNo; + @io.swagger.annotations.ApiModelProperty(value="支付状态: 0-支付中;1-支付成功;2-支付失败",name="payOrderStatus") + private Integer payOrderStatus; + @io.swagger.annotations.ApiModelProperty(value="是否支持分账(0:不支持,1:支持)",name="share") + private Integer share; + @io.swagger.annotations.ApiModelProperty(value="分账金额(总金额扣掉手续费后的金额)",name="shareAmount") + private Integer shareAmount; + @io.swagger.annotations.ApiModelProperty(value="分账实际通道费",name="rateAmount") + private Integer rateAmount; + @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") + private String failReason; + @io.swagger.annotations.ApiModelProperty(value="扫码支付授权码",name="authCode") + private String authCode; + @io.swagger.annotations.ApiModelProperty(value="微信支付后获取的open_id",name="openId") + private String openId; + @io.swagger.annotations.ApiModelProperty(value="支付后结果来源(0:callback, 1:query)",name="payEndFrom") + private Integer payEndFrom; + + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/PosOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/PosOrderMapper.java new file mode 100644 index 000000000..120bccc68 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/PosOrderMapper.java @@ -0,0 +1,17 @@ +package com.iformall.mapper; + +import java.util.*; +import com.iformall.common.CommonMapper; +import org.apache.ibatis.annotations.Param; +import com.iformall.domain.po.PosOrder; + +public interface PosOrderMapper extends CommonMapper { + + List findList(PosOrder posOrder); + + + + + + +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/PosPayOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/PosPayOrderMapper.java new file mode 100644 index 000000000..e34479bfa --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/PosPayOrderMapper.java @@ -0,0 +1,17 @@ +package com.iformall.mapper; + +import java.util.*; +import com.iformall.common.CommonMapper; +import org.apache.ibatis.annotations.Param; +import com.iformall.domain.po.PosPayOrder; + +public interface PosPayOrderMapper extends CommonMapper { + + List findList(PosPayOrder posPayOrder); + + + + + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/PosOrderService.java b/mallinkService/src/main/java/com/iformall/service/PosOrderService.java new file mode 100644 index 000000000..e739d52d1 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/PosOrderService.java @@ -0,0 +1,48 @@ +package com.iformall.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.PosOrder; + +public interface PosOrderService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(PosOrder record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + PosOrder getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(PosOrder record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/PosPayOrderService.java b/mallinkService/src/main/java/com/iformall/service/PosPayOrderService.java new file mode 100644 index 000000000..823e36ab3 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/PosPayOrderService.java @@ -0,0 +1,48 @@ +package com.iformall.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.PosPayOrder; + +public interface PosPayOrderService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(PosPayOrder record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + PosPayOrder getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(PosPayOrder record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java new file mode 100644 index 000000000..18d0393f2 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java @@ -0,0 +1,54 @@ +package com.iformall.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.PosOrder; +import com.iformall.mapper.PosOrderMapper; +import com.iformall.service.PosOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.iformall.common.IdWorker; + +@Service +public class PosOrderServiceImpl implements PosOrderService { + + @Autowired + PosOrderMapper posOrderMapper; + + + @Override + public PageInfo listAsPage(PosOrder record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> posOrderMapper.findList(record)); + } + + @Override + public PosOrder getById(Long id) { + return posOrderMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(PosOrder record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + posOrderMapper.insertSelective(record); + } else { + posOrderMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + posOrderMapper.deleteByPrimaryKey(id); + } + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PosPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PosPayOrderServiceImpl.java new file mode 100644 index 000000000..457077ccb --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/PosPayOrderServiceImpl.java @@ -0,0 +1,54 @@ +package com.iformall.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.PosPayOrder; +import com.iformall.mapper.PosPayOrderMapper; +import com.iformall.service.PosPayOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.iformall.common.IdWorker; + +@Service +public class PosPayOrderServiceImpl implements PosPayOrderService { + + @Autowired + PosPayOrderMapper posPayOrderMapper; + + + @Override + public PageInfo listAsPage(PosPayOrder record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> posPayOrderMapper.findList(record)); + } + + @Override + public PosPayOrder getById(Long id) { + return posPayOrderMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(PosPayOrder record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + posPayOrderMapper.insertSelective(record); + } else { + posPayOrderMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + posPayOrderMapper.deleteByPrimaryKey(id); + } + + + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/PosOrderMapper.xml b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml new file mode 100644 index 000000000..a006ce4e2 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + `id`,`tenant_id`,`pos_order_no`,`type`,`order_status`,`bu_user_id`,`create_date`,`update_date` + + + + where 1 = 1 + + and `id` = #{id} + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + and `pos_order_no` like concat('%', #{posOrderNo},'%') + + + and `type` = #{type} + + + and `order_status` = #{orderStatus} + + + and `bu_user_id` = #{buUserId} + + + and `create_date` = #{createDate} + + + and `update_date` = #{updateDate} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml b/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml new file mode 100644 index 000000000..8b4b28166 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/PosPayOrderMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`create_time`,`update_time`,`order_id`,`bu_user_id`,`type`,`pay_from`,`pay_amount`,`pay_time_start`,`pay_time_end`,`prepay_id`,`transaction_id`,`pay_vendor`,`pay_order_no`,`pay_order_status`,`share`,`share_amount`,`rate_amount`,`fail_reason`,`auth_code`,`open_id`,`pay_end_from` + + + + where 1 = 1 + + and `id` = #{id} + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + and `create_time` = #{createTime} + + + and `update_time` = #{updateTime} + + + and `order_id` = #{orderId} + + + and `bu_user_id` = #{buUserId} + + + and `type` = #{type} + + + and `pay_from` = #{payFrom} + + + and `pay_amount` = #{payAmount} + + + and `pay_time_start` = #{payTimeStart} + + + and `pay_time_end` = #{payTimeEnd} + + + and `prepay_id` like concat('%', #{prepayId},'%') + + + and `transaction_id` like concat('%', #{transactionId},'%') + + + and `pay_vendor` = #{payVendor} + + + and `pay_order_no` like concat('%', #{payOrderNo},'%') + + + and `pay_order_status` = #{payOrderStatus} + + + and `share` = #{share} + + + and `share_amount` = #{shareAmount} + + + and `rate_amount` = #{rateAmount} + + + and `fail_reason` like concat('%', #{failReason},'%') + + + and `auth_code` like concat('%', #{authCode},'%') + + + and `open_id` like concat('%', #{openId},'%') + + + and `pay_end_from` = #{payEndFrom} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + From f0c3e6ad8a79cb471dc93003df899942d24560ad Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 22 Aug 2019 11:12:40 +0800 Subject: [PATCH 09/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:POS=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=8APOS=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V201908221020__POS_ORDER.sql | 4 +- .../controller/PosOrderController.java | 48 ++++++++++++------- .../controller/PosPayOrderController.java | 33 +++++++------ .../service/impl/PosOrderServiceImpl.java | 2 - 4 files changed, 50 insertions(+), 37 deletions(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql b/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql index d85becbaa..3fe0edf87 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V201908221020__POS_ORDER.sql @@ -3,8 +3,10 @@ create table `pos_order` ( `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', `pos_order_no` varchar(20) NULL COMMENT 'POS订单ID', `type` tinyint(6) NOT NULL DEFAULT 0 COMMENT '支付类型(1: 独立核销, 2:支付)', - `order_status` tinyint(6) NOT NULL DEFAULT '0' COMMENT '订单状态:0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败', + `order_status` tinyint(6) NOT NULL DEFAULT '0' COMMENT '订单状态:0-待付款/待核销;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败', `bu_user_id` bigint(20) DEFAULT NULL COMMENT 'b端用户', + `payment_type` smallint(2) NOT NULL COMMENT '0: 付款 1: 退款 2:自动退款 3:A端退款 10:独立核销', + `payment` int(11) default NULL COMMENT '支付金额:允许有负数,退款时为负值。核销时,金额可以不填写', `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java index 5b6695529..d63db0f8d 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java @@ -1,5 +1,7 @@ package com.iformall.controller; +import com.iformall.common.ErrorCode; +import com.iformall.enums.EnumPosOrderType; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import org.slf4j.Logger; @@ -25,21 +27,34 @@ public class PosOrderController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final PosOrderService posOrderService; - - @ApiOperation("分页列表接口") + + @ApiOperation("分页列表接口") @GetMapping("list") - @ApiImplicitParams({ - @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), - @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) - public ResultData list(@ModelAttribute PosOrder posOrder,Integer pageNum, Integer pageSize) { - if (null == posOrder) posOrder = new PosOrder(); + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute PosOrder posOrder, Integer pageNum, Integer pageSize) { + if (null == posOrder) posOrder = new PosOrder(); final PageInfo page = posOrderService.listAsPage(posOrder, pageNum, pageSize); return new ResultData(page); } - @ApiOperation("新增POS订单接口") + @ApiOperation("新增POS订单接口") @PostMapping("add") public ResultData add(@RequestBody PosOrder posOrder) { + if (posOrder == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + if (posOrder.getType() == null) { + String errMessage = "订单类型为空"; + logger.error(errMessage); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } + if (posOrder.getBuUserId() == null) { + String errMessage = "操作员为空"; + logger.error(errMessage); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); + } posOrderService.saveOrUpdate(posOrder); return new ResultData(); } @@ -53,19 +68,18 @@ public class PosOrderController extends BaseController { @ApiOperation("根据id删除接口") @GetMapping("/del") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData delete(Long id) { posOrderService.deleteById(id); return new ResultData(Result.SUCCESS, "删除成功", null); } - - @ApiOperation("根据id查询接口") - @GetMapping("/findById") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData findById(Long id) { - return new ResultData(Result.SUCCESS,"查询成功",posOrderService.getById(id)); + return new ResultData(Result.SUCCESS, "查询成功", posOrderService.getById(id)); } - - - + + } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java index cd7805928..d4c40aac4 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosPayOrderController.java @@ -25,19 +25,19 @@ public class PosPayOrderController extends BaseController { private final PosPayOrderService posPayOrderService; - - @ApiOperation("分页列表接口") + + @ApiOperation("分页列表接口") @GetMapping("list") - @ApiImplicitParams({ - @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), - @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) - public ResultData list(@ModelAttribute PosPayOrder posPayOrder,Integer pageNum, Integer pageSize) { - if (null == posPayOrder) posPayOrder = new PosPayOrder(); + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute PosPayOrder posPayOrder, Integer pageNum, Integer pageSize) { + if (null == posPayOrder) posPayOrder = new PosPayOrder(); final PageInfo page = posPayOrderService.listAsPage(posPayOrder, pageNum, pageSize); return new ResultData(page); } - @ApiOperation("新增POS订单接口") + @ApiOperation("新增POS订单接口") @PostMapping("add") public ResultData add(@RequestBody PosPayOrder posPayOrder) { //Assert.notNull(posPayOrder.getName(), "角色名不能为空"); @@ -55,19 +55,18 @@ public class PosPayOrderController extends BaseController { @ApiOperation("根据id删除接口") @GetMapping("/del") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData delete(Long id) { posPayOrderService.deleteById(id); return new ResultData(Result.SUCCESS, "删除成功", null); } - - @ApiOperation("根据id查询接口") - @GetMapping("/findById") - @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + + @ApiOperation("根据id查询接口") + @GetMapping("/findById") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData findById(Long id) { - return new ResultData(Result.SUCCESS,"查询成功",posPayOrderService.getById(id)); + return new ResultData(Result.SUCCESS, "查询成功", posPayOrderService.getById(id)); } - - - + + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java index 18d0393f2..33d526251 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PosOrderServiceImpl.java @@ -1,6 +1,5 @@ package com.iformall.service.impl; -import java.util.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PosOrder; @@ -30,7 +29,6 @@ public class PosOrderServiceImpl implements PosOrderService { @Override public void saveOrUpdate(PosOrder record) { if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); posOrderMapper.insertSelective(record); From edfa3cc90474d1e04f3b65465c4e9a44dbdaa54f Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 22 Aug 2019 11:16:50 +0800 Subject: [PATCH 10/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:POS=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=8APOS=E6=94=AF=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/domain/po/PosOrder.java | 7 +++- .../com/iformall/enums/EnumPosOrderType.java | 38 +++++++++++++++++++ .../main/resources/mapper/PosOrderMapper.xml | 10 ++++- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java index 31bdcc489..190bfcd18 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java @@ -3,7 +3,6 @@ package com.iformall.domain.po; import lombok.Data; import javax.persistence.*; import java.util.*; -import java.math.*; import javax.persistence.Transient; import java.util.List; import javax.persistence.Id; @@ -26,10 +25,14 @@ public class PosOrder implements Serializable { private String posOrderNo; @io.swagger.annotations.ApiModelProperty(value="支付类型(1: 独立核销, 2:支付)",name="type") private Integer type; - @io.swagger.annotations.ApiModelProperty(value="订单状态:0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败",name="orderStatus") + @io.swagger.annotations.ApiModelProperty(value="订单状态:0-待付款/待核销;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败",name="orderStatus") private Integer orderStatus; @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") private Long buUserId; + @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款 2:自动退款 3:A端退款",name="paymentType") + private Integer paymentType; + @io.swagger.annotations.ApiModelProperty(value="支付金额:允许有负数,退款时为负值。核销时,金额可以不填写",name="paymentType") + private Integer payment; @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") private Date createDate; @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java new file mode 100644 index 000000000..6dc086784 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ + +public enum EnumPosOrderType { + + VERIFY_INDEPENDENT(1,"独立核销"), + PAY(2,"支付") + ; + + public static EnumPosOrderType getEnum(Integer code) { + for (EnumPosOrderType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPosOrderType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/resources/mapper/PosOrderMapper.xml b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml index a006ce4e2..b3663fc51 100644 --- a/mallinkService/src/main/resources/mapper/PosOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/PosOrderMapper.xml @@ -8,6 +8,8 @@ + + @@ -35,7 +37,13 @@ and `bu_user_id` = #{buUserId} - + + + and `payment_type` = #{paymentType} + + + and `payment` = #{payment} + and `create_date` = #{createDate} From bf6b7e5318d6a1e812a285bee962ea80f0e42b1d Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 22 Aug 2019 11:17:00 +0800 Subject: [PATCH 11/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/domain/vo/RatioVo.java | 13 +++ .../service/impl/WxBillRentServiceImpl.java | 60 ++---------- .../impl/WxRentContractServiceImpl.java | 97 +++++++++++-------- 3 files changed, 78 insertions(+), 92 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/RatioVo.java diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/RatioVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/RatioVo.java new file mode 100644 index 000000000..ff1c59b15 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/RatioVo.java @@ -0,0 +1,13 @@ +package com.iformall.domain.vo; + +import lombok.Data; +import java.math.BigDecimal; + +@Data +public class RatioVo { + + //扣点率 + private Integer ratio = 0; + //超出部分金额 + private BigDecimal balance; +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index 8fd47de1c..b31899f0b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -268,56 +268,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { return months; } - - /** - * 获取设置的跳点率 - * ["1000-1200:10",">3000:20"] - * @param record - */ - public Integer getPayRatio(WxBillRent record,WxRentContract wxRentContract,EnumMissTimeType timeType){ - wxRentContract.setPayRatio(0); - BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); - List ratioList = JSONArray.parseArray(wxRentContract.getBusDiscountRatio(), String.class); - long dayCount = DateUtils.startToEnd(record.getStarttime(),record.getEndtime()); - - for (String e:ratioList) { - String[] array = e.split(":"); - Integer ratio = Integer.parseInt(array[1]); - - if(e.indexOf("-") >= 0){ - String[] revenueArray = array[0].split("-"); - BigDecimal start = new BigDecimal(revenueArray[0]); - BigDecimal end = new BigDecimal(revenueArray[1]); - - //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) - if(EnumMissTimeType.YEAR.getCode().equals(timeType.getCode())){ - start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - }else if(EnumMissTimeType.MONTH.getCode().equals(timeType.getCode())){ - start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - } - if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ - return ratio; - } - }if(e.indexOf(">") >= 0){ - String[] revenueArray = array[0].split(">"); - BigDecimal end = new BigDecimal(revenueArray[1]); - - //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) - if(EnumMissTimeType.YEAR.getCode().equals(timeType.getCode())){ - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - }else if(EnumMissTimeType.MONTH.getCode().equals(timeType.getCode())){ - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - } - if (revenue.compareTo(end) >= 0){ - return ratio; - } - } - } - return 0; - } - @Override @Transactional(rollbackFor = {Exception.class}) public ResultData updateRevenue(WxBillRent record, MallUserInfo user) { @@ -334,19 +284,21 @@ public class WxBillRentServiceImpl implements WxBillRentService { Integer ratio = 0; if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ + long dayCount = DateUtils.startToEnd(record.getStarttime(),record.getEndtime()); + if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ if(startInt == endInt && months == 12){ //刚好1年 - ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); + ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount).getRatio(); }else{ - ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.YEAR); + ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount).getRatio(); } }else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ if(startInt == endInt && months == 1){ //刚好1个月 - ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.OTHER); + ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount).getRatio(); }else{ - ratio = getPayRatio(wxBillRent,wxRentContract,EnumMissTimeType.MONTH); + ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount).getRatio(); } } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 1a06c2a6c..17db2e675 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -10,6 +10,7 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.vo.BillTimeVo; +import com.iformall.domain.vo.RatioVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; @@ -250,17 +251,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { /** * 获取设置的跳点率 - * 合同这,不需要年份月份转换 * ["1000-1200:10",">3000:20"] - * @param record */ - public BigDecimal getPayRatio(WxRentContract record){ - record.setPayRatio(0); - if(StringUtils.isBlank(record.getBusDiscountRatio())){ - return null; - } - BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); - List ratioList = JSONArray.parseArray(record.getBusDiscountRatio(), String.class); + public static RatioVo getPayRatio(Long revenueLong,String busDiscountRatio,int timeType,long dayCount){ + RatioVo ratioVo = new RatioVo(); + BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); + List ratioList = JSONArray.parseArray(busDiscountRatio, String.class); for (int i = 0; i < ratioList.size(); i++) { String e = ratioList.get(i); @@ -271,20 +267,40 @@ public class WxRentContractServiceImpl implements WxRentContractService { String[] revenueArray = array[0].split("-"); BigDecimal start = new BigDecimal(revenueArray[0]); BigDecimal end = new BigDecimal(revenueArray[1]); + + //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) + if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ + start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + //revenue = revenue.divide(new BigDecimal(365)); + }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ + start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + //revenue = revenue.divide(new BigDecimal(30)); + } + if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ - record.setPayRatio(ratio); + ratioVo.setRatio(ratio); break; } - - }if(e.indexOf(">") >= 0){ + }else if(e.indexOf(">") >= 0){ String[] revenueArray = array[0].split(">"); BigDecimal end = new BigDecimal(revenueArray[1]); + + //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) + if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + //revenue = revenue.divide(new BigDecimal(365)); + }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + //revenue = revenue.divide(new BigDecimal(30)); + } if (revenue.compareTo(end) >= 0){ - record.setPayRatio(ratio); + ratioVo.setRatio(ratio); //计算超出部分 - BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - BigDecimal balance = new BigDecimal(record.getRevenue()).subtract(end.multiply(new BigDecimal(1000000))); + BigDecimal payRatio = new BigDecimal(ratio).divide(new BigDecimal(10000)); + BigDecimal balance = new BigDecimal(revenueLong).subtract(end.multiply(new BigDecimal(1000000))); BigDecimal price = balance.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); array = ratioList.get(i-1).split(":"); @@ -292,11 +308,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { BigDecimal frontRatio = new BigDecimal(frontatio).divide(new BigDecimal(10000)); BigDecimal frontPrice = end.multiply(new BigDecimal(1000000).multiply(frontRatio).setScale(2, RoundingMode.HALF_EVEN)); - return price.add(frontPrice); + ratioVo.setBalance(price.add(frontPrice)); + return ratioVo; } } } - return null; + return ratioVo; } @Transactional(rollbackFor = {Exception.class}) @@ -322,18 +339,24 @@ public class WxRentContractServiceImpl implements WxRentContractService { } if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - BigDecimal balance = getPayRatio(record); //有超出部分 - BigDecimal hundred = new BigDecimal(100); - BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); - BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - - BigDecimal price; - if(balance != null){ - //计算超出部分 - record.setPrice(balance.longValue()); + if(record.getRevenue() == null || record.getRevenue().longValue() <=0){ + record.setPrice(0l); }else{ - price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); - record.setPrice(price.multiply(hundred).longValue()); + int dayCount = record.getReceivePeriod() * 30; + RatioVo ratioVo = getPayRatio(record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount); + record.setPayRatio(ratioVo.getRatio()); + BigDecimal hundred = new BigDecimal(100); + BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); + BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); + + BigDecimal price; + if(ratioVo.getBalance() != null){ + //计算超出部分 + record.setPrice(ratioVo.getBalance().longValue()); + }else{ + price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); + record.setPrice(price.multiply(hundred).longValue()); + } } } else { if (StringUtils.isNotEmpty(record.getPriceStr())) { @@ -540,6 +563,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillRentMapper.insertBills(record.getPreviewBillRentList()); } + + public ResultData getResultDataForUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate) { //更新租赁合同信息 WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); @@ -556,16 +581,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { instance.add(dayType, record.getLease()); instance.add(Calendar.DAY_OF_MONTH, -1); - if(from != 1){ + if(!EnumFromType.SWITCH.getCode().equals(from)){ if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - BigDecimal balance = getPayRatio(record); + int dayCount = record.getReceivePeriod() * 30; + RatioVo ratioVo = getPayRatio(record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount); + record.setPayRatio(ratioVo.getRatio()); BigDecimal hundred = new BigDecimal(100); BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); BigDecimal price; - if(balance != null){ - record.setPrice(balance.longValue()); + if(ratioVo.getBalance() != null){ + record.setPrice(ratioVo.getBalance().longValue()); }else { price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); record.setPrice(price.multiply(hundred).longValue()); @@ -2091,12 +2118,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { Double total = new Double(0); int[] diff; - System.out.println(sd.format(start)); - System.out.println(sd.format(end)); - if(sd.format(end).equals("2020-08-18")){ - System.out.println(); - } - //同一天 if(sd.format(start).equals(sd.format(end))){ int dayCount = DateUtils.getMonthDayCount(start); From ce2b0212e65f8fe0b9a9c8e0c9d73498b2423421 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 22 Aug 2019 12:30:30 +0800 Subject: [PATCH 12/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/enums/EnumGetRatioFrom.java | 32 +++++++++++++ .../com/iformall/enums/EnumMissTimeType.java | 10 ++--- .../service/impl/WxBillRentServiceImpl.java | 10 +++-- .../impl/WxRentContractServiceImpl.java | 45 +++++++++++++------ 4 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumGetRatioFrom.java diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumGetRatioFrom.java b/mallinkService/src/main/java/com/iformall/enums/EnumGetRatioFrom.java new file mode 100644 index 000000000..26cd88222 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumGetRatioFrom.java @@ -0,0 +1,32 @@ +package com.iformall.enums; + +public enum EnumGetRatioFrom { + RENT(1, "合同"), + BILL(2, "账单录入营业额"), + ; + + public static EnumGetRatioFrom getEnum(Integer code) { + for (EnumGetRatioFrom value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumGetRatioFrom(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumMissTimeType.java b/mallinkService/src/main/java/com/iformall/enums/EnumMissTimeType.java index 6ef644ee3..3f10dd93c 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumMissTimeType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumMissTimeType.java @@ -1,13 +1,11 @@ package com.iformall.enums; -/** - * Created by Stormeye on 2018/08/09. - */ public enum EnumMissTimeType { - YEAR(1, "残年"), - MONTH(2, "残月"), - OTHER(3, "其他"), + YEAR(1, "年"), + MONTH(2, "月"), + PERIOD(3, "周期"), + OTHER(4, "其他"), ; public static EnumMissTimeType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index b31899f0b..a83629168 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -289,17 +289,19 @@ public class WxBillRentServiceImpl implements WxBillRentService { if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ if(startInt == endInt && months == 12){ //刚好1年 - ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount).getRatio(); + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); }else{ - ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount).getRatio(); + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount,0).getRatio(); } }else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ if(startInt == endInt && months == 1){ //刚好1个月 - ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount).getRatio(); + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); }else{ - ratio = WxRentContractServiceImpl.getPayRatio(wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount).getRatio(); + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount,0).getRatio(); } + }else if(EnumBusRatioTime.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())){ + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.PERIOD.getCode(),dayCount,wxRentContract.getReceivePeriod()).getRatio(); } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 17db2e675..23488f2c0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -253,7 +253,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { * 获取设置的跳点率 * ["1000-1200:10",">3000:20"] */ - public static RatioVo getPayRatio(Long revenueLong,String busDiscountRatio,int timeType,long dayCount){ + public static RatioVo getPayRatio(int from,Long revenueLong,String busDiscountRatio,int timeType,long dayCount,int period){ RatioVo ratioVo = new RatioVo(); BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(busDiscountRatio, String.class); @@ -270,13 +270,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ - start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - //revenue = revenue.divide(new BigDecimal(365)); + if(EnumGetRatioFrom.BILL.getCode().equals(from)) { + start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(365), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + } + if(EnumGetRatioFrom.RENT.getCode().equals(from)) { + revenue = revenue.divide(new BigDecimal(12)); + } }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ - start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - //revenue = revenue.divide(new BigDecimal(30)); + if(EnumGetRatioFrom.BILL.getCode().equals(from)) { + start = new BigDecimal(revenueArray[0]).divide(new BigDecimal(30), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + } + }else if(EnumMissTimeType.PERIOD.getCode().equals(timeType)){ + if(EnumGetRatioFrom.RENT.getCode().equals(from)) { + revenue = revenue.divide(new BigDecimal(period)); + } } if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ @@ -289,12 +298,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { //残年 (小金额 / 365 * 账单周期天数 )--(大金额 / 365 * 账单周期天数) if(EnumMissTimeType.YEAR.getCode().equals(timeType)){ - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - //revenue = revenue.divide(new BigDecimal(365)); + if(EnumGetRatioFrom.BILL.getCode().equals(from)) { + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(365), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + } + if(EnumGetRatioFrom.RENT.getCode().equals(from)) { + revenue = revenue.divide(new BigDecimal(12)); + } }else if(EnumMissTimeType.MONTH.getCode().equals(timeType)){ - end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30),10,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); - //revenue = revenue.divide(new BigDecimal(30)); + if(EnumGetRatioFrom.BILL.getCode().equals(from)) { + end = new BigDecimal(revenueArray[1]).divide(new BigDecimal(30), 10, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(dayCount)); + } + }else if(EnumMissTimeType.PERIOD.getCode().equals(timeType)){ + if(EnumGetRatioFrom.RENT.getCode().equals(from)) { + revenue = revenue.divide(new BigDecimal(period)); + } } + if (revenue.compareTo(end) >= 0){ ratioVo.setRatio(ratio); @@ -343,7 +362,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.setPrice(0l); }else{ int dayCount = record.getReceivePeriod() * 30; - RatioVo ratioVo = getPayRatio(record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount); + RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod()); record.setPayRatio(ratioVo.getRatio()); BigDecimal hundred = new BigDecimal(100); BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); @@ -584,7 +603,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(!EnumFromType.SWITCH.getCode().equals(from)){ if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { int dayCount = record.getReceivePeriod() * 30; - RatioVo ratioVo = getPayRatio(record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount); + RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,wxRentContract.getReceivePeriod()); record.setPayRatio(ratioVo.getRatio()); BigDecimal hundred = new BigDecimal(100); BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); From d803dfb121bfe935078639a6e7255eb59ac41e80 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 22 Aug 2019 13:38:09 +0800 Subject: [PATCH 13/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/service/impl/WxRentContractServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 23488f2c0..182698497 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -254,6 +254,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { * ["1000-1200:10",">3000:20"] */ public static RatioVo getPayRatio(int from,Long revenueLong,String busDiscountRatio,int timeType,long dayCount,int period){ + if(StringUtils.isBlank(busDiscountRatio)){ + return new RatioVo(); + } RatioVo ratioVo = new RatioVo(); BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(busDiscountRatio, String.class); From 154c0100dcbb31ba3baf69f65516030f7fb630f3 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 22 Aug 2019 13:38:37 +0800 Subject: [PATCH 14/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/service/impl/WxRentContractServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 182698497..eb24b22e9 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -254,10 +254,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { * ["1000-1200:10",">3000:20"] */ public static RatioVo getPayRatio(int from,Long revenueLong,String busDiscountRatio,int timeType,long dayCount,int period){ + RatioVo ratioVo = new RatioVo(); if(StringUtils.isBlank(busDiscountRatio)){ - return new RatioVo(); + return ratioVo; } - RatioVo ratioVo = new RatioVo(); BigDecimal revenue = new BigDecimal(revenueLong).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); List ratioList = JSONArray.parseArray(busDiscountRatio, String.class); From 813f3e531e7477058f895e12cf70e9277c44f50e Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 22 Aug 2019 14:00:59 +0800 Subject: [PATCH 15/19] =?UTF-8?q?[=E6=B4=BB=E5=8A=A8=E6=8A=A5=E5=90=8D][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E7=AD=BE=E5=88=B0=E6=8F=90=E7=A4=BA]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/common/ErrorCode.java | 2 ++ .../service/impl/WxActivityJoinServiceImpl.java | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index 19ad4739e..e7cc69584 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -489,6 +489,8 @@ public enum ErrorCode{ ACTIVITY_SEND_ERROR(30004, "活动投放到宣传页失败,宣传页显示已达七条上限!"), ACTIVITY_TIME_ERROR(30005, "活动报名结束时间不能大于活动结束时间"), ACTIVITY_WAIT_CONFIRMED(30006, "您报名的活动还在审核中"), + ACTIVITY_EXPIRED(30007, "您报名的活动已过期"), + /** * 文件上传 */ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java index f771563b9..177711dc7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java @@ -204,16 +204,17 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { if (activityJoin == null) { return new ResultData(ErrorCode.ACTIVITY_JOIN_NOT_FOUND); } - wxActivityJoin.setStatus(EnumActivityJoinStatus.CONFIRMED.getCode()); - activityJoin = wxActivityJoinMapper.selectOne(wxActivityJoin); - if (activityJoin == null) { + if (activityJoin.getStatus().equals(EnumActivityJoinStatus.NOT_CONFIRMED.getCode())) { return new ResultData(ErrorCode.ACTIVITY_WAIT_CONFIRMED); } - activityJoin.setSignIn(EnumActivityJoinSignStatus.YES.getCode()); - wxActivityJoinMapper.updateByPrimaryKeySelective(activityJoin); - //查询活动名称 - WxActivity activity = wxActivityMapper.selectByPrimaryKey(wxActivityJoin.getActivityId()); - return new ResultData(Result.SUCCESS, "签到成功", activity.getTitle()); + if (activityJoin.getStatus().equals(EnumActivityJoinStatus.CONFIRMED.getCode())) { + activityJoin.setSignIn(EnumActivityJoinSignStatus.YES.getCode()); + wxActivityJoinMapper.updateByPrimaryKeySelective(activityJoin); + //查询活动名称 + WxActivity activity = wxActivityMapper.selectByPrimaryKey(wxActivityJoin.getActivityId()); + return new ResultData(Result.SUCCESS, "签到成功", activity.getTitle()); + } + return new ResultData(ErrorCode.ACTIVITY_EXPIRED); } private void sendMessage(WxActivityJoin join, WxActivity activity) { From eda8682a47c98a84773d6d4a65744d70cfd35eaf Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 22 Aug 2019 14:22:42 +0800 Subject: [PATCH 16/19] =?UTF-8?q?[=E7=94=B5=E8=A1=A8=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/PowerBillAutoBuildSchedule.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java index 9b7e935ce..92be3c8bd 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/PowerBillAutoBuildSchedule.java @@ -1,5 +1,6 @@ package com.iformall.schedule; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.iformall.domain.dto.KwMeterDataDto; import com.iformall.domain.po.*; @@ -91,35 +92,45 @@ public class PowerBillAutoBuildSchedule { Date lastdate = monthDate.get("lastdate"); MallUserInfo mallUserInfo = getMallUserInfo(); WxBillDaily wxBillDaily = getBillDaily(wxMerchantPowerBillConfig); - JSONObject priceDetal = new JSONObject(); Date receiveDate = getReceiveDate(Integer.parseInt(wxPowerBillAutoConfig.getReceiveDay())); - long receivePay = 0L; + long receivePay; + String unitPrice; + long usedPower = 0L; Long merchantId = wxMerchantPowerBillConfig.getMerchantId(); if (wxMerchantPowerBillConfig.getBuildWay().equals(EnumPowerBillBuildWay.METER.getCode())) { //根据日期拉取电量 单价 * 电量 = 电费 - int usedPower = getUsedPower(startdate, lastdate, merchantId); + usedPower = getUsedPower(startdate, lastdate, merchantId); if (usedPower == 0) { logger.info("没有电量使用,不生成账单>>>>商户ID:" + merchantId); return; } - String price = wxMerchantPowerBillConfig.getPrice(); - priceDetal.put("unitPrice", price); - priceDetal.put("power", usedPower); - receivePay = new BigDecimal(price).multiply(new BigDecimal(100)) + //按电表 单价从商户配置表中取 因为会修改 + unitPrice = wxMerchantPowerBillConfig.getPrice(); + receivePay = new BigDecimal(unitPrice).multiply(new BigDecimal(100)) .multiply(new BigDecimal(usedPower)).longValue(); } else { - String unitPrice = wxPowerBillAutoConfig.getUnitPrice(); + //按固定金额 单位从统一配置表中取 + unitPrice = wxPowerBillAutoConfig.getUnitPrice(); String price = wxMerchantPowerBillConfig.getPrice(); - priceDetal.put("unitPrice", unitPrice); - priceDetal.put("power", 0); receivePay = new BigDecimal(price).multiply(new BigDecimal(100)).longValue(); } + + JSONArray priceDetals = new JSONArray(); + JSONObject priceDetal = new JSONObject(); + priceDetal.put("key", "unitPrice"); + priceDetal.put("value", unitPrice); + priceDetals.add(priceDetal); + priceDetal = new JSONObject(); + priceDetal.put("key", "power"); + priceDetal.put("value", usedPower); + priceDetals.add(priceDetal); + wxBillDaily.setReceivePay(receivePay); wxBillDaily.setNeedPay(receivePay); wxBillDaily.setReceiveDate(receiveDate); wxBillDaily.setStarttime(startdate); wxBillDaily.setEndtime(enddate); - wxBillDaily.setPriceDetail(priceDetal.toJSONString()); + wxBillDaily.setPriceDetail(priceDetals.toJSONString()); wxBillDailyService.saveOrUpdate(wxBillDaily, mallUserInfo); } From 05982cc5c09ceeffa675e8a8a5469a16332ff904 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 22 Aug 2019 14:42:37 +0800 Subject: [PATCH 17/19] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=B4=A6=E5=8D=95=E7=BB=93=E7=AE=97]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V201908221440__L_CONTRACT.sql | 2 + .../service/impl/WxBillRentServiceImpl.java | 39 ++++++----- .../impl/WxRentContractServiceImpl.java | 65 +++++++++++-------- 3 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V201908221440__L_CONTRACT.sql diff --git a/mallinkAdmin/src/main/resources/db/migration/V201908221440__L_CONTRACT.sql b/mallinkAdmin/src/main/resources/db/migration/V201908221440__L_CONTRACT.sql new file mode 100644 index 000000000..bbd20f642 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201908221440__L_CONTRACT.sql @@ -0,0 +1,2 @@ +alter table wx_bill_rent +add column `bus_discount_ratio` int(5) NULL DEFAULT NULL COMMENT '连营扣点跳点率'; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index a83629168..bef858971 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -283,25 +283,28 @@ public class WxBillRentServiceImpl implements WxBillRentService { wxBillRent.setRevenue(record.getRevenue()); Integer ratio = 0; - if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ - long dayCount = DateUtils.startToEnd(record.getStarttime(),record.getEndtime()); - - if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ - if(startInt == endInt && months == 12){ - //刚好1年 - ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); - }else{ - ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount,0).getRatio(); - } - }else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ - if(startInt == endInt && months == 1){ - //刚好1个月 - ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); - }else{ - ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount,0).getRatio(); + if(wxRentContract.getPayRatio() != null){ + ratio = wxRentContract.getPayRatio(); + }else{ + if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ + long dayCount = DateUtils.startToEnd(record.getStarttime(),record.getEndtime()); + if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ + if(startInt == endInt && months == 12){ + //刚好1年 + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); + }else{ + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount,0).getRatio(); + } + }else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ + if(startInt == endInt && months == 1){ + //刚好1个月 + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0).getRatio(); + }else{ + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount,0).getRatio(); + } + }else if(EnumBusRatioTime.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())){ + ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.PERIOD.getCode(),dayCount,wxRentContract.getReceivePeriod()).getRatio(); } - }else if(EnumBusRatioTime.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())){ - ratio = WxRentContractServiceImpl.getPayRatio(EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.PERIOD.getCode(),dayCount,wxRentContract.getReceivePeriod()).getRatio(); } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index eb24b22e9..46ef1f505 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -338,6 +338,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { return ratioVo; } + /** + * 计算金额 + * @param ratio + * @param revenueLong + * @return + */ + public Long countPrice(Integer ratio,Long revenueLong){ + BigDecimal hundred = new BigDecimal(100); + BigDecimal revenue = new BigDecimal(revenueLong == null ? 0 : revenueLong).divide(hundred); + BigDecimal payRatio = new BigDecimal(ratio == null ? 0 : ratio).divide(new BigDecimal(10000)); + BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); + return price.multiply(hundred).longValue(); + } + @Transactional(rollbackFor = {Exception.class}) @Override public ResultData save(WxRentContract record,Long userId,String userName,Date oldRentStartDate) { @@ -361,23 +375,21 @@ public class WxRentContractServiceImpl implements WxRentContractService { } if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - if(record.getRevenue() == null || record.getRevenue().longValue() <=0){ + if(record.getRevenue() == null || record.getRevenue().longValue() <= 0){ record.setPrice(0l); }else{ - int dayCount = record.getReceivePeriod() * 30; - RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod()); - record.setPayRatio(ratioVo.getRatio()); - BigDecimal hundred = new BigDecimal(100); - BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); - BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - - BigDecimal price; - if(ratioVo.getBalance() != null){ - //计算超出部分 - record.setPrice(ratioVo.getBalance().longValue()); + if(record.getPayRatio()!=null){ + record.setPrice(countPrice(record.getPayRatio(),record.getRevenue())); }else{ - price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); - record.setPrice(price.multiply(hundred).longValue()); + int dayCount = record.getReceivePeriod() * 30; + RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod()); + record.setPayRatio(ratioVo.getRatio()); + if(ratioVo.getBalance() != null){ + //有超出部分,在getPayRatio里计算 + record.setPrice(ratioVo.getBalance().longValue()); + }else{ + record.setPrice(countPrice(record.getPayRatio(),record.getRevenue())); + } } } } else { @@ -605,19 +617,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(!EnumFromType.SWITCH.getCode().equals(from)){ if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - int dayCount = record.getReceivePeriod() * 30; - RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,wxRentContract.getReceivePeriod()); - record.setPayRatio(ratioVo.getRatio()); - BigDecimal hundred = new BigDecimal(100); - BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); - BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); - - BigDecimal price; - if(ratioVo.getBalance() != null){ - record.setPrice(ratioVo.getBalance().longValue()); - }else { - price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); - record.setPrice(price.multiply(hundred).longValue()); + if(record.getPayRatio()!=null){ + record.setPrice(countPrice(record.getPayRatio(),record.getRevenue())); + }else{ + int dayCount = record.getReceivePeriod() * 30; + RatioVo ratioVo = getPayRatio(EnumGetRatioFrom.RENT.getCode(),record.getRevenue(),record.getBusDiscountRatio(),record.getBusDiscountTime(),dayCount,record.getReceivePeriod()); + record.setPayRatio(ratioVo.getRatio()); + if(ratioVo.getBalance() != null){ + //有超出部分,在getPayRatio里计算 + record.setPrice(ratioVo.getBalance().longValue()); + }else{ + record.setPrice(countPrice(record.getPayRatio(),record.getRevenue())); + } } } else { if (StringUtils.isNotEmpty(record.getPriceStr())) { From fda5ab7f0c4bacff57519a39339c186b551cffed Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 22 Aug 2019 14:45:34 +0800 Subject: [PATCH 18/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:B=E7=AB=AF?= =?UTF-8?q?=E8=81=94=E8=B0=83-POS=E5=88=B8=E7=8B=AC=E7=AB=8B=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PosOrderController.java | 4 +- .../iformall/controller/WxPosController.java | 261 +--------- .../com/iformall/service/PosBrunService.java | 451 ++++++++++++++++++ .../main/java/com/iformall/utils/PosUtil.java | 14 +- .../iformall/service/impl/PosServiceImpl.java | 17 +- .../java/com/iformall/domain/po/PosOrder.java | 2 +- .../com/iformall/domain/po/PosPayOrder.java | 2 +- .../iformall/enums/EnumPosOrderStatus.java | 47 ++ .../com/iformall/enums/EnumPosOrderType.java | 2 +- .../com/iformall/enums/EnumPosPayType.java | 38 ++ .../java/com/iformall/pay/WxPayConstant.java | 8 + 11 files changed, 598 insertions(+), 248 deletions(-) create mode 100644 mallinkBApi/src/main/java/com/iformall/service/PosBrunService.java create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumPosOrderStatus.java create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumPosPayType.java diff --git a/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java index d63db0f8d..4298e6716 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosOrderController.java @@ -1,7 +1,8 @@ package com.iformall.controller; import com.iformall.common.ErrorCode; -import com.iformall.enums.EnumPosOrderType; +import com.iformall.service.PosBrunService; +import com.iformall.service.PosPayOrderService; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import org.slf4j.Logger; @@ -26,6 +27,7 @@ import io.swagger.annotations.ApiOperation; public class PosOrderController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private final PosOrderService posOrderService; @ApiOperation("分页列表接口") diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java index ee5072ee7..abb5300be 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java @@ -1,15 +1,11 @@ package com.iformall.controller; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.iformall.common.ErrorCode; -import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.exception.MallinkException; import com.iformall.pay.WxPayConstant; -import com.iformall.pay.WxPayment; -import com.iformall.utils.PosUtil; +import com.iformall.service.PosBrunService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -27,36 +23,12 @@ public class WxPosController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired - private String posDevId; - - @Autowired - private String posReqKey; - - @Autowired - private String posResKey; - - @Autowired - private String posUrl; - - PosUtil posUtil = new PosUtil(); + private PosBrunService posService; @ApiOperation(value = "检查POS Server是否正常", notes = "") @GetMapping("checkAvaiable") public ResultData checkAvaiable() { - try { - String resStr = posUtil.checkPosMemServer(posUrl); - if (resStr != null) { - return new ResultData(); - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.checkAvaiable(); } @ApiOperation(value = "商户POS用户/B端用户登录检查") @@ -72,79 +44,19 @@ public class WxPosController extends BaseController { if (StringUtils.isBlank(password)) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); } - try { - String resStr = posUtil.checkUserPassword(posUrl, posDevId, posReqKey, - user.getTenantId(), phone, password); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.checkUserPassword(user, phone, password); } @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用") @PostMapping("getPosMemConfig") public ResultData getPosMemConfig() { - try { - String resStr = posUtil.getPosMemConfig(posUrl, posDevId, posReqKey, - getTenantId()); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.getPosMemConfig(getTenantId()); } @ApiOperation(value = "获取注册二维码及小票二维码规则") @PostMapping("getQrCode") public ResultData getQrCode() { - try { - String resStr = posUtil.getQrCode(posUrl, posDevId, posReqKey, - getTenantId()); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.getQrCode(getTenantId()); } @ApiOperation(value = "会员识别") @@ -172,80 +84,22 @@ public class WxPosController extends BaseController { logger.error(errMessage); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); } - try { - String resStr = posUtil.checkMem(posUrl, posDevId, posReqKey, - user.getTenantId(), String.valueOf(user.getMerchantId()), - memIdStr, memPhoneStr, posOrderIdStr, posAmountStr); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.checkMem(user, memIdStr, memPhoneStr, posOrderIdStr, posAmountStr); } - @ApiOperation(value = "券核销检查") - @PostMapping("checkCouponOrderForVerify") - public ResultData checkCouponOrderForVerify(@RequestBody Map params) { + @ApiOperation(value = "券独立核销检查") + @PostMapping("checkCouponOrderForIndepentVerify") + public ResultData checkCouponOrderForIndepentVerify(@RequestBody Map params) { WxMerchantBUser user = getUser(); String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID - String verifyType = params.get(WxPayConstant.VERIFY_TYPE); // 核销类型 - String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID - String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) if (StringUtils.isBlank(couponOrderIdStr)) { String errMessage = "request params[coupon_order_id] error."; logger.error(errMessage); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); } - if (StringUtils.isBlank(verifyType)) { - String errMessage = "request params[verify_type] error."; - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); - } - if (StringUtils.isBlank(posOrderIdStr)) { - String errMessage = "request params[pos_order_id] error."; - logger.error(errMessage); - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); - } - if (StringUtils.isBlank(posAmountStr)) { - String errMessage = "request params[pos_amount] error."; - logger.error(errMessage); - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); - } - try { - String resStr = posUtil.checkCouponOrderForVerify(posUrl, posDevId, posReqKey, - user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), - couponOrderIdStr, verifyType, posOrderIdStr, posAmountStr); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + String verifyType = WxPayConstant.VERIFY_TYPE_INDEPENT; + return posService.checkCouponOrderForIndepentVerify(user, verifyType, couponOrderIdStr); } @ApiOperation(value = "券预核销") @@ -271,28 +125,7 @@ public class WxPosController extends BaseController { logger.error(errMessage); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); } - try { - String resStr = posUtil.couponOrderPreVerify(posUrl, posDevId, posReqKey, - user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), - couponOrderIdStr, posOrderIdStr, posAmountStr); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.couponOrderPreVerify(user, couponOrderIdStr, posOrderIdStr, posAmountStr); } @ApiOperation(value = "券预核销取消") @@ -318,69 +151,21 @@ public class WxPosController extends BaseController { logger.error(errMessage); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); } - try { - String resStr = posUtil.couponOrderPreVerifyCancel(posUrl, posDevId, posReqKey, - user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), - couponOrderIdStr, posOrderIdStr, posAmountStr); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); - } + return posService.couponOrderPreVerifyCancel(user, couponOrderIdStr, posOrderIdStr, posAmountStr); } - @ApiOperation(value = "券独立核销") - @PostMapping("couponOrderIndependentVerify") - public ResultData couponOrderIndependentVerify(@RequestBody Map params) { + @ApiOperation(value = "券独立核销", notes = "{\"couponOrderId\":\"string\", \"payment\":\"string(单位:分)\"}") + @PostMapping("posVerifyIndepent") + public ResultData posVerifyIndepent(@RequestBody Map params) { WxMerchantBUser user = getUser(); - String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID - String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID - - if (StringUtils.isBlank(couponOrderIdStr)) { - String errMessage = "request params[coupon_order_id] error."; - logger.error(errMessage); - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); - } - if (StringUtils.isBlank(posOrderIdStr)) { - String errMessage = "request params[pos_order_id] error."; + String couponOrderId = params.get("coupon_order_id"); + String payment = params.get("payment"); + if (StringUtils.isBlank(couponOrderId)) { + String errMessage = "券ID为空"; logger.error(errMessage); - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); - } - try { - String resStr = posUtil.couponOrderIndependentVerify(posUrl, posDevId, posReqKey, - user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), - couponOrderIdStr, posOrderIdStr); - if (resStr != null) { - JSONObject retObj = JSON.parseObject(resStr); - Map options = retObj; - if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { - return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); - } else { - return new ResultData(resStr); - } - } else { - return new ResultData(Result.ERROR, "无返回值"); - } - } catch (MallinkException e) { - logger.error(e.getMessage()); - return new ResultData(e.getErrorCode(), e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - return new ResultData(Result.ERROR, e.getMessage()); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); } + return posService.posVerifyIndepent(user, couponOrderId, payment); } @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") diff --git a/mallinkBApi/src/main/java/com/iformall/service/PosBrunService.java b/mallinkBApi/src/main/java/com/iformall/service/PosBrunService.java new file mode 100644 index 000000000..a1a1601e9 --- /dev/null +++ b/mallinkBApi/src/main/java/com/iformall/service/PosBrunService.java @@ -0,0 +1,451 @@ +package com.iformall.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.iformall.common.ErrorCode; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.domain.po.PosOrder; +import com.iformall.domain.po.PosPayOrder; +import com.iformall.domain.po.WxMerchantBUser; +import com.iformall.enums.EnumPosOrderStatus; +import com.iformall.enums.EnumPosOrderType; +import com.iformall.enums.EnumPosPayType; +import com.iformall.exception.MallinkException; +import com.iformall.pay.WxPayConstant; +import com.iformall.pay.WxPayment; +import com.iformall.utils.PosUtil; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.Date; +import java.util.Map; + +@Service +public class PosBrunService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private String posDevId; + + @Autowired + private String posReqKey; + + @Autowired + private String posResKey; + + @Autowired + private String posUrl; + + @Autowired + private PosOrderService posOrderService; + + @Autowired + private PosPayOrderService posPayOrderService; + + PosUtil posUtil = new PosUtil(); + + /** + * 检查POS Server是否正常 + * @return + */ + public ResultData checkAvaiable() { + try { + String resStr = posUtil.checkPosMemServer(posUrl); + if (resStr != null) { + return new ResultData(); + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 商户POS用户/B端用户登录检查 + * @param user + * @param phone + * @param password + * @return + */ + public ResultData checkUserPassword(WxMerchantBUser user, String phone, String password) { + try { + String resStr = posUtil.checkUserPassword(posUrl, posDevId, posReqKey, + user.getTenantId(), phone, password); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 获取会员折扣/优惠券/消费卡是否启用 + * @param tenantId + * @return + */ + public ResultData getPosMemConfig(String tenantId) { + try { + String resStr = posUtil.getPosMemConfig(posUrl, posDevId, posReqKey, tenantId); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 获取注册二维码及小票二维码规则 + * @param tenantId + * @return + */ + public ResultData getQrCode(String tenantId) { + try { + String resStr = posUtil.getQrCode(posUrl, posDevId, posReqKey, tenantId); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 会员识别 + * @param user + * @param memIdStr + * @param memPhoneStr + * @param posOrderIdStr + * @param posAmountStr + * @return + */ + public ResultData checkMem(WxMerchantBUser user, + String memIdStr, String memPhoneStr, + String posOrderIdStr, String posAmountStr) { + try { + String resStr = posUtil.checkMem(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), + memIdStr, memPhoneStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 券独立核销检查 + * @param user + * @param verifyType + * @param couponOrderIdStr + * @return + */ + public ResultData checkCouponOrderForIndepentVerify(WxMerchantBUser user, + String verifyType, + String couponOrderIdStr) { + try { + String resStr = posUtil.checkCouponOrderForVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + verifyType, couponOrderIdStr, null, null); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 券独立核销检查 + * @param user + * @param verifyType + * @param couponOrderIdStr + * @param posOrderIdStr + * @param posAmountStr + * @return + */ + public ResultData checkCouponOrderForVerify(WxMerchantBUser user, + String verifyType, + String couponOrderIdStr, + String posOrderIdStr, String posAmountStr) { + try { + String resStr = posUtil.checkCouponOrderForVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, verifyType, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 券预核销 + * @param user + * @param couponOrderIdStr + * @param posOrderIdStr + * @param posAmountStr + * @return + */ + public ResultData couponOrderPreVerify(WxMerchantBUser user, + String couponOrderIdStr, + String posOrderIdStr, String posAmountStr) { + try { + String resStr = posUtil.couponOrderPreVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 券预核销取消 + * @param user + * @param couponOrderIdStr + * @param posOrderIdStr + * @param posAmountStr + * @return + */ + public ResultData couponOrderPreVerifyCancel(WxMerchantBUser user, + String couponOrderIdStr, + String posOrderIdStr, String posAmountStr) { + try { + String resStr = posUtil.couponOrderPreVerifyCancel(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr, posAmountStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + /** + * 券独立核销 + * @param user + * @param couponOrderIdStr + * @param posOrderIdStr + * @return + */ + public ResultData couponOrderIndependentVerify(WxMerchantBUser user, String couponOrderIdStr, String posOrderIdStr) { + try { + String resStr = posUtil.couponOrderIndependentVerify(posUrl, posDevId, posReqKey, + user.getTenantId(), String.valueOf(user.getMerchantId()), String.valueOf(user.getId()), + couponOrderIdStr, posOrderIdStr); + if (resStr != null) { + JSONObject retObj = JSON.parseObject(resStr); + Map options = retObj; + if (!WxPayment.verifyNotifyHMAC(options, posResKey)) { + return new ResultData(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); + } else { + return new ResultData(resStr); + } + } else { + return new ResultData(Result.ERROR, "无返回值"); + } + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + } + + public ResultData posVerifyIndepent(WxMerchantBUser user, String couponOrderId, String payment) { + // 1. 创建 POS订单 + PosOrder posOrder = new PosOrder(); + posOrder.setTenantId(user.getTenantId()); + posOrder.setType(EnumPosOrderType.VERIFY_INDEPENDENT.getCode()); + posOrder.setBuUserId(user.getId()); + posOrder.setOrderStatus(EnumPosOrderStatus.PENDING_VERIFY.getCode()); + posOrder.setPaymentType(EnumPosPayType.PAY_VERIFY_INDEPENT.getCode()); + if (StringUtils.isNotBlank(payment)) { + posOrder.setPayment(Integer.valueOf(payment)); + } + try { + posOrderService.saveOrUpdate(posOrder); + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + // 2. 创建 POS支付订单 + Date curDate = new Date(); + PosPayOrder posPayOrder = new PosPayOrder(); + posPayOrder.setTenantId(user.getTenantId()); + posPayOrder.setBuUserId(user.getId()); + posPayOrder.setOrderId(posOrder.getId()); + posPayOrder.setType(EnumPosPayType.PAY_VERIFY_INDEPENT.getCode()); + posPayOrder.setPayTimeStart(curDate); + posPayOrder.setPayTimeEnd(curDate); + posPayOrder.setPayOrderNo(couponOrderId); + posPayOrder.setPayOrderStatus(EnumPosOrderStatus.PENDING_VERIFY.getCode()); + posPayOrder.setCreateTime(curDate); + posPayOrder.setUpdateTime(curDate); + try { + posPayOrderService.saveOrUpdate(posPayOrder); + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + + // 3. POS支付订单支付 + try { + couponOrderIndependentVerify(user, couponOrderId, posOrder.getPosOrderNo()); + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + + try { + PosPayOrder updateOrder = new PosPayOrder(); + updateOrder.setId(posPayOrder.getId()); + updateOrder.setPayOrderStatus(EnumPosOrderStatus.VERIFY_SUCCESS.getCode()); + posPayOrderService.saveOrUpdate(posPayOrder); + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + + // 4. POS订单支付 + try { + PosOrder updateOrder = new PosOrder(); + updateOrder.setId(posOrder.getId()); + posOrder.setOrderStatus(EnumPosOrderStatus.VERIFY_SUCCESS.getCode()); + posOrderService.saveOrUpdate(posOrder); + } catch (MallinkException e) { + logger.error(e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); + } + return new ResultData(); + } +} diff --git a/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java b/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java index a7a6217aa..c5a8e57eb 100755 --- a/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java +++ b/mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java @@ -254,25 +254,29 @@ public class PosUtil { * @param tenantId * @param merchantId * @param buUserId - * @param couponOrderId * @param verifyType + * @param couponOrderId * @param posOrderId * @param posAmount * @return 券是否可核销 */ public String checkCouponOrderForVerify(String baseUrl, String devId, String reqKey, String tenantId, String merchantId, String buUserId, - String couponOrderId, String verifyType, + String verifyType, String couponOrderId, String posOrderId, String posAmount) throws MallinkException { Map paramMap = new HashMap<>(); paramMap.put(WxPayConstant.DEV_ID, devId); paramMap.put(WxPayConstant.TENANT_ID, tenantId); paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); paramMap.put(WxPayConstant.BUSER_ID, buUserId); - paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); paramMap.put(WxPayConstant.VERIFY_TYPE, verifyType); - paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); - paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); + paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); + if (StringUtils.isNotBlank(posOrderId)) { + paramMap.put(WxPayConstant.POS_ORDER_ID, posOrderId); + } + if (StringUtils.isNotBlank(posAmount)) { + paramMap.put(WxPayConstant.POS_AMOUNT, posAmount); + } paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); String respStr = doPost(baseUrl + URL_CheckCouponOrderForVerify, paramMap); diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index cd2e9be77..5d53f3f77 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -13,7 +13,6 @@ import com.iformall.mapper.WxCouponMapper; import com.iformall.mapper.WxCouponMerchantMapper; import com.iformall.mapper.WxCouponOrderMapper; import com.iformall.mapper.WxOrderMapper; -import com.iformall.pay.WxPay; import com.iformall.pay.WxPayConstant; import com.iformall.service.*; import lombok.AllArgsConstructor; @@ -24,6 +23,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -53,6 +53,9 @@ public class PosServiceImpl implements PosService { private final WxCouponMerchantMapper couponMerchantMapper; private final WxCouponMapper couponMapper; + + private final SimpleDateFormat mydateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + /** * 门店用户登录检查 * @param params @@ -711,11 +714,23 @@ public class PosServiceImpl implements PosService { logger.info("券可以被核销: " + couponOrderIdStr); retMap.put(WxPayConstant.ID, couponOrderIdStr); retMap.put(WxPayConstant.CHECK, WxPayConstant.TRUE); + retMap.put(WxPayConstant.MEM_ID, String.valueOf(couponOrderCVo.getCUserId())); + retMap.put(WxPayConstant.TITLE, couponOrderCVo.getTitle()); + retMap.put(WxPayConstant.COVER_IMG, couponOrderCVo.getCoverImg()); + retMap.put(WxPayConstant.EXPIRE_TIME, mydateFormat.format(couponOrderCVo.getExpiredTime())); + retMap.put(WxPayConstant.PRICE, String.valueOf(couponOrderCVo.getPrice())); + retMap.put(WxPayConstant.STATUS, EnumCouponOrderStatus.getEnum(couponOrderCVo.getCouponOrderStatus()).getMessage()); return retMap; } else if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())) { logger.info("券可以被核销: " + couponOrderIdStr); retMap.put(WxPayConstant.ID, couponOrderIdStr); retMap.put(WxPayConstant.CHECK, WxPayConstant.TRUE); + retMap.put(WxPayConstant.MEM_ID, String.valueOf(couponOrderCVo.getCUserId())); + retMap.put(WxPayConstant.TITLE, couponOrderCVo.getTitle()); + retMap.put(WxPayConstant.COVER_IMG, couponOrderCVo.getCoverImg()); + retMap.put(WxPayConstant.EXPIRE_TIME, mydateFormat.format(couponOrderCVo.getExpiredTime())); + retMap.put(WxPayConstant.PRICE, String.valueOf(couponOrderCVo.getPrice())); + retMap.put(WxPayConstant.STATUS, EnumCouponOrderStatus.getEnum(couponOrderCVo.getCouponOrderStatus()).getMessage()); return retMap; } } else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY)) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java index 190bfcd18..d1fe3ec3f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/PosOrder.java @@ -29,7 +29,7 @@ public class PosOrder implements Serializable { private Integer orderStatus; @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") private Long buUserId; - @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款 2:自动退款 3:A端退款",name="paymentType") + @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款 2:自动退款 3:A端退款 10.核销",name="paymentType") private Integer paymentType; @io.swagger.annotations.ApiModelProperty(value="支付金额:允许有负数,退款时为负值。核销时,金额可以不填写",name="paymentType") private Integer payment; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java index afe44f95f..a837da83f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/PosPayOrder.java @@ -32,7 +32,7 @@ public class PosPayOrder implements Serializable { private Long buUserId; @io.swagger.annotations.ApiModelProperty(value="支付类型(1:独立核销 2:支付核销 3:现金支付)",name="type") private Integer type; - @io.swagger.annotations.ApiModelProperty(value="支付来源(0: 现金, 1:微信 2:支付核销 3:现金支付)",name="payFrom") + @io.swagger.annotations.ApiModelProperty(value="支付来源(0: 现金, 1:微信 2:支付核销 3:现金支付, 10:券)",name="payFrom") private Integer payFrom; @io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payAmount") private Integer payAmount; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderStatus.java new file mode 100644 index 000000000..3d5db965c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderStatus.java @@ -0,0 +1,47 @@ +package com.iformall.enums; + + +/** + * @author Stormeye + */ + +public enum EnumPosOrderStatus { + + PENDING_PAYMENT(0, "待付款"), + PAYMENT_SUCCESS(1, "已支付"), + OVERTIME_CANCEL(2, "已取消"), + PENDING_REFUND(3, "待退款"), + REFUND_SUCCESS(4,"已退款"), + REFUND_FAILD(5, "退款失败"), + PENDING_VERIFY(10, "待核销"), + VERIFY_SUCCESS(11, "已核销"), + VERIFY_CANCEL(12, "核销待退"), + VERIFY_CANCELED(13, "核销已退") + ; + + + public static EnumPosOrderStatus getEnum(Integer code) { + for (EnumPosOrderStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPosOrderStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java index 6dc086784..035ce0fac 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPosOrderType.java @@ -2,7 +2,7 @@ package com.iformall.enums; /** - * @author gongbiao + * @author Stormeye */ public enum EnumPosOrderType { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPosPayType.java b/mallinkService/src/main/java/com/iformall/enums/EnumPosPayType.java new file mode 100644 index 000000000..6775daf55 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPosPayType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumPosPayType { + + PAY_PAYMENT(0, "付款"), + PAY_B_REFUND(1, "B端退款"), + PAY_AUTO_REFUND(2, "自动退款"), + PAY_ADMIN_REFUND(3, "A端退款"), + PAY_VERIFY_INDEPENT(10, "核销"), + ; + public static EnumPosPayType getEnum(Integer code) { + for (EnumPosPayType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPosPayType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java b/mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java index 80dc3ed4a..8d2cf8628 100644 --- a/mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java +++ b/mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java @@ -32,6 +32,14 @@ public class WxPayConstant { public final static String PHONE = "phone"; public final static String PASSWORD = "password"; + public final static String TITLE = "title"; + public final static String COVER_IMG = "cover_img"; + public final static String EXPIRE_TIME = "expire_time"; + public final static String VALID_START_DATE = "valid_start_date"; + public final static String VALID_END_DATE = "valid_end_date"; + public final static String PRICE = "price"; + public final static String STATUS = "status"; + public final static String VERIFY_TYPE = "verify_type"; public final static String VERIFY_TYPE_INDEPENT = "independent"; public final static String VERIFY_TYPE_PAY = "pay"; From 9de1e1ac829a3fb7d5e5028b9d467c478be38824 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 22 Aug 2019 14:46:13 +0800 Subject: [PATCH 19/19] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:B=E7=AB=AF?= =?UTF-8?q?=E8=81=94=E8=B0=83-POS=E5=88=B8=E7=8B=AC=E7=AB=8B=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/{WxPosController.java => PosController.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename mallinkBApi/src/main/java/com/iformall/controller/{WxPosController.java => PosController.java} (99%) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java b/mallinkBApi/src/main/java/com/iformall/controller/PosController.java similarity index 99% rename from mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java rename to mallinkBApi/src/main/java/com/iformall/controller/PosController.java index abb5300be..bde3a1398 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxPosController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/PosController.java @@ -19,7 +19,7 @@ import java.util.Map; @RestController @RequestMapping("/api/pos") @Api(description = "POS服务相关接口") -public class WxPosController extends BaseController { +public class PosController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired