From 8db128ccc83087ef6fe4c9bb611015b85c940e17 Mon Sep 17 00:00:00 2001 From: xyc <3422692813@qq.com> Date: Fri, 11 Jul 2025 13:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B00711?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../company/service/CompanyService.java | 15 +- .../service/impl/CompanyServiceImpl.java | 17 + .../service/InspectionNoticeService.java | 8 + .../impl/InspectionNoticeServiceImpl.java | 21 + .../controller/AppGoodsController.java | 4 +- .../InspectionMallPartnersController.java | 16 +- .../controller/PartnerOwnController.java | 23 +- .../ShopInspectionGoodsController.java | 8 +- .../app/AppInspectionController.java | 12 + .../app/AppInspectionGoodsController.java | 130 ++++- .../app/AppInspectionOrderController.java | 1 + .../controller/app/AppSiteInfoController.java | 35 ++ .../controller/app/AppUserInfoController.java | 87 ++- .../entity/InspectionAppointment.java | 4 +- .../inspection/entity/InspectionInfo.java | 5 + .../InspectionBusinessChannelMapper.java | 8 + .../inspection/query/OrderTableQuery.java | 2 + .../IInspectionAppointmentService.java | 1 + .../InspectionBusinessChannelService.java | 9 + .../service/InspectionStaffService.java | 2 + .../impl/AppInspectionGoodsServiceImpl.java | 94 ++-- .../impl/AppInspectionOrderServiceImpl.java | 17 +- .../impl/AppInspectionPartnerServiceImpl.java | 70 ++- .../InspectionAppointmentServiceImpl.java | 51 +- .../InspectionBusinessChannelServiceImpl.java | 26 + .../impl/InspectionStaffServiceImpl.java | 15 + .../controller/app/AppWxPayController.java | 519 ++++++++++++++++++ .../payment/controller/app/OrderApi.java | 195 +++++++ .../module/payment/entity/OrderInfo.java | 8 + .../service/impl/OrderInfoServiceImpl.java | 1 + .../app/SmallAppShopController.java | 2 + .../yudao/module/shop/entity/ShopCoupon.java | 16 + .../module/shop/mapper/ShopCouponMapper.java | 2 +- .../inspection/AppInspectionPartnerMapper.xml | 3 + .../InspectionAppointmentMapper.xml | 13 +- .../InspectionBusinessChannelMapper.xml | 9 + .../inspection/InspectionInfoMapper.xml | 26 +- .../inspection/InspectionStaffMapper.xml | 3 +- .../mapper/payment/OrderInfoMapper.xml | 12 +- .../mapper/shop/ShopCouponMapper.xml | 6 +- .../controller/app/AppSysLoginController.java | 4 + .../dal/mysql/permission/UserRoleMapper.java | 2 + .../service/permission/RoleService.java | 8 + .../service/permission/RoleServiceImpl.java | 11 + .../main/resources/mapper/UserRoleMapper.xml | 26 + 45 files changed, 1411 insertions(+), 136 deletions(-) create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppSiteInfoController.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/AppWxPayController.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/OrderApi.java diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java index 5c800903..b0221b1c 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java @@ -63,18 +63,27 @@ public interface CompanyService extends IService { /** * 通过服务名称查能提供服务的企业 分页 * + * @param company 企业对象,主要是serverCodes * @author 小李 * @date 14:09 2024/9/23 - * @param company 企业对象,主要是serverCodes **/ IPage getCompanyPageByServer(Company company, Page page); /** * 查企业能提供的业务 * + * @param id 企业ID * @author 小李 * @date 10:21 2024/9/24 - * @param id 企业ID **/ CompanyToServerVO getCompanyServerById(String id); -} \ No newline at end of file + + /** + * 通过租户ID和系统编码查询企业信息 + * + * @param tenantId 租户ID + * @param systemCode 系统编码 + * @return + */ + CompanyRespVO getCompanyByTenantIdAndSystemCode(Long tenantId, String systemCode); +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java index dda1ca55..52395486 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.company.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.exception.ErrorCode; @@ -18,6 +19,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import com.baomidou.dynamic.datasource.annotation.DSTransactional; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.iocoder.yudao.module.company.vo.CompanyReqVO; import org.springframework.beans.factory.annotation.Autowired; @@ -213,4 +215,19 @@ public class CompanyServiceImpl extends ServiceImpl impl Optional.ofNullable(servicePackageByIds).ifPresent(result::setServicePackages); return result; } + + /** + * 通过租户ID和系统编码查询企业信息 + * + * @param tenantId 租户ID + * @param systemCode 系统编码 + * @return + */ + @Override + public CompanyRespVO getCompanyByTenantIdAndSystemCode(Long tenantId, String systemCode) { + return BeanUtil.copyProperties(baseMapper.selectOne(Wrappers.lambdaQuery() + .eq(Company::getTenantId, tenantId) + .like(ObjectUtil.isNotEmpty(systemCode), Company::getServiceCodes, systemCode)), + CompanyRespVO.class); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java index ba0f071b..7195fa74 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java @@ -9,4 +9,12 @@ public interface InspectionNoticeService { * @param text 消息通知内容 **/ void sentMessage(Long userId, String text); + + /** + * 向指定用户发送消息 + * + * @param userId 用户id + * @param text 消息通知内容 + **/ + void sentMessage(Long userId, String text, Long tenantId); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java index 00e6ee6c..76d4fbed 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java @@ -38,4 +38,25 @@ public class InspectionNoticeServiceImpl implements InspectionNoticeService { .setTemplateParams(templateParams)); } + + /** + * 向指定用户发送消息 + * + * @param userId 用户id + * @param text 消息通知内容 + **/ + @Override + public void sentMessage(Long userId, String text, Long tenantId) { + // 准备发送参数 + Map templateParams = new HashMap<>(); + // 发送模版内容 + templateParams.put("text", text); + // 发送站内信 + sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO() + .setUserId(userId) + .setTemplateCode(TICKET_EMPLOY) + .setSystemCode(SystemEnum.INSPECTION.getCode()) + .setTemplateParams(templateParams), tenantId); + + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppGoodsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppGoodsController.java index 3dcdf88e..7e39cd04 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppGoodsController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/AppGoodsController.java @@ -102,9 +102,9 @@ public class AppGoodsController extends BaseController { * 预约功能 */ @GetMapping("/appointmentDateList") - public CommonResult appointmentDateList(Long goodsId,String type) + public CommonResult appointmentDateList(Long goodsId,String type,Long tenantId) { - return success(appointmentService.appointmentDateList(goodsId,type)); + return success(appointmentService.appointmentDateList(goodsId,type,tenantId)); } /** diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionMallPartnersController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionMallPartnersController.java index de08dfab..3d1bfdac 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionMallPartnersController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionMallPartnersController.java @@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -181,7 +182,7 @@ public class InspectionMallPartnersController extends BaseController { Map stringObjectMap = orderInfoService.workOrderData(query); rows.add(CollUtil.newArrayList("公示价格汇总:", "", String.valueOf(Double.parseDouble(stringObjectMap.get("goodsPriceSum").toString()) / 100d) + "元", "实付金额汇总:", "", String.valueOf(Double.parseDouble(stringObjectMap.get("payMoneySum").toString()) / 100d) + "元")); - rows.add(CollUtil.newArrayList("车牌号", "检测车型", "检测类型", "业务渠道", "客户来源", "经办人", "公示价格", "实收金额", "付款时间", "客户手机号", "支付方式", "开始时间", "结束时间", "检测结果")); + rows.add(CollUtil.newArrayList("车牌号", "检测车型", "检测类型", "业务渠道", "客户来源", "经办人", "公示价格", "实收金额", "付款时间", "客户手机号", "支付方式", "开始时间", "结束时间", "检测结果","出纳是否确认")); List sysDictData = dictDataService.getDictDataListByDictType("pay_type"); @@ -210,13 +211,22 @@ public class InspectionMallPartnersController extends BaseController { } else { payTypeStr = payMap.get(item.getPayType()); } + // 出纳是否审核 + String cashier = "待审核"; + if (ObjectUtil.isNotEmpty(item.getCashierConfirm())) { + if (item.getCashierConfirm().equals("0")) { + cashier = "待审核"; + }else { + cashier = "已审核"; + } + } rows.add(CollUtil.newArrayList(Optional.ofNullable(item.getCarNum()).orElse(""), Optional.ofNullable(item.getGoodsTitle()).orElse(""), Optional.ofNullable(item.getSkuName()).orElse(""), Optional.ofNullable(item.getBusinessChannel()).orElse(""), Optional.ofNullable(item.getCustomerSource()).orElse(""), Optional.ofNullable(item.getOtherName()).orElse(""), ObjectUtil.isEmpty(item.getGoodsPrice()) ? "" : BigDecimal.valueOf(item.getGoodsPrice()) .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP) .toString(), ObjectUtil.isEmpty(item.getRealPayMoney()) ? "暂未支付" : BigDecimal.valueOf(item.getRealPayMoney()) .divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP) .toString(), ObjectUtil.isEmpty(item.getPayTime()) ? "暂未支付" : DateUtil.format(item.getPayTime(), "yyyy-MM-dd hh:mm"), - Optional.ofNullable(item.getBuyPhone()).orElse(""), payTypeStr, ObjectUtil.isEmpty(item.getStartTime()) ? "" : DateUtil.format(item.getStartTime(), "yyyy-MM-dd hh:mm"), ObjectUtil.isEmpty(item.getEndTime()) ? "" : DateUtil.format(item.getEndTime(), "yyyy-MM-dd hh:mm"), isPassStr)); + Optional.ofNullable(item.getBuyPhone()).orElse(""), payTypeStr, ObjectUtil.isEmpty(item.getStartTime()) ? "" : DateUtil.format(item.getStartTime(), "yyyy-MM-dd hh:mm"), ObjectUtil.isEmpty(item.getEndTime()) ? "" : DateUtil.format(item.getEndTime(), "yyyy-MM-dd hh:mm"), isPassStr, cashier)); } ExcelWriter writer = ExcelUtil.getWriter(); @@ -226,7 +236,7 @@ public class InspectionMallPartnersController extends BaseController { writer.write(rows, true); ExcelExtraHelper.enhanceExcel(writer, rows, - CollUtil.newArrayList(8,11,12), + CollUtil.newArrayList(8,11,12,15), null); //out为OutputStream,需要写出到的目标流 //response为HttpServletResponse对象 diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java index acb9fc62..b962dfd1 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java @@ -663,15 +663,19 @@ public class PartnerOwnController extends BaseController { if (ObjectUtil.isEmpty(query.getIds())) { throw new SecurityException("请选择结算工单"); } - /* 2.实付金额不能为空*/ - if (ObjectUtil.isEmpty(query.getRealPayMoney())) { - throw new SecurityException("请填写实付金额"); + if (ObjectUtil.isEmpty(query.getType())) { + throw new SecurityException("请选择类型"); } - /* 3.支付方式不能为空*/ - if (ObjectUtil.isEmpty(query.getPayType())) { - throw new SecurityException("请选择支付方式"); + if ("cn".equals(query.getType())) { + /* 2.实付金额不能为空*/ + if (ObjectUtil.isEmpty(query.getRealPayMoney())) { + throw new SecurityException("请填写实付金额"); + } + /* 3.支付方式不能为空*/ + if (ObjectUtil.isEmpty(query.getPayType())) { + throw new SecurityException("请选择支付方式"); + } } - query.setType("selected"); partnerList.batchSettlement(query); return success(); } @@ -708,8 +712,9 @@ public class PartnerOwnController extends BaseController { //新增银行卡账户 @PostMapping("/addBankAccount") public CommonResult addBankAccount(@RequestBody SysDictData dictData) throws Exception { - ShopMallPartners partners = partnerList.shopInfo(); - String dictStr = "partner_bankList-" + partners.getPartnerId(); + // 获取当前租户id + Long tenantId = SecurityFrameworkUtils.getLoginUser().getTenantId(); + String dictStr = "partner_bankList-" + tenantId; DictTypeDO sysDictType = dictTypeService.getDictType(dictStr); DictDataSaveReqVO dictSave = new DictDataSaveReqVO(); diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java index bf30bc71..de199b19 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java @@ -186,9 +186,9 @@ public class ShopInspectionGoodsController extends BaseController { @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) throws Exception { LoginUser user = SecurityFrameworkUtils.getLoginUser(); - Set userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(user.getId()); - List roleList = roleService.getRoleList(userRoleIdListByUserId); - List roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); +// Set userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(user.getId()); +// List roleList = roleService.getRoleList(userRoleIdListByUserId); +// List roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); // ShopMallPartners partner = new ShopMallPartners(); // if (roles.contains("jcshop")) { @@ -209,7 +209,7 @@ public class ShopInspectionGoodsController extends BaseController { // partner.setPartnerId(worker.getPartnerId()); // } // shopInspectionOrder.setPartnerId(partner.getPartnerId()); - shopInspectionOrder.setValidationTime(new Date()); +// shopInspectionOrder.setValidationTime(new Date()); Page page = new Page<>(pageNo, pageSize); return CommonResult.success(orderInfoService.queryListPage(shopInspectionOrder, page)); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionController.java index 04062b19..55047e48 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionController.java @@ -32,4 +32,16 @@ public class AppInspectionController { public CommonResult getInspectionStaffByUniqueCode(@RequestParam("uniqueCode") String uniqueCode) { return CommonResult.success(inspectionStaffService.getInspectionStaffByUniqueCode(uniqueCode)); } + + /** + * 根据唯一码查询业务 + * + * @param uniqueCode 唯一码 + * @return 业务 + */ + @RequestMapping("/getBusinessByUniqueCode") + @TenantIgnore + public CommonResult getBusinessByUniqueCode(@RequestParam("uniqueCode") String uniqueCode) { + return CommonResult.success(inspectionStaffService.getBusinessByUniqueCode(uniqueCode)); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionGoodsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionGoodsController.java index 14b1ec2f..81059713 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionGoodsController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionGoodsController.java @@ -1,13 +1,20 @@ package cn.iocoder.yudao.module.inspection.controller.app; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.inspection.entity.InspectionAppointment; +import cn.iocoder.yudao.module.inspection.entity.InspectionGoodsSku; +import cn.iocoder.yudao.module.inspection.entity.InspectionPickCar; import cn.iocoder.yudao.module.inspection.query.GoodsQuery; import cn.iocoder.yudao.module.inspection.service.AppInspectionGoodsService; import cn.iocoder.yudao.module.inspection.service.IInspectionAppointmentService; +import cn.iocoder.yudao.module.inspection.service.InspectionGoodsSkuService; +import cn.iocoder.yudao.module.shop.service.IShopCouponService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.text.ParseException; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -20,11 +27,16 @@ public class AppInspectionGoodsController private AppInspectionGoodsService appInspectionGoodsService; @Autowired private IInspectionAppointmentService appointmentService; + @Autowired + private IShopCouponService couponService; + @Autowired + private InspectionGoodsSkuService skuService; /** * 获取商品规格 */ @GetMapping("/goodsSkuList") + @TenantIgnore public CommonResult goodsSkuList(GoodsQuery goodsQuery) { return success(appInspectionGoodsService.goodsSkuList(goodsQuery)); @@ -34,6 +46,7 @@ public class AppInspectionGoodsController * 预约功能 */ @GetMapping("/appointmentDateList") + @TenantIgnore public CommonResult appointmentDateList(Long goodsId,String type) { return success(appointmentService.appointmentDateList(goodsId,type)); @@ -43,6 +56,7 @@ public class AppInspectionGoodsController * 获取商品详情 */ @GetMapping("/goodsDetail") + @TenantIgnore public CommonResult goodsDetail(GoodsQuery goodsQuery) { return success(appInspectionGoodsService.goodsDetail(goodsQuery)); @@ -52,8 +66,118 @@ public class AppInspectionGoodsController * 下单页信息返回 */ @GetMapping("/orderSkuInfo") + @TenantIgnore public CommonResult orderSkuInfo(GoodsQuery goodsQuery) { return success(appInspectionGoodsService.orderSkuInfo(goodsQuery)); } + + /** + * 下单页信息返回 + */ + @GetMapping("/orderGoodsInfo") + @TenantIgnore + public CommonResult orderGoodsInfo(GoodsQuery goodsQuery) + { + return success(appInspectionGoodsService.orderGoodsInfo(goodsQuery)); + } + /** + * 下单页信息返回 + */ + @GetMapping("/canUseCoupon") + @TenantIgnore + public CommonResult canUseCoupon(Integer objectId,String type) + { + Integer goodsId =objectId; + if (type.equals("sku")){ + InspectionGoodsSku sku = skuService.getById(objectId); + goodsId=sku.getGoodsId() ; + } + return success(couponService.canUseCoupon(goodsId,"检测项目现金券")); + } + + /** + * 上门取车功能 + */ + @GetMapping("/pickCarInfo") + @TenantIgnore + public CommonResult pickCarInfo() + { + return success(appointmentService.pickCarInfo()); + } + + /** + * 根据经纬度计算距离和价格 + */ + @GetMapping("/computeDistanceAndPrice") + public CommonResult computeDistanceAndPrice(Long goodsId,Double longitude,Double latitude,String type ) throws Exception { + return success(appointmentService.computeDistanceAndPrice(goodsId,longitude,latitude,type)); + } + /** + * 预约功能 + */ + @PostMapping("/appointmentInspection") + @TenantIgnore + @PreAuthenticated + public CommonResult appointmentInspection(@RequestBody InspectionAppointment appointment) throws ParseException { + return success(appointmentService.appointmentInspection(appointment)); + } + /** + * 修改预约功能 + */ + @PostMapping("/editAppointment") + @TenantIgnore + public CommonResult editAppointment(@RequestBody InspectionAppointment appointment) + { + return success(appointmentService.editAppointment(appointment)); + } + + /** + * 删除预约信息 + */ + @PostMapping("/delAppointment") + @TenantIgnore + public CommonResult delAppointment(@RequestParam("appointmentId") Long appointmentId) + { + appointmentService.delAppointment(appointmentId); + return success(true); + } + /** + * 上门取车 + */ + @PostMapping("/pickCarInspection") + @TenantIgnore + public CommonResult pickCarInspection(@RequestBody InspectionPickCar pickCar) throws Exception { + return success(appointmentService.pickCarInspection(pickCar)); + } + /** + * 进店获取可领取的优惠券 + */ + @GetMapping("/canLedCoupon") + @TenantIgnore + public CommonResult canLedCoupon(Long partnerId) + { + return success(couponService.canLedCoupon(partnerId)); + } + @PostMapping("/drawDownCoupon") + public CommonResult drawDownCoupon(Long partnerId) + { + couponService.drawDownCoupon(partnerId); + return success(true); + } + + /** + * 平台赠送的可以领取的优惠券 + */ + @GetMapping("/canLedCouponPlatform") + public CommonResult canLedCouponPlatform() + { + return success(couponService.canLedCouponPlatform()); + } + @PostMapping("/drawDownCouponPlatform") + public CommonResult drawDownCouponPlatform() + { + couponService.drawDownCouponPlatform(); + return success(true); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionOrderController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionOrderController.java index bc9f0081..42fa4d28 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionOrderController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppInspectionOrderController.java @@ -30,6 +30,7 @@ public class AppInspectionOrderController extends BaseController { return success(orderInfos); } @GetMapping("/orderDetail") + @TenantIgnore public CommonResult orderDetail(Long orderId) { return CommonResult.success(appInspectionOrderService.orderDetailApp(orderId)); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppSiteInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppSiteInfoController.java new file mode 100644 index 00000000..f7b632b8 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppSiteInfoController.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.inspection.controller.app; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.inspection.entity.SiteInfo; +import cn.iocoder.yudao.module.inspection.service.ISiteInfoService; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@RestController +@RequestMapping("/inspection/info") +public class AppSiteInfoController { + + @Autowired + private ISiteInfoService siteInfoService; + + /** + * 查询inspection列表 + */ + @GetMapping("/list") + @TenantIgnore + public CommonResult list(SiteInfo siteInfo, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage list = siteInfoService.selectSiteInfoList(page,siteInfo); + return success(list); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppUserInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppUserInfoController.java index 047225da..e96e0e63 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppUserInfoController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/AppUserInfoController.java @@ -4,12 +4,20 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.core.page.PageDomain; +import cn.iocoder.yudao.module.core.page.TableSupport; import cn.iocoder.yudao.module.inspection.service.AppUserOwnService; +import cn.iocoder.yudao.module.inspection.service.IInspectionAppointmentService; +import cn.iocoder.yudao.module.payment.entity.OrderInfo; +import cn.iocoder.yudao.module.payment.service.OrderInfoService; +import cn.iocoder.yudao.module.shop.entity.ShopCoupon; +import cn.iocoder.yudao.module.shop.service.IShopCouponService; import cn.iocoder.yudao.module.shop.service.IShopUserCarService; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -21,9 +29,17 @@ public class AppUserInfoController { private AppUserOwnService ownService; @Autowired - private IShopUserCarService shopUserCarService; + @Autowired + private OrderInfoService orderInfoService; + + @Autowired + private IInspectionAppointmentService inspectionAppointmentService; + + @Autowired + private IShopCouponService shopCouponService; + @GetMapping("/getCars") @TenantIgnore public CommonResult getCars() @@ -31,6 +47,17 @@ public class AppUserInfoController { return success(ownService.getCars()); } + @GetMapping("/getDbList") + @TenantIgnore + public CommonResult getDbList(String searchValue, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage dbList = ownService.getDbListTow(page,searchValue); + return success(dbList); + } + @GetMapping(value = "/getUserCar") @TenantIgnore public CommonResult getUserCarByUserId() @@ -39,4 +66,56 @@ public class AppUserInfoController { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); return success(shopUserCarService.selectShopUserCarByUserId(loginUser.getId())); } + + @GetMapping("/orderList") + @TenantIgnore + public CommonResult orderList(String status, String title, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + IPage orderInfos = orderInfoService.orderListApp(page, status, title, "jc"); + return success(orderInfos); + } + + @GetMapping("/getAppointmentOwn") + @TenantIgnore + public CommonResult getAppointmentOwn() + { + return success(inspectionAppointmentService.getAppointmentOwn()); + } + + @GetMapping(value = "/getDetail") + @TenantIgnore + public CommonResult getDetail(@RequestParam("id") Long id) + { + return success(inspectionAppointmentService.getById(id)); + } + + @GetMapping("/getInfoCard") + @TenantIgnore + public CommonResult getInfoCard() + { + return success( shopUserCarService.getInfoCard()); + } + + @PostMapping("/infoCardOCR") + @TenantIgnore + public CommonResult infoCardOCR(String imagePath) throws Exception + { + shopUserCarService.infoCardOCR(imagePath); + return success(true); + } + + @GetMapping(value = "/listByUserId") + @TenantIgnore + public CommonResult listByUserId(ShopCoupon shopCoupon, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + shopCoupon.setUserId(SecurityFrameworkUtils.getLoginUserId()); + PageDomain pageDomain = TableSupport.getPageDomain(); + Page page = new Page<>(pageNum, pageSize); + IPage list = shopCouponService.selectShopCouponByUserId(page,shopCoupon); + return success(list); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionAppointment.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionAppointment.java index 11f4624a..84f27ea0 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionAppointment.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionAppointment.java @@ -99,6 +99,8 @@ public class InspectionAppointment extends TenantBaseDO */ @TableField(exist = false) private String sourceType; - @TableField(exist = false) private String customerSource; + private Integer customerSourceId; //客户来源id + private Integer businessChannelId; //业务渠道id + private String businessChannel; //业务渠道 } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java index cb1fd8b3..e27ab28f 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java @@ -229,6 +229,11 @@ public class InspectionInfo extends TenantBaseDO */ @TableField(exist = false) private String cashierConfirmRemark; + /** + * 出纳确认备注 + */ + @TableField(exist = false) + private String cashierConfirmTime; /** * 会计是否确认 0-未到账 1-已到账 null-待确认 */ diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionBusinessChannelMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionBusinessChannelMapper.java index 4007b91b..427fa0ab 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionBusinessChannelMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionBusinessChannelMapper.java @@ -4,6 +4,14 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionBusinessChannel; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import java.util.Map; + @Mapper public interface InspectionBusinessChannelMapper extends BaseMapper { + /** + * 获取业务渠道 和 客户来源 + * @param userId + * @return + */ + InspectionBusinessChannel getBusinessChannelByUserId(Long userId); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/query/OrderTableQuery.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/query/OrderTableQuery.java index 51fd9d54..b1b25b19 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/query/OrderTableQuery.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/query/OrderTableQuery.java @@ -66,4 +66,6 @@ public class OrderTableQuery { private Long realPayMoney; private String remark; + + private String receivablesAccount; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionAppointmentService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionAppointmentService.java index a6fd1d84..5abb39c4 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionAppointmentService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionAppointmentService.java @@ -72,6 +72,7 @@ public interface IInspectionAppointmentService extends IService { List getChannelTree(); + + /** + * 获取业务渠道和客户来源 + * + * @param userId 用户id + * @return + */ + Map getBusinessChannelByUserId(Long userId); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/InspectionStaffService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/InspectionStaffService.java index 80f13a98..a2097c9b 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/InspectionStaffService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/InspectionStaffService.java @@ -92,5 +92,7 @@ public interface InspectionStaffService extends IService { * @return */ InspectionStaffSaveVo getInspectionStaffByUniqueCode(String uniqueCode); + + Map getBusinessByUniqueCode(String uniqueCode); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionGoodsServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionGoodsServiceImpl.java index 0a81a597..a772707d 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionGoodsServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionGoodsServiceImpl.java @@ -94,44 +94,61 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl goodsVoList = baseMapper.goodsList(goodsQuery); //获取当前登录用户 LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - Set userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId()); - List roleList = roleService.getRoleList(userRoleIdListByUserId); - List roleKeys = roleList.stream().map(item->item.getCode()).collect(Collectors.toList()); - for (GoodsVo goodsVo : goodsVoList) { - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper(); - queryWrapper.eq(InspectionGoodsSku::getGoodsId,goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum); - List list = skuService.list(queryWrapper); - Integer goodsId = list.get(0).getGoodsId(); - ShopInspectionGoods goods = this.getById(goodsId); - try { - if (roleKeys.contains("jcdb")){ - //先判断是否为代办 - for (InspectionGoodsSku skuItem : list) { - skuItem.setPrice(skuItem.getDbPrice()); - } - }else if (roleKeys.contains("jcdwgly")){ - //单位管理员 - for (InspectionGoodsSku skuItem : list) { - skuItem.setPrice(skuItem.getDwPrice()); - } - }else if (roleKeys.contains("jcworker")||roleKeys.contains("jcshop")){ - //检测工人 - //判断是否为当前店铺的工人 - LambdaQueryWrapper queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(PartnerWorker::getUserId,loginUser.getId()).eq(PartnerWorker::getPartnerId,goods.getPartnerId()).last("limit 1"); - PartnerWorker one = workerService.getOne(queryWrapper1); - if (ObjectUtils.isNotEmpty(one)){ + if (loginUser!=null) { + Set userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId()); + List roleList = roleService.getRoleList(userRoleIdListByUserId); + List roleKeys = roleList.stream().map(item -> item.getCode()).collect(Collectors.toList()); + + for (GoodsVo goodsVo : goodsVoList) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum); + List list = skuService.list(queryWrapper); + Integer goodsId = list.get(0).getGoodsId(); + ShopInspectionGoods goods = this.getById(goodsId); + try { + if (roleKeys.contains("jcdb")) { + //先判断是否为代办 for (InspectionGoodsSku skuItem : list) { - skuItem.setPrice(skuItem.getYgPrice()); + skuItem.setPrice(skuItem.getDbPrice()); + } + } else if (roleKeys.contains("jcdwgly")) { + //单位管理员 + for (InspectionGoodsSku skuItem : list) { + skuItem.setPrice(skuItem.getDwPrice()); + } + } else if (roleKeys.contains("jcworker") || roleKeys.contains("jcshop")) { + //检测工人 + //判断是否为当前店铺的工人 + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(PartnerWorker::getUserId, loginUser.getId()).eq(PartnerWorker::getPartnerId, goods.getPartnerId()).last("limit 1"); + PartnerWorker one = workerService.getOne(queryWrapper1); + if (ObjectUtils.isNotEmpty(one)) { + for (InspectionGoodsSku skuItem : list) { + skuItem.setPrice(skuItem.getYgPrice()); + } + } + }else { + for (InspectionGoodsSku skuItem : list) { + skuItem.setPrice(skuItem.getPrice()); } } + + } catch (Exception e) { + log.error(e.getMessage()); } + goodsVo.setSkuList(list); - }catch (Exception e){ - log.error(e.getMessage()); } - - goodsVo.setSkuList(list); + }else { + for (GoodsVo goodsVo : goodsVoList) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum); + List list = skuService.list(queryWrapper); + for (InspectionGoodsSku skuItem : list) { + skuItem.setPrice(skuItem.getPrice()); + } + goodsVo.setSkuList(list); + } } return goodsVoList; } @@ -146,7 +163,10 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId()); List roleList = roleService.getRoleList(userRoleIdListByUserId); List roleKeys = roleList.stream().map(item->item.getCode()).collect(Collectors.toList()); @@ -328,7 +351,10 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl list = inspectionInfoService.list(Wrappers.lambdaQuery() - .in(InspectionInfo::getId, query.getIds())); + // 根据ids 查询工单 + List list = inspectionInfoService.list(Wrappers.lambdaQuery() + .in(InspectionInfo::getId, query.getIds())); - // 提取出订单ids - List orderIds = list.stream().map(InspectionInfo::getInspectionOrderId).collect(Collectors.toList()); - // 根据ids 修改工单结算 - orderService.update(Wrappers.lambdaUpdate() - .in(OrderInfo::getId, orderIds) - .set(OrderInfo::getPayMoney, averageMoney) - .set(OrderInfo::getPayType, query.getPayType()) - .set(OrderInfo::getCashierConfirm, "1") - .set(OrderInfo::getCashierConfirmUser, SecurityFrameworkUtils.getLoginUserId()) - .set(ObjectUtil.isNotEmpty(query.getRemark()), OrderInfo::getCashierConfirmRemark, query.getRemark())); + // 提取出订单ids + List orderIds = list.stream().map(InspectionInfo::getInspectionOrderId).collect(Collectors.toList()); - // 插入批量结算订单表 - InspectionBatchSettlementOrder inspectionBatchSettlementOrder = new InspectionBatchSettlementOrder(); - inspectionBatchSettlementOrder.setOrderIds(orderIds.stream() - .map(String::valueOf) // 将 Long 转为 String - .collect(Collectors.joining(","))); - inspectionBatchSettlementOrder.setPayMoney(realPayMoney); - batchSettlementOrderService.save(inspectionBatchSettlementOrder); - break; - } + if (query.getType().equals("cn")) { + Long realPayMoney = query.getRealPayMoney(); + long averageMoney = realPayMoney / query.getIds().size(); + // 根据ids 修改工单结算 + orderService.update(Wrappers.lambdaUpdate() + .in(OrderInfo::getId, orderIds) + .set(OrderInfo::getPayMoney, averageMoney) + .set(OrderInfo::getPayType, query.getPayType()) + .set(OrderInfo::getCashierConfirm, "1") + .set(OrderInfo::getReceivablesAccount, query.getReceivablesAccount()) + .set(OrderInfo::getCashierConfirmUser, SecurityFrameworkUtils.getLoginUserId()) + .set(OrderInfo::getCashierConfirmTime, new Date()) + .set(ObjectUtil.isNotEmpty(query.getRemark()), OrderInfo::getCashierConfirmRemark, query.getRemark())); + + // 插入批量结算订单表 + InspectionBatchSettlementOrder inspectionBatchSettlementOrder = new InspectionBatchSettlementOrder(); + inspectionBatchSettlementOrder.setOrderIds(orderIds.stream() + .map(String::valueOf) // 将 Long 转为 String + .collect(Collectors.joining(","))); + inspectionBatchSettlementOrder.setPayMoney(realPayMoney); + batchSettlementOrderService.save(inspectionBatchSettlementOrder); + } else { + // 会计审核 + orderService.update(Wrappers.lambdaUpdate() + .in(OrderInfo::getId, orderIds) + .set(OrderInfo::getAccountingConfirm, "1") + .set(ObjectUtil.isNotEmpty(query.getRemark()), OrderInfo::getAccountingConfirmRemark, query.getRemark()) + .set(OrderInfo::getAccountingConfirmTime, new Date()) + .set(OrderInfo::getAccountingConfirmUser, SecurityFrameworkUtils.getLoginUserId())); } } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java index d67b7938..d73609ff 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java @@ -155,6 +155,9 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl codes = roleList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList()); //根据角色查询用户 - List userListByCodes = roleService.getUserListByCodes(codes); + List userListByCodes = roleService.getUserListByCodesAndTenantId(codes, appointment.getTenantId()); // 组装消息 String day = Objects.equals(appointment.getAppointmentPeriod(), "0") ? "上午" : "下午"; @@ -249,7 +252,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl resList = new ArrayList<>(); + List sevenDaysList = getSevenDaysList(); + for (Date date : sevenDaysList) { + JSONObject item = new JSONObject(); + String dateStr = DateUtil.format(date, "yyyy-MM-dd"); + item.put("dateStr", dateStr); + item.put("weekStr", getDayOfWeek(date)); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod, "0"); + long morningCount = this.count(queryWrapper); + queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod, "1"); + long afterCount = this.count(queryWrapper); + item.put("morningCount", morningCount); + item.put("afterCount", afterCount); + resList.add(item); + + } + res.put("dataList", resList); + ShopInspectionGoods goods = goodsService.getById(goodsId); + ShopMallPartners partner = partnerService.getById(goods.getPartnerId()); + res.put("partnerName", partner.getPartnerName()); + res.put("address", partner.getAddress()); + res.put("partnerId", partner.getPartnerId()); + return res; + } + @Override public JSONObject pickCarInfo() { JSONObject res = new JSONObject(); diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionBusinessChannelServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionBusinessChannelServiceImpl.java index c443bcb6..d03477ec 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionBusinessChannelServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionBusinessChannelServiceImpl.java @@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.inspection.service.impl; import cn.iocoder.yudao.module.inspection.entity.InspectionBusinessChannel; import cn.iocoder.yudao.module.inspection.mapper.InspectionBusinessChannelMapper; import cn.iocoder.yudao.module.inspection.service.InspectionBusinessChannelService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -19,4 +21,28 @@ public class InspectionBusinessChannelServiceImpl extends ServiceImpl getBusinessChannelByUserId(Long userId) { + Map map = new HashMap<>(); + // 客户来源 + InspectionBusinessChannel channel = baseMapper.getBusinessChannelByUserId(userId); + if (channel == null) { + return null; + } + map.put("channel", channel); + // 根据客户来源的父id查询业务渠道 + InspectionBusinessChannel business = getOne(Wrappers.lambdaQuery() + .eq(InspectionBusinessChannel::getId, channel.getPid())); + if (business != null) { + map.put("business", business); + } + return map; + } + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java index 461275f4..e13bb291 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java @@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper; import cn.iocoder.yudao.module.inspection.query.InspectionListQuery; import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery; import cn.iocoder.yudao.module.inspection.service.IInspectionFileService; +import cn.iocoder.yudao.module.inspection.service.InspectionBusinessChannelService; import cn.iocoder.yudao.module.inspection.service.InspectionStaffService; import cn.iocoder.yudao.module.inspection.vo.ImportStaffVo; import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo; @@ -74,6 +75,9 @@ public class InspectionStaffServiceImpl extends ServiceImpl getBusinessByUniqueCode(String uniqueCode) { + InspectionStaffSaveVo staff = getInspectionStaffByUniqueCode(uniqueCode); + // 通过员工id查找 业务渠道和客户来源 + return inspectionBusinessChannelService.getBusinessChannelByUserId(staff.getId()); + } + /** * 保存检测员工 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/AppWxPayController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/AppWxPayController.java new file mode 100644 index 00000000..945b08ec --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/AppWxPayController.java @@ -0,0 +1,519 @@ +package cn.iocoder.yudao.module.payment.controller.app; + + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService; +import cn.iocoder.yudao.module.partner.entity.PartnerBankInfo; +import cn.iocoder.yudao.module.payment.entity.FzRecord; +import cn.iocoder.yudao.module.payment.entity.OrderInfo; +import cn.iocoder.yudao.module.payment.entity.OrderInfoDetail; +import cn.iocoder.yudao.module.payment.service.IFzRecordService; +import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService; +import cn.iocoder.yudao.module.payment.service.OrderInfoService; +import cn.iocoder.yudao.module.shop.entity.ShopConfig; +import cn.iocoder.yudao.module.shop.entity.ShopCoupon; +import cn.iocoder.yudao.module.shop.service.IShopConfigService; +import cn.iocoder.yudao.module.shop.service.IShopCouponService; +import cn.iocoder.yudao.module.shop.service.IUserBalanceService; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import cn.iocoder.yudao.util.StringUtils; +import cn.iocoder.yudao.util.WechatPayConfig; +import cn.iocoder.yudao.util.WechatPayRequest; +import cn.iocoder.yudao.util.WechatPayUrlEnum; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.partner.service.IPartnerBankInfoService; +import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; +import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; +import com.wechat.pay.java.core.Config; +import com.wechat.pay.java.core.RSAAutoCertificateConfig; +import com.wechat.pay.java.service.payments.jsapi.JsapiService; +import com.wechat.pay.java.service.payments.jsapi.model.*; +import com.wechat.pay.java.service.profitsharing.ProfitsharingService; +import com.wechat.pay.java.service.profitsharing.model.CreateOrderReceiver; +import com.wechat.pay.java.service.profitsharing.model.CreateOrderRequest; +import com.wechat.pay.java.service.profitsharing.model.OrdersEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.util.*; +import java.util.concurrent.locks.ReentrantLock; + + +@RestController +@RequestMapping("/payApi") +public class AppWxPayController { + + @Resource + private WechatPayConfig wechatPayConfig; + @Autowired + private IShopCouponService shopCouponService; + @Resource + private WechatPayRequest wechatPayRequest; + @Autowired + private OrderInfoService orderInfoService; + @Autowired + private IPartnerBankInfoService partnerBankInfoService; + @Autowired + private AdminUserService adminUserService; + @Autowired + private IShopConfigService configService; + @Autowired + private IOrderInfoDetailService orderInfoDetailService; + @Autowired + private IUserBalanceService userBalanceService; + @Autowired + private AppInspectionPartnerService partnerService; + @Autowired + private IFzRecordService fzRecordService; + private final ReentrantLock lock = new ReentrantLock(); + + /** + * type:h5、jsapi、app、native、sub_jsapi + * @param type + * @return + */ + + @GetMapping("/prepayment") + public Map transactions(String type,Long orderId) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException, IOException { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + AdminUserDO user = adminUserService.getUser(loginUser.getId()); + OrderInfo orderInfo = orderInfoService.getById(orderId); + // 统一参数封装 + Map params = new HashMap<>(8); + params.put("appid", wechatPayConfig.getJcAppId()); + params.put("mchid", wechatPayConfig.getMchId()); + params.put("description", orderInfo.getGoodsTitle()); + params.put("out_trade_no", orderInfo.getOrderNo()); + params.put("notify_url", wechatPayConfig.getJcNotifyUrl()); + Map amountMap = new HashMap<>(4); + // 金额单位为分 + amountMap.put("total", orderInfo.getPayMoney()); + //人民币 + amountMap.put("currency", "CNY"); + params.put("amount", amountMap); + + // 场景信息 + Map sceneInfoMap = new HashMap<>(4); + // 客户端IP + sceneInfoMap.put("payer_client_ip", "127.0.0.1"); + // 商户端设备号(门店号或收银设备ID) + sceneInfoMap.put("device_id", "127.0.0.1"); + // 除H5与JSAPI有特殊参数外,其他的支付方式都一样 + if (type.equals(WechatPayUrlEnum.H5.getType())) { + Map h5InfoMap = new HashMap<>(4); + // 场景类型:iOS, Android, Wap + h5InfoMap.put("type", "IOS"); + sceneInfoMap.put("h5_info", h5InfoMap); + } else if (type.equals(WechatPayUrlEnum.JSAPI.getType()) || type.equals(WechatPayUrlEnum.SUB_JSAPI.getType())) { + Map payerMap = new HashMap<>(4); + payerMap.put("openid", user.getOpenId()); + params.put("payer", payerMap); + } + params.put("scene_info", sceneInfoMap); + String paramsStr = JSON.toJSONString(params); + + String resStr = wechatPayRequest.wechatHttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi",paramsStr); + Map resMap = JSONObject.parseObject(resStr); + Map signMap = paySignMsg(resMap.get("prepay_id").toString(), wechatPayConfig.getAppId(),null); + return signMap; + } + + /** + * type:h5、jsapi、app、native、sub_jsapi + * @param type + * @return + */ + + @GetMapping("/jcPrepayment2") + public Map jcPrepayment2(String type,Long orderId) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException, IOException { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + AdminUserDO user = adminUserService.getUser(loginUser.getId()); + OrderInfo orderInfo = orderInfoService.getById(orderId); + // 统一参数封装 + Map params = new HashMap<>(8); + params.put("appid", wechatPayConfig.getJcAppId()); + params.put("mchid", wechatPayConfig.getMchId()); + params.put("description", orderInfo.getGoodsTitle()); + params.put("out_trade_no", orderInfo.getOrderNo()); + params.put("notify_url", wechatPayConfig.getJcNotifyUrl()); + Map amountMap = new HashMap<>(4); + // 金额单位为分 + amountMap.put("total", orderInfo.getPayMoney()); + //人民币 + amountMap.put("currency", "CNY"); + params.put("amount", amountMap); + + // 场景信息 + Map sceneInfoMap = new HashMap<>(4); + // 客户端IP + sceneInfoMap.put("payer_client_ip", "127.0.0.1"); + // 商户端设备号(门店号或收银设备ID) + sceneInfoMap.put("device_id", "127.0.0.1"); + // 除H5与JSAPI有特殊参数外,其他的支付方式都一样 + if (type.equals(WechatPayUrlEnum.H5.getType())) { + Map h5InfoMap = new HashMap<>(4); + // 场景类型:iOS, Android, Wap + h5InfoMap.put("type", "IOS"); + sceneInfoMap.put("h5_info", h5InfoMap); + } else if (type.equals(WechatPayUrlEnum.JSAPI.getType()) || type.equals(WechatPayUrlEnum.SUB_JSAPI.getType())) { + Map payerMap = new HashMap<>(4); + payerMap.put("openid", user.getJcOpenId()); + params.put("payer", payerMap); + } + params.put("scene_info", sceneInfoMap); + String paramsStr = JSON.toJSONString(params); + + String resStr = wechatPayRequest.wechatHttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi",paramsStr); + Map resMap = JSONObject.parseObject(resStr); + Map signMap = paySignMsg(resMap.get("prepay_id").toString(), wechatPayConfig.getAppId(),null); + return signMap; + } + + /** + * type:h5、jsapi、app、native、sub_jsapi + * @param type + * @return + */ + + @GetMapping("/jcPrepayment") + @TenantIgnore + public Map jcPrepayment(String type,Long orderId) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException, IOException { + + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + AdminUserDO user = adminUserService.getUser(loginUser.getId()); + OrderInfo orderInfo = orderInfoService.getById(orderId); + LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerBankInfo::getPartnerId,orderInfo.getPartnerId()); + PartnerBankInfo bankInfo = partnerBankInfoService.getOne(queryWrapper); + + String prepayId = this.toGetPayInfo(wechatPayConfig.getJcAppId(), bankInfo.getMchId(), bankInfo.getApiclientKey(), orderInfo.getPayMoney().intValue() + , user.getJcOpenId(), bankInfo.getSerialNo(), bankInfo.getApiV3Key(), orderInfo.getGoodsTitle(), + wechatPayConfig.getJcNotifyUrl(), orderInfo.getOrderNo()); + Map resMap = paySignMsg(prepayId, wechatPayConfig.getJcAppId(),bankInfo.getApiclientKey()); + return resMap; + } + private Map paySignMsg(String prepayId,String appId,String privateKeyStr) throws IOException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { + long timeMillis = System.currentTimeMillis(); + String timeStamp = timeMillis/1000+""; + String nonceStr = timeMillis+""; + String packageStr = "prepay_id="+prepayId; + // 公共参数 + Map resMap = new HashMap<>(); + resMap.put("nonceStr",nonceStr); + resMap.put("timeStamp",timeStamp); + resMap.put("appId",appId); + resMap.put("package", packageStr); + // 使用字段appId、timeStamp、nonceStr、package进行签名 + //从下往上依次生成 + String message = buildMessage(appId, timeStamp, nonceStr, packageStr); + //签名 + String paySign = sign(message.getBytes("utf-8"), privateKeyStr); + resMap.put("paySign", paySign); + resMap.put("signType", "RSA"); + return resMap; + } + + + String sign(byte[] message,String privateKeyStr) throws NoSuchAlgorithmException, SignatureException, IOException, InvalidKeyException { + //签名方式 + Signature sign = Signature.getInstance("SHA256withRSA"); + //私钥,通过MyPrivateKey来获取,这是个静态类可以接调用方法 ,需要的是_key.pem文件的绝对路径配上文件名 + PrivateKey privateKey =null; + if (StringUtils.isNotEmpty(privateKeyStr)){ + privateKey = PemUtil.loadPrivateKey(privateKeyStr); + }else { + privateKey = wechatPayConfig.getPrivateKey(wechatPayConfig.getKeyPemPath()); + } + + sign.initSign(privateKey); + sign.update(message); + return Base64.getEncoder().encodeToString(sign.sign()); + } + + /** + * 按照前端签名文档规范进行排序,\n是换行 + * @param timestamp + * @param nonceStr + * @param prepay_id + * @return + */ + String buildMessage(String appId, String timestamp,String nonceStr,String prepay_id) { + + return appId + "\n" + + timestamp + "\n" + + nonceStr + "\n" + + prepay_id + "\n"; + } + + + public String toGetPayInfo(String appId, String merchantId,String privateKey,Integer total,String openId, + String merchantSerialNumber,String apiV3Key,String title,String notifyUrl,String orderNo){ + Config config = + new RSAAutoCertificateConfig.Builder() + .merchantId(merchantId) + .privateKey(privateKey) + .merchantSerialNumber(merchantSerialNumber) + .apiV3Key(apiV3Key) + .build(); + // 构建service + JsapiService service = new JsapiService.Builder().config(config).build(); + // request.setXxx(val)设置所需参数,具体参数可见Request定义 + PrepayRequest request = new PrepayRequest(); + Amount amount = new Amount(); + amount.setTotal(total); + amount.setCurrency("CNY"); + + request.setAmount(amount); + request.setAppid(appId); + request.setMchid(merchantId); + request.setDescription(title); + request.setNotifyUrl(notifyUrl); + request.setOutTradeNo(orderNo); + Payer payer =new Payer(); + payer.setOpenid(openId); + request.setPayer(payer); + SettleInfo settleInfo =new SettleInfo(); + settleInfo.setProfitSharing(true); + request.setSettleInfo(settleInfo); + // 调用下单方法,得到应答 + PrepayResponse response = service.prepay(request); + return response.getPrepayId(); + } + + + @PostMapping("/payNotify") + public Map payNotify(@RequestBody JSONObject jsonObject) { + String method = Thread.currentThread().getStackTrace()[1].getMethodName(); + + try { + String key = wechatPayConfig.getApiV3Key(); + String json = jsonObject.toString(); + String associated_data = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.associated_data"); + String ciphertext = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.ciphertext"); + String nonce = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.nonce"); + + String decryptData = new AesUtil(key.getBytes(StandardCharsets.UTF_8)).decryptToString(associated_data.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext); + //验签成功 + JSONObject decryptDataObj = JSONObject.parseObject(decryptData, JSONObject.class); + if(lock.tryLock()) { + try { + ShopConfig shopConfig = configService.selectShopConfigById(1L); + // 解密resource中的通知数据 + String orderNo = decryptDataObj.get("out_trade_no").toString(); + OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo); + //追加订单明细记录 + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"支付成功",new Date(),orderInfo.getPayMoney(),"0")); + JSONObject balanceObject =new JSONObject(); + balanceObject.put("goodsType",orderInfo.getGoodsType()); + balanceObject.put("goodsTitle",orderInfo.getGoodsTitle()); + if (orderInfo.getOrderStatus().equals("0")){ + orderInfo.setTransactionId(decryptDataObj.get("transaction_id").toString()); + // 生成16位核销码 加到支付回调里 + UUID uuid = UUID.randomUUID(); + long mostSignificantBits = uuid.getMostSignificantBits(); + long leastSignificantBits = uuid.getLeastSignificantBits(); + + String combinedBits = mostSignificantBits+ String.valueOf(leastSignificantBits); + String shortUuid = combinedBits.substring(combinedBits.length() - 16); + orderInfo.setAccessCode(shortUuid); + if (orderInfo.getGoodsType().equals("cz")){ + balanceObject.put("silverNum", shopConfig.getShopUserSilver().longValue()); + balanceObject.put("goldNum", shopConfig.getShopUserGold().longValue()); + balanceObject.put("platinum", shopConfig.getShopUserPlatinum().longValue()); + //积分充值的逻辑处理 + orderInfo.setPayTime(new Date()); + //状态直接值为 3 已完成 忽略 使用 评价的过程 + orderInfo.setOrderStatus("3"); + orderInfoService.updateById(orderInfo); + //处理 用户积分的变化 + userBalanceService.addBalance(orderInfo.getPayMoney(),orderInfo.getUserId(),balanceObject); + }else if(orderInfo.getGoodsType().equals("jymd")){ + //救援买单 忽略核销过程 直接修改为待评价 + orderInfo.setPayTime(new Date()); + orderInfo.setOrderStatus("2"); + orderInfoService.updateById(orderInfo); + if (!ObjectUtil.isEmpty(orderInfo.getBalance())&&orderInfo.getBalance()>0){ + //处理积分 + userBalanceService.subtractFrozenBalance(orderInfo.getBalance(),orderInfo.getUserId(),balanceObject); + } + }else { + orderInfo.setPayTime(new Date()); + orderInfo.setOrderStatus("1"); + orderInfoService.updateById(orderInfo); + if (!ObjectUtil.isEmpty(orderInfo.getIsCoupon())&&orderInfo.getIsCoupon().equals("1")){ + ShopCoupon shopCoupon = shopCouponService.selectShopCouponByCouponId(orderInfo.getCouponId()); + //处理优惠卷 + shopCoupon.setCouponStatus("1"); + shopCoupon.setOrderId(orderInfo.getId()); + shopCoupon.setUseTime(new Date()); + shopCouponService.updateShopCoupon(shopCoupon); + orderInfo.setCouponId(shopCoupon.getCouponId()); + orderInfo.setCouponDiscount(orderInfo.getCouponDiscount()); + } + if (!ObjectUtil.isEmpty(orderInfo.getBalance())&&orderInfo.getBalance()>0){ + //处理积分 + userBalanceService.subtractFrozenBalance(orderInfo.getBalance(),orderInfo.getUserId(),balanceObject); + } + //店铺销量+1 + if (orderInfo.getPartnerId()!=null){ + partnerService.addSalesNum(orderInfo.getPartnerId()); + } + } + //最后处理邀请人的积分奖励 + AdminUserDO sysUser = adminUserService.getUser(orderInfo.getUserId()); + if (ObjectUtil.isNotEmpty(sysUser.getInviteId())){ + AdminUserDO inviteUser = adminUserService.getUser(sysUser.getInviteId()); + userBalanceService.inviteSpend(inviteUser.getId(),orderInfo.getPayMoney()); + } + //处理分账功能 + if (ObjectUtil.isNotEmpty(shopConfig.getFzRatio())&&shopConfig.getFzRatio()>0d&&orderInfo.getSkuName().contains("环检")){ + Timer timer = new Timer(); + TimerTask task = new TimerTask() { + @Override + public void run() { + LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerBankInfo::getPartnerId,orderInfo.getPartnerId()); + PartnerBankInfo bankInfo = partnerBankInfoService.getOne(queryWrapper); + profitsharing(wechatPayConfig.getAppId(),bankInfo.getMchId(),bankInfo.getApiclientKey(),3000L, + bankInfo.getSerialNo(),bankInfo.getApiV3Key(),orderInfo.getOrderNo(),orderInfo.getTransactionId(),orderInfo.getPartnerId() + ,orderInfo.getPartnerName(),orderInfo.getId(),orderInfo.getPayMoney()); + } + }; + long delay = 300 * 1000; // 一分钟后执行,单位是毫秒 + timer.schedule(task, delay); + } + } + } finally { + //要主动释放锁 + lock.unlock(); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + + Map res = new HashMap<>(); + res.put("code", "SUCCESS"); + res.put("message", "成功"); + return res; + } + + @PostMapping("/profitsharing") + void profitsharing(String appId, String merchantId,String privateKey,Long amount, + String merchantSerialNumber,String apiV3Key,String orderNo,String transactionId + ,Long partnerId,String partnerName,Long orderId,Long totalAmount){ + try { + Config config = + new RSAAutoCertificateConfig.Builder() + .merchantId(merchantId) + .privateKey(privateKey) + .merchantSerialNumber(merchantSerialNumber) + .apiV3Key(apiV3Key) + .build(); + // 构建service + ProfitsharingService service = new ProfitsharingService.Builder().config(config).build(); + CreateOrderRequest request =new CreateOrderRequest(); + request.setAppid(appId); + request.setTransactionId(transactionId); + request.setOutOrderNo(orderNo); + request.setUnfreezeUnsplit(true); + List receivers =new ArrayList<>(); + CreateOrderReceiver receiver =new CreateOrderReceiver(); + receiver.setType("MERCHANT_ID"); + receiver.setAccount(wechatPayConfig.getMchId()); + receiver.setName("官方"); + receiver.setAmount(amount); + receiver.setDescription("平台收取一定费用"); + receivers.add(receiver); + request.setReceivers(receivers); + OrdersEntity order = service.createOrder(request); + FzRecord fzRecord =new FzRecord(); + fzRecord.setPartnerId(partnerId); + fzRecord.setPartnerName(partnerName); + fzRecord.setOrderId(orderId); + fzRecord.setOrderNo(orderNo); + fzRecord.setIsSuccess("1"); + fzRecord.setReason(JSONObject.toJSONString(order)); + fzRecord.setAmount(amount); + fzRecord.setTotalAmount(totalAmount); + fzRecordService.save(fzRecord); + }catch (Exception e){ + FzRecord fzRecord =new FzRecord(); + fzRecord.setPartnerId(partnerId); + fzRecord.setPartnerName(partnerName); + fzRecord.setOrderId(orderId); + fzRecord.setOrderNo(orderNo); + fzRecord.setIsSuccess("0"); + fzRecord.setReason(e.getMessage()); + fzRecord.setAmount(amount); + fzRecord.setTotalAmount(totalAmount); + fzRecordService.save(fzRecord); + } + + + + } + + @PostMapping("/refundNotify") + public Map refundNotify(@RequestBody JSONObject jsonObject) throws GeneralSecurityException, IOException { + String key = wechatPayConfig.getApiV3Key(); + String json = jsonObject.toString(); + String associated_data = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.associated_data"); + String ciphertext = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.ciphertext"); + String nonce = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.nonce"); + + String decryptData = new AesUtil(key.getBytes(StandardCharsets.UTF_8)).decryptToString(associated_data.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext); + //验签成功 + JSONObject decryptDataObj = JSONObject.parseObject(decryptData, JSONObject.class); + if(lock.tryLock()) { + try { + String orderNo = decryptDataObj.get("out_trade_no").toString(); + //根据订单编号进行退款处理 + OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo); + //追加订单明细记录 + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"退款成功",new Date(),orderInfo.getPayMoney(),"1")); + if (orderInfo.getOrderStatus().equals("4")){ + if (orderInfo.getIsCoupon().equals("1")){ + //处理优惠卷 + ShopCoupon shopCoupon = shopCouponService.selectShopCouponByCouponId(orderInfo.getCouponId()); + shopCoupon.setCouponStatus("0"); + shopCouponService.hfStatus(shopCoupon); + } + //申请退款的状态 + //处理订单状态 + orderInfo.setOrderStatus("5"); + orderInfoService.updateById(orderInfo); + if (null!=orderInfo.getBalance()&&orderInfo.getBalance()>0){ + //1处理积分 + Long balance = orderInfo.getBalance(); + JSONObject balanceObject =new JSONObject(); + balanceObject.put("goodsType",orderInfo.getGoodsType()); + balanceObject.put("goodsTitle",orderInfo.getGoodsTitle()); + userBalanceService.refundBalance(orderInfo.getUserId(),balance,balanceObject); + } + } + //log.warn("=========== 根据订单号,做幂等处理 ==========="); + } finally { + //要主动释放锁 + lock.unlock(); + } + } + //成功应答 + Map res = new HashMap<>(); + res.put("code", "SUCCESS"); + res.put("message", "成功"); + return res; + } + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/OrderApi.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/OrderApi.java new file mode 100644 index 00000000..7b42bfce --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/controller/app/OrderApi.java @@ -0,0 +1,195 @@ +package cn.iocoder.yudao.module.payment.controller.app; + + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.core.controller.BaseController; +import cn.iocoder.yudao.module.core.page.PageDomain; +import cn.iocoder.yudao.module.core.page.TableSupport; +import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService; +import cn.iocoder.yudao.module.payment.entity.OrderInfo; +import cn.iocoder.yudao.module.payment.entity.commentVo; +import cn.iocoder.yudao.module.payment.service.OrderInfoService; +import cn.iocoder.yudao.module.shop.entity.ShopMallPartners; +import cn.iocoder.yudao.module.shop.service.IShopMallPartnersService; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; +import java.util.Objects; + + +@RequestMapping("/orderApi") +@RestController +public class OrderApi extends BaseController { + + @Autowired + private OrderInfoService orderInfoService; + @Autowired + private IShopMallPartnersService shopMallPartnersService; + @Autowired + private AppInspectionPartnerService partnerService; + + + @PostMapping("/createOrder") + @TenantIgnore + public CommonResult createOrder(@RequestBody OrderInfo orderInfo) throws Exception { + return CommonResult.success(orderInfoService.createOrder(orderInfo)); + } + + + @GetMapping("/orderDetail") + public CommonResult orderDetail(Long goodsId, String type, String title, Integer amount) { + return CommonResult.success(orderInfoService.orderDetail(goodsId, type, title, amount)); + } + + @GetMapping("/pickCarDetail") + public CommonResult pickCarDetail(Long pickCarId) { + return CommonResult.success(orderInfoService.pickCarDetail(pickCarId)); + } + + //取消支付 + @PostMapping("/cancelPay") + public CommonResult cancelPay(Long orderId) { + orderInfoService.cancelPay(orderId); + return CommonResult.ok(); + } + + @GetMapping("/orderList") + public CommonResult orderList(String status, String title, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + IPage orderInfos = orderInfoService.orderList(page,status, title); + return success(orderInfos); + + } + + // 用于自营维修保养核销 + @PostMapping("/validation") + public CommonResult validation(@RequestBody Map requestBody) { + Object accessCodeValue = requestBody.get("accessCode"); + if (accessCodeValue != null) { + String accessCode = accessCodeValue.toString(); + return CommonResult.success(orderInfoService.validation(accessCode)); + } else { + return CommonResult.error(500,"核销码错误"); + } + } + + // 用于商城核销 + @PostMapping("/validationMall") + public CommonResult validationMall(@RequestBody Map requestBody) { + Object accessCodeValue = requestBody.get("accessCode"); + if (accessCodeValue != null) { + String accessCode = accessCodeValue.toString(); + return CommonResult.success(orderInfoService.validationMall(accessCode)); + } else { + return CommonResult.error(500,"核销码错误"); + } + } + + // 核销记录By核销人Id 微信端 + @GetMapping("/validationListWx") + public CommonResult validationListWx(@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + IPage list = orderInfoService.validationListWx(page); + return success(list); + } + + // 商城核销记录By核销人Id PC + @GetMapping("/validationListPc") + public CommonResult validationListPc(@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + IPage list = orderInfoService.validationListPc(page); + return success(list); + } + + + //评论商品和星级 + @PostMapping("/reviewOrder") + public CommonResult reviewOrder(String orderId, Integer starLevel, String reviewStr) throws Exception { + orderInfoService.reviewOrder(orderId, starLevel, reviewStr); + return CommonResult.ok(); + } + + /** + * 查询检测订单列表 + */ + @GetMapping("/orderListSystem") + public CommonResult orderListSystem(OrderInfo shopInspectionOrder, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + IPage list = orderInfoService.orderListSystem(page,shopInspectionOrder); + return success(list); + } + + /** + * 订单评价 + */ + + @PostMapping("/commentOrder") + public CommonResult commentOrder(@RequestBody OrderInfo orderInfo) throws Exception { + OrderInfo curOrderInfo = orderInfoService.getById(orderInfo.getId()); + if (!Objects.equals(curOrderInfo.getUserId(), getUserId())) { + return CommonResult.error(500,"非当前用户订单,禁止评论"); + } + return CommonResult.success(orderInfoService.commentOrder(orderInfo)); + } + + /** + * 获取尚未评价的订单 + */ + + @GetMapping("/getNoCommentOrder") + public CommonResult getNoCommentOrder() { + return CommonResult.success(orderInfoService.getNoCommentOrder()); + } + + /** + * 获取商品的评价列表 + */ + + @GetMapping("/getCommentOrderList") + public CommonResult getCommentOrderList( + @RequestParam(value = "tenantId" ,required = false ,defaultValue = "1") Long tenantId, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + //判断商家是否开启评论区 +// ShopMallPartners partners = partnerService.getById(partnerId); +// if (StringUtils.isEmpty(partners.getOpenComment())||partners.getOpenComment().equals("0")){ +// return success(new ArrayList<>()); +// } + Page page = new Page<>(pageNum, pageSize); + IPage commentOrderList = orderInfoService.getCommentOrderList(page,tenantId); + return success(commentOrderList); + } + + // pc端合作商订单列表 + @GetMapping("/listPc") + public CommonResult listPc(OrderInfo orderInfo, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) { + // 当前合作商的商品 + ShopMallPartners shopMallPartners = shopMallPartnersService.selectShopMallPartnersByUserId(getUserId(),"sc"); + orderInfo.setPartnerId(shopMallPartners.getPartnerId()); + PageDomain pageDomain = TableSupport.getPageDomain(); + Page page = new Page<>(pageNum, pageSize); + IPage list = orderInfoService.orderListPc(page,orderInfo); + return success(list); + } + + @GetMapping("/getOrderInfo/{id}") + public CommonResult getOrderInfo(@PathVariable("id") Long id) throws Exception { + OrderInfo curOrderInfo = orderInfoService.getById(id); + if (!Objects.equals(curOrderInfo.getUserId(), getUserId())) { + return CommonResult.error(500,"非当前用户订单"); + } + return CommonResult.success(curOrderInfo); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java index 457afc0b..dc171c62 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java @@ -111,6 +111,10 @@ public class OrderInfo extends TenantBaseDO { * 出纳确认备注 */ private String cashierConfirmRemark; + /** + * 出纳确认时间 + */ + private Date cashierConfirmTime; /** * 出纳人 */ @@ -123,6 +127,10 @@ public class OrderInfo extends TenantBaseDO { * 会计确认备注 */ private String accountingConfirmRemark; + /** + * 会计确认时间 + */ + private Date accountingConfirmTime; /** * 出纳人 */ diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java index f02774ac..c498733b 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java @@ -333,6 +333,7 @@ public class OrderInfoServiceImpl extends ServiceImpl params; + @TableField(exist = false) + private String beginStartTime; + + @TableField(exist = false) + private String beginExpirationTime; + + @TableField(exist = false) + private String endExpirationTime; + + @TableField(exist = false) + private Date beginUseTime; + + @TableField(exist = false) + private Date endUseTime; + + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/shop/mapper/ShopCouponMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/shop/mapper/ShopCouponMapper.java index abfa8ffd..12d2ff4d 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/shop/mapper/ShopCouponMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/shop/mapper/ShopCouponMapper.java @@ -69,7 +69,7 @@ public interface ShopCouponMapper extends BaseMapper */ public int deleteShopCouponByCouponIds(Long[] couponIds); - IPage selectShopCouponByUserId(Page page, @Param("vo") ShopCoupon shopCoupon); + IPage selectShopCouponByUserId(@Param("page") Page page, @Param("vo") ShopCoupon shopCoupon); IPage availableCouponsListByUserId(Page page, @Param("vo") ShopCoupon shopCoupon); diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml index 3eb4d5f8..b6f40d7f 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml @@ -717,6 +717,9 @@ FROM AND ii.customer_source = #{query.customerSource} + + AND ii.business_channel = #{query.businessChannel} + AND ( ii.car_model LIKE concat('%',#{query.carModelOrCarYear},'%') OR ii.car_num LIKE concat('%',#{query.carModelOrCarYear},'%') ) diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionAppointmentMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionAppointmentMapper.xml index 9abb7957..d2c12f04 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionAppointmentMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionAppointmentMapper.xml @@ -111,21 +111,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" CONVERT(suc.car_model USING utf8mb4) COLLATE utf8mb4_general_ci AS car_model, CONVERT(suc.car_no USING utf8mb4) COLLATE utf8mb4_general_ci AS car_no, CONVERT(igs.sku_name USING utf8mb4) COLLATE utf8mb4_general_ci AS sku_name, - CONVERT("" USING utf8mb4) COLLATE utf8mb4_general_ci AS customerSource, + CONVERT(ip.customer_source USING utf8mb4) COLLATE utf8mb4_general_ci AS customerSource, ip.create_time AS createTime, CONVERT('appointment' USING utf8mb4) COLLATE utf8mb4_general_ci AS sourceType FROM inspection_appointment ip - INNER JOIN system_users su ON ip.user_id = su.id AND ip.tenant_id = 180 AND su.tenant_id = 180 - LEFT JOIN order_info oi ON ip.order_id = oi.id AND oi.deleted=0 AND oi.tenant_id=180 - LEFT JOIN shop_user_car suc ON suc.car_id = oi.user_car_id AND suc.deleted=0 AND suc.tenant_id=180 - LEFT JOIN inspection_goods_sku igs ON igs.id = ip.sku_id AND igs.tenant_id=180 + INNER JOIN system_users su ON ip.user_id = su.id + LEFT JOIN order_info oi ON ip.order_id = oi.id AND oi.deleted=0 + LEFT JOIN shop_user_car suc ON suc.car_id = oi.user_car_id AND suc.deleted=0 + LEFT JOIN inspection_goods_sku igs ON igs.id = ip.sku_id WHERE ip.deleted=0 AND oi.validation_time IS NULL AND (su.mobile LIKE concat('%',#{phoneNum},'%') OR ip.car_no LIKE concat('%',#{phoneNum},'%')) - - AND ip.partner_id = #{partnerId} - AND ip.car_no LIKE concat('%',#{carNo},'%') diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionBusinessChannelMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionBusinessChannelMapper.xml index 7d4db801..9ea521af 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionBusinessChannelMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionBusinessChannelMapper.xml @@ -4,4 +4,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml index 396f39e7..4a646cee 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml @@ -701,8 +701,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -237,6 +242,9 @@ order_info oi LEFT JOIN inspection_info info ON oi.id = info.inspection_order_id where comment_star is not null + + and oi.tenant_id = #{tenantId} + ORDER BY comment_time desc +