| @@ -294,12 +294,9 @@ public class PosController extends BaseController { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| String returnCode = retMap.get(WxPayConstant.RETURN_CODE); | |||
| String resultCode = retMap.get(WxPayConstant.RESULT_CODE); | |||
| String errCode = retMap.get(WxPayConstant.ERR_CODE); | |||
| if(returnCode.equalsIgnoreCase(WxPayConstant.RET_SUCCESS) && | |||
| resultCode.equalsIgnoreCase(WxPayConstant.RET_SUCCESS) && | |||
| StringUtils.isBlank(errCode)) { | |||
| if(StringUtils.isBlank(errCode)) { | |||
| // 无异常信息,核销成功 | |||
| couponOrderService.sendInsideCouponVerifyMsg(tenantId, couponOrderId, buUserId); | |||
| } | |||
| @@ -46,23 +46,24 @@ public class SystemLogAspect { | |||
| posActionLog.setMethod(request.getMethod()); | |||
| posActionLog.setReqJson(JSON.toJSONString(joinPoint.getArgs()[0])); | |||
| posActionLog.setStartTime(startTime); | |||
| try { | |||
| Object o = joinPoint.proceed(); | |||
| Object o = joinPoint.proceed(); | |||
| posActionLog.setResJson(JSON.toJSONString(o)); | |||
| long endTime = System.currentTimeMillis(); | |||
| posActionLog.setEndTime(endTime); | |||
| posActionLog.setCostTime(Long.valueOf(endTime-startTime).intValue()); | |||
| posActionLogService.saveOrUpdate(posActionLog); | |||
| posActionLog.setCostTime(Long.valueOf(endTime - startTime).intValue()); | |||
| try { | |||
| posActionLogService.saveOrUpdate(posActionLog); | |||
| } catch (Exception e) { | |||
| logger.error("save pos log error: " + e.getMessage()); | |||
| } | |||
| return o; | |||
| } catch (Throwable e) { | |||
| String errMessage = e.getMessage(); | |||
| logger.error(errMessage); | |||
| Map map = new HashMap<>(); | |||
| map.put(WxPayConstant.RETURN_CODE, WxPayConstant.RET_FAIL); | |||
| map.put(WxPayConstant.RETURN_MSG, errMessage); | |||
| map.put(WxPayConstant.RESULT_CODE, WxPayConstant.RET_FAIL); | |||
| return map; | |||
| } catch (Throwable throwable) { | |||
| logger.error("异常: " + throwable.getMessage()); | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| @@ -376,7 +376,7 @@ public class PosServiceImpl implements PosService { | |||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| retMap.put("ret", coRetArr.toJSONString()); | |||
| retMap.put(WxPayConstant.RET, coRetArr.toJSONString()); | |||
| return retMap; | |||
| } | |||
| @@ -493,7 +493,7 @@ public class PosServiceImpl implements PosService { | |||
| } | |||
| } | |||
| } | |||
| retMap.put("ret", coRetArr.toJSONString()); | |||
| retMap.put(WxPayConstant.RET, coRetArr.toJSONString()); | |||
| return retMap; | |||
| } | |||
| @@ -820,9 +820,14 @@ public class PosServiceImpl implements PosService { | |||
| logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())) { | |||
| logger.error("券包ID: " + couponOrderCVo.getId() + "未核销"); | |||
| throw new MallinkException(ErrorCode.POS_COUPON_ORDER_NOT_VERIFY); | |||
| } | |||
| // 5. 有价券无法反向, 补贴券无法反向 | |||
| WxCoupon coupon = couponMapper.selectByPrimaryKey(couponOrderCVo.getCouponId()); | |||
| if (coupon.getSalePrice() > 0 || coupon.getSubsidyNum() > 0) { | |||
| if (coupon.getSalePrice() > 0 || | |||
| (coupon.getSubsidyType() > EnumCouponSubsidyType.NO_SUBSIDY.getCode() && coupon.getSubsidyNum() > 0)) { | |||
| logger.error("券包ID: " + couponOrderCVo.getId() + "核销无法退回"); | |||
| throw new MallinkException(ErrorCode.POS_COUPON_ORDER_VERIFY_NOT_CANCEL); | |||
| } | |||
| @@ -50,7 +50,7 @@ public class PosAppTest { | |||
| /* | |||
| 可用的交易券, 支付可用(1, 2, 6), 独立核销可用(4, 6, 8, 9) | |||
| coupon_order_id, coupon_type, 售价, 面额, ava_cancel | |||
| coupon_order_id, coupon_type, 售价, 面额, cancellable | |||
| 321872988134408192, 4, 0, 2000, NO | |||
| 321877927162249216, 2, 0, 10000, YES | |||
| 321878123232591872, 2, 1, 10000, NO | |||
| @@ -199,7 +199,7 @@ public class PosAppTest { | |||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | |||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | |||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744"); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878123232591872"); | |||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||
| reqObj.put(WxPayConstant.VERIFY_TYPE, "pay"); | |||
| reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); | |||
| @@ -227,7 +227,7 @@ public class PosAppTest { | |||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | |||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | |||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321872988134408192"); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878223800205312"); | |||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||
| reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); | |||
| reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); | |||
| @@ -254,7 +254,7 @@ public class PosAppTest { | |||
| reqObj.put(WxPayConstant.TENANT_ID, tenantId); | |||
| reqObj.put(WxPayConstant.MERCHANT_ID, merchantId); | |||
| reqObj.put(WxPayConstant.BUSER_ID, buUserId); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744"); | |||
| reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878223800205312"); | |||
| reqObj.put(WxPayConstant.NONCE_STR, "1"); | |||
| reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); | |||
| reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); | |||
| @@ -238,8 +238,9 @@ public enum ErrorCode{ | |||
| POS_CONFIG_NOT_FOUND(11100, "POS会员相关未设置"), | |||
| POS_CONFIG_MEM_DISCOUNT_DISABLE(11101, "POS会员折扣未启用"), | |||
| POS_CONFIG_MEM_COUPON_DISABLE(11102, "POS会员优惠券未启用"), | |||
| POS_COUPON_ORDER_VERIFY_NOT_CANCEL(11103, "此券核销无法取消"), | |||
| POS_CAR_PAY_NOT_CANCEL(11104, "卡支付无法取消"), | |||
| POS_COUPON_ORDER_NOT_VERIFY(11103, "此券未核销"), | |||
| POS_COUPON_ORDER_VERIFY_NOT_CANCEL(11104, "此券核销无法取消"), | |||
| POS_CAR_PAY_NOT_CANCEL(11105, "卡支付无法取消"), | |||
| /** | |||
| @@ -1045,7 +1045,7 @@ | |||
| <select id="findAvailCouponOrder" parameterType="java.util.Map" resultType="hashmap"> | |||
| select co.id, c.title, c.type, co.create_date, co.expired_time, c.price, | |||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as ava_cancel | |||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as cancellable | |||
| from wx_coupon_order co | |||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||
| left join wx_coupon c on c.id = co.coupon_id | |||
| @@ -1061,7 +1061,7 @@ | |||
| </if> | |||
| union | |||
| select co.id, c.title, c.type, co.create_date, co.expired_time, c.price, | |||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as ava_cancel | |||
| if((co.coupon_price > 0 or (c.subsidy_type>0 and c.subsidy_num >0)), 'NO', 'YES') as cancellable | |||
| from wx_coupon_order co | |||
| left join wx_coupon_merchant cm on cm.product_id = co.coupon_id | |||
| left join wx_coupon c on c.id = co.coupon_id | |||