diff --git a/src/main/java/cn/com/tenlion/operator/controller/resource/packageorder/PackageOrderResourceController.java b/src/main/java/cn/com/tenlion/operator/controller/resource/packageorder/PackageOrderResourceController.java index 5763ac6..d48cdc4 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/resource/packageorder/PackageOrderResourceController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/resource/packageorder/PackageOrderResourceController.java @@ -1,7 +1,9 @@ package cn.com.tenlion.operator.controller.resource.packageorder; +import cn.com.tenlion.operator.pojo.dtos.packageinfo.PackageInfoAppDTO; import cn.com.tenlion.operator.pojo.dtos.packageinfo.PackageInfoDTO; import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderAppVO; +import cn.com.tenlion.operator.service.packageinfo.IPackageInfoService; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.exceptions.SaveException; @@ -38,6 +40,22 @@ public class PackageOrderResourceController extends DefaultBaseController { @Autowired private IPackageOrderService packageOrderService; + @Autowired + private IPackageInfoService iPackageInfoService; + + @ApiOperation(value = "套餐包详情", notes = "套餐包详情接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), + @ApiImplicitParam(name = "packageInfoId", value = "套餐包ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getByNo/{packageNo}") + public PackageOrderDTO getByNo(@PathVariable("packageNo") String packageNo) { + PackageOrderDTO orderDTO = packageOrderService.getByPackageNo(packageNo); + PackageInfoAppDTO appDTO = iPackageInfoService.getById(orderDTO.getPackageInfoId()); + orderDTO.setPackageInfoAppDTO(appDTO); + return orderDTO; + } @ApiOperation(value = "套餐包详情", notes = "套餐包详情接口") @ApiImplicitParams({ @@ -47,48 +65,52 @@ public class PackageOrderResourceController extends DefaultBaseController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get/{packageOrderId}") public PackageOrderDTO get(@PathVariable("packageOrderId") String packageOrderId) { - return packageOrderService.get(packageOrderId); + PackageOrderDTO orderDTO = packageOrderService.get(packageOrderId); + PackageInfoAppDTO appDTO = iPackageInfoService.getById(orderDTO.getPackageInfoId()); + orderDTO.setPackageInfoAppDTO(appDTO); + return orderDTO; } @ApiOperation(value = "套餐包删除-订单", notes = "套餐包删除-订单接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("update-close/{packageNo}") @CheckRequestBodyAnnotation - public SuccessResult updateClose(@PathVariable String packageNo) { + public SuccessResultData updateClose(@PathVariable String packageNo) { try{ packageOrderService.updateClose(packageNo); }catch(Exception e) { - throw new UpdateException(e.getMessage()); + return new SuccessResultData(e.getMessage()); } - return new SuccessResult(); + return new SuccessResultData("Success"); } @ApiOperation(value = "套餐包到账-订单", notes = "套餐包到账-订单接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("update-pay/{packageNo}") + @PostMapping("update-pay/{packageNo}/{packageAccountItem}") @CheckRequestBodyAnnotation - public SuccessResult updatePay(@PathVariable String packageNo) { + public SuccessResultData updatePay(@PathVariable String packageNo, @PathVariable String packageAccountItem) { try{ PackageOrderAppVO packageOrderVO = new PackageOrderAppVO(); + packageOrderVO.setPackageAccountItem(packageAccountItem); packageOrderVO.setAccountRechargeId(packageNo); packageOrderService.updateOrder(packageOrderVO); }catch(Exception e) { - throw new UpdateException(e.getMessage()); + return new SuccessResultData(e.getMessage()); } - return new SuccessResult(); + return new SuccessResultData("Success"); } @ApiOperation(value = "新增套餐包-订单", notes = "新增套餐包-订单接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("save") @CheckRequestBodyAnnotation - public SuccessResult save(@RequestBody PackageOrderAppVO packageOrderVO) { + public SuccessResultData save(@RequestBody PackageOrderAppVO packageOrderVO) { try{ packageOrderService.saveOrder(packageOrderVO); }catch(Exception e) { - throw new SaveException(e.getMessage()); + return new SuccessResultData(e.getMessage()); } - return new SuccessResult(); + return new SuccessResultData("Success"); } @ApiOperation(value = "指定套餐包订单列表", notes = "指定套餐包订单列表接口") diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderAppVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderAppVO.java index 74fbb6b..b2232b5 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderAppVO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderAppVO.java @@ -16,14 +16,21 @@ import io.swagger.annotations.ApiModelProperty; public class PackageOrderAppVO { @ApiModelProperty(name = "packageInfoId", value = "套餐ID") - @CheckEmptyAnnotation(name = "套餐ID") private String packageInfoId; @ApiModelProperty(name = "userId", value = "用户ID") - @CheckEmptyAnnotation(name = "用户ID") private String userId; @ApiModelProperty(name = "accountRechargeId", value = "用户充值记录ID") - @CheckEmptyAnnotation(name = "用户充值记录") private String accountRechargeId; + @ApiModelProperty(name = "accountRechargeId", value = "用户充值记录ID") + private String packageAccountItem; + + public String getPackageAccountItem() { + return packageAccountItem == null ? "" : packageAccountItem.trim(); + } + + public void setPackageAccountItem(String packageAccountItem) { + this.packageAccountItem = packageAccountItem; + } public String getAccountRechargeId() { return accountRechargeId == null ? "" : accountRechargeId.trim(); diff --git a/src/main/java/cn/com/tenlion/operator/service/packageorder/impl/PackageOrderServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/packageorder/impl/PackageOrderServiceImpl.java index 8a0260f..236c6e3 100644 --- a/src/main/java/cn/com/tenlion/operator/service/packageorder/impl/PackageOrderServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/packageorder/impl/PackageOrderServiceImpl.java @@ -196,24 +196,12 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack if(orderDTO.getPackagePayStatus().equals("1")) { // 当前状态已经是已支付的不做操作 return; } - PackageInfoDTO packageInfoDTO = iPackageInfoService.getByPackageInfoId(packageOrderVO.getPackageInfoId()); /** - * 1. 创建流水 - */ - AccountItemVO vo = new AccountItemVO(); - vo.setType(2); - vo.setMode(2); - vo.setAccountId(packageOrderVO.getUserId()); - vo.setOrderId(orderDTO.getPackageOrderId()); - vo.setAccountMoney(packageInfoDTO.getPackageMoney()); - vo.setDescription("购买" + (packageInfoDTO.getPackageType().equals("ALL") ? "全托管" : "写材料" ) + "套餐包 " + packageInfoDTO.getPackageCount() + " 件:" + packageInfoDTO.getPackageName()); - String accountItemId = iAccountItemService.saveReturnId(vo); - /** - * 2. 更改到账时间 , 状态 + * 1. 更改到账时间 , 状态 */ Map params = super.getHashMap(2); params.put("packageNo", packageOrderVO.getAccountRechargeId());// 关联支付 - params.put("packageAccountItem", accountItemId); // 关联扣款流水 + params.put("packageAccountItem", packageOrderVO.getPackageAccountItem()); // 关联扣款流水 params.put("packagePayStatus", "1"); // 已支付 params.put("packagePay", DateUtil.getTime()); // 支付时间 packageOrderDao.updatePay(params); diff --git a/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/impl/AccountRechargeServiceImpl.java b/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/impl/AccountRechargeServiceImpl.java index 37c7b6a..4758fcf 100644 --- a/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/impl/AccountRechargeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/impl/AccountRechargeServiceImpl.java @@ -11,12 +11,15 @@ import cn.com.tenlion.operator.pojo.bos.accountrecharge.AccountRechargeBO; import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargeDTO; import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargePayDTO; import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargePayResultDTO; +import cn.com.tenlion.operator.pojo.dtos.packageinfo.PackageInfoDTO; +import cn.com.tenlion.operator.pojo.dtos.packageorder.PackageOrderDTO; import cn.com.tenlion.operator.pojo.dtos.user.info.UserInfoDTO; import cn.com.tenlion.operator.pojo.pos.accountrecharge.AccountRechargePO; import cn.com.tenlion.operator.pojo.vos.accountitem.AccountItemVO; import cn.com.tenlion.operator.pojo.vos.accountrecharge.AccountRechargeVO; import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderAppVO; import cn.com.tenlion.operator.properties.SystemApiPathProperties; +import cn.com.tenlion.operator.service.packageinfo.IPackageInfoService; import cn.com.tenlion.operator.service.packageorder.IPackageOrderService; import cn.com.tenlion.operator.serviceother.operator.accountitem.IAccountItemService; import cn.com.tenlion.operator.serviceother.operator.accountrecharge.IAccountRechargeService; @@ -392,6 +395,8 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA @Autowired private IPackageOrderService iPackageOrderService; + @Autowired + private IPackageInfoService iPackageInfoService; @Override public synchronized void updateCheck(String accountRechargeId, RechargeCheckEnum check, String checkRemark, String accountItemId, String orderId, String successTime) { @@ -420,10 +425,25 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA AccountRechargeDTO dto = get(accountRechargeId); // 绑定了套餐包 & 已对账 & 已到账 if(!StringUtils.isEmpty(dto.getPackageInfoId()) && dto.getReconciliationStatus().equals("1") && dto.getRechargeCheck().equals("2")) { + PackageInfoDTO packageInfoDTO = iPackageInfoService.get(dto.getPackageInfoId()); + PackageOrderDTO orderDTO = iPackageOrderService.getByPackageNo(accountRechargeId); + /** + * 1. 创建流水 + */ + AccountItemVO vo = new AccountItemVO(); + vo.setType(2); + vo.setMode(2); + vo.setAccountId(orderDTO.getCreator()); + vo.setOrderId(orderDTO.getPackageOrderId()); + vo.setAccountMoney(packageInfoDTO.getPackageMoney()); + vo.setDescription("购买" + (packageInfoDTO.getPackageType().equals("ALL") ? "全托管" : "写材料" ) + "套餐包 " + packageInfoDTO.getPackageCount() + " 件:" + packageInfoDTO.getPackageName()); + String accountItemId1 = iAccountItemService.saveReturnId(vo); + PackageOrderAppVO appVO = new PackageOrderAppVO(); appVO.setPackageInfoId(dto.getPackageInfoId()); appVO.setUserId(dto.getCreator()); appVO.setAccountRechargeId(dto.getAccountRechargeId()); + appVO.setPackageAccountItem(accountItemId1); iPackageOrderService.updateOrder(appVO); } // 绑定了套餐包 & 已对账 & 已关闭 diff --git a/src/main/resources/mybatis/mapper/packageorder/package-order-mapper.xml b/src/main/resources/mybatis/mapper/packageorder/package-order-mapper.xml index ac72612..122359b 100644 --- a/src/main/resources/mybatis/mapper/packageorder/package-order-mapper.xml +++ b/src/main/resources/mybatis/mapper/packageorder/package-order-mapper.xml @@ -176,6 +176,7 @@