Просмотр исходного кода

[储值卡退卡][新增]:储值卡退卡退款逻辑添加

release_toaliyun_real
Stormeye Wu 7 лет назад
Родитель
Сommit
59d9eb6576
5 измененных файлов: 62 добавлений и 18 удалений
  1. +11
    -13
      mallinkAdmin/src/main/java/com/iformall/controller/WxCardPayController.java
  2. +6
    -0
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  3. +2
    -2
      mallinkService/src/main/java/com/iformall/service/WxCardSpendService.java
  4. +42
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  5. +1
    -1
      mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml

+ 11
- 13
mallinkAdmin/src/main/java/com/iformall/controller/WxCardPayController.java Просмотреть файл

@@ -58,7 +58,7 @@ public class WxCardPayController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) { public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr(); String ipStr = getIpAddr();
logger.info("cardOrderList: " + ipStr);
logger.info("cardPay/cardOrderList: " + ipStr);
if (wxCardVo == null) wxCardVo = new WxCardVo(); if (wxCardVo == null) wxCardVo = new WxCardVo();
MallUserInfo user = getUser(); MallUserInfo user = getUser();
wxCardVo.setTenantId(user.getTenantId()); wxCardVo.setTenantId(user.getTenantId());
@@ -83,7 +83,7 @@ public class WxCardPayController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) {
String ipStr = getIpAddr(); String ipStr = getIpAddr();
logger.info("cardSpendlist: " + ipStr);
logger.info("cardPay/cardSpendlist: " + ipStr);
if (wxCardSpendVo == null) { if (wxCardSpendVo == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
} }
@@ -107,7 +107,7 @@ public class WxCardPayController extends BaseController {
@GetMapping("sum") @GetMapping("sum")
public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) {
String ipStr = getIpAddr(); String ipStr = getIpAddr();
logger.info("sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString());
logger.info("cardPay/sumCardSpendList: " + 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(), "过滤条件为空");
} }
@@ -120,7 +120,7 @@ public class WxCardPayController extends BaseController {
@ApiOperation("交易流水导出") @ApiOperation("交易流水导出")
@GetMapping("/exportData") @GetMapping("/exportData")
public void exportData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) { public void exportData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) {
logger.info("[" + getIpAddr() + "] WxCardPayController::exportData");
logger.info("[" + getIpAddr() + "] cardPay/exportData");
if (wxCardSpendVo == null) { if (wxCardSpendVo == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
} }
@@ -138,19 +138,17 @@ public class WxCardPayController extends BaseController {
wxCardSpendService.exportData(wxCardSpendVo, request, response); wxCardSpendService.exportData(wxCardSpendVo, request, response);
} }


@ApiOperation("更新补贴记录")
@PostMapping("update")
public ResultData update(@RequestBody WxCardSpendVo wxCardSpendVo) {
@ApiOperation("更新卡消费支付状态")
@PostMapping("/updatePayStatus")
public ResultData update(@RequestBody WxCardSpend wxCardSpend) {
String ipStr = getIpAddr(); String ipStr = getIpAddr();
logger.info("subsidy/update: " + ipStr + " :" + wxCardSpendVo.toString());
if (wxCardSpendVo == null) {
logger.info("cardPay/updatePayStatus: " + ipStr + " :" + wxCardSpend.toString());
if (wxCardSpend == null) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空");
} }
MallUserInfo user = getUser(); MallUserInfo user = getUser();
wxCardSpendVo.setTenantId(user.getTenantId());
wxCardSpendVo.setStatus(EnumCardSpendStatus.MANUAL_PAY.getCode());
wxCardSpendVo.setUpdateDate(new Date());
int num = wxCardSpendService.update(wxCardSpendVo);
wxCardSpend.setTenantId(user.getTenantId());
int num = wxCardSpendService.update(wxCardSpend);
return new ResultData(num); return new ResultData(num);
} }
} }

+ 6
- 0
mallinkService/src/main/java/com/iformall/common/ErrorCode.java Просмотреть файл

@@ -150,6 +150,12 @@ public enum ErrorCode{
*/ */
CARD_IS_NOT_FOUND(9001, "优惠卡不存在"), CARD_IS_NOT_FOUND(9001, "优惠卡不存在"),
CARD_REMAIN_AMOUNT_IS_NOT_ENOUGH(9002, "优惠卡余额不足"), CARD_REMAIN_AMOUNT_IS_NOT_ENOUGH(9002, "优惠卡余额不足"),
CARD_IS_NOT_COST(9003, "优惠卡未消费,退款请用卡券退款,钱直接退回购买人手里"),

/**
* 卡消费
*/
CARD_SPEND_IS_PAID(9050, "卡消费已支付"),








+ 2
- 2
mallinkService/src/main/java/com/iformall/service/WxCardSpendService.java Просмотреть файл

@@ -73,7 +73,7 @@ public interface WxCardSpendService {
* *
* @param record * @param record
*/ */
int update(WxCardSpendVo record);
int update(WxCardSpend record);


/** /**
* 根据Id删除实体 * 根据Id删除实体
@@ -84,7 +84,7 @@ public interface WxCardSpendService {


/** /**
* cardPay分账 * cardPay分账
*
* @param tenantId
* @param orderId * @param orderId
* @param cardSpendId * @param cardSpendId
*/ */


+ 42
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java Просмотреть файл

@@ -275,8 +275,19 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
} }


@Override @Override
public int update(WxCardSpendVo record) {
return wxCardSpendMapper.updateByCond(record);
public int update(WxCardSpend record) {
// 1. 检查符合条件的卡消费记录是否已支付
List<WxCardSpend> cardSpends = wxCardSpendMapper.findList(record);
if (cardSpends.stream().anyMatch((cs->(!cs.getPayStatus().equals(EnumCardSpendStatus.NOT_PAY.getCode()))))){
throw new MallinkException(ErrorCode.CARD_SPEND_IS_PAID);
}
// 2. 更新支付状态
record.setPayStatus(EnumCardSpendStatus.MANUAL_PAY.getCode());
record.setUpdateDate(new Date());
int num = wxCardSpendMapper.updateByCond(record);
// 3. 分账完结
shareFinishForCardPay(record.getTenantId(), record.getCardId());
return num;
} }


@Override @Override
@@ -364,6 +375,35 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
} }
} }


private void shareFinishForCardPay(String tenantId, Long cardId) {
// admin用户手动帮已用卡消费用户退卡, 此卡需要分账完结, 买卡的钱进商场账户
WxCardInfo cardInfo = null;
try {
cardInfo = wxCardInfoMapper.selectByPrimaryKey(cardId);
} catch (Exception e) {
logger.error("微信分账: " + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), e.getMessage());
}
if(cardInfo != null) {
if (cardInfo.getRemainingAmount().equals(cardInfo.getAmount())){
logger.error("请用订单退款接口: ");
throw new MallinkException(ErrorCode.CARD_IS_NOT_COST);
} else {
try {
WxCouponOrder couponOrder = wxCouponOrderMapper.selectByPrimaryKey(cardInfo.getId());
WxSharingOrderDto shareOrder = new WxSharingOrderDto();
shareOrder.setcUserId(couponOrder.getOwnerId());
shareOrder.setTenantId(tenantId);
shareOrder.setTransactionId(cardInfo.getTransactionId());
cardShareFinished(cardInfo, shareOrder);
} catch (MallinkException e) {
logger.error("微信分账: " + e.getMessage());
throw new MallinkException(e.getErrorCode(), e.getMessage());
}
}
}
}

/** /**
* 卡分账完结 * 卡分账完结
* @param cardInfo * @param cardInfo


+ 1
- 1
mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml Просмотреть файл

@@ -73,7 +73,7 @@
<if test=" null != updateDate "> <if test=" null != updateDate ">
and `update_date` = #{updateDate} and `update_date` = #{updateDate}
</if> </if>
<if test=" null != status ">
<if test=" null != payStatus ">
and `pay_status` = #{payStatus} and `pay_status` = #{payStatus}
</if> </if>
<if test=" null != startdate and null!=enddate"> <if test=" null != startdate and null!=enddate">


Загрузка…
Отмена
Сохранить