| @@ -1,2 +1,58 @@ | |||
| ALTER TABLE `mallink`.`wx_card_spend` | |||
| ADD COLUMN `pay_type` smallint(2) NOT NULL DEFAULT 0 AFTER `owner_id`; | |||
| ADD COLUMN `pay_type` smallint(2) NOT NULL DEFAULT 0 AFTER `owner_id`; | |||
| ALTER TABLE `mallink`.`wx_card_spend` | |||
| ADD COLUMN `refund_status` smallint(2) NOT NULL DEFAULT 0 COMMENT '退款状态' AFTER `subsidy`, | |||
| ADD COLUMN `refund_remark` varchar(255) AFTER `refund_status`; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '789') parent_id, | |||
| '789' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1001') parent_id, | |||
| '1001' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1002') parent_id, | |||
| '1002' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1003') parent_id, | |||
| '1003' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1004') parent_id, | |||
| '1004' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1005') parent_id, | |||
| '1005' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1006') parent_id, | |||
| '1006' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1007') parent_id, | |||
| '1007' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1008') parent_id, | |||
| '1008' tenant_id,'1028' parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| INSERT INTO `wx_flow_config` (`id`, `parent_id`, `tenant_id`,`parent_tenant_id`, `name`, `type`, `model_id`, `sort`) | |||
| select (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id, | |||
| (select id from wx_flow_config where name = '营销审批' and tenant_id = '1007') parent_id, | |||
| '1007' tenant_id,null parent_tenant_id, '消费卡退款审批' name, 31 type, 0 model_id, 10 sort from dual; | |||
| @@ -26,10 +26,7 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| /** | |||
| @@ -98,6 +95,39 @@ public class WxCardPayController extends BaseController { | |||
| final Map<String, BigDecimal> mapList = wxCardSpendService.sumCardSpend(wxCardSpend); | |||
| return new ResultData(mapList); | |||
| } | |||
| @ApiOperation("支付详情") | |||
| @GetMapping("detail") | |||
| public ResultData sumCardSpendList(Long cardSpendId) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("sumCardSpendList: " + ipStr + " :" + cardSpendId.toString()); | |||
| if (cardSpendId == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "cardSpendId不能为空"); | |||
| } | |||
| Map<String,Object> map = new HashMap<>(); | |||
| WxCardSpend cardSend = wxCardSpendService.getById(cardSpendId); | |||
| if(cardSend == null || !EnumPayType.PAY_PAYMENT.getCode().equals(cardSend.getPayType())){ | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "未找到订单"); | |||
| } | |||
| if(!getLoginBUser().getMerchantId().equals(cardSend.getMerchantId())){ | |||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL.getCode(), "该门店与订单不匹配"); | |||
| } | |||
| map.put("cardSend",cardSend); | |||
| if(EnumPayType.PAY_PAYMENT.getCode().equals(cardSend.getPayType())){//付款订单 | |||
| if(!EnumRentContractAppStatus.DEFAULT.getCode().equals(cardSend.getRefundStatus())){//查询退款订单 | |||
| WxRefundOrder refundOrder = wxRefundOrderService.findRefundOrder(cardSend, cardSend.getOrderId()); | |||
| map.put("refund",refundOrder); | |||
| } | |||
| }else if(EnumPayType.PAY_B_REFUND.getCode().equals(cardSend.getPayType())){ | |||
| //查询原cardSend | |||
| WxCardSpend payCardSend = wxCardSpendService.findPayCardSpend(cardSend,cardSend.getCardId(),cardSend.getOrderId()); | |||
| map.put("oldCardSend",payCardSend); | |||
| }else{ | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "订单类型错误"); | |||
| } | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation(value = "微信B端扫储值卡码支付订单", notes = "params:{\"dynamicId\":\"String\",\"totalFee\":\"String(元)\"}") | |||
| @PostMapping("scanCard") | |||
| @@ -77,6 +77,12 @@ public class WxCardSpend extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remark") | |||
| private String remark; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumRentContractAppStatus ",name="refundStatus") | |||
| private Integer refundStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="refundRemark") | |||
| private String refundRemark; | |||
| @TableField(exist = false) | |||
| @Excel(name = "消费金额(元)", width = 20, orderNum = "7") | |||
| private String deductionAmountStr; | |||
| @@ -12,7 +12,7 @@ public enum EnumCardSpendStatus { | |||
| MANUAL_PAY(2, "已人工分账"), | |||
| PREV_PAY(10, "预支付(POS短期内占用)"), | |||
| PENDING_REFUND(3, "待退款"),//占库存 | |||
| PENDING_REFUND(3, "待退款"), | |||
| REFUND_SUCCESS(4,"已退款"), | |||
| ; | |||
| @@ -41,7 +41,7 @@ public enum EnumFlowKey { | |||
| CASH_OUT(23,"商户提现审批"), | |||
| CARD_ORDER_REFUND(31,"商户提现审批") | |||
| CARD_ORDER_REFUND(31,"消费卡退款审批") | |||
| ; | |||
| public static EnumFlowKey getEnum(Integer code) { | |||
| @@ -116,5 +116,6 @@ public interface WxCardSpendService { | |||
| WxCardSpend cardSpendForPosPay(PromotionCalc scoreCreditCalc, WxCardSpend record, WxMerchant merchant, WxMerchantBUser buUser,Integer payWay) throws MallinkException; | |||
| Integer sumRealPayment(WxCardSpendVo wxCardSpend); | |||
| WxCardSpend findPayCardSpend(TenantEntity tenantEntity, Long cardId, Long orderId); | |||
| } | |||
| @@ -408,7 +408,8 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { | |||
| cardInfoUpd.setAmount(amount); | |||
| cardInfoUpd.setRemainingAmount(remainingAmount); | |||
| cardInfoUpd.setRemainingShareFeeAmount(remainingShareFeeAmount); | |||
| int i = wxCardInfoMapper.updAmount(cardInfo); | |||
| logger.info("----"+remainingAmount+"----"+remainingShareFeeAmount); | |||
| int i = wxCardInfoMapper.updAmount(cardInfoUpd); | |||
| redisLock.unlock("cardInfoLockAmountSet_"+cardInfo.getId(), timeStr); | |||
| if(i != 1){ | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"卡余额不足 error."); | |||
| @@ -1330,4 +1330,14 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| public Integer sumRealPayment(WxCardSpendVo wxCardSpend) { | |||
| return wxCardSpendMapper.sumRealPayment(wxCardSpend); | |||
| } | |||
| @Override | |||
| public WxCardSpend findPayCardSpend(TenantEntity tenantEntity, Long cardId, Long orderId) { | |||
| WxCardSpend wxCardSpendQ = new WxCardSpend(); | |||
| wxCardSpendQ.updateTenantInfo(tenantEntity); | |||
| wxCardSpendQ.setPayType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| wxCardSpendQ.setCardId(cardId); | |||
| wxCardSpendQ.setOrderId(orderId); | |||
| return wxCardSpendMapper.selectOne(new QueryWrapper<>(wxCardSpendQ)); | |||
| } | |||
| } | |||
| @@ -122,9 +122,10 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '砍价审批', '12', '0', '" + nowTimestr + "', '" + nowTimestr + "', '4')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '商户建券审批', '22', '0', '" + nowTimestr + "', '" + nowTimestr + "', '5')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '商户提现审批', '23', '0', '" + nowTimestr + "', '" + nowTimestr + "', '6')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '商品预购审批', '24', '0', '" + nowTimestr + "', '" + nowTimestr + "', '5')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '配送商品审批', '25', '0', '" + nowTimestr + "', '" + nowTimestr + "', '5')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '积分券审批', '26', '0', '" + nowTimestr + "', '" + nowTimestr + "', '5')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '商品预购审批', '24', '0', '" + nowTimestr + "', '" + nowTimestr + "', '7')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '配送商品审批', '25', '0', '" + nowTimestr + "', '" + nowTimestr + "', '8')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '积分券审批', '26', '0', '" + nowTimestr + "', '" + nowTimestr + "', '9')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id1 + "', '" + tenantId + "', '消费卡退款审批', '31', '0', '" + nowTimestr + "', '" + nowTimestr + "', '10')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id2 + "', '" + tenantId + "', '商铺租金合同签约', '4', '0', '" + nowTimestr + "', '" + nowTimestr + "', '1')," + | |||
| " ( '" + idWorker.nextId() + "', '" + id2 + "', '" + tenantId + "', '多经点位租金合同签约', '5', '0', '" + nowTimestr + "', '" + nowTimestr + "', '2')," + | |||
| @@ -1188,6 +1188,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| cardSpendUpd.setId(cardSend.getId()); | |||
| cardSpendUpd.updateTenantInfo(cardSend); | |||
| cardSpendUpd.setPayStatus(EnumCardSpendStatus.PENDING_REFUND.getCode()); | |||
| cardSpendUpd.setRefundStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| cardSpendUpd.setUpdateDate(currentDate); | |||
| try { | |||
| wxCardSpendMapper.updateById(cardSpendUpd); | |||
| @@ -1311,6 +1312,8 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| cardSpendUpd.setId(cardSend.getId()); | |||
| cardSpendUpd.updateTenantInfo(cardSend); | |||
| cardSpendUpd.setPayStatus(EnumCardSpendStatus.REFUND_SUCCESS.getCode()); | |||
| cardSpendUpd.setRefundStatus(EnumRentContractAppStatus.FINISH.getCode()); | |||
| cardSpendUpd.setRefundRemark("success!"); | |||
| cardSpendUpd.setUpdateDate(currentDate); | |||
| try { | |||
| wxCardSpendMapper.updateById(cardSpendUpd); | |||
| @@ -1469,6 +1472,8 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| cardSpendUpd.setId(cardSend.getId()); | |||
| cardSpendUpd.updateTenantInfo(cardSend); | |||
| cardSpendUpd.setPayStatus(EnumCardSpendStatus.NOT_PAY.getCode()); | |||
| cardSpendUpd.setRefundStatus(EnumRentContractAppStatus.REJECT.getCode()); | |||
| cardSpendUpd.setRefundRemark(remark); | |||
| cardSpendUpd.setUpdateDate(currentDate); | |||
| try { | |||
| wxCardSpendMapper.updateById(cardSpendUpd); | |||
| @@ -1490,4 +1495,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -163,7 +163,7 @@ | |||
| <if test=" null != remainingShareFeeAmount "> | |||
| `remaining_share_fee_amount` = remaining_share_fee_amount+#{remainingShareFeeAmount}, | |||
| </if> | |||
| ,update_date=now() | |||
| update_date=now() | |||
| where id=#{id} and tenant_id = #{tenantId} | |||
| and remaining_amount+#{remainingAmount} >= 0 | |||
| </update> | |||
| @@ -23,13 +23,15 @@ | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="pay_status" jdbcType="INTEGER" property="payStatus"/> | |||
| <result column="pay_from" jdbcType="INTEGER" property="payFrom"/> | |||
| <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/> | |||
| <result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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`, | |||
| `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, | |||
| `create_date`, `update_date`, `pay_status`, `pay_from` | |||
| `create_date`, `update_date`, `pay_status`, `pay_from`, `refund_status`, `refund_remark` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -94,6 +96,9 @@ | |||
| <if test=" null != payFrom "> | |||
| and `pay_from` = #{payFrom} | |||
| </if> | |||
| <if test=" null != refundStatus "> | |||
| and `refund_status` = #{refundStatus} | |||
| </if> | |||
| <if test=" null != startdate"> | |||
| and `create_date` >= #{startdate} | |||