diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/packageorder/PackageOrderController.java b/src/main/java/cn/com/tenlion/operator/controller/api/packageorder/PackageOrderController.java index 01c79d3..73abf51 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/packageorder/PackageOrderController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/packageorder/PackageOrderController.java @@ -1,5 +1,6 @@ package cn.com.tenlion.operator.controller.api.packageorder; +import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderWriteoffVO; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; @@ -54,6 +55,18 @@ public class PackageOrderController extends DefaultBaseController { return new SuccessResult(); } + @ApiOperation(value = "修改套餐包-订单", notes = "修改套餐包-订单接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "packageOrderId", value = "套餐包-订单ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("update-writeoff/{packageOrderId}") + @CheckRequestBodyAnnotation + public SuccessResult updateWriteoff(@PathVariable("packageOrderId") String packageOrderId, @RequestBody PackageOrderWriteoffVO packageOrderWriteoffVO) { + packageOrderService.updateWriteoff(packageOrderId, packageOrderWriteoffVO); + return new SuccessResult(); + } + @ApiOperation(value = "修改套餐包-订单", notes = "修改套餐包-订单接口") @ApiImplicitParams({ @ApiImplicitParam(name = "packageOrderId", value = "套餐包-订单ID", paramType = "path") diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/user/info/PayVO.java b/src/main/java/cn/com/tenlion/operator/controller/api/user/info/PayVO.java new file mode 100644 index 0000000..73f1ff3 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/api/user/info/PayVO.java @@ -0,0 +1,64 @@ +package cn.com.tenlion.operator.controller.api.user.info; + +import io.swagger.annotations.ApiModelProperty; + +/** + * 支付实体 + * @author : LY + * @date :2024-1-30 10:16 + * @description : + * @modyified By: + */ +public class PayVO { + + @ApiModelProperty(name = "auditExplain", value = "用户ID") + private String userId; + @ApiModelProperty(name = "accountMoney", value = "金额") + private Integer accountMoney; + @ApiModelProperty(name = "description", value = "说明") + private String description; + @ApiModelProperty(name = "orderId", value = "订单ID") + private String orderId; + @ApiModelProperty(name = "code", value = "") + private String code; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Integer getAccountMoney() { + return accountMoney; + } + + public void setAccountMoney(Integer accountMoney) { + this.accountMoney = accountMoney; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/user/info/UserInfoController.java b/src/main/java/cn/com/tenlion/operator/controller/api/user/info/UserInfoController.java index d8f951a..0a1935e 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/user/info/UserInfoController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/user/info/UserInfoController.java @@ -7,6 +7,7 @@ import cn.com.tenlion.operator.pojo.vos.useric.UserRechargeVO; import cn.com.tenlion.operator.pojo.vos.useric.UsericVO; import cn.com.tenlion.operator.service.user.info.IUserInfoService; import cn.com.tenlion.operator.serviceother.operator.accountrecharge.IAccountRechargeService; +import cn.com.tenlion.operator.util.PayUtil; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; @@ -47,19 +48,30 @@ public class UserInfoController extends DefaultBaseController { @PutMapping("save-recharge/{userId}") @CheckRequestBodyAnnotation public SuccessResult saveRecharge(@PathVariable("userId") String userId, @RequestBody UserRechargeVO userRechargeVO) { - /** - * 创建充值记录 - */ - AccountRechargeVO rechargeVO = new AccountRechargeVO(); - rechargeVO.setThirdParty(ThirdPartyEnum.XT.getValue()); - rechargeVO.setAccountId(userId); - rechargeVO.setReconciliationStatus("1"); - rechargeVO.setRechargeCheck("2"); - rechargeVO.setRechargeFinalTime(DateUtil.getTime()); - rechargeVO.setRechargeType("1"); - rechargeVO.setRechargeRemark(userRechargeVO.getRechargeRemark()); - rechargeVO.setRechargeMoney(userRechargeVO.getRechargeMoney()); - iAccountRechargeService.saveSystem(rechargeVO); + if(userRechargeVO.getThirdPartyMode().equals("充值")) { + /** + * 创建充值记录 + */ + AccountRechargeVO rechargeVO = new AccountRechargeVO(); + rechargeVO.setThirdParty(ThirdPartyEnum.XT.getValue()); + rechargeVO.setAccountId(userId); + rechargeVO.setReconciliationStatus("1"); + rechargeVO.setRechargeCheck("2"); + rechargeVO.setRechargeFinalTime(DateUtil.getTime()); + rechargeVO.setRechargeType("1"); + rechargeVO.setRechargeRemark(userRechargeVO.getRechargeRemark()); + rechargeVO.setRechargeMoney(userRechargeVO.getRechargeMoney()); + iAccountRechargeService.saveSystem(rechargeVO); + }else { + /** + * 创建扣款记录 + */ + AccountRechargeVO rechargeVO = new AccountRechargeVO(); + rechargeVO.setAccountId(userId); + rechargeVO.setRechargeRemark(userRechargeVO.getRechargeRemark()); + rechargeVO.setRechargeMoney(userRechargeVO.getRechargeMoney()); + iAccountRechargeService.saveSystemReduce(rechargeVO); + } return new SuccessResult(); } diff --git a/src/main/java/cn/com/tenlion/operator/controller/route/user/info/UserInfoRouteController.java b/src/main/java/cn/com/tenlion/operator/controller/route/user/info/UserInfoRouteController.java index 81c0df2..5ec0ab0 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/route/user/info/UserInfoRouteController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/route/user/info/UserInfoRouteController.java @@ -1,5 +1,6 @@ package cn.com.tenlion.operator.controller.route.user.info; +import cn.com.tenlion.projectconfig.util.ProjectConfigUtil; import ink.wgink.interfaces.consts.ISystemConstant; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -35,10 +36,23 @@ public class UserInfoRouteController { return modelAndView; } - @GetMapping("recharge-pay") - public ModelAndView rechargePay() { - ModelAndView modelAndView = new ModelAndView("user/info/recharge-pay"); + @GetMapping("package-list") + public ModelAndView packageList() { + ModelAndView modelAndView = new ModelAndView("user/info/package-list"); return modelAndView; } -} + @GetMapping("recharge-pay") + public ModelAndView rechargePay() { + ModelAndView modelAndView = new ModelAndView("user/info/recharge-pay"); + modelAndView.addObject("phone", ProjectConfigUtil.getText("HandleInvoicePhones")); + return modelAndView; + } + + @GetMapping("package-writeoff") + public ModelAndView packageWriteof() { + ModelAndView modelAndView = new ModelAndView("user/info/package-writeoff"); + modelAndView.addObject("phone", ProjectConfigUtil.getText("HandleInvoicePhones")); + return modelAndView; + } +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/pojo/dtos/packageorderitem/PackageOrderItemDTO.java b/src/main/java/cn/com/tenlion/operator/pojo/dtos/packageorderitem/PackageOrderItemDTO.java index 51e5858..23398fb 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/dtos/packageorderitem/PackageOrderItemDTO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/dtos/packageorderitem/PackageOrderItemDTO.java @@ -24,6 +24,8 @@ public class PackageOrderItemDTO { private String accountItemId; @ApiModelProperty(name = "mode", value = "方式1:次数+1,2:次数-1") private Integer mode; + @ApiModelProperty(name = "itemUseCount", value = "本次使用") + private Integer itemUseCount; @ApiModelProperty(name = "description", value = "流水描述") private String description; @ApiModelProperty(name = "orderId", value = "关联的平台订单ID") @@ -41,6 +43,14 @@ public class PackageOrderItemDTO { @ApiModelProperty(name = "packageName", value = "套餐包名称") private String packageName; + public Integer getItemUseCount() { + return itemUseCount == null ? 0 : itemUseCount; + } + + public void setItemUseCount(Integer itemUseCount) { + this.itemUseCount = itemUseCount; + } + public String getPackageName() { return packageName == null ? "" : packageName.trim(); } diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderWriteoffVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderWriteoffVO.java new file mode 100644 index 0000000..107140d --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorder/PackageOrderWriteoffVO.java @@ -0,0 +1,41 @@ +package cn.com.tenlion.operator.pojo.vos.packageorder; + +import ink.wgink.annotation.CheckEmptyAnnotation; +import ink.wgink.annotation.CheckNumberAnnotation; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * + * @ClassName: PackageOrderVO + * @Description: 套餐包-订单 + * @Author: CodeFactory + * @Date: 2025-02-26 14:48:15 + * @Version: 3.0 + **/ +@ApiModel +public class PackageOrderWriteoffVO { + + @ApiModelProperty(name = "packageOutCount", value = "核销次数") + @CheckEmptyAnnotation(name = "核销次数") + private Integer packageOutCount; + @ApiModelProperty(name = "packageTotalMoney", value = "核销备注") + @CheckEmptyAnnotation(name = "核销备注") + private String packageOutRemark; + + public Integer getPackageOutCount() { + return packageOutCount == null ? 0 : packageOutCount; + } + + public void setPackageOutCount(Integer packageOutCount) { + this.packageOutCount = packageOutCount; + } + + public String getPackageOutRemark() { + return packageOutRemark == null ? "" : packageOutRemark.trim(); + } + + public void setPackageOutRemark(String packageOutRemark) { + this.packageOutRemark = packageOutRemark; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemAppVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemAppVO.java index 635b7a2..ef89b9c 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemAppVO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemAppVO.java @@ -34,6 +34,16 @@ public class PackageOrderItemAppVO { @ApiModelProperty(name = "code", value = "加密内容") @CheckEmptyAnnotation(name = "加密内容") private String code; + @ApiModelProperty(name = "itemUseCount", value = "次数") + private Integer itemUseCount; + + public Integer getItemUseCount() { + return itemUseCount == null ? 1 : itemUseCount; + } + + public void setItemUseCount(Integer itemUseCount) { + this.itemUseCount = itemUseCount; + } public String getUserId() { return userId == null ? "" : userId.trim(); diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemVO.java index 845cb6f..963a9eb 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemVO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/packageorderitem/PackageOrderItemVO.java @@ -36,6 +36,15 @@ public class PackageOrderItemVO { private String orderTitle; @ApiModelProperty(name = "itemCount", value = "剩余次数") private Integer itemCount; + @ApiModelProperty(name = "itemUseCount", value = "本次使用") + private Integer itemUseCount; + public Integer getItemUseCount() { + return itemUseCount == null ? 1 : itemUseCount; + } + + public void setItemUseCount(Integer itemUseCount) { + this.itemUseCount = itemUseCount; + } public Integer getItemCount() { return itemCount == null ? 0 : itemCount; diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/useric/UserRechargeVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/useric/UserRechargeVO.java index e2adfdb..5a2b411 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/vos/useric/UserRechargeVO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/useric/UserRechargeVO.java @@ -19,7 +19,8 @@ public class UserRechargeVO { @ApiModelProperty(name = "rechargeMoney", value = "金额") @CheckNumberAnnotation(name = "金额") private Double rechargeMoney; - + @ApiModelProperty(name = "thirdPartyMode", value = "充值扣款") + private String thirdPartyMode; @ApiModelProperty(name = "rechargeRemark", value = "备注") private String rechargeRemark; @ApiModelProperty(name = "userId", value = "用户") @@ -29,6 +30,14 @@ public class UserRechargeVO { @ApiModelProperty(name = "code", value = "加密串") private String code; + public String getThirdPartyMode() { + return thirdPartyMode == null ? "" : thirdPartyMode.trim(); + } + + public void setThirdPartyMode(String thirdPartyMode) { + this.thirdPartyMode = thirdPartyMode; + } + public String getRechargeRemark() { return rechargeRemark == null ? "" : rechargeRemark.trim(); } diff --git a/src/main/java/cn/com/tenlion/operator/remote/accountitem/IAccountItemRemoteService.java b/src/main/java/cn/com/tenlion/operator/remote/accountitem/IAccountItemRemoteService.java index cc65e4c..6ed3cae 100644 --- a/src/main/java/cn/com/tenlion/operator/remote/accountitem/IAccountItemRemoteService.java +++ b/src/main/java/cn/com/tenlion/operator/remote/accountitem/IAccountItemRemoteService.java @@ -38,6 +38,16 @@ public interface IAccountItemRemoteService { SuccessResult payOut(@RemoteServerParams String server, @RemoteJsonBodyParams AccountItemOrderVO accountItemOrderVO, @RemoteQueryParams("access_token") String accessToken); - + /** + * 支出 + * @param server + * @param accountItemOrderVO + * @param accessToken + * @return + */ + @RemotePostMethod("pay-in/ai") + SuccessResult payIn(@RemoteServerParams String server, + @RemoteJsonBodyParams AccountItemOrderVO accountItemOrderVO, + @RemoteQueryParams("access_token") String accessToken); } diff --git a/src/main/java/cn/com/tenlion/operator/service/packageorder/IPackageOrderService.java b/src/main/java/cn/com/tenlion/operator/service/packageorder/IPackageOrderService.java index d4b7280..12a92d2 100644 --- a/src/main/java/cn/com/tenlion/operator/service/packageorder/IPackageOrderService.java +++ b/src/main/java/cn/com/tenlion/operator/service/packageorder/IPackageOrderService.java @@ -1,6 +1,7 @@ package cn.com.tenlion.operator.service.packageorder; import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderAppVO; +import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderWriteoffVO; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; import cn.com.tenlion.operator.pojo.dtos.packageorder.PackageOrderDTO; @@ -202,4 +203,6 @@ public interface IPackageOrderService { void updateClose(String packageNo); Map getCount(String userId); + + void updateWriteoff(String packageOrderId, PackageOrderWriteoffVO packageOrderWriteoffVO); } \ No newline at end of file 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 fe16ea1..4ae766e 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 @@ -10,10 +10,13 @@ import cn.com.tenlion.operator.pojo.dtos.user.info.UserInfoDTO; import cn.com.tenlion.operator.pojo.vos.accountitem.AccountItemOrderVO; import cn.com.tenlion.operator.pojo.vos.accountitem.AccountItemVO; import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderAppVO; +import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderWriteoffVO; +import cn.com.tenlion.operator.pojo.vos.packageorderitem.PackageOrderItemAppVO; import cn.com.tenlion.operator.properties.SystemApiPathProperties; import cn.com.tenlion.operator.remote.accountitem.IAccountItemRemoteService; import cn.com.tenlion.operator.remote.user.info.IUserInfoRemoteService; import cn.com.tenlion.operator.service.packageinfo.IPackageInfoService; +import cn.com.tenlion.operator.service.packageorderitem.IPackageOrderItemService; import cn.com.tenlion.operator.serviceother.operator.accountitem.IAccountItemService; import cn.com.tenlion.operator.serviceother.operator.accountrecharge.IAccountRechargeService; import cn.com.tenlion.operator.util.EncryptUtil; @@ -273,6 +276,9 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack packageOrderDao.remove(params); } + @Autowired + private IPackageOrderItemService packageOrderItemService; + @Override public Map getCount(String userId) { Map result = new HashMap<>(); @@ -295,6 +301,24 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack return result; } + @Override + public void updateWriteoff(String packageOrderId, PackageOrderWriteoffVO packageOrderWriteoffVO) { + PackageOrderDTO packageOrderDTO = get(packageOrderId); + if(packageOrderWriteoffVO.getPackageOutCount() > packageOrderDTO.getPackageTotalSurplusCount()) { + throw new SaveException("核销次数超出了剩余次数"); + } + PackageInfoDTO infoDTO = iPackageInfoService.get(packageOrderDTO.getPackageInfoId()); + PackageOrderItemAppVO packageOrderItemAppVO = new PackageOrderItemAppVO(); + packageOrderItemAppVO.setUserId(packageOrderDTO.getCreator()); + packageOrderItemAppVO.setOrderId("SYS" + DateUtil.getSdfTimes() + ( (int) (Math.random() * (99999 - 10000 + 1)) + 10000 )); + packageOrderItemAppVO.setPackageOrderId(packageOrderId); + packageOrderItemAppVO.setOrderType(infoDTO.getPackageType()); + packageOrderItemAppVO.setOrderTitle("系统核销"); + packageOrderItemAppVO.setItemUseCount(packageOrderWriteoffVO.getPackageOutCount()); + packageOrderItemAppVO.setDescription("系统核销 . " + packageOrderWriteoffVO.getPackageOutRemark()); + packageOrderItemService.saveApp("minus", packageOrderItemAppVO); + } + @Override public List list(Map params) { List list = packageOrderDao.list(params); diff --git a/src/main/java/cn/com/tenlion/operator/service/packageorderitem/impl/PackageOrderItemServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/packageorderitem/impl/PackageOrderItemServiceImpl.java index 5c6e0f4..04f9231 100644 --- a/src/main/java/cn/com/tenlion/operator/service/packageorderitem/impl/PackageOrderItemServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/packageorderitem/impl/PackageOrderItemServiceImpl.java @@ -218,11 +218,11 @@ public class PackageOrderItemServiceImpl extends DefaultBaseService implements I throw new SaveException("无可用的套餐包"); } if (!type.equals("plus")) { - if (orderDTO.getPackageTotalSurplusCount() < 1) { + if (orderDTO.getPackageTotalSurplusCount() < packageOrderItemAppVO.getItemUseCount()) { throw new SaveException("该套餐包余额不足"); } }else{ - if (orderDTO.getPackageTotalCount() < orderDTO.getPackageTotalSurplusCount() + 1) { + if (orderDTO.getPackageTotalCount() < orderDTO.getPackageTotalSurplusCount() + packageOrderItemAppVO.getItemUseCount()) { throw new SaveException("说你想干嘛?"); } } @@ -233,8 +233,9 @@ public class PackageOrderItemServiceImpl extends DefaultBaseService implements I itemVO.setOrderType(packageOrderItemAppVO.getOrderType()); itemVO.setPackageOrderAvgMoney(orderDTO.getPackageTotalAvgMoney()); itemVO.setMode(type.equals("plus") ? 1 : 2); + itemVO.setItemUseCount( packageOrderItemAppVO.getItemUseCount() ); itemVO.setOrderTitle(packageOrderItemAppVO.getOrderTitle()); - itemVO.setItemCount(type.equals("plus") ? orderDTO.getPackageTotalSurplusCount() + 1 : orderDTO.getPackageTotalSurplusCount() - 1); + itemVO.setItemCount(type.equals("plus") ? orderDTO.getPackageTotalSurplusCount() + packageOrderItemAppVO.getItemUseCount() : orderDTO.getPackageTotalSurplusCount() - packageOrderItemAppVO.getItemUseCount()); String packageOrderItemId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(itemVO); @@ -252,7 +253,7 @@ public class PackageOrderItemServiceImpl extends DefaultBaseService implements I Map update = super.getHashMap(2); update.put("packageOrderId", orderDTO.getPackageOrderId() ); update.put("gmtModified", currentDate); - update.put("packageTotalSurplusCount", type.equals("plus") ? orderDTO.getPackageTotalSurplusCount() + 1 : orderDTO.getPackageTotalSurplusCount() - 1); + update.put("packageTotalSurplusCount", type.equals("plus") ? orderDTO.getPackageTotalSurplusCount() + packageOrderItemAppVO.getItemUseCount() : orderDTO.getPackageTotalSurplusCount() - packageOrderItemAppVO.getItemUseCount()); iPackageOrderService.updateCount(update); } diff --git a/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/IAccountRechargeService.java b/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/IAccountRechargeService.java index d7e114c..ed6595b 100644 --- a/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/IAccountRechargeService.java +++ b/src/main/java/cn/com/tenlion/operator/serviceother/operator/accountrecharge/IAccountRechargeService.java @@ -31,7 +31,9 @@ public interface IAccountRechargeService { */ void save(AccountRechargeVO accountRechargeVO); - String saveSystem(AccountRechargeVO accountRechargeVO); + void saveSystemReduce(AccountRechargeVO accountRechargeVO); + + void saveSystem(AccountRechargeVO accountRechargeVO); /** * 新增账户充值 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 d519799..3fcabc9 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 @@ -1,5 +1,6 @@ package cn.com.tenlion.operator.serviceother.operator.accountrecharge.impl; +import cn.com.tenlion.operator.controller.api.user.info.PayVO; import cn.com.tenlion.operator.daoother.operator.IAccountRechargeDao; import cn.com.tenlion.operator.daoother.operator.userinfo.IUserInfoDao; import cn.com.tenlion.operator.enums.RechargeCheckEnum; @@ -16,10 +17,12 @@ 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.AccountItemOrderVO; 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.remote.accountitem.IAccountItemRemoteService; import cn.com.tenlion.operator.service.packageinfo.IPackageInfoService; import cn.com.tenlion.operator.service.packageorder.IPackageOrderService; import cn.com.tenlion.operator.serviceother.operator.account.IAccountService; @@ -27,6 +30,7 @@ import cn.com.tenlion.operator.serviceother.operator.accountitem.IAccountItemSer import cn.com.tenlion.operator.serviceother.operator.accountrecharge.IAccountRechargeService; import cn.com.tenlion.operator.service.user.info.IUserInfoService; import cn.com.tenlion.operator.service.sys.callback.SysCallbackService; +import cn.com.tenlion.operator.util.EncryptUtil; import cn.com.tenlion.operator.util.PayUtil; import cn.com.tenlion.operator.util.TenlionSMS; import cn.com.tenlion.operator.util.UserUtil; @@ -39,6 +43,7 @@ import ink.wgink.exceptions.ParamsException; import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SearchException; import ink.wgink.interfaces.user.IUserBaseService; +import ink.wgink.module.oauth2.manager.OAuth2ClientTokenManager; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.result.SuccessResultList; @@ -84,6 +89,8 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA private SysCallbackService sysCallbackService; @Autowired private IAccountItemService iAccountItemService; + @Autowired + private IAccountItemRemoteService iAccountItemRemoteService; @Override public SuccessResultList> getCanIsSueInvoices(String userId, ListPage page) { @@ -117,39 +124,81 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA } @Override - public String saveSystem(AccountRechargeVO accountRechargeVO) { - accountRechargeVO.setReconciliationStatus("0"); + public void saveSystemReduce(AccountRechargeVO accountRechargeVO) { + // 生成流水记录 + AccountItemOrderVO accountItemOrderVO = new AccountItemOrderVO(); + accountItemOrderVO.setOrderId("SYS" + DateUtil.getSdfTimes() + ( (int) (Math.random() * (99999 - 10000 + 1)) + 10000 )); + accountItemOrderVO.setUserId(accountRechargeVO.getAccountId()); // 代理商userId + accountItemOrderVO.setAccountMoney(PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney())); + accountItemOrderVO.setDescription("系统扣款" + (StringUtils.isEmpty(accountRechargeVO.getRechargeRemark()) ? "" : " * " + accountRechargeVO.getRechargeRemark() ) ); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("time", DateUtil.getTime()); + jsonObject.put("money" ,PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney())); + jsonObject.put("userId", accountRechargeVO.getAccountId()); + jsonObject.put("orderId", accountItemOrderVO.getOrderId()); + accountItemOrderVO.setCode(EncryptUtil.encode(jsonObject.toJSONString())); + accountItemOrderVO.setType(4); + iAccountItemRemoteService.payOut(apiPathProperties.getUserCenter(), accountItemOrderVO, getAccessToken()); + } + + @Override + public void saveSystem(AccountRechargeVO accountRechargeVO) { + accountRechargeVO.setReconciliationStatus("1"); accountRechargeVO.setRechargeCheck("2"); String accountRechargeId = getUUID("sys"); Map params = HashMapUtil.beanToMap(accountRechargeVO); params.put("accountRechargeId", accountRechargeId); + params.put("reconciliationTime", DateUtil.getTime()); setSaveInfo(params); accountRechargeDao.save(params); - AccountRechargeDTO dto = get(accountRechargeId); - if (StringUtils.isEmpty(dto.getAccountItemId()) && dto.getReconciliationStatus().equals(ReconciliationStatusEnum.UN_RECONCILIATION.getValue())) { - // 1. 生成流水记录 - AccountItemVO vo = new AccountItemVO(); - vo.setType(1); - vo.setMode(1); - vo.setAccountId(dto.getAccountId()); - vo.setAccountMoney(PayUtil.buiderMoney(dto.getRechargeMoney())); - vo.setDescription("系统充值" + (StringUtils.isEmpty(accountRechargeVO.getRechargeRemark()) ? "" : " * " + accountRechargeVO.getRechargeRemark() ) ); - iAccountItemService.saveReturnId(vo); + // 1. 生成流水记录 +/* AccountItemVO vo = new AccountItemVO(); + vo.setType(1); + vo.setMode(1); + vo.setAccountId(dto.getAccountId()); + vo.setAccountMoney(PayUtil.buiderMoney(dto.getRechargeMoney())); + vo.setDescription("系统充值" + (StringUtils.isEmpty(accountRechargeVO.getRechargeRemark()) ? "" : " * " + accountRechargeVO.getRechargeRemark() ) ); + iAccountItemService.saveReturnId(vo);*/ + + // 生成流水记录 + AccountItemOrderVO accountItemOrderVO = new AccountItemOrderVO(); + accountItemOrderVO.setOrderId("SYS" + DateUtil.getSdfTimes() + ( (int) (Math.random() * (99999 - 10000 + 1)) + 10000 )); + accountItemOrderVO.setUserId(accountRechargeVO.getAccountId()); // 代理商userId + accountItemOrderVO.setType(1); + accountItemOrderVO.setAccountMoney(PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney())); + accountItemOrderVO.setDescription("系统充值" + (StringUtils.isEmpty(accountRechargeVO.getRechargeRemark()) ? "" : " * " + accountRechargeVO.getRechargeRemark() ) ); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("time", DateUtil.getTime()); + jsonObject.put("money" ,PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney())); + jsonObject.put("userId", accountRechargeVO.getAccountId()); + jsonObject.put("orderId", accountItemOrderVO.getOrderId()); + accountItemOrderVO.setCode(EncryptUtil.encode(jsonObject.toJSONString())); + iAccountItemRemoteService.payIn(apiPathProperties.getUserCenter(), accountItemOrderVO, getAccessToken()); + + try{ // 3. 调用第三方接口, 告知充值到账 JSONObject jsonobject =new JSONObject(); - jsonobject.put("money", dto.getRechargeMoney()); - sysCallbackService.save("系统充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), jsonobject); - // 更新到账状态 - Map params1 = getHashMap(2); - params1.put("accountRechargeIds", "1"); - params1.put("reconciliationTime", DateUtil.getTime()); - params1.put("accountRechargeId", accountRechargeId); - accountRechargeDao.update(params1); + jsonobject.put("money", accountRechargeVO.getRechargeMoney()); + sysCallbackService.save("系统充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + accountRechargeVO.getAccountId(), jsonobject); + }catch(Exception e) { + e.printStackTrace(); } + } - return accountRechargeId; + /** + * 获取accesstoken + * @return + */ + private String getAccessToken(){ + String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); + if(StringUtils.isBlank(accessToken)){ + throw new SearchException("获取accesstoken失败"); + } + return accessToken; } @Override diff --git a/src/main/resources/mybatis/mapper/packageorderitem/package-order-item-mapper.xml b/src/main/resources/mybatis/mapper/packageorderitem/package-order-item-mapper.xml index d394399..265f054 100644 --- a/src/main/resources/mybatis/mapper/packageorderitem/package-order-item-mapper.xml +++ b/src/main/resources/mybatis/mapper/packageorderitem/package-order-item-mapper.xml @@ -12,6 +12,7 @@ + @@ -56,6 +57,7 @@ mode, description, item_count, + item_use_count, order_id, order_type, order_title, @@ -69,6 +71,7 @@ #{mode}, #{description}, #{itemCount}, + #{itemUseCount}, #{orderId}, #{orderType}, #{orderTitle}, @@ -134,7 +137,8 @@ t1.order_id, t1.order_type, t1.order_title, - t1.package_order_item_id + t1.package_order_item_id, + t1.item_use_count FROM operator_package_order_item t1 WHERE @@ -208,7 +212,8 @@ t1.order_title, t1.creator, t1.gmt_create, - t3.package_name + t3.package_name, + t1.item_use_count FROM operator_package_order_item t1 LEFT JOIN diff --git a/src/main/resources/templates/packageorderitem/list.html b/src/main/resources/templates/packageorderitem/list.html index 1af4114..5b394df 100644 --- a/src/main/resources/templates/packageorderitem/list.html +++ b/src/main/resources/templates/packageorderitem/list.html @@ -87,16 +87,17 @@ [ {type:'checkbox', fixed: 'left'}, {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'}, - {field: 'mode', width: 100, title: '类型', align:'center', fixed: 'left', + {field: 'mode', width: 120, title: '类型', align:'center', fixed: 'left', templet: function(row) { var rowData = row[this.field]; + var itemUseCount = row["itemUseCount"]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { return '-'; } if(rowData == 1) { - return '退回 + 1次'; + return '退回 + ' + itemUseCount + ' 次'; }else if(rowData == 2) { - return '使用 - 1 次'; + return '使用 - ' + itemUseCount + ' 次'; } return rowData; } diff --git a/src/main/resources/templates/user/info/list.html b/src/main/resources/templates/user/info/list.html index b9177cb..ee7d05f 100644 --- a/src/main/resources/templates/user/info/list.html +++ b/src/main/resources/templates/user/info/list.html @@ -104,7 +104,10 @@ 充值记录 + @@ -434,7 +437,7 @@ } else { top.layer.open({ type: 2, - title: "用户 " + checkDatas[0].userName + " " + checkDatas[0].userInfoName+ " 系统充值【当前余额 " + (checkDatas[0].accountMoney / 100.0) + ' 元】', + title: "用户 " + checkDatas[0].userName + " " + checkDatas[0].userInfoName+ " 系统充值与扣款【当前余额 " + (checkDatas[0].accountMoney / 100.0) + ' 元】', closeBtn: 1, area: ['50%', '50%'], shadeClose: true, @@ -445,6 +448,25 @@ } }); } + }else if(layEvent === 'packageEvent') { + if(checkDatas.length === 0) { + top.dialog.msg(top.dataMessage.table.selectEdit); + } else if(checkDatas.length > 1) { + top.dialog.msg(top.dataMessage.table.selectOneEdit); + } else { + top.layer.open({ + type: 2, + title: "用户 " + checkDatas[0].userName + " " + checkDatas[0].userInfoName+ " 套餐包【当前余额 " + (checkDatas[0].accountMoney / 100.0) + ' 元】', + closeBtn: 1, + area: ['80%', '80%'], + shadeClose: true, + anim: 2, + content: top.restAjax.path('route/user/info/package-list?accountId={accountId}', [checkDatas[0].userId]), + end: function() { + reloadTable(); + } + }); + } }else if(layEvent === 'rechargeRecordEvent') { if(checkDatas.length === 0) { top.dialog.msg(top.dataMessage.table.selectEdit); diff --git a/src/main/resources/templates/user/info/package-list.html b/src/main/resources/templates/user/info/package-list.html new file mode 100644 index 0000000..0d2cb32 --- /dev/null +++ b/src/main/resources/templates/user/info/package-list.html @@ -0,0 +1,317 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/user/info/package-writeoff.html b/src/main/resources/templates/user/info/package-writeoff.html new file mode 100644 index 0000000..5fba1d4 --- /dev/null +++ b/src/main/resources/templates/user/info/package-writeoff.html @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/user/info/recharge-pay.html b/src/main/resources/templates/user/info/recharge-pay.html index 0d90f31..48cb586 100644 --- a/src/main/resources/templates/user/info/recharge-pay.html +++ b/src/main/resources/templates/user/info/recharge-pay.html @@ -35,14 +35,14 @@
- +
- +
- +
@@ -50,16 +50,23 @@
+
+ +
+ + +
+
- +
@@ -104,13 +111,21 @@ // 提交表单 form.on('submit(submitForm)', function(formData) { - top.dialog.confirm("提交后会充值到用户账号中,且无法回退。", function(index) { + top.dialog.confirm("提交后会直接操作用户账号,且无法回退。", function(index) { $('#submit').attr("disabled", "disabled"); $('#submit').addClass("layui-btn-disabled"); top.dialog.close(index); +/* + layer.prompt({title: '已发送验证码 至 [[${phone}]]', formType: 3 , value: "" , placeholder : "请输入验证码" }, function(title, index1){ + if(title) { + + } + }); + + */ var loadLayerIndex; top.restAjax.put(top.restAjax.path('api/user/info/save-recharge/{accountId}', [accountId]), formData.field, null, function(code, data) { - layer.alert("充值成功"); + layer.alert("操作成功"); closeBox(); }, function(code, data) { top.dialog.msg(data.msg);