| @@ -1,7 +1,8 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ErrorCode; | 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 io.swagger.annotations.Api; | ||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -26,6 +27,7 @@ import io.swagger.annotations.ApiOperation; | |||||
| public class PosOrderController extends BaseController { | public class PosOrderController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| private final PosOrderService posOrderService; | private final PosOrderService posOrderService; | ||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @@ -1,15 +1,11 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMerchantBUser; | import com.iformall.domain.po.WxMerchantBUser; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.pay.WxPayConstant; | 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.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -27,36 +23,12 @@ public class WxPosController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @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 = "") | @ApiOperation(value = "检查POS Server是否正常", notes = "") | ||||
| @GetMapping("checkAvaiable") | @GetMapping("checkAvaiable") | ||||
| public ResultData 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端用户登录检查") | @ApiOperation(value = "商户POS用户/B端用户登录检查") | ||||
| @@ -72,79 +44,19 @@ public class WxPosController extends BaseController { | |||||
| if (StringUtils.isBlank(password)) { | if (StringUtils.isBlank(password)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | 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 = "获取会员折扣/优惠券/消费卡是否启用") | @ApiOperation(value = "获取会员折扣/优惠券/消费卡是否启用") | ||||
| @PostMapping("getPosMemConfig") | @PostMapping("getPosMemConfig") | ||||
| public ResultData 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 = "获取注册二维码及小票二维码规则") | @ApiOperation(value = "获取注册二维码及小票二维码规则") | ||||
| @PostMapping("getQrCode") | @PostMapping("getQrCode") | ||||
| public ResultData 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 = "会员识别") | @ApiOperation(value = "会员识别") | ||||
| @@ -172,80 +84,22 @@ public class WxPosController extends BaseController { | |||||
| logger.error(errMessage); | logger.error(errMessage); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), 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<String, String> params) { | |||||
| @ApiOperation(value = "券独立核销检查") | |||||
| @PostMapping("checkCouponOrderForIndepentVerify") | |||||
| public ResultData checkCouponOrderForIndepentVerify(@RequestBody Map<String, String> params) { | |||||
| WxMerchantBUser user = getUser(); | WxMerchantBUser user = getUser(); | ||||
| String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券包ID | 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)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| String errMessage = "request params[coupon_order_id] error."; | String errMessage = "request params[coupon_order_id] error."; | ||||
| logger.error(errMessage); | logger.error(errMessage); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), 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 = "券预核销") | @ApiOperation(value = "券预核销") | ||||
| @@ -271,28 +125,7 @@ public class WxPosController extends BaseController { | |||||
| logger.error(errMessage); | logger.error(errMessage); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), 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 = "券预核销取消") | @ApiOperation(value = "券预核销取消") | ||||
| @@ -318,69 +151,21 @@ public class WxPosController extends BaseController { | |||||
| logger.error(errMessage); | logger.error(errMessage); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), 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<String, String> params) { | |||||
| @ApiOperation(value = "券独立核销", notes = "{\"couponOrderId\":\"string\", \"payment\":\"string(单位:分)\"}") | |||||
| @PostMapping("posVerifyIndepent") | |||||
| public ResultData posVerifyIndepent(@RequestBody Map<String, String> params) { | |||||
| WxMerchantBUser user = getUser(); | 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); | 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\"}") | @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") | ||||
| @@ -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(); | |||||
| } | |||||
| } | |||||
| @@ -254,25 +254,29 @@ public class PosUtil { | |||||
| * @param tenantId | * @param tenantId | ||||
| * @param merchantId | * @param merchantId | ||||
| * @param buUserId | * @param buUserId | ||||
| * @param couponOrderId | |||||
| * @param verifyType | * @param verifyType | ||||
| * @param couponOrderId | |||||
| * @param posOrderId | * @param posOrderId | ||||
| * @param posAmount | * @param posAmount | ||||
| * @return 券是否可核销 | * @return 券是否可核销 | ||||
| */ | */ | ||||
| public String checkCouponOrderForVerify(String baseUrl, String devId, String reqKey, | public String checkCouponOrderForVerify(String baseUrl, String devId, String reqKey, | ||||
| String tenantId, String merchantId, String buUserId, | String tenantId, String merchantId, String buUserId, | ||||
| String couponOrderId, String verifyType, | |||||
| String verifyType, String couponOrderId, | |||||
| String posOrderId, String posAmount) throws MallinkException { | String posOrderId, String posAmount) throws MallinkException { | ||||
| Map<String, String> paramMap = new HashMap<>(); | Map<String, String> paramMap = new HashMap<>(); | ||||
| paramMap.put(WxPayConstant.DEV_ID, devId); | paramMap.put(WxPayConstant.DEV_ID, devId); | ||||
| paramMap.put(WxPayConstant.TENANT_ID, tenantId); | paramMap.put(WxPayConstant.TENANT_ID, tenantId); | ||||
| paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); | paramMap.put(WxPayConstant.MERCHANT_ID, merchantId); | ||||
| paramMap.put(WxPayConstant.BUSER_ID, buUserId); | paramMap.put(WxPayConstant.BUSER_ID, buUserId); | ||||
| paramMap.put(WxPayConstant.COUPON_ORDER_ID, couponOrderId); | |||||
| paramMap.put(WxPayConstant.VERIFY_TYPE, verifyType); | 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); | paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey); | ||||
| String respStr = doPost(baseUrl + URL_CheckCouponOrderForVerify, paramMap); | String respStr = doPost(baseUrl + URL_CheckCouponOrderForVerify, paramMap); | ||||
| @@ -13,7 +13,6 @@ import com.iformall.mapper.WxCouponMapper; | |||||
| import com.iformall.mapper.WxCouponMerchantMapper; | import com.iformall.mapper.WxCouponMerchantMapper; | ||||
| import com.iformall.mapper.WxCouponOrderMapper; | import com.iformall.mapper.WxCouponOrderMapper; | ||||
| import com.iformall.mapper.WxOrderMapper; | import com.iformall.mapper.WxOrderMapper; | ||||
| import com.iformall.pay.WxPay; | |||||
| import com.iformall.pay.WxPayConstant; | import com.iformall.pay.WxPayConstant; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
| @@ -24,6 +23,7 @@ import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | import org.springframework.web.bind.annotation.RequestBody; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -53,6 +53,9 @@ public class PosServiceImpl implements PosService { | |||||
| private final WxCouponMerchantMapper couponMerchantMapper; | private final WxCouponMerchantMapper couponMerchantMapper; | ||||
| private final WxCouponMapper couponMapper; | private final WxCouponMapper couponMapper; | ||||
| private final SimpleDateFormat mydateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||||
| /** | /** | ||||
| * 门店用户登录检查 | * 门店用户登录检查 | ||||
| * @param params | * @param params | ||||
| @@ -711,11 +714,23 @@ public class PosServiceImpl implements PosService { | |||||
| logger.info("券可以被核销: " + couponOrderIdStr); | logger.info("券可以被核销: " + couponOrderIdStr); | ||||
| retMap.put(WxPayConstant.ID, couponOrderIdStr); | retMap.put(WxPayConstant.ID, couponOrderIdStr); | ||||
| retMap.put(WxPayConstant.CHECK, WxPayConstant.TRUE); | 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; | return retMap; | ||||
| } else if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())) { | } else if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())) { | ||||
| logger.info("券可以被核销: " + couponOrderIdStr); | logger.info("券可以被核销: " + couponOrderIdStr); | ||||
| retMap.put(WxPayConstant.ID, couponOrderIdStr); | retMap.put(WxPayConstant.ID, couponOrderIdStr); | ||||
| retMap.put(WxPayConstant.CHECK, WxPayConstant.TRUE); | 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; | return retMap; | ||||
| } | } | ||||
| } else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY)) { | } else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY)) { | ||||
| @@ -29,7 +29,7 @@ public class PosOrder implements Serializable { | |||||
| private Integer orderStatus; | private Integer orderStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") | @io.swagger.annotations.ApiModelProperty(value="b端用户",name="buUserId") | ||||
| private Long 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; | private Integer paymentType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付金额:允许有负数,退款时为负值。核销时,金额可以不填写",name="paymentType") | @io.swagger.annotations.ApiModelProperty(value="支付金额:允许有负数,退款时为负值。核销时,金额可以不填写",name="paymentType") | ||||
| private Integer payment; | private Integer payment; | ||||
| @@ -32,7 +32,7 @@ public class PosPayOrder implements Serializable { | |||||
| private Long buUserId; | private Long buUserId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付类型(1:独立核销 2:支付核销 3:现金支付)",name="type") | @io.swagger.annotations.ApiModelProperty(value="支付类型(1:独立核销 2:支付核销 3:现金支付)",name="type") | ||||
| private Integer 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; | private Integer payFrom; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payAmount") | @io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payAmount") | ||||
| private Integer payAmount; | private Integer payAmount; | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -2,7 +2,7 @@ package com.iformall.enums; | |||||
| /** | /** | ||||
| * @author gongbiao | |||||
| * @author Stormeye | |||||
| */ | */ | ||||
| public enum EnumPosOrderType { | public enum EnumPosOrderType { | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -32,6 +32,14 @@ public class WxPayConstant { | |||||
| public final static String PHONE = "phone"; | public final static String PHONE = "phone"; | ||||
| public final static String PASSWORD = "password"; | 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 = "verify_type"; | ||||
| public final static String VERIFY_TYPE_INDEPENT = "independent"; | public final static String VERIFY_TYPE_INDEPENT = "independent"; | ||||
| public final static String VERIFY_TYPE_PAY = "pay"; | public final static String VERIFY_TYPE_PAY = "pay"; | ||||