| @@ -103,88 +103,17 @@ public class WxCardInfoController extends BaseController { | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| // @ApiOperation("C端扫B端储值卡交易流水(消费记录 + 补贴)列表接口") | |||||
| // @GetMapping("cardSpendlist") | |||||
| // @ApiImplicitParams({ | |||||
| // @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| // @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| // @SystemControllerLog(description = "储值卡支付-储值卡交易流水") | |||||
| // public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { | |||||
| // String ipStr = getIpAddr(); | |||||
| // logger.info("cardPay/cardSpendlist: " + ipStr); | |||||
| // if (wxCardSpendVo == null) { | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| // } | |||||
| // wxCardSpendVo.updateTenantInfo(getTenantInfo()); | |||||
| // if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { | |||||
| // String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); | |||||
| // List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| // for(String status: statusAttr) { | |||||
| // tmpList.add(Integer.valueOf(status)); | |||||
| // } | |||||
| // if(!tmpList.isEmpty()) { | |||||
| // wxCardSpendVo.setPayStatusS(tmpList); | |||||
| // } | |||||
| // } | |||||
| // List<Integer> sources = new ArrayList<Integer>(); | |||||
| // sources.add(EnumMerchantSubsidySource.CARD.getCode()); | |||||
| // wxCardSpendVo.setSources(sources); | |||||
| // wxCardSpendVo.setCardSpendListShow(1); | |||||
| // final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpendVo, pageNum, pageSize); | |||||
| // return new ResultData(page); | |||||
| // } | |||||
| // | |||||
| // @ApiOperation("C端扫B端储值卡交易流水SUM") | |||||
| // @GetMapping("sum") | |||||
| // @SystemControllerLog(description = "储值卡支付-储值卡交易流水SUM") | |||||
| // public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { | |||||
| // String ipStr = getIpAddr(); | |||||
| // logger.info("cardPay/sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); | |||||
| // if (wxCardSpend == null) { | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| // } | |||||
| // wxCardSpend.updateTenantInfo(getTenantInfo()); | |||||
| // List<Integer> sources = new ArrayList<Integer>(); | |||||
| // sources.add(EnumMerchantSubsidySource.CARD.getCode()); | |||||
| // wxCardSpend.setSources(sources); | |||||
| // wxCardSpend.setCardSpendListShow(1); | |||||
| // final List<Map<String, Object>> mapList = wxCardSpendService.sumCardSpendForMerchant(wxCardSpend); | |||||
| // return new ResultData(mapList); | |||||
| // } | |||||
| // | |||||
| // @ApiOperation("交易流水导出") | |||||
| // @GetMapping("/exportData") | |||||
| // @SystemControllerLog(description = "储值卡支付-储值卡交易流水导出") | |||||
| // public void exportData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) { | |||||
| // logger.info("[" + getIpAddr() + "] cardPay/exportData"); | |||||
| // if (wxCardSpendVo == null) { | |||||
| // throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| // } | |||||
| // wxCardSpendVo.updateTenantInfo(getTenantInfo()); | |||||
| // if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { | |||||
| // String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); | |||||
| // List<Integer> tmpList = new ArrayList<Integer>(); | |||||
| // for(String status: statusAttr) { | |||||
| // tmpList.add(Integer.valueOf(status)); | |||||
| // } | |||||
| // if(!tmpList.isEmpty()) { | |||||
| // wxCardSpendVo.setPayStatusS(tmpList); | |||||
| // } | |||||
| // } | |||||
| // wxCardSpendService.exportData(wxCardSpendVo, request, response); | |||||
| // } | |||||
| @ApiOperation("更新卡消费支付状态") | @ApiOperation("更新卡消费支付状态") | ||||
| @PostMapping("/updatePayStatus") | |||||
| @PostMapping("/spendFinish") | |||||
| @SystemControllerLog(description = "储值卡支付-更新卡消费支付状态") | @SystemControllerLog(description = "储值卡支付-更新卡消费支付状态") | ||||
| public ResultData update(@RequestBody WxCardSpend wxCardSpend) { | |||||
| public ResultData spendFinish(@RequestBody WxCardSpend wxCardSpend) { | |||||
| String ipStr = getIpAddr(); | String ipStr = getIpAddr(); | ||||
| logger.info("cardPay/updatePayStatus: " + ipStr + " :" + wxCardSpend.toString()); | |||||
| logger.info("cardPay/spendFinish: " + ipStr + " :" + wxCardSpend.toString()); | |||||
| if (wxCardSpend == null) { | if (wxCardSpend == null) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | ||||
| } | } | ||||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | wxCardSpend.updateTenantInfo(getTenantInfo()); | ||||
| wxCardSpendService.update(wxCardSpend); | |||||
| wxCardSpendService.spendFinish(wxCardSpend); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -191,37 +191,6 @@ public class WxCardPayController extends BaseController { | |||||
| wxCardSpendService.exportMerchantData(wxCardSpendVo, request, response); | wxCardSpendService.exportMerchantData(wxCardSpendVo, request, response); | ||||
| } | } | ||||
| @ApiOperation("更新卡消费支付状态") | |||||
| @PostMapping("/updatePayStatus") | |||||
| @SystemControllerLog(description = "储值卡支付-更新卡消费支付状态") | |||||
| public ResultData update(@RequestBody WxCardSpend wxCardSpend) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("cardPay/updatePayStatus: " + ipStr + " :" + wxCardSpend.toString()); | |||||
| if (wxCardSpend == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| wxCardSpend.updateTenantInfo(getTenantInfo()); | |||||
| wxCardSpendService.update(wxCardSpend); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("卡完结") | |||||
| @PostMapping("/finishCard") | |||||
| @SystemControllerLog(description = "储值卡支付-卡完结") | |||||
| public ResultData finishCard(@RequestBody WxCardInfo wxCardInfo) { | |||||
| String ipStr = getIpAddr(); | |||||
| logger.info("cardPay/finishCard: " + ipStr + " :" + wxCardInfo.toString()); | |||||
| if (wxCardInfo == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||||
| } | |||||
| if (wxCardInfo.getId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件ID为空"); | |||||
| } | |||||
| wxCardInfo.updateTenantInfo(getTenantInfo()); | |||||
| int remainShareAmount = wxCardSpendService.finishCard(wxCardInfo); | |||||
| return new ResultData(remainShareAmount); | |||||
| } | |||||
| @ApiOperation("卡订单-导出数据") | @ApiOperation("卡订单-导出数据") | ||||
| @GetMapping("/exportCardOrder") | @GetMapping("/exportCardOrder") | ||||
| @SystemControllerLog(description = "卡订单-导出数据") | @SystemControllerLog(description = "卡订单-导出数据") | ||||
| @@ -0,0 +1,8 @@ | |||||
| ALTER TABLE `mallink`.`wx_card_spend` | |||||
| ADD COLUMN `settlement_status` smallint(2) NOT NULL DEFAULT 0 COMMENT '结算状态' ; | |||||
| update wx_card_spend set settlement_status = pay_status where pay_status in (1,2); | |||||
| update wx_card_spend set pay_status = 0 where pay_status in (1,2); | |||||
| @@ -388,6 +388,10 @@ public class WxCardPayController extends BaseController { | |||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "该门店与订单不匹配"); | return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "该门店与订单不匹配"); | ||||
| } | } | ||||
| if(!EnumCardSpendSettlementStatus.NOT_SETTLE.getCode().equals(cardSend.getSettlementStatus())){ | |||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "该订单已结算"); | |||||
| } | |||||
| if(!DateUtils.isSameMonth(new Date(),cardSend.getCreateDate())){ | if(!DateUtils.isSameMonth(new Date(),cardSend.getCreateDate())){ | ||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "只能退本月订单"); | return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "只能退本月订单"); | ||||
| } | } | ||||
| @@ -268,9 +268,10 @@ public enum ErrorCode{ | |||||
| /** | /** | ||||
| * 卡消费 | * 卡消费 | ||||
| */ | */ | ||||
| CARD_SPEND_IS_PAID(9050, "卡消费已支付"), | |||||
| CARD_SPEND_IS_PAID(9050, "卡消费订单状态存在异常"), | |||||
| CARD_SPEND_IS_NOT_PREV(9051, "卡消费不是预消费订单"), | CARD_SPEND_IS_NOT_PREV(9051, "卡消费不是预消费订单"), | ||||
| CARD_SPEND_IS_NOT_FOUND(9052, "卡消费信息未找到"), | CARD_SPEND_IS_NOT_FOUND(9052, "卡消费信息未找到"), | ||||
| CARD_SPEND_IS_SETTLE(9053, "卡消费订单已结算"), | |||||
| /** | /** | ||||
| * 砍价 | * 砍价 | ||||
| @@ -67,9 +67,8 @@ public class WxCardSpend extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| //@Excel(name = "支付状态", width = 20, orderNum = "11", replace = {"未支付_0", "已分账_1", "已人工分账_2"}) | |||||
| @Excel(name = "支付状态", width = 20, orderNum = "14", replace = {"未线上分账_0", "已线上分账_1", "已线下结算_2", "退款中_3", "已退款_4"}) | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付状态(0:未分帐, 1:已分账, 2:已人工分账, 10:预支付(POS))",name="payStatus") | |||||
| @Excel(name = "支付状态", width = 20, orderNum = "14", replace = {"已支付_0", "退款中_3", "已退款_4"}) | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付状态(0:未分帐, 10:预支付(POS)) EnumCardSpendStatus",name="payStatus") | |||||
| private Integer payStatus; | private Integer payStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="来源(0:C端小程序扫一扫, 1:POS支付)",name="payFrom") | @io.swagger.annotations.ApiModelProperty(value="来源(0:C端小程序扫一扫, 1:POS支付)",name="payFrom") | ||||
| @@ -78,12 +77,17 @@ public class WxCardSpend extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remark") | @io.swagger.annotations.ApiModelProperty(value="说明",name="remark") | ||||
| private String remark; | private String remark; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumRentContractAppStatus ",name="refundStatus") | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款审核状态 EnumRentContractAppStatus ",name="refundStatus") | |||||
| private Integer refundStatus; | private Integer refundStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="refundRemark") | @io.swagger.annotations.ApiModelProperty(value="说明",name="refundRemark") | ||||
| private String refundRemark; | private String refundRemark; | ||||
| @Excel(name = "结算状态", width = 20, orderNum = "15", replace = {"未结算_0", "自动结算_1", "手动结算_2"}) | |||||
| @io.swagger.annotations.ApiModelProperty(value="结算状态 EnumCardSpendSettlementStatus",name="settlementStatus") | |||||
| private Integer settlementStatus; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @Excel(name = "消费金额(元)", width = 20, orderNum = "10") | @Excel(name = "消费金额(元)", width = 20, orderNum = "10") | ||||
| private String deductionAmountStr; | private String deductionAmountStr; | ||||
| @@ -0,0 +1,37 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCardSpendSettlementStatus { | |||||
| NOT_SETTLE(0, "未结算"), | |||||
| AUTO_SETTLE(1, "自动结算"), | |||||
| OFFLINE_SETTLE(2, "人工结算"), | |||||
| ; | |||||
| public static EnumCardSpendSettlementStatus getEnum(Integer code) { | |||||
| for (EnumCardSpendSettlementStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCardSpendSettlementStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -5,14 +5,12 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumCardSpendStatus { | public enum EnumCardSpendStatus { | ||||
| // 0-未支付;1-已分账;2:已人工分账; | |||||
| // 0-未支付;; | |||||
| NOT_PAY(0, "已支付,开始记录"), | NOT_PAY(0, "已支付,开始记录"), | ||||
| PS_SHARED(1, "已分账"), | |||||
| MANUAL_PAY(2, "已人工分账"), | |||||
| PREV_PAY(10, "预支付(POS短期内占用)"), | PREV_PAY(10, "预支付(POS短期内占用)"), | ||||
| PENDING_REFUND(3, "待退款"), | |||||
| PENDING_REFUND(3, "退款中"), | |||||
| REFUND_SUCCESS(4,"已退款"), | REFUND_SUCCESS(4,"已退款"), | ||||
| ; | ; | ||||
| @@ -76,7 +76,7 @@ public interface WxCardSpendService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void update(WxCardSpend record); | |||||
| void spendFinish(WxCardSpend record); | |||||
| /** | /** | ||||
| * 卡完结 | * 卡完结 | ||||
| @@ -185,6 +185,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| // 5 insert card_spend | // 5 insert card_spend | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.updateTenantInfo(cardInfo); | record.updateTenantInfo(cardInfo); | ||||
| record.setPayType(EnumPayType.PAY_PAYMENT.getCode()); | |||||
| if(record.getPayFrom() == null){ | if(record.getPayFrom() == null){ | ||||
| record.setPayFrom(EnumCardSpendFrom.C.getCode()); | record.setPayFrom(EnumCardSpendFrom.C.getCode()); | ||||
| } | } | ||||
| @@ -783,14 +784,17 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void update(WxCardSpend record) { | |||||
| // 1. 检查符合条件的卡消费记录是否已支付 | |||||
| public void spendFinish(WxCardSpend record) { | |||||
| // 1. 检查符合条件的卡消费记录是否已结算 | |||||
| List<WxCardSpend> cardSpends = wxCardSpendMapper.findList(record); | List<WxCardSpend> cardSpends = wxCardSpendMapper.findList(record); | ||||
| if (cardSpends.stream().anyMatch((cs -> (!cs.getPayStatus().equals(EnumCardSpendStatus.NOT_PAY.getCode()))))) { | |||||
| if (cardSpends.stream().anyMatch((cs -> (EnumCardSpendStatus.PREV_PAY.getCode().equals(cs.getPayStatus()))))) { | |||||
| throw new MallinkException(ErrorCode.CARD_SPEND_IS_PAID); | throw new MallinkException(ErrorCode.CARD_SPEND_IS_PAID); | ||||
| } | } | ||||
| // 2. 更新支付状态 | |||||
| record.setPayStatus(EnumCardSpendStatus.MANUAL_PAY.getCode()); | |||||
| if (cardSpends.stream().anyMatch((cs -> (!EnumCardSpendSettlementStatus.NOT_SETTLE.getCode().equals(cs.getSettlementStatus()))))) { | |||||
| throw new MallinkException(ErrorCode.CARD_SPEND_IS_SETTLE); | |||||
| } | |||||
| // 2. 结算状态更新 | |||||
| record.setSettlementStatus(EnumCardSpendSettlementStatus.OFFLINE_SETTLE.getCode()); | |||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCardSpendMapper.updateByCond(record); | wxCardSpendMapper.updateByCond(record); | ||||
| } | } | ||||
| @@ -825,13 +829,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| cardInfo1.setUpdateDate(new Date()); | cardInfo1.setUpdateDate(new Date()); | ||||
| wxCardInfoMapper.updateById(cardInfo1); | wxCardInfoMapper.updateById(cardInfo1); | ||||
| // 卡不分账完结 | |||||
| // WxSharingOrderDto shareOrder = new WxSharingOrderDto(); | |||||
| // shareOrder.setCUserId(couponOrder.getOwnerId()); | |||||
| // shareOrder.updateTenantInfo(wxCardInfo); | |||||
| // shareOrder.setMerchantId(0L); // 卡完结,默认给0 | |||||
| // shareOrder.setTransactionId(cardInfo.getTransactionId()); | |||||
| // cardShareFinished(cardInfo, shareOrder,couponOrder.getPayVendor()); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("微信分账: " + e.getMessage()); | logger.error("微信分账: " + e.getMessage()); | ||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | throw new MallinkException(e.getErrorCode(), e.getMessage()); | ||||
| @@ -1231,6 +1231,9 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| logger.error("付款订单未找到, e:"); | logger.error("付款订单未找到, e:"); | ||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | ||||
| } | } | ||||
| if(!EnumCardSpendSettlementStatus.NOT_SETTLE.getCode().equals(cardSend.getSettlementStatus())){ | |||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "该订单已结算"); | |||||
| } | |||||
| if(!DateUtils.isSameMonth(new Date(),cardSend.getCreateDate())){ | if(!DateUtils.isSameMonth(new Date(),cardSend.getCreateDate())){ | ||||
| throw new MallinkException(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "只能退本月订单"); | throw new MallinkException(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "只能退本月订单"); | ||||
| } | } | ||||
| @@ -25,13 +25,14 @@ | |||||
| <result column="pay_from" jdbcType="INTEGER" property="payFrom"/> | <result column="pay_from" jdbcType="INTEGER" property="payFrom"/> | ||||
| <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/> | <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/> | ||||
| <result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/> | <result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/> | ||||
| <result column="settlement_status" jdbcType="INTEGER" property="settlementStatus"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`pay_type`,`merchant_id`,`order_id`,`pos_order_id`, | `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`pay_type`,`merchant_id`,`order_id`,`pos_order_id`, | ||||
| `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`, | `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`, | ||||
| `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, | `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, | ||||
| `create_date`, `update_date`, `pay_status`, `pay_from`, `refund_status`, `refund_remark` | |||||
| `create_date`, `update_date`, `pay_status`, `pay_from`, `refund_status`, `refund_remark`, `settlement_status` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -99,6 +100,9 @@ | |||||
| <if test=" null != refundStatus "> | <if test=" null != refundStatus "> | ||||
| and `refund_status` = #{refundStatus} | and `refund_status` = #{refundStatus} | ||||
| </if> | </if> | ||||
| <if test=" null != settlementStatus "> | |||||
| and `settlement_status` = #{settlementStatus} | |||||
| </if> | |||||
| <if test=" null != startdate"> | <if test=" null != startdate"> | ||||
| and `create_date` >= #{startdate} | and `create_date` >= #{startdate} | ||||