From c50e3e4afb60214946b534e88ee3ac1cba4fd761 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Thu, 10 Oct 2024 08:50:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E5=9E=8B=20=E6=94=B6=E8=B4=B9?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=AD=89=20app=E9=A6=96=E9=A1=B5=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/app/AppController.java | 13 + .../controller/app/AppVerifyController.java | 41 +- .../appadmin/AppAdminController.java | 377 ++++++++++++++++++ .../web/controller/rl/RlDeviceController.java | 27 -- .../common/core/domain/entity/RlUserVO.java | 5 +- .../com/ruoyi/common/enums/BusinessType.java | 29 +- .../framework/config/SecurityConfig.java | 1 + .../system/domain/device/RlDeviceQuery.java | 5 +- .../ruoyi/system/domain/model/RlModel.java | 3 + .../ruoyi/system/domain/model/RlModelVO.java | 3 + .../ruoyi/system/domain/order/RlOrder.java | 4 + .../system/domain/order/RlOrderQuery.java | 3 + .../ruoyi/system/domain/order/RlOrderVO.java | 7 +- .../ruoyi/system/domain/refund/RlRefund.java | 7 +- .../ruoyi/system/domain/rule/RlFeeRule.java | 3 + .../com/ruoyi/system/domain/store/Store.java | 4 +- .../system/domain/userExt/RlUserExt.java | 9 + .../ruoyi/system/domain/vo/IndexAdminVo.java | 45 +++ .../system/domain/withdraw/RlWithdraw.java | 140 +------ .../ruoyi/system/mapper/RlModelMapper.java | 2 + .../ruoyi/system/mapper/RlUserExtMapper.java | 8 + .../service/IRlChangeBalanceService.java | 3 +- .../system/service/IRlDeviceService.java | 6 + .../ruoyi/system/service/IRlModelService.java | 8 + .../ruoyi/system/service/IRlOrderService.java | 25 ++ .../system/service/IRlUserExtService.java | 8 + .../ruoyi/system/service/IRlUserService.java | 16 +- .../system/service/IRlWithdrawService.java | 8 +- .../service/impl/CallbackServiceImpl.java | 14 + .../impl/RlChangeBalanceServiceImpl.java | 8 +- .../service/impl/RlDeviceServiceImpl.java | 27 +- .../service/impl/RlModelServiceImpl.java | 26 ++ .../service/impl/RlOrderServiceImpl.java | 176 +++++++- .../service/impl/RlUserExtServiceImpl.java | 11 + .../service/impl/RlUserServiceImpl.java | 153 ++++++- .../system/service/impl/WxPayService.java | 2 +- .../mapper/system/RlDeviceMapper.xml | 46 +-- .../mapper/system/RlFeeRuleMapper.xml | 20 +- .../resources/mapper/system/RlModelMapper.xml | 10 +- .../resources/mapper/system/RlOrderMapper.xml | 24 +- .../mapper/system/RlUserExtMapper.xml | 16 +- .../resources/mapper/system/RlUserMapper.xml | 8 +- .../mapper/system/RlWithdrawMapper.xml | 10 +- .../resources/mapper/system/StoreMapper.xml | 21 +- 44 files changed, 1053 insertions(+), 329 deletions(-) create mode 100644 ridelease-admin/src/main/java/com/ruoyi/web/controller/appadmin/AppAdminController.java create mode 100644 ridelease-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java diff --git a/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java b/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java index 31ecca2..e9c7070 100644 --- a/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java +++ b/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java @@ -130,6 +130,19 @@ public class AppController extends BaseController return error("代理商不存在"); } + /** + * 根据代理商id获取车型列表 + */ + @GetMapping("/getModelListByAgentId") + public AjaxResult getModelListByAgentId(Long agentId) + { + logger.info("根据代理商id获取车型列表:【agentId="+agentId+"】"); + if(agentId==null){ + return error("代理商id不能为空"); + } + return success(modelService.selectEModelListByAgentId(agentId)); + } + /** * 根据定位获取哪个城市 */ diff --git a/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 4d6dc08..117ac22 100644 --- a/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/ridelease-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -8,6 +8,8 @@ import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.RlUser; +import com.ruoyi.common.core.domain.entity.RlUserVO; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.ServiceException; @@ -28,6 +30,8 @@ import com.ruoyi.system.domain.query.AuthenticationQuery; import com.ruoyi.system.domain.store.StoreVo; import com.ruoyi.system.domain.vo.PriceVO; import com.ruoyi.system.domain.vo.RlUserQuery; +import com.ruoyi.system.domain.withdraw.RlWithdraw; +import com.ruoyi.system.domain.withdraw.RlWithdrawQuery; import com.ruoyi.system.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -137,7 +141,7 @@ public class AppVerifyController extends BaseController throw new ServiceException("取车时间不能为空"); } // 取车经纬度不能为空 - if(StringUtils.isEmpty(order.getPickupLon()) && StringUtils.isEmpty(order.getPickupLat())){ + if(StringUtils.isEmpty(order.getPickupLon()) && StringUtils.isEmpty(order.getPickupLat()) && !order.getDeliveryMethod().equals(ServiceConstants.DELIVERY_METHOD_SELF_PICKUP)){ throw new ServiceException("取车经度不能为空"); } // ruleId不能为空 @@ -256,6 +260,18 @@ public class AppVerifyController extends BaseController @PutMapping("/device/edit") public AjaxResult deviceEdit(String sn, String vehicleNum, String status) { + logger.info("【更新车牌号】请求参数:sn={},vehicleNum={}", sn,vehicleNum); + if(StrUtil.isBlank(sn)){ + return error("【更新车牌号】sn不能为空"); + } + RlDevice rlDevice = deviceService.selectDeviceBySn(sn); + + if(rlDevice == null){ + return error("【更新车牌号】设备不存在【"+sn+"】"); + } + if(StrUtil.isBlank(vehicleNum)){ + return error("【更新车牌号】车牌号不能为空"); + } RlDevice device = new RlDevice(); device.setSn(sn); device.setVehicleNum(vehicleNum); @@ -301,17 +317,6 @@ public class AppVerifyController extends BaseController return success(aBoolean); } - /** - * 车辆列表 - */ - @GetMapping(value = "/vehicleList") - public AjaxResult allVehicleInfo(RlDeviceQuery query) - { - logger.info("【车辆列表】请求参数:query={}", JSON.toJSONString(query)); - List devices = deviceService.selectDeviceList(query); - return success(devices); - } - /** * 管理员开锁 */ @@ -408,18 +413,6 @@ public class AppVerifyController extends BaseController return error(); } - /** - * 我的账户 - */ - @GetMapping(value = { "/myAccountInfo" }) - public AjaxResult myAccountInfo() - { - AjaxResult ajax = AjaxResult.success(); - RlUser rlUser = rlUserService.myAccountInfoByUserId(getUserId()); - ajax.put(AjaxResult.DATA_TAG, rlUser); - return ajax; - } - /** * 获取提现记录详细信息 diff --git a/ridelease-admin/src/main/java/com/ruoyi/web/controller/appadmin/AppAdminController.java b/ridelease-admin/src/main/java/com/ruoyi/web/controller/appadmin/AppAdminController.java new file mode 100644 index 0000000..22afdfd --- /dev/null +++ b/ridelease-admin/src/main/java/com/ruoyi/web/controller/appadmin/AppAdminController.java @@ -0,0 +1,377 @@ +package com.ruoyi.web.controller.appadmin; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ServiceConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.ValidGroup; +import com.ruoyi.common.core.domain.entity.RlUserVO; +import com.ruoyi.common.core.domain.model.LoginBody; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ServiceUtil; +import com.ruoyi.framework.web.service.SysLoginService; +import com.ruoyi.system.domain.changeBalance.RlChangeBalance; +import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery; +import com.ruoyi.system.domain.device.RlDeviceQuery; +import com.ruoyi.system.domain.device.RlDeviceVO; +import com.ruoyi.system.domain.model.RlModel; +import com.ruoyi.system.domain.model.RlModelQuery; +import com.ruoyi.system.domain.order.RlOrderQuery; +import com.ruoyi.system.domain.order.RlOrderVO; +import com.ruoyi.system.domain.rule.RlFeeRule; +import com.ruoyi.system.domain.store.StoreBO; +import com.ruoyi.system.domain.store.StoreVo; +import com.ruoyi.system.domain.userExt.RlUserExt; +import com.ruoyi.system.domain.vo.IndexAdminVo; +import com.ruoyi.system.domain.withdraw.RlWithdrawQuery; +import com.ruoyi.system.service.*; +import com.ruoyi.system.service.store.RlStoreService; +import com.ruoyi.system.service.store.StoreAssembler; +import com.ruoyi.system.service.store.StoreValidator; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +/** + * app接口(需要登录校验的) + * 校验 + * @author ruoyi + */ +@Slf4j +@RestController +@RequestMapping("/appAdmin") +public class AppAdminController extends BaseController +{ + + @Resource + private IRlUserService rlUserService; + + @Autowired + private SysLoginService loginService; + + @Resource + private IRlOrderService orderService; + + @Autowired + private IRlDeviceService deviceService; + + @Autowired + private IRlUserExtService rlUserExtService; + + @Autowired + private IRlModelService modelService; + + @Autowired + private RlStoreService storeService; + + @Autowired + private StoreValidator storeValidator; + + @Autowired + private StoreAssembler storeAssembler; + + @Autowired + private IRlFeeRuleService feeRuleService; + + /** + * 首页统计 + */ + @GetMapping(value = { "/index" }) + public AjaxResult index() + { + AjaxResult ajax = AjaxResult.success(); + IndexAdminVo incomeVos = orderService.indexStatistics(getUserId()); + ajax.put(AjaxResult.DATA_TAG, incomeVos); + return ajax; + } + + /** + * 验证码登录 + */ + @PostMapping("/appCodeLogin") + public AjaxResult appCodeLogin(@RequestBody LoginBody loginBody) { + AjaxResult ajax = AjaxResult.success(); + /**通过手机号找到用户名*/ + String phone = loginBody.getPhone(); + // 生成令牌 + String token = loginService.appCodeLogin(phone, loginBody.getPhoneCode(),loginBody.getPassword(), loginBody.getUuid()); + ajax.put(Constants.TOKEN, token); + return ajax; + } + + /** + * 微信登录 + */ + @PostMapping("/wxlogin") + public AjaxResult wxlogin(String mobileCode,String jsCode) { + log.info("【微信登录/wxlogin】areaId参数:【mobileCode={}】", mobileCode); + AjaxResult ajax = AjaxResult.success(); + // 生成令牌 + String token = loginService.wxloing(mobileCode,jsCode); + ajax.put(Constants.TOKEN, token); + return ajax; + } + + /** + * 我的账户 + */ + @GetMapping(value = { "/myAccountInfo" }) + public AjaxResult myAccountInfo() + { + AjaxResult ajax = AjaxResult.success(); + RlUserVO rlUser = rlUserService.myAccountInfoByUserId(getUserId()); + ajax.put(AjaxResult.DATA_TAG, rlUser); + return ajax; + } + + /** + * 账变记录 + */ + @GetMapping(value = { "/myChangeBalanceList" }) + public AjaxResult myChangeBalanceList(RlChangeBalanceQuery query) + { + log.info("【账变记录/myChangeBalanceList】参数:【query={}】", query); + AjaxResult ajax = AjaxResult.success(); + if(query.getType().equals("0")){ + query.setType(null); + } + List changeBalances = rlUserService.myChangeBalanceList(query,getUserId()); + ajax.put(AjaxResult.DATA_TAG, changeBalances); + return ajax; + } + + /** + * 车辆列表 + */ + @GetMapping(value = "/vehicleList") + public AjaxResult allVehicleInfo(RlDeviceQuery query) + { + logger.info("【车辆列表】请求参数:query={}", JSON.toJSONString(query)); + List devices = deviceService.selectDeviceList(query); + return success(devices); + } + + /** + * 上传收款码 + * type:1-微信收款码,2-支付宝收款码 + */ + @Log(title = "上传收款码", businessType = BusinessType.UPDATE) + @PostMapping("/uploadPaymentCode") + public AjaxResult uploadPaymentCode(String collectionCode,String type) + { + log.info("【上传收款码】请求参数:collectionCode={}", collectionCode); + if(collectionCode == null || collectionCode.equals("")){ + return AjaxResult.warn("收款码不能为空"); + } + if(type == null || type.equals("")){ + return AjaxResult.warn("收款码类型不能为空"); + } + RlUserExt userExt = new RlUserExt(); + userExt.setUserId(getUserId()); + if(type.equals("1")){ + userExt.setWxCollectionCode(collectionCode); + }else{ + userExt.setAliCollectionCode(collectionCode); + } + int result = rlUserExtService.updateRlUserExt(userExt); + return toAjax(result); + } + + + + /** + * 车辆上线 + */ + @Log(title = "车辆上线", businessType = BusinessType.ONLINE) + @PostMapping("/device/online") + public AjaxResult online(String sn) + { + logger.info("【车辆上线请求】:{}",sn); + Boolean aBoolean = deviceService.online(sn); + return success(aBoolean); + } + + /** + * 车辆下线 + */ + @Log(title = "车辆下线", businessType = BusinessType.OFFLINE) + @PostMapping("/device/offline") + public AjaxResult offline(String sn) + { + logger.info("【车辆下线请求】:{}",sn); + Boolean aBoolean = deviceService.offline(sn, ServiceConstants.VEHICLE_STATUS_IN_OFFLINE); + return success(aBoolean); + } + + /** + * + * 根据商户id[merchantId]获取车型列表 + */ + @GetMapping("/getModelListByMerchantId") + public AjaxResult getModelListByMerchantId() + { + logger.info("根据userid获取车型列表:【userId="+getUserId()+"】"); + return success(modelService.getModelListByMerchantId(getUserId())); + } + + /** + * 订单列表 + */ + @GetMapping("/orderList") + public AjaxResult orderList(RlOrderQuery order) + { + order.setMerchantId(getUserId()); + logger.info("订单列表请求:order=【"+JSON.toJSONString(order)+"】"); + List rlOrderVOS = orderService.selectRlOrderList(order); + return success(rlOrderVOS); + } + + /** + * 订单信息 + */ + @GetMapping("/orderInfo") + public AjaxResult orderInfo(String orderNo) + { + logger.info("订单列表请求:order=【"+JSON.toJSON(orderNo)+"】"); + RlOrderVO rlOrder = orderService.getOrderInfoByOrderNo(orderNo); + return success(rlOrder); + } + + /** + * 退款 + */ + @Log(title = "订单退款", businessType = BusinessType.REFUND) + @PutMapping("/order/refund") + public AjaxResult orderRefund(@RequestBody RlOrderQuery order) + { + logger.info("【订单退款请求】:{}", JSON.toJSON(order)); + return toAjax(orderService.refund(order)); + } + + /** + * 管理员提现 + */ + @Log(title = "管理员提现", businessType = BusinessType.ADMINWITHDRAW) + @PostMapping("/admin/withdraw") + public AjaxResult add(@RequestBody RlWithdrawQuery withdraw) + { + logger.info("管理员提现请求:【{}】", JSON.toJSON(withdraw)); + int i = rlUserService.adminWithdraw(withdraw); + return toAjax(i); + } + + /** + * 获取商户详细信息 + */ + @GetMapping(value = "/store/{storeId}") + public AjaxResult getInfo(@PathVariable("storeId") Long storeId) + { + StoreVo store = storeService.selectSmStoreById(storeId); + List list = Collections.singletonList(store); + storeAssembler.assembleDeviceCount(list); // 设备数量 + storeAssembler.assembleRevenue(list); // 经营数据 + return success(store); + } + + /** + * 保存店铺 + */ + @Log(title = "保存店铺", businessType = BusinessType.SAVESTORE) + @PostMapping(value = "/store/save") + public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) StoreBO store) + { + int result; + store.setMerchantId(getUserId()); + if(ObjectUtil.isNull(store.getStoreId())){ + store = store.filterCreate(); + ServiceUtil.assertion(storeValidator.preCreate(store)); + result = storeService.insertSmStore(store); + }else{ + store = store.filterUpdate(); + ServiceUtil.assertion(storeValidator.preUpdate(store)); + result = storeService.updateSmStore(store); + } + return toAjax(result); + } + + /** + * 新增车辆型号 + */ + @Log(title = "车辆型号", businessType = BusinessType.INSERT) + @PostMapping(value = "/model/save") + public AjaxResult add(@RequestBody RlModelQuery model) + { + return toAjax(modelService.insertEModel(model)); + } + + /** + * 修改车辆型号 + */ + @Log(title = "车辆型号", businessType = BusinessType.UPDATE) + @PutMapping(value = "/model/edit") + public AjaxResult edit(@RequestBody RlModelQuery model) + { + return toAjax(modelService.updateEModel(model)); + } + + /** + * 删除车辆型号 + */ + @Log(title = "车辆型号", businessType = BusinessType.DELETE) + @DeleteMapping("/model/{modelIds}") + public AjaxResult remove(@PathVariable Long[] modelIds) + { + for (Long modelId:modelIds) { + RlModel model = new RlModel(); + model.setModelId(modelId); + model.setDelFlag("2"); + modelService.updateEModel(model); + } + return toAjax(1); + } + + /** + * 新增收费模板 + */ + @Log(title = "收费模板", businessType = BusinessType.INSERT) + @PostMapping("/rule/save") + public AjaxResult addModel(@RequestBody RlFeeRule rlFeeRule) + { + return toAjax(feeRuleService.insertRlFeeRule(rlFeeRule)); + } + + /** + * 修改收费模板 + */ + @Log(title = "收费模板", businessType = BusinessType.UPDATE) + @PutMapping("/rule/edit") + public AjaxResult editModel(@RequestBody RlFeeRule rlFeeRule) + { + return toAjax(feeRuleService.updateRlFeeRule(rlFeeRule)); + } + + /** + * 删除收费模板 + */ + @Log(title = "收费模板", businessType = BusinessType.DELETE) + @DeleteMapping("/rule/{ruleIds}") + public AjaxResult removeModel(@PathVariable Long[] ruleIds) + { + for (Long ruleId:ruleIds) { + RlFeeRule rule = new RlFeeRule(); + rule.setRuleId(ruleId); + rule.setDelFlag("2"); + feeRuleService.updateRlFeeRule(rule); + } + return toAjax(1); + } + +} diff --git a/ridelease-admin/src/main/java/com/ruoyi/web/controller/rl/RlDeviceController.java b/ridelease-admin/src/main/java/com/ruoyi/web/controller/rl/RlDeviceController.java index bf46174..0a327a4 100644 --- a/ridelease-admin/src/main/java/com/ruoyi/web/controller/rl/RlDeviceController.java +++ b/ridelease-admin/src/main/java/com/ruoyi/web/controller/rl/RlDeviceController.java @@ -249,33 +249,6 @@ public class RlDeviceController extends BaseController // Boolean aBoolean =eDeviceService.adminLockByMac(mac,getUsername()); // return success(aBoolean); // } -// -// -// /** -// * 车辆上线 -// */ -// @PreAuthorize("@ss.hasPermi('system:device:online')") -// @Log(title = "车辆上线", businessType = BusinessType.ONLINE) -// @PostMapping("/device/online") -// public AjaxResult online(String sn) -// { -// logger.info("【车辆上线请求】:{}",sn); -// Boolean aBoolean =eDeviceService.online(sn); -// return success(aBoolean); -// } -// -// /** -// * 车辆下线 -// */ -// @PreAuthorize("@ss.hasPermi('system:device:online')") -// @Log(title = "车辆下线", businessType = BusinessType.OFFLINE) -// @PostMapping("/device/offline") -// public AjaxResult offline(String sn) -// { -// logger.info("【车辆下线请求】:{}",sn); -// Boolean aBoolean =eDeviceService.offline(sn, ServiceConstants.VEHICLE_STATUS_IN_OFFLINE); -// return success(aBoolean); -// } } diff --git a/ridelease-common/src/main/java/com/ruoyi/common/core/domain/entity/RlUserVO.java b/ridelease-common/src/main/java/com/ruoyi/common/core/domain/entity/RlUserVO.java index a64eff2..3a315fd 100644 --- a/ridelease-common/src/main/java/com/ruoyi/common/core/domain/entity/RlUserVO.java +++ b/ridelease-common/src/main/java/com/ruoyi/common/core/domain/entity/RlUserVO.java @@ -10,10 +10,7 @@ import java.util.List; public class RlUserVO extends RlUser{ /** 累计提现金额 */ - private BigDecimal totalWithdrawAmount; - - /** 账变记录 */ - List changeBalanceList; + private BigDecimal totalWithdrawAmount = new BigDecimal("0.00"); /** 余额 */ private String balance; diff --git a/ridelease-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/ridelease-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index 90c8a3e..0d9cf1e 100644 --- a/ridelease-common/src/main/java/com/ruoyi/common/enums/BusinessType.java +++ b/ridelease-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -113,4 +113,31 @@ public enum BusinessType * 改价 */ EDITPRICE, -} + + /** + * 退款 + */ + REFUND, + + /** + * 车辆上线 + */ + ONLINE, + + /** + * 车辆下线 + */ + OFFLINE, + /** + * 提现 + */ + WITHDRAW, + /** + * 管理员提现 + */ + ADMINWITHDRAW, + /** + * 保存店铺 + */ + SAVESTORE + } diff --git a/ridelease-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ridelease-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index d842f21..528093a 100644 --- a/ridelease-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ridelease-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -129,6 +129,7 @@ public class SecurityConfig requests .antMatchers("/login", "/wxlogin", + "/appAdmin/wxlogin", "/register", "/captchaImage", "/appCaptcha", diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/device/RlDeviceQuery.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/device/RlDeviceQuery.java index eda1795..8e74abc 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/device/RlDeviceQuery.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/device/RlDeviceQuery.java @@ -6,5 +6,8 @@ import lombok.Data; public class RlDeviceQuery extends RlDevice{ /** 排序 */ - private String orderBy; + private String sort; + + /** 关键字: sn或车牌号 */ + private String keywords; } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModel.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModel.java index 053e093..d0bfb94 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModel.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModel.java @@ -56,4 +56,7 @@ public class RlModel extends BaseEntity /** 描述 */ private String description; + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModelVO.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModelVO.java index fecd56b..45928fd 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModelVO.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/model/RlModelVO.java @@ -25,4 +25,7 @@ public class RlModelVO extends RlModel{ @ApiModelProperty("功能列表") private List functionList; + + /** 代理商名称 */ + private String agnetName; } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrder.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrder.java index 3ec79b1..275850f 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrder.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrder.java @@ -62,6 +62,10 @@ public class RlOrder extends BaseEntity @Excel(name = "车型id") private Long modelId; + /** 车型 */ + @Excel(name = "车型") + private String model; + /** 支付时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderQuery.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderQuery.java index 53d6af8..b5b604b 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderQuery.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderQuery.java @@ -32,4 +32,7 @@ public class RlOrderQuery extends RlOrder{ /** 类型 1-租赁订单,2-续租订单*/ private String type; + /** 关键字: 手机号或订单号 */ + private String keywords; + } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderVO.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderVO.java index 71c2a10..a6e4442 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderVO.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/order/RlOrderVO.java @@ -1,6 +1,7 @@ package com.ruoyi.system.domain.order; import com.ruoyi.common.annotation.Excel; +import com.ruoyi.system.domain.RlFunction; import com.ruoyi.system.domain.accessory.RlAccessoryVO; import com.ruoyi.system.domain.rule.RlFeeRule; import lombok.Data; @@ -25,15 +26,15 @@ public class RlOrderVO extends RlOrder{ /** 店铺地址 */ private String storeAddress; - /** 车型 */ - private String model; - /** 代理商 */ private String agentName; @Excel(name = "配件列表") private List accessorys; + @Excel(name = "功能列表") + private List functionList; + /** 图片 */ @Excel(name = "图片") private String picture; diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/refund/RlRefund.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/refund/RlRefund.java index d583c00..afe0e04 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/refund/RlRefund.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/refund/RlRefund.java @@ -51,15 +51,12 @@ public class RlRefund extends BaseEntity /** 调度费 */ private BigDecimal dispatchFee; - /** 停车点外调度费 */ - private BigDecimal manageFee; + /** 配送费 */ + private BigDecimal deliveryFee; /** 骑行费 */ private BigDecimal leaseFee; - /** 预约费 */ - private BigDecimal appointmentFee; - /** 退款原因 */ @Excel(name = "退款原因") private String reason; diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/rule/RlFeeRule.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/rule/RlFeeRule.java index 1daac36..9550c5b 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/rule/RlFeeRule.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/rule/RlFeeRule.java @@ -52,4 +52,7 @@ public class RlFeeRule extends BaseEntity /** 车型id */ private Long modelId; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/store/Store.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/store/Store.java index 35baa88..5dbe194 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/store/Store.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/store/Store.java @@ -40,7 +40,7 @@ public class Store extends BaseEntity /** 用户 */ @Excel(name = "用户") @ApiModelProperty("用户id") - @NotNull(message = "用户id不能为空", groups = {ValidGroup.Create.class}) +// @NotNull(message = "用户id不能为空", groups = {ValidGroup.Create.class}) private Long userId; /** 代理商 */ @@ -124,7 +124,7 @@ public class Store extends BaseEntity private String contactMobile; @ApiModelProperty("是否展示店铺") - @NotNull(message = "是否展示店铺不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class}) +// @NotNull(message = "是否展示店铺不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class}) private Boolean show; @ApiModelProperty("状态") diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/userExt/RlUserExt.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/userExt/RlUserExt.java index 0581a76..e00f773 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/userExt/RlUserExt.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/userExt/RlUserExt.java @@ -41,4 +41,13 @@ public class RlUserExt extends BaseEntity /** 分账状态 */ @Excel(name = "分账状态") private Boolean dividendStatus; + + /** 微信收款码 */ + public String wxCollectionCode; + + /** 支付宝收款码 */ + public String aliCollectionCode; + + /** 代理商id */ + private Long agentId; } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java new file mode 100644 index 0000000..32ecb28 --- /dev/null +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java @@ -0,0 +1,45 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * app首页统计 + * + * @author 邱贞招 + * @date 2024-05-09 + */ +@Data +public class IndexAdminVo { + + /** 收入统计list */ + private List incomeVoList; + + /** + * 7日营收 + */ + @Data + public static class IncomeVo { + /** 日期 */ + private String day; + /** 订单金额 */ + private BigDecimal orderFee; + /** 订单数 */ + private Integer orderNum; + } + + /** 今日营收 */ + private BigDecimal todayIncome; + + /** 今日订单数 */ + private BigDecimal todayOrderNum; + + /** 较昨日营收 */ + private BigDecimal comparedYesterdayIncome; + + /** 较昨日订单数 */ + private BigDecimal comparedYesterdayOrderNum; + +} diff --git a/ridelease-system/src/main/java/com/ruoyi/system/domain/withdraw/RlWithdraw.java b/ridelease-system/src/main/java/com/ruoyi/system/domain/withdraw/RlWithdraw.java index 2414626..3e10a77 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/domain/withdraw/RlWithdraw.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/domain/withdraw/RlWithdraw.java @@ -1,6 +1,8 @@ package com.ruoyi.system.domain.withdraw; import java.math.BigDecimal; + +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -12,6 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * @author qzz * @date 2024-09-28 */ +@Data public class RlWithdraw extends BaseEntity { private static final long serialVersionUID = 1L; @@ -27,10 +30,6 @@ public class RlWithdraw extends BaseEntity @Excel(name = "提现金额") private BigDecimal amount; - /** 运营商id */ - @Excel(name = "运营商id") - private Long deptId; - /** 状态 */ @Excel(name = "状态") private String status; @@ -51,9 +50,9 @@ public class RlWithdraw extends BaseEntity @Excel(name = "手机号") private String ownerPhone; - /** 服务费 */ - @Excel(name = "服务费") - private BigDecimal serviceCharge; + /** 手续费 */ + @Excel(name = "手续费") + private BigDecimal handlingCharge; /** 成本 */ @Excel(name = "成本") @@ -63,131 +62,4 @@ public class RlWithdraw extends BaseEntity @Excel(name = "打款方式") private String paymentMethod; - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - public void setWithdrawNo(String withdrawNo) - { - this.withdrawNo = withdrawNo; - } - - public String getWithdrawNo() - { - return withdrawNo; - } - public void setAmount(BigDecimal amount) - { - this.amount = amount; - } - - public BigDecimal getAmount() - { - return amount; - } - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getDeptId() - { - return deptId; - } - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - public void setRejectReason(String rejectReason) - { - this.rejectReason = rejectReason; - } - - public String getRejectReason() - { - return rejectReason; - } - public void setOwnerName(String ownerName) - { - this.ownerName = ownerName; - } - - public String getOwnerName() - { - return ownerName; - } - public void setOwnerId(Long ownerId) - { - this.ownerId = ownerId; - } - - public Long getOwnerId() - { - return ownerId; - } - public void setOwnerPhone(String ownerPhone) - { - this.ownerPhone = ownerPhone; - } - - public String getOwnerPhone() - { - return ownerPhone; - } - public void setServiceCharge(BigDecimal serviceCharge) - { - this.serviceCharge = serviceCharge; - } - - public BigDecimal getServiceCharge() - { - return serviceCharge; - } - public void setCost(BigDecimal cost) - { - this.cost = cost; - } - - public BigDecimal getCost() - { - return cost; - } - public void setPaymentMethod(String paymentMethod) - { - this.paymentMethod = paymentMethod; - } - - public String getPaymentMethod() - { - return paymentMethod; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("withdrawNo", getWithdrawNo()) - .append("amount", getAmount()) - .append("deptId", getDeptId()) - .append("status", getStatus()) - .append("createTime", getCreateTime()) - .append("rejectReason", getRejectReason()) - .append("ownerName", getOwnerName()) - .append("ownerId", getOwnerId()) - .append("ownerPhone", getOwnerPhone()) - .append("serviceCharge", getServiceCharge()) - .append("cost", getCost()) - .append("paymentMethod", getPaymentMethod()) - .toString(); - } } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlModelMapper.java b/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlModelMapper.java index 6381225..c227828 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlModelMapper.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlModelMapper.java @@ -79,4 +79,6 @@ public interface RlModelMapper int selectAllCount(); + + List getModelListByMerchantId(Long merchantId); } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlUserExtMapper.java b/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlUserExtMapper.java index c7e3e28..fa4af54 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlUserExtMapper.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/mapper/RlUserExtMapper.java @@ -20,6 +20,14 @@ public interface RlUserExtMapper */ public RlUserExt selectRlUserExtByExtId(Long extId); + /** + * 查询用户扩展 + * + * @param userId 用户扩展主键 + * @return 用户扩展 + */ + public RlUserExt selectRlUserExtByUserId(Long userId); + /** * 查询用户扩展列表 * diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlChangeBalanceService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlChangeBalanceService.java index 989b6bb..9fb4bb4 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlChangeBalanceService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlChangeBalanceService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service; import com.ruoyi.system.domain.changeBalance.RlChangeBalance; +import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery; import java.util.List; @@ -34,7 +35,7 @@ public interface IRlChangeBalanceService * @param userId 余额变动 * @return 余额变动集合 */ - public List selectRlChangeBalanceListByUserId(Long userId); + public List selectRlChangeBalanceListByUserId(RlChangeBalanceQuery query, Long userId); /** diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlDeviceService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlDeviceService.java index fefb490..449c4de 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlDeviceService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlDeviceService.java @@ -6,8 +6,11 @@ import com.ruoyi.common.utils.onenet.ResponseVo; import com.ruoyi.system.domain.device.RlDevice; import com.ruoyi.system.domain.device.RlDeviceQuery; import com.ruoyi.system.domain.device.RlDeviceVO; +import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrderQuery; +import com.ruoyi.system.domain.order.RlOrderVO; +import java.math.BigDecimal; import java.util.List; /** @@ -393,4 +396,7 @@ public interface IRlDeviceService extends IService // * 是否靠近运营区边界 // */ // boolean isCloseToTheBoundary(String sn, EtOperatingArea area); + + /** 计算逾期费用 */ + public BigDecimal computeOverdueFee(RlOrderVO order, RlOrder updateOrder); } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlModelService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlModelService.java index 33a94ec..0fb189d 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlModelService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlModelService.java @@ -38,6 +38,14 @@ public interface IRlModelService */ public List selectEModelListByAgentId(Long agentId); + /** + * 根据商户id查询车辆型号列表 + * + * @param merchantId 商户id + * @return 车辆型号集合 + */ + public List getModelListByMerchantId(Long merchantId); + /** * 根据店铺id查询车辆型号列表 diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlOrderService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlOrderService.java index 03dd382..453d72d 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlOrderService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlOrderService.java @@ -4,10 +4,13 @@ import com.ruoyi.common.utils.wx.vo.PrepayResponseVO; import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderVO; +import com.ruoyi.system.domain.refund.RlRefund; import com.ruoyi.system.domain.store.StoreVo; +import com.ruoyi.system.domain.vo.IndexAdminVo; import com.ruoyi.system.domain.vo.PriceVO; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; /** @@ -141,6 +144,23 @@ public interface IRlOrderService */ Boolean depositRefund(String orderNo); + /** + * 订单退款 + */ + int refund(RlOrderQuery order); + + /** + * 创建退款 + * + */ + public RlRefund createRefund(String reason, Long userId,String orderNo, + BigDecimal refundAmount, + BigDecimal dispatchFee, + BigDecimal deliveryFee, + BigDecimal leaseFee, String outRefundNo, String type); + + + /** * 计算价格 */ @@ -158,4 +178,9 @@ public interface IRlOrderService void validate(RlOrderQuery orderQuery); + + /** + * app首页统计 + */ + IndexAdminVo indexStatistics(Long userId); } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserExtService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserExtService.java index b8fd86b..ae613ed 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserExtService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserExtService.java @@ -20,6 +20,14 @@ public interface IRlUserExtService */ public RlUserExt selectRlUserExtByExtId(Long extId); + /** + * 查询用户扩展 + * + * @param userId 用户id + * @return 用户扩展 + */ + public RlUserExt selectRlUserExtByUserId(Long userId); + /** * 查询用户扩展列表 * diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserService.java index c5cc5d6..01506c4 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlUserService.java @@ -2,8 +2,12 @@ package com.ruoyi.system.service; import com.ruoyi.common.core.domain.entity.RlUser; import com.ruoyi.common.core.domain.entity.RlUserVO; +import com.ruoyi.system.domain.changeBalance.RlChangeBalance; +import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery; import com.ruoyi.system.domain.query.AuthenticationQuery; import com.ruoyi.system.domain.vo.RlUserQuery; +import com.ruoyi.system.domain.withdraw.RlWithdraw; +import com.ruoyi.system.domain.withdraw.RlWithdrawQuery; import java.math.BigDecimal; import java.util.List; @@ -61,7 +65,7 @@ public interface IRlUserService * @param RlUserId 用户ID * @return 用户对象信息 */ - public RlUser myAccountInfoByUserId(Long RlUserId); + public RlUserVO myAccountInfoByUserId(Long RlUserId); @@ -376,4 +380,14 @@ public interface IRlUserService * @return 结果 */ BigDecimal selectUserBalanceById(Long userId); + + /** + * 账变记录 + */ + List myChangeBalanceList(RlChangeBalanceQuery query, Long userId); + + /** + * 管理员提现 + */ + int adminWithdraw(RlWithdrawQuery withdraw); } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlWithdrawService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlWithdrawService.java index 70226f5..de67595 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/IRlWithdrawService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/IRlWithdrawService.java @@ -62,5 +62,11 @@ public interface IRlWithdrawService */ public int deleteRlWithdrawById(Long id); - BigDecimal cumulativeWithdrawalAmount(Long RlUserId); + /** + * 累计提现金额 + * + * @param userId 用户id + * @return 结果 + */ + BigDecimal cumulativeWithdrawalAmount(Long userId); } diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java index 310299b..dd3a355 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java @@ -134,6 +134,20 @@ public class CallbackServiceImpl implements CallbackService { order1.setStatus(ServiceConstants.ORDER_STATUS_TO_BE_SENT); } order1.setCost(getCost(channelVO,order.getPayFee())); + + // 如果是续租的订单,结束原订单 + if(order.getType().equals(ServiceConstants.ORDER_TYPE_RELET)){ + String originalOrderNo = order.getOriginalOrderNo(); + RlOrder originalOrder = orderService.selectRlOrderByOrderNo(originalOrderNo); + RlOrder updateOriginalOrder = new RlOrder(); + updateOriginalOrder.setOrderId(originalOrder.getOrderId()); + updateOriginalOrder.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END); + int i = orderService.updateRlOrder(updateOriginalOrder); + if(i==1){ + logger.error("【微信支付回调】更新原订单状态成功"); + } + order1.setStatus(ServiceConstants.ORDER_STATUS_IN_USE); + } logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(order1)); int updateEtOrder = orderService.updateRlOrder(order1); if(updateEtOrder==0){ diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlChangeBalanceServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlChangeBalanceServiceImpl.java index 2a63524..b8e5cc7 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlChangeBalanceServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlChangeBalanceServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.domain.changeBalance.RlChangeBalance; +import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery; import com.ruoyi.system.mapper.RlChangeBalanceMapper; import com.ruoyi.system.service.IRlChangeBalanceService; import org.springframework.beans.factory.annotation.Autowired; @@ -52,11 +53,10 @@ public class RlChangeBalanceServiceImpl implements IRlChangeBalanceService * @return 余额变动 */ @Override - public List selectRlChangeBalanceListByUserId(Long RlUserId) + public List selectRlChangeBalanceListByUserId(RlChangeBalanceQuery query, Long RlUserId) { - RlChangeBalance rlChangeBalance = new RlChangeBalance(); - rlChangeBalance.setOwnerId(RlUserId); - return rlChangeBalanceMapper.selectRlChangeBalanceList(rlChangeBalance); + query.setOwnerId(RlUserId); + return rlChangeBalanceMapper.selectRlChangeBalanceList(query); } /** diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlDeviceServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlDeviceServiceImpl.java index 8d1ab88..0c2e5f9 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlDeviceServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlDeviceServiceImpl.java @@ -214,12 +214,18 @@ public class RlDeviceServiceImpl extends ServiceImpl i StoreVo storeVo = storeService.selectSmStoreById(rlDevice.getStoreId()); if(ObjectUtil.isNotNull(storeVo)){ rlDevice.setStoreLocation(storeVo.getAddress()); + rlDevice.setStoreName(storeVo.getName()); } RlModelVO rlModelVO = modelService.selectEModelByModelId(rlDevice.getModelId()); if(ObjectUtil.isNotNull(rlModelVO)){ + if(StrUtil.isNotBlank(rlDevice.getVoltage())){ + rlDevice.setRemainingMileage(CommonUtil.getRemainingMileage(rlDevice.getVoltage(),rlModelVO.getFullVoltage(),rlModelVO.getLowVoltage(),rlModelVO.getFullEndurance())); + } rlDevice.setModel(rlModelVO.getModel()); List functionList = modelService.getFunctionListByModelId(rlDevice.getModelId()); + List rlAccessoryVOS = accessoryService.selectRlAccessoryListByModelId(rlDevice.getModelId()); rlDevice.setFunctionList(functionList); + rlDevice.setAccessorys(rlAccessoryVOS); } return rlDevice; } @@ -245,25 +251,6 @@ public class RlDeviceServiceImpl extends ServiceImpl i public List selectDeviceList(RlDeviceQuery asDevice) { List asDevices = deviceMapper.selectDeviceList(asDevice); -// for (EDevice asDevice1:asDevices){ -// Long areaId = asDevice1.getAreaId(); -// if (ObjectUtil.isNotNull(areaId) && areaId!=0){ -// EtOperatingArea etOperatingArea = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); -// asDevice1.setAreaName(etOperatingArea.getAreaName()); -// } -// Long modelId = asDevice1.getModelId(); -// if (ObjectUtil.isNotNull(modelId)){ -// EtModel model = etModelService.selectEtModelByModelId(modelId); -// if(ObjectUtil.isNotNull(model)){ -// asDevice1.setModel(model.getModel()); -// } -// } -// String status = asDevice1.getStatus(); -// if(ObjectUtil.isNotNull(status)){ -// String typeName = sysDictDataService.selectDictLabel("as_device_status", status); -// asDevice1.setStatusStr(typeName); -// } -// } return asDevices; } @@ -1565,7 +1552,7 @@ public class RlDeviceServiceImpl extends ServiceImpl i } /** 计算逾期费用 */ - private BigDecimal computeOverdueFee(RlOrderVO order, RlOrder updateOrder) { + public BigDecimal computeOverdueFee(RlOrderVO order, RlOrder updateOrder) { String outUnit = order.getOutUnit(); BigDecimal outPrice = order.getOutPrice(); // 计算逾期的时间单位 diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlModelServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlModelServiceImpl.java index 0c8b706..36d4c6b 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlModelServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlModelServiceImpl.java @@ -8,11 +8,13 @@ import com.ruoyi.system.domain.accessory.RlAccessoryVO; import com.ruoyi.system.domain.device.RlDevice; import com.ruoyi.system.domain.model.RlModel; import com.ruoyi.system.domain.model.RlModelVO; +import com.ruoyi.system.domain.store.StoreVo; import com.ruoyi.system.mapper.RlModelMapper; import com.ruoyi.system.service.IRlAccessoryService; import com.ruoyi.system.service.IRlDeviceService; import com.ruoyi.system.service.IRlFunctionService; import com.ruoyi.system.service.IRlModelService; +import com.ruoyi.system.service.store.RlStoreService; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +22,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; /** @@ -44,6 +47,10 @@ public class RlModelServiceImpl implements IRlModelService @Autowired private IRlFunctionService rlFunctionService; + @Autowired + private RlStoreService storeService; + + /** * 查询车辆型号 @@ -104,6 +111,25 @@ public class RlModelServiceImpl implements IRlModelService return etModels; } + /** + * 根据商户id查询车辆型号列表 + * + * @param merchantId 商户id + * @return 车辆型号集合 + */ + @Override + public List getModelListByMerchantId(Long merchantId) + { + List rlModelVOS = new ArrayList<>(); + // 根据商户获取到店铺列表 + List storeVos = storeService.selectSmStoreListBYMerchantId(merchantId); + for(StoreVo storeVo:storeVos){ + List rlModelVOS1 = selectEModelListByStoreId(storeVo.getStoreId()); + rlModelVOS.addAll(rlModelVOS1); + } + return rlModelVOS; + } + /** * 根据店铺id查询车辆型号列表 diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlOrderServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlOrderServiceImpl.java index f398565..090c0cf 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlOrderServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlOrderServiceImpl.java @@ -6,12 +6,14 @@ import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.RlUser; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.map.GeoUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.wx.vo.PrepayResponseVO; +import com.ruoyi.system.domain.RlFunction; import com.ruoyi.system.domain.accessory.RlAccessoryVO; import com.ruoyi.system.domain.agent.RlAgent; import com.ruoyi.system.domain.device.RlDevice; @@ -19,8 +21,11 @@ import com.ruoyi.system.domain.model.RlModelVO; import com.ruoyi.system.domain.order.RlOrder; import com.ruoyi.system.domain.order.RlOrderQuery; import com.ruoyi.system.domain.order.RlOrderVO; +import com.ruoyi.system.domain.refund.RlRefund; import com.ruoyi.system.domain.rule.RlFeeRule; import com.ruoyi.system.domain.store.StoreVo; +import com.ruoyi.system.domain.userExt.RlUserExt; +import com.ruoyi.system.domain.vo.IndexAdminVo; import com.ruoyi.system.domain.vo.PriceVO; import com.ruoyi.system.mapper.RlOrderMapper; import com.ruoyi.system.service.*; @@ -31,6 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Resource; @@ -86,6 +92,12 @@ public class RlOrderServiceImpl implements IRlOrderService @Autowired private TransactionTemplate transactionTemplate; + @Autowired + private IRlUserExtService userExtService; + + @Autowired + private IRlRefundService refundService; + /** * 查询订单 * @@ -133,8 +145,17 @@ public class RlOrderServiceImpl implements IRlOrderService public RlOrderVO getOrderInfoByOrderNo(String orderNo) { RlOrderVO order = orderMapper.selectRlOrderByOrderNo(orderNo); - List accessorys = accessoryService.selectRlAccessoryListByModelId(order.getModelId()); - order.setAccessorys(accessorys); + if(order.getModelId() == null){ + throw new ServiceException("订单中没有车型id"); + } + RlModelVO rlModelVO = modelService.selectEModelByModelId(order.getModelId()); + if(ObjectUtil.isNotNull(rlModelVO)){ + List functionList = modelService.getFunctionListByModelId(order.getModelId()); + List rlAccessoryVOS = accessoryService.selectRlAccessoryListByModelId(order.getModelId()); + order.setFunctionList(functionList); + order.setAccessorys(rlAccessoryVOS); + } + RlDevice rlDevice = deviceService.selectDeviceBySn(order.getSn()); if(ObjectUtil.isNotNull(rlDevice)) { order.setPicture(rlDevice.getPicture()); @@ -362,6 +383,7 @@ public class RlOrderServiceImpl implements IRlOrderService rlOrder.setOrderNo(orderNo); rlOrder.setSn(sn); rlOrder.setStatus(ServiceConstants.ORDER_STATUS_IN_USE); + rlOrder.setPickupTime(DateUtils.getNowDate()); int i = orderMapper.updateRlOrderByOrderNo(rlOrder); if(i > 0){ /** 更新设备状态 */ @@ -391,15 +413,29 @@ public class RlOrderServiceImpl implements IRlOrderService } RlOrderQuery orderQuery = new RlOrderQuery(); BeanUtils.copyBeanProp(orderQuery,order); - /** 原订单已经到期 */ - Date nowDate = DateUtils.getNowDate(); - if (order.getExpiryTime().before(nowDate)) { - /** */ -// throw new RuntimeException("订单已过期,请重新下单"); - } + /** 原订单已经到期 续租订单的到期时间是根据原订单的到期时间算出来的 */ +// Date nowDate = DateUtils.getNowDate(); +// if (order.getExpiryTime().before(nowDate)) { +// /** 到期后先计算逾期费用,保存在订单中,在还车时一起结算 */ +// RlOrder updateOrder = new RlOrder(); +// updateOrder.setOrderId(order.getOrderId()); +// BigDecimal overdueFee= BigDecimal.ZERO; +// if(ObjectUtil.isNull(order.getExpiryTime())){ +// throw new ServiceException("【续租】订单没有到期时间"); +// } +// if (order.getExpiryTime().before(DateUtils.getNowDate())) { +// overdueFee = deviceService.computeOverdueFee(order, updateOrder); +// } +// updateOrder.setOverdueFee(overdueFee); +// int i = updateRlOrder(updateOrder); +// if(i==0){ +// throw new ServiceException("更新订单状态失败"); +// } +// } orderQuery.setOriginalOrderNo(query.getOrderNo()); orderQuery.setRuleId(query.getRuleId()); orderQuery.setPickupTime(order.getExpiryTime()); + orderQuery.setNum(query.getNum()); String newOrderNo = IdUtils.getOrderNo("xz"); PrepayResponseVO responseVO = getPrepayResponseVO(orderQuery,newOrderNo,ServiceConstants.ORDER_TYPE_RELET,SecurityUtils.getUserId()); return responseVO; @@ -472,6 +508,108 @@ public class RlOrderServiceImpl implements IRlOrderService return null; } + /** + * todo 未完成 + * 退款 + * 1. 校验 + * 2. 用户余额不足判断 + * 3. 计算出退款的比例 + * 4. 遍历用户,新增账变 + * 5. 新增退款明细 + * 6. 发起退款 + */ + @Transactional + @Override + public int refund(RlOrderQuery etOrder) { + //根据订单号查询订单信息 + /** 1. 校验 */ + RlOrderVO rlOrderVO = orderMapper.selectRlOrderByOrderNo(etOrder.getOrderNo()); + if(ObjectUtil.isNull(rlOrderVO)){ + throw new ServiceException("订单不存在"); + } + if(!ServiceConstants.ORDER_STATUS_ORDER_END.equals(rlOrderVO.getStatus())){ + throw new ServiceException("退款失败,订单未结束"); + } + if(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(rlOrderVO.getPaid())){ + throw new ServiceException("订单未支付,不能退款"); + } + + /** 1.退款*/ + //退款金额 调度费(商家取车) 配送费(送车上门) 租赁费 + BigDecimal refundAmount = new BigDecimal("0"); + BigDecimal dispatchFee = etOrder.getDispatchFee(); + if(ObjectUtil.isNotNull(dispatchFee) && !dispatchFee.equals(BigDecimal.ZERO)){ + refundAmount = refundAmount.add(dispatchFee); + } + BigDecimal deliveryFee = etOrder.getDeliveryFee(); + if(ObjectUtil.isNotNull(deliveryFee) && !deliveryFee.equals(BigDecimal.ZERO)){ + refundAmount = refundAmount.add(deliveryFee); + } + BigDecimal leaseFee = etOrder.getLeaseFee(); + if(ObjectUtil.isNotNull(leaseFee) && !leaseFee.equals(BigDecimal.ZERO)){ + refundAmount = refundAmount.add(leaseFee); + } + if(refundAmount.compareTo(BigDecimal.ZERO) == 0){ + throw new ServiceException("总退款金额不能为0"); + } + /** 3.计算出退款的比例 */ + BigDecimal divide = refundAmount.divide(rlOrderVO.getPayFee()); + /** 4. 遍历用户,新增账变 */ + Long agentId = rlOrderVO.getAgentId(); + + /** todo 2. 每个用户都要余额不足判断 */ + RlUserExt rlUserExt = userExtService.selectRlUserExtByUserId(SecurityUtils.getUserId()); + BigDecimal subtract = rlUserExt.getBalance().subtract(etOrder.getTotalFee()); + if(subtract.compareTo(BigDecimal.ZERO) <= 0){ + throw new ServiceException("余额不足,不能退款"); + } + + // 新增账变 +// etOrder1.setPayFee(refundAmount); +// callbackService.capitalFlowRecords(etOrder1,ServiceConstants.FLOW_TYPE_DISBURSE,ServiceConstants.ORDER_TYPE_RIDING_REFUND,ServiceConstants.OWNER_TYPE_OPERATOR,null,ServiceConstants.PAY_TYPE_WX); + String outRefundNo = IdUtils.getOrderNo("ref"); + /** 2.记录退款表 创建退款对象*/ + RlRefund refund1= createRefund("商家退款金额",rlOrderVO.getUserId(),rlOrderVO.getOrderNo(), refundAmount, dispatchFee, deliveryFee, leaseFee, outRefundNo,ServiceConstants.REFUND_TYPE_SYSTEM); + int i = refundService.insertEtRefund(refund1); + if(i>0){ + logger.info("保存退款对象成功"); + } + logger.info("总金额:【{}】,退款金额:【{}】", rlOrderVO.getTotalFee(), refundAmount); + /** 6. 发起退款 */ + wxPayService.refund(rlOrderVO, "商家退款金额", refundAmount,outRefundNo); + return 1; + } + + @Override + public RlRefund createRefund(String reason, Long userId,String orderNo,BigDecimal refundAmount, BigDecimal dispatchFee, BigDecimal deliveryFee, BigDecimal leaseFee, String outRefundNo, String type) { + RlRefund etRefund = new RlRefund(); + etRefund.setAmount(refundAmount); + etRefund.setReason(reason); + etRefund.setDispatchFee(dispatchFee); + etRefund.setDeliveryFee(deliveryFee); + etRefund.setLeaseFee(leaseFee); + etRefund.setOrderNo(orderNo); + etRefund.setUserId(userId); + etRefund.setRefundNo(outRefundNo); + etRefund.setType(type); + if(type.equals(ServiceConstants.REFUND_TYPE_DEPOSIT)){ + etRefund.setItemDesc("押金退款"); + }else{ + StringBuilder itemDesc = new StringBuilder(); + if(ObjectUtil.isNotNull(deliveryFee) && !deliveryFee.equals(BigDecimal.ZERO)){ + itemDesc.append("配送费:").append(deliveryFee).append("元,"); + } + if(ObjectUtil.isNotNull(dispatchFee) && !dispatchFee.equals(BigDecimal.ZERO)){ + itemDesc.append("调度费:").append(dispatchFee).append("元,"); + } + if(ObjectUtil.isNotNull(leaseFee) && !leaseFee.equals(BigDecimal.ZERO)){ + itemDesc.append("租赁费:").append(leaseFee).append("元,"); + } + etRefund.setItemDesc(itemDesc.toString()); + } + return etRefund; + } + /** * 计算价格 */ @@ -550,6 +688,28 @@ public class RlOrderServiceImpl implements IRlOrderService } } + /** + * 首页统计 + */ + @Override + public IndexAdminVo indexStatistics(Long userId) { + IndexAdminVo indexAdminVo = new IndexAdminVo(); + ArrayList incomeVos = new ArrayList<>(); + for (int i = 1; i < 7; i++) { + IndexAdminVo.IncomeVo orderFee = new IndexAdminVo.IncomeVo(); + orderFee.setDay("2024-10-0"+i); + orderFee.setOrderFee(BigDecimal.valueOf(i*100)); + orderFee.setOrderNum(i*10); + incomeVos.add(orderFee); + } + indexAdminVo.setIncomeVoList(incomeVos); + indexAdminVo.setTodayOrderNum(new BigDecimal(10)); + indexAdminVo.setTodayIncome(new BigDecimal(100)); + indexAdminVo.setComparedYesterdayIncome(new BigDecimal(5)); + indexAdminVo.setComparedYesterdayOrderNum(new BigDecimal(5)); + return indexAdminVo; + } + private BigDecimal deposit(Long modelId, PriceVO priceVO) { RlModelVO rlModelVO = modelService.selectEModelByModelId(modelId); if(rlModelVO == null){ diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserExtServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserExtServiceImpl.java index f3f5751..942a6ad 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserExtServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserExtServiceImpl.java @@ -32,6 +32,17 @@ public class RlUserExtServiceImpl implements IRlUserExtService return rlUserExtMapper.selectRlUserExtByExtId(extId); } + /** + * 查询用户扩展 + * + * @param userId 用户id + * @return 用户扩展 + */ + @Override + public RlUserExt selectRlUserExtByUserId(Long userId) { + return rlUserExtMapper.selectRlUserExtByUserId(userId); + } + /** * 查询用户扩展列表 * diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserServiceImpl.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserServiceImpl.java index 4ba6e7d..533f81b 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserServiceImpl.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/RlUserServiceImpl.java @@ -1,24 +1,35 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.ChangeBalanceInterface; import com.ruoyi.common.core.domain.entity.RlUser; import com.ruoyi.common.core.domain.entity.RlUserVO; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.*; +import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.verify.VerifyIdentityUtil; +import com.ruoyi.system.domain.RlMsgLog; import com.ruoyi.system.domain.SysUserPost; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.domain.agent.RlAgentVO; import com.ruoyi.system.domain.changeBalance.RlChangeBalance; +import com.ruoyi.system.domain.changeBalance.RlChangeBalanceQuery; +import com.ruoyi.system.domain.channel.ChannelVO; import com.ruoyi.system.domain.query.AuthenticationQuery; +import com.ruoyi.system.domain.userExt.RlUserExt; import com.ruoyi.system.domain.vo.RlUserQuery; +import com.ruoyi.system.domain.withdraw.RlWithdraw; +import com.ruoyi.system.domain.withdraw.RlWithdrawQuery; import com.ruoyi.system.mapper.RlUserMapper; import com.ruoyi.system.mapper.SysUserPostMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; -import com.ruoyi.system.service.IRlChangeBalanceService; -import com.ruoyi.system.service.IRlUserService; -import com.ruoyi.system.service.IRlWithdrawService; +import com.ruoyi.system.service.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -28,8 +39,11 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.validation.Validator; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * 用户 业务层处理 @@ -43,6 +57,15 @@ public class RlUserServiceImpl implements IRlUserService{ @Resource private RlUserMapper rlUserMapper; + @Resource + private IRlUserExtService userExtService; + + @Resource + private IRlAgentService agentService; + + @Autowired + private RlChannelService channelService; + @Autowired protected Validator validator; @@ -58,6 +81,27 @@ public class RlUserServiceImpl implements IRlUserService{ @Resource private SysUserPostMapper userPostMapper; + @Autowired + private ScheduledExecutorService scheduledExecutorService; + + @Autowired + private IRlMsgLogService msgLogService; + + @Value("${aliyun.accessKeyId}") + private String accessKeyId; + + @Value("${aliyun.accessKeySecret}") + private String accessKeySecret; + + @Value("${aliyun.signName}") + private String signName; + + @Value("${aliyun.templateCode3}") + private String templateCode3; + + @Value("${aliyun.phone}") + private String phone; + // @Autowired // private IEtOrderService etOrderService; // @@ -150,22 +194,19 @@ public class RlUserServiceImpl implements IRlUserService{ /** * 通过用户ID查询账户 * - * @param RlUserId 用户ID + * @param userId 用户ID * @return 用户对象信息 */ @Override - public RlUserVO myAccountInfoByUserId(Long RlUserId) + public RlUserVO myAccountInfoByUserId(Long userId) { - RlUserVO users = rlUserMapper.myAccountInfoByUserId(RlUserId); + RlUserVO users = rlUserMapper.myAccountInfoByUserId(userId); /** 累计提现*/ - BigDecimal totalWithdrawAmount = rlWithdrawService.cumulativeWithdrawalAmount(RlUserId); + BigDecimal totalWithdrawAmount = rlWithdrawService.cumulativeWithdrawalAmount(userId); + if(ObjectUtil.isNull(totalWithdrawAmount)){ + totalWithdrawAmount = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP); + } users.setTotalWithdrawAmount(totalWithdrawAmount); - - /** 账变明细*/ - List changeBalances = new ArrayList<>(); - List rlChangeBalances = rlChangeBalanceService.selectRlChangeBalanceListByUserId(RlUserId); - changeBalances.addAll(rlChangeBalances); - users.setChangeBalanceList(changeBalances); return users; } @@ -659,6 +700,90 @@ public class RlUserServiceImpl implements IRlUserService{ return rlUserMapper.selectUserBalanceById(userId); } + /** + * 账变记录 + */ + @Override + public List myChangeBalanceList(RlChangeBalanceQuery query,Long userId) { + /** 账变明细*/ + List rlChangeBalances = rlChangeBalanceService.selectRlChangeBalanceListByUserId(query,userId); + return rlChangeBalances; + } + + /** + * 管理员提现 + * 1. 获取当前用户 + * 2. 记录提现记录 + * 3. 扣余额,记录账变 + * 4. 发起提现(如果是自动api提现) + */ + @Override + public int adminWithdraw(RlWithdrawQuery withdraw) { + String orderNo = IdUtils.getOrderNo("tx"); + /** 1. 获取当前用户*/ + RlUser user = rlUserMapper.selectUserById(SecurityUtils.getUserId()); + RlUserExt rlUserExt = userExtService.selectRlUserExtByUserId(user.getUserId()); + RlAgentVO rlAgentVO = agentService.selectRlAgentByAgentId(rlUserExt.getAgentId()); + ChannelVO channelVO = channelService.selectSmChannelByChannelId(rlAgentVO.getPayChannel()); +// log.info(); + + /** 2. 记录提现记录*/ + RlWithdraw rlWithdraw = new RlWithdraw(); + rlWithdraw.setWithdrawNo(orderNo); + rlWithdraw.setCreateTime(DateUtils.getNowDate()); + rlWithdraw.setAmount(withdraw.getAmount()); + rlWithdraw.setStatus(ServiceConstants.FLOW_STATUS_APPLY); + rlWithdraw.setOwnerId(user.getUserId()); + rlWithdraw.setOwnerName(user.getUserName()); + rlWithdraw.setOwnerPhone(user.getPhonenumber()); +// rlWithdraw.setHandlingCharge(new BigDecimal(0));手续费、成本 + rlWithdraw.setPaymentMethod(withdraw.getPaymentMethod()); + int i = rlWithdrawService.insertRlWithdraw(rlWithdraw); + + + + + // 发短信通知转账人 + asynchronousMsg(user.getUserName()); + return 0; + } + + private void asynchronousMsg(String userName) { + scheduledExecutorService.schedule(() -> { + /** 提现申请发送一个短信给审核人*/ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("name", userName); + + SendSmsVo sendSmsVo = new SendSmsVo(); + sendSmsVo.setMobile(phone); + sendSmsVo.setTemplateCode(templateCode3); + sendSmsVo.setParam(jsonObject.toJSONString()); + sendSmsVo.setSignName(signName); + SendSmsResponse response = null; + log.info("【提现申请】向阿里云发送短信,请求,----------【{}】", JSON.toJSONString(sendSmsVo)); + try { + response = SendAliSmsUtil.sendVerifyCode(accessKeyId,accessKeySecret,sendSmsVo); + } catch (ClientException e) { + e.printStackTrace(); + } + log.info("【提现申请】发送阿里云短信成功,返回----------【{}】",JSON.toJSONString(response)); + + // 短信日志 + RlMsgLog etMsgLog = new RlMsgLog(); + etMsgLog.setPhone(phone); + etMsgLog.setContent("用户【"+userName+"】,发起押金提现申请,请尽快审核!"); + etMsgLog.setType("2"); + etMsgLog.setSignName(signName); + etMsgLog.setTemplateCode(templateCode3); + int i = msgLogService.insertEtMsgLog(etMsgLog); + if(i>0){ + log.info("【提现申请】短信日志记录成功"); + }else{ + log.info("【提现申请】短信日志记录失败"); + } + }, 0 , TimeUnit.HOURS); + } + /** * 新增用户岗位信息 * diff --git a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java index cb9c798..8061dea 100644 --- a/ridelease-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java +++ b/ridelease-system/src/main/java/com/ruoyi/system/service/impl/WxPayService.java @@ -162,7 +162,7 @@ public class WxPayService implements IWxPayService { JsapiServiceExtension jsapiServiceExtension = getJsapiServiceExtension(channelVO); PrepayWithRequestPaymentResponse res = jsapiServiceExtension.prepayWithRequestPayment(request); - if(StrUtil.isNotBlank(order.getOutTradeNo())){ + if(StrUtil.isNotBlank(order.getOutTradeNo()) && order.getType().equals(ServiceConstants.ORDER_TYPE_LEASE)){ String tradeNo = order.getOutTradeNo(); // 关闭订单 CloseOrderRequest closeOrderRequest = new CloseOrderRequest(); diff --git a/ridelease-system/src/main/resources/mapper/system/RlDeviceMapper.xml b/ridelease-system/src/main/resources/mapper/system/RlDeviceMapper.xml index ac6f6fb..02c7261 100644 --- a/ridelease-system/src/main/resources/mapper/system/RlDeviceMapper.xml +++ b/ridelease-system/src/main/resources/mapper/system/RlDeviceMapper.xml @@ -5,35 +5,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - select device_id, picture, device_name, mac, sn, model_id, hardware_version_id, vehicle_num, activation_time, @@ -44,9 +15,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - and rental_unit = #{rentalUnit} - and price = #{price} - and `explain` = #{explain} - and instructions = #{instructions} - and out_unit = #{outUnit} - and out_price = #{outPrice} - and is_deleted = #{isDeleted} - + select r.rule_id, r.rental_unit, r.price, r.`explain`, r.instructions, r.out_unit, r.out_price, r.is_deleted, r.model_id from rl_fee_rule r + where del_flag = '0' + and r.rental_unit = #{rentalUnit} + and r.price = #{price} + and r.`explain` = #{explain} + and r.instructions = #{instructions} + and r.out_unit = #{outUnit} + and r.out_price = #{outPrice} + and r.is_deleted = #{isDeleted} select m.model_id, m.model, m.full_voltage, m.low_voltage, - m.full_endurance, m.create_by, m.create_time, + m.full_endurance, m.create_by, m.create_time,a.name agnetName, m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture,m.description from rl_model m - where 1 = 1 + left join rl_agent a on a.agent_id = m.agent_id + where m.del_flag = '0' and m.model = #{model} ${params.dataScope} @@ -68,6 +69,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.model_id + + insert into rl_model @@ -123,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" deposit = #{deposit}, picture = #{picture}, description = #{description}, + del_flag = #{delFlag}, where model_id = #{modelId} diff --git a/ridelease-system/src/main/resources/mapper/system/RlOrderMapper.xml b/ridelease-system/src/main/resources/mapper/system/RlOrderMapper.xml index 881767d..a3e76a3 100644 --- a/ridelease-system/src/main/resources/mapper/system/RlOrderMapper.xml +++ b/ridelease-system/src/main/resources/mapper/system/RlOrderMapper.xml @@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select order_id, order_no, out_trade_no, user_id, user_name, real_name, phone, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee, lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason, auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time, - agent_id, store_id, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, expiry_time, original_order_no, num, price, `explain`, + agent_id, store_id, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, model, expiry_time, original_order_no, num, price, `explain`, instructions, out_unit, out_price,return_type,return_method,address,auto_cancel_time,cost, is_overdue from rl_order @@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" o.delivery_fee, o.lease_fee, o.model_id, + o.model, o.mark, o.duration, o.status, @@ -72,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" o.out_price, u.user_name as userName, s.name as storeName, - s.address as storeAddress, + s.simple_address as storeAddress, m.model, a.name agentName, r.rental_unit as rentalUnit, @@ -116,12 +117,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -26,6 +26,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ext_id = #{extId} + + insert into rl_user_ext @@ -34,6 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dividend_proportion, cooperation_time, dividend_status, + wx_collection_code, + ali_collection_code, + agent_id, #{userId}, @@ -41,6 +49,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{dividendProportion}, #{cooperationTime}, #{dividendStatus}, + #{wxCollectionCode}, + #{aliCollectionCode}, + #{agentId}, @@ -52,6 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" dividend_proportion = #{dividendProportion}, cooperation_time = #{cooperationTime}, dividend_status = #{dividendStatus}, + wx_collection_code = #{wxCollectionCode}, + ali_collection_code = #{aliCollectionCode}, + agent_id = #{agentId}, where user_id = #{userId} diff --git a/ridelease-system/src/main/resources/mapper/system/RlUserMapper.xml b/ridelease-system/src/main/resources/mapper/system/RlUserMapper.xml index 61cbe89..d6e65e4 100644 --- a/ridelease-system/src/main/resources/mapper/system/RlUserMapper.xml +++ b/ridelease-system/src/main/resources/mapper/system/RlUserMapper.xml @@ -88,7 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select u.user_id, u.user_name, u.real_name, u.id_card, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, - u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.is_authentication + u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.wxopenid,u.is_authentication, + ex.balance,ex.dividend_proportion dividendProportion,ex.cooperation_time cooperationTime,ex.dividend_status dividendStatus from rl_user u - where user_id = #{userId} + left join rl_user_ext ex on u.user_id = ex.user_id + where u.user_id = #{userId} @@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and owner_name like concat('%', #{ownerName}, '%') and owner_id = #{ownerId} and owner_phone = #{ownerPhone} - and service_charge = #{serviceCharge} + and handling_charge = #{handlingCharge} and cost = #{cost} and payment_method = #{paymentMethod} @@ -48,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" owner_name, owner_id, owner_phone, - service_charge, + handling_charge, cost, payment_method, @@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{ownerName}, #{ownerId}, #{ownerPhone}, - #{serviceCharge}, + #{handlingCharge}, #{cost}, #{paymentMethod}, @@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" owner_name = #{ownerName}, owner_id = #{ownerId}, owner_phone = #{ownerPhone}, - service_charge = #{serviceCharge}, + handling_charge = #{handlingCharge}, cost = #{cost}, payment_method = #{paymentMethod}, diff --git a/ridelease-system/src/main/resources/mapper/system/StoreMapper.xml b/ridelease-system/src/main/resources/mapper/system/StoreMapper.xml index 3cb278f..2a18d61 100644 --- a/ridelease-system/src/main/resources/mapper/system/StoreMapper.xml +++ b/ridelease-system/src/main/resources/mapper/system/StoreMapper.xml @@ -10,7 +10,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select ss.store_id, ss.name, - ss.user_id, ss.group_sort, ss.is_default, ss.address, @@ -40,13 +39,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ss.simple_address, ss.merchant_id from rl_store ss - left join rl_user su on su.user_id = ss.user_id + left join rl_user su on su.user_id = ss.merchant_id left join rl_agent a on a.agent_id = ss.agent_id and ss.name like concat('%', #{query.name}, '%') - and ss.user_id = #{query.userId} and ss.show = #{query.show} and ss.store_id = #{query.storeId} and ss.is_default = #{query.isDefault} @@ -75,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and ss.user_id in + and ss.merchant_id in #{item} @@ -151,7 +149,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into rl_store name, - user_id, create_time, create_by, group_sort, @@ -178,7 +175,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{name}, - #{userId}, #{createTime}, #{createBy}, #{groupSort}, @@ -215,7 +211,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" `name` = #{data.name}, - user_id = #{data.userId}, group_sort = #{data.groupSort}, picture = #{data.picture}, address = #{data.address}, @@ -269,16 +264,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - WHEN #{item.storeId} THEN #{item.userId} - - - WHEN #{item.storeId} THEN user_id - - - @@ -308,7 +293,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update rl_store set is_default = if(store_id = #{storeId}, true, false) - where user_id = #{userId} + where merchant_id = #{userId}