更新0711

This commit is contained in:
xyc 2025-07-11 13:22:18 +08:00
parent e78b5a0c4f
commit 8db128ccc8
45 changed files with 1411 additions and 136 deletions

View File

@ -63,18 +63,27 @@ public interface CompanyService extends IService<Company> {
/**
* 通过服务名称查能提供服务的企业 分页
*
* @param company 企业对象主要是serverCodes
* @author 小李
* @date 14:09 2024/9/23
* @param company 企业对象主要是serverCodes
**/
IPage<Company> getCompanyPageByServer(Company company, Page<Company> page);
/**
* 查企业能提供的业务
*
* @param id 企业ID
* @author 小李
* @date 10:21 2024/9/24
* @param id 企业ID
**/
CompanyToServerVO getCompanyServerById(String id);
}
/**
* 通过租户ID和系统编码查询企业信息
*
* @param tenantId 租户ID
* @param systemCode 系统编码
* @return
*/
CompanyRespVO getCompanyByTenantIdAndSystemCode(Long tenantId, String systemCode);
}

View File

@ -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<CompanyMapper, Company> 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.<Company>lambdaQuery()
.eq(Company::getTenantId, tenantId)
.like(ObjectUtil.isNotEmpty(systemCode), Company::getServiceCodes, systemCode)),
CompanyRespVO.class);
}
}

View File

@ -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);
}

View File

@ -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<String, Object> templateParams = new HashMap<>();
// 发送模版内容
templateParams.put("text", text);
// 发送站内信
sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId)
.setTemplateCode(TICKET_EMPLOY)
.setSystemCode(SystemEnum.INSPECTION.getCode())
.setTemplateParams(templateParams), tenantId);
}
}

View File

@ -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));
}
/**

View File

@ -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<String, Object> 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<DictDataDO> 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对象

View File

@ -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();

View File

@ -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<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(user.getId());
List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId);
List<String> roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList());
// Set<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(user.getId());
// List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId);
// List<String> 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<OrderInfo> page = new Page<>(pageNo, pageSize);
return CommonResult.success(orderInfoService.queryListPage(shopInspectionOrder, page));
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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));
}

View File

@ -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<SiteInfo> page = new Page<>(pageNum, pageSize);
IPage<SiteInfo> list = siteInfoService.selectSiteInfoList(page,siteInfo);
return success(list);
}
}

View File

@ -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<AdminUserDO> page = new Page<>(pageNum, pageSize);
IPage<AdminUserDO> 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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> 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<ShopCoupon> page = new Page<>(pageNum, pageSize);
IPage<ShopCoupon> list = shopCouponService.selectShopCouponByUserId(page,shopCoupon);
return success(list);
}
}

View File

@ -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; //业务渠道
}

View File

@ -229,6 +229,11 @@ public class InspectionInfo extends TenantBaseDO
*/
@TableField(exist = false)
private String cashierConfirmRemark;
/**
* 出纳确认备注
*/
@TableField(exist = false)
private String cashierConfirmTime;
/**
* 会计是否确认 0-未到账 1-已到账 null-待确认
*/

View File

@ -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<InspectionBusinessChannel> {
/**
* 获取业务渠道 客户来源
* @param userId
* @return
*/
InspectionBusinessChannel getBusinessChannelByUserId(Long userId);
}

View File

@ -66,4 +66,6 @@ public class OrderTableQuery {
private Long realPayMoney;
private String remark;
private String receivablesAccount;
}

View File

@ -72,6 +72,7 @@ public interface IInspectionAppointmentService extends IService<InspectionAppoi
Long pickCarInspection(InspectionPickCar pickCar) throws Exception;
JSONObject appointmentDateList(Long goodsId,String type);
JSONObject appointmentDateList(Long goodsId,String type,Long tenantId);
JSONObject pickCarInfo();
JSONObject computeDistanceAndPrice(Long goodsId,Double longitude,Double latitude,String type ) throws Exception;

View File

@ -4,7 +4,16 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionBusinessChannel;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
public interface InspectionBusinessChannelService extends IService<InspectionBusinessChannel> {
List<InspectionBusinessChannel> getChannelTree();
/**
* 获取业务渠道和客户来源
*
* @param userId 用户id
* @return
*/
Map<String, Object> getBusinessChannelByUserId(Long userId);
}

View File

@ -92,5 +92,7 @@ public interface InspectionStaffService extends IService<InspectionStaff> {
* @return
*/
InspectionStaffSaveVo getInspectionStaffByUniqueCode(String uniqueCode);
Map<String, Object> getBusinessByUniqueCode(String uniqueCode);
}

View File

@ -94,44 +94,61 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl<AppInspectionGood
List<GoodsVo> goodsVoList = baseMapper.goodsList(goodsQuery);
//获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Set<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId());
List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId);
List<String> roleKeys = roleList.stream().map(item->item.getCode()).collect(Collectors.toList());
for (GoodsVo goodsVo : goodsVoList) {
LambdaQueryWrapper<InspectionGoodsSku> queryWrapper =new LambdaQueryWrapper();
queryWrapper.eq(InspectionGoodsSku::getGoodsId,goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum);
List<InspectionGoodsSku> 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<PartnerWorker> 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<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId());
List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId);
List<String> roleKeys = roleList.stream().map(item -> item.getCode()).collect(Collectors.toList());
for (GoodsVo goodsVo : goodsVoList) {
LambdaQueryWrapper<InspectionGoodsSku> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum);
List<InspectionGoodsSku> 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<PartnerWorker> 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<InspectionGoodsSku> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsVo.getGoodsId()).orderByAsc(InspectionGoodsSku::getOrderNum);
List<InspectionGoodsSku> 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<AppInspectionGood
Long userId = SecurityFrameworkUtils.getLoginUserId();
GoodsDetail resInfo =new GoodsDetail();
AdminUserDO sysUser = userService.getUser(userId);
Integer userLevel = sysUser.getUserLevel();
Integer userLevel = 0;
if (sysUser!=null) {
userLevel = sysUser.getUserLevel();
}
ShopInspectionGoods goods = baseMapper.selectById(goodsQuery.getGoodsId());
//处理图片格式
if (!StringUtils.isEmpty(goods.getImages())){
@ -234,6 +254,9 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl<AppInspectionGood
ShopInspectionGoods goods = this.getById(goodsId);
//获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (ObjectUtils.isEmpty(loginUser)) {
return list;
}
Set<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(loginUser.getId());
List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId);
List<String> roleKeys = roleList.stream().map(item->item.getCode()).collect(Collectors.toList());
@ -328,7 +351,10 @@ public class AppInspectionGoodsServiceImpl extends ServiceImpl<AppInspectionGood
InspectionGoodsSku goodsSku = skuService.getById(goodsQuery.getGoodsId());
ShopInspectionGoods goodsInfo = this.getById(goodsSku.getGoodsId());
AdminUserDO sysUser = userService.getUser(userId);
Integer userLevel = sysUser.getUserLevel();
Integer userLevel = 0;
if (ObjectUtils.isNotEmpty(sysUser)) {
userLevel = sysUser.getUserLevel();
}
res.setGoodsId(goodsSku.getId());
res.setGoodsName(goodsSku.getSkuName());
res.setGoodsImage(goodsInfo.getImage());

View File

@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import cn.iocoder.yudao.module.partner.entity.PartnerWorker;
import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService;
import cn.iocoder.yudao.module.payment.entity.OrderInfo;
@ -54,6 +56,8 @@ public class AppInspectionOrderServiceImpl extends ServiceImpl<OrderInfoMapper,
private IShopInspectionGoodsService goodsService;
@Autowired
private ShopInspectionCategoryService categoryService;
@Autowired
private CompanyService companyService;
//app的订单详情
@Override
@ -63,6 +67,8 @@ public class AppInspectionOrderServiceImpl extends ServiceImpl<OrderInfoMapper,
if (!user.getId().equals(orderInfo.getUserId())){
return null;
}
// 通过订单租户id 查询商家信息
CompanyRespVO partners = companyService.getCompanyByTenantIdAndSystemCode(orderInfo.getTenantId(), "jiance");
OrderAppDetail orderDetail =new OrderAppDetail();
orderDetail.setOrderStatus(orderInfo.getOrderStatus());
orderDetail.setGoodsId(orderInfo.getGoodsId());
@ -78,13 +84,14 @@ public class AppInspectionOrderServiceImpl extends ServiceImpl<OrderInfoMapper,
orderDetail.setPartnerName(orderInfo.getPartnerName());
orderDetail.setReduceMoney(orderInfo.getReduceMoney());
orderDetail.setValidationTime(orderInfo.getValidationTime());
ShopMallPartners partners = partnerService.getById(orderInfo.getPartnerId());
// ShopMallPartners partners = partnerService.getById(orderInfo.getPartnerId());
orderDetail.setPartnerName(partners.getCorpName());
orderDetail.setAccessCode(orderInfo.getAccessCode());
orderDetail.setPartnerAddress(Optional.ofNullable(partners.getAddress()).orElse(""));
orderDetail.setContactNumber(partners.getContactNumber());
orderDetail.setLatitude(partners.getLatitude());
orderDetail.setLongitude(partners.getLongitude());
orderDetail.setWorkTimeStr(partners.getWorkTime());
orderDetail.setContactNumber(partners.getMobilePhone());
orderDetail.setLatitude(partners.getLat() == null ? "" : partners.getLat().toString());
orderDetail.setLongitude(partners.getLgt() == null ? "" : partners.getLgt().toString());
orderDetail.setWorkTimeStr(partners.getBusinessStartTime() + "~" + partners.getBusinessEndTime());
orderDetail.setCommentStar(orderInfo.getCommentStar());
orderDetail.setCommentDesc(orderInfo.getCommentDesc());
return orderDetail;

View File

@ -2645,45 +2645,43 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
@Override
@Transactional
public void batchSettlement(OrderTableQuery query) {
// 获取type
if (query.getType() == null) {
throw new RuntimeException("请选择结算类型");
}
switch (query.getType()) {
case "all": {
// 这是根据筛选条件将所有的工单结算
InspectionInfoVo infoVo = query.getInfoVo();
break;
}
case "selected": {
InspectionInfoVo infoVo = query.getInfoVo();
Long realPayMoney = query.getRealPayMoney();
long averageMoney = realPayMoney / query.getIds().size();
// 根据ids 查询工单
List<InspectionInfo> list = inspectionInfoService.list(Wrappers.<InspectionInfo>lambdaQuery()
.in(InspectionInfo::getId, query.getIds()));
// 根据ids 查询工单
List<InspectionInfo> list = inspectionInfoService.list(Wrappers.<InspectionInfo>lambdaQuery()
.in(InspectionInfo::getId, query.getIds()));
// 提取出订单ids
List<Long> orderIds = list.stream().map(InspectionInfo::getInspectionOrderId).collect(Collectors.toList());
// 根据ids 修改工单结算
orderService.update(Wrappers.<OrderInfo>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<Long> 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.<OrderInfo>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.<OrderInfo>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()));
}
}
}

View File

@ -155,6 +155,9 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
public Long appointmentInspection(InspectionAppointment appointment) throws ParseException {
//当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (loginUser == null) {
throw new RuntimeException("请登录");
}
appointment.setUserId(loginUser.getId());
AdminUserDO ownUser = userService.getUser(loginUser.getId());
InspectionGoodsSku sku = skuService.getById(appointment.getSkuId());
@ -195,19 +198,19 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
if (StringUtils.isNotEmpty(appointment.getOtherPhone())) {
phone = appointment.getOtherPhone();
//给联系人发送
// SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
// , partners.getPartnerName(), sysUser.getNickname(), sysUser.getMobile()
//// },appointment.getOtherPhone(),"1400852709","机动车管家小程序","2112792");
// }, appointment.getOtherPhone(), "1400852709", "机动车管家小程序", "2386324");
}, appointment.getOtherPhone(), "1400852709", "机动车管家小程序", "2386324");
} else {
phone = ownUser.getMobile();
//给本人发送
//给联系人发送
// SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
// , partners.getPartnerName(), sysUser.getNickname(), sysUser.getMobile()
//// },ownUser.getMobile(),"1400852709","机动车管家小程序","2112792");
// }, ownUser.getMobile(), "1400852709", "机动车管家小程序", "2386324");
// },ownUser.getMobile(),"1400852709","机动车管家小程序","2112792");
}, ownUser.getMobile(), "1400852709", "机动车管家小程序", "2386324");
}
}
//给检测站发送
@ -226,7 +229,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
List<String> codes = roleList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
//根据角色查询用户
List<UserDTO> userListByCodes = roleService.getUserListByCodes(codes);
List<UserDTO> userListByCodes = roleService.getUserListByCodesAndTenantId(codes, appointment.getTenantId());
// 组装消息
String day = Objects.equals(appointment.getAppointmentPeriod(), "0") ? "上午" : "下午";
@ -249,7 +252,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
redisDelayedQueueService.addToQueue(message, triggerTimeMillis);
// 发送站内信
noticeService.sentMessage(userListByCode.getId(), msg);
noticeService.sentMessage(userListByCode.getId(), msg, appointment.getTenantId());
}
@ -414,6 +417,40 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
return res;
}
@Override
public JSONObject appointmentDateList(Long goodsId, String type,Long tenantId) {
if (type.equals("sku")) {
InspectionGoodsSku goodsSku = skuService.getById(goodsId);
goodsId = Long.parseLong(goodsSku.getGoodsId().toString());
}
JSONObject res = new JSONObject();
List<JSONObject> resList = new ArrayList<>();
List<Date> 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<InspectionAppointment> 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();

View File

@ -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<Inspection
return this.list();
}
/**
* 获取业务渠道和客户来源
*
* @param userId 用户id
* @return
*/
@Override
public Map<String, Object> getBusinessChannelByUserId(Long userId) {
Map<String, Object> map = new HashMap<>();
// 客户来源
InspectionBusinessChannel channel = baseMapper.getBusinessChannelByUserId(userId);
if (channel == null) {
return null;
}
map.put("channel", channel);
// 根据客户来源的父id查询业务渠道
InspectionBusinessChannel business = getOne(Wrappers.<InspectionBusinessChannel>lambdaQuery()
.eq(InspectionBusinessChannel::getId, channel.getPid()));
if (business != null) {
map.put("business", business);
}
return map;
}
}

View File

@ -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<InspectionStaffMappe
@Resource
private UniqueCodeService uniqueCodeService;
@Autowired
private InspectionBusinessChannelService inspectionBusinessChannelService;
/**
* 获取检测员工分页
*
@ -317,6 +321,17 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
return baseMapper.getInspectionStaffByUniqueCode(uniqueCode);
}
/**
* @param uniqueCode
* @return
*/
@Override
public Map<String, Object> getBusinessByUniqueCode(String uniqueCode) {
InspectionStaffSaveVo staff = getInspectionStaffByUniqueCode(uniqueCode);
// 通过员工id查找 业务渠道和客户来源
return inspectionBusinessChannelService.getBusinessChannelByUserId(staff.getId());
}
/**
* 保存检测员工
*

View File

@ -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();
/**
* typeh5jsapiappnativesub_jsapi
* @param type
* @return
*/
@GetMapping("/prepayment")
public Map<String,Object> 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<String, Object> 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<String, Object> amountMap = new HashMap<>(4);
// 金额单位为分
amountMap.put("total", orderInfo.getPayMoney());
//人民币
amountMap.put("currency", "CNY");
params.put("amount", amountMap);
// 场景信息
Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> resMap = JSONObject.parseObject(resStr);
Map<String, Object> signMap = paySignMsg(resMap.get("prepay_id").toString(), wechatPayConfig.getAppId(),null);
return signMap;
}
/**
* typeh5jsapiappnativesub_jsapi
* @param type
* @return
*/
@GetMapping("/jcPrepayment2")
public Map<String,Object> 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<String, Object> 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<String, Object> amountMap = new HashMap<>(4);
// 金额单位为分
amountMap.put("total", orderInfo.getPayMoney());
//人民币
amountMap.put("currency", "CNY");
params.put("amount", amountMap);
// 场景信息
Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> resMap = JSONObject.parseObject(resStr);
Map<String, Object> signMap = paySignMsg(resMap.get("prepay_id").toString(), wechatPayConfig.getAppId(),null);
return signMap;
}
/**
* typeh5jsapiappnativesub_jsapi
* @param type
* @return
*/
@GetMapping("/jcPrepayment")
@TenantIgnore
public Map<String,Object> 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<PartnerBankInfo> 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<String, Object> resMap = paySignMsg(prepayId, wechatPayConfig.getJcAppId(),bankInfo.getApiclientKey());
return resMap;
}
private Map<String, Object> 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<String, Object> resMap = new HashMap<>();
resMap.put("nonceStr",nonceStr);
resMap.put("timeStamp",timeStamp);
resMap.put("appId",appId);
resMap.put("package", packageStr);
// 使用字段appIdtimeStampnonceStrpackage进行签名
//从下往上依次生成
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<String, String> 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<PartnerBankInfo> 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<String, String> 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<CreateOrderReceiver> 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<String, String> 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<String, String> res = new HashMap<>();
res.put("code", "SUCCESS");
res.put("message", "成功");
return res;
}
}

View File

@ -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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> orderInfos = orderInfoService.orderList(page,status, title);
return success(orderInfos);
}
// 用于自营维修保养核销
@PostMapping("/validation")
public CommonResult validation(@RequestBody Map<String, Object> 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<String, Object> 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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> 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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> 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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> 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<commentVo> page = new Page<>(pageNum, pageSize);
IPage<commentVo> 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<OrderInfo> page = new Page<>(pageNum, pageSize);
IPage<OrderInfo> 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);
}
}

View File

@ -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;
/**
* 出纳人
*/

View File

@ -333,6 +333,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
createOrder.setDriverLicenesImg(orderInfo.getDriverLicenesImg());
createOrder.setIsPayOnline(orderInfo.getIsPayOnline());
createOrder.setIsPickCar(orderInfo.getIsPickCar());
createOrder.setTenantId(orderInfo.getTenantId());
if (isCoupon.equals("1")) {
createOrder.setCouponId(orderInfo.getCouponId());

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.shop.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.service.IInspectionAppointmentService;
@ -29,6 +30,7 @@ public class SmallAppShopController {
*/
@PostMapping("/appointmentInspection")
@TenantIgnore
@PreAuthenticated
public CommonResult appointmentInspection(@RequestBody InspectionAppointment appointment) throws ParseException {
return success(appointmentService.appointmentInspection(appointment));
}

View File

@ -87,5 +87,21 @@ public class ShopCoupon extends TenantBaseDO
@TableField(exist = false)
private Map<String,Object> 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;
}

View File

@ -69,7 +69,7 @@ public interface ShopCouponMapper extends BaseMapper<ShopCoupon>
*/
public int deleteShopCouponByCouponIds(Long[] couponIds);
IPage<ShopCoupon> selectShopCouponByUserId(Page<ShopCoupon> page, @Param("vo") ShopCoupon shopCoupon);
IPage<ShopCoupon> selectShopCouponByUserId(@Param("page") Page<ShopCoupon> page, @Param("vo") ShopCoupon shopCoupon);
IPage<ShopCoupon> availableCouponsListByUserId(Page<ShopCoupon> page, @Param("vo") ShopCoupon shopCoupon);

View File

@ -717,6 +717,9 @@ FROM
<if test="query.customerSource!=null and query.customerSource!=''">
AND ii.customer_source = #{query.customerSource}
</if>
<if test="query.businessChannel!=null and query.businessChannel!=''">
AND ii.business_channel = #{query.businessChannel}
</if>
<if test="query.carModelOrCarYear!=null and query.carModelOrCarYear!=''">
AND ( ii.car_model LIKE concat('%',#{query.carModelOrCarYear},'%')
OR ii.car_num LIKE concat('%',#{query.carModelOrCarYear},'%') )

View File

@ -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
<if test="phoneNum!=null and phoneNum!=''">
AND (su.mobile LIKE concat('%',#{phoneNum},'%') OR ip.car_no LIKE concat('%',#{phoneNum},'%'))
</if>
<if test="partnerId!=null and partnerId!=''">
AND ip.partner_id = #{partnerId}
</if>
<if test="carNo != null and carNo != ''">
AND ip.car_no LIKE concat('%',#{carNo},'%')
</if>

View File

@ -4,4 +4,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.inspection.mapper.InspectionBusinessChannelMapper">
<select id="getBusinessChannelByUserId" parameterType="java.lang.Long">
SELECT
*
FROM inspection_business_channel
WHERE FIND_IN_SET(#{userId}, user_ids)
ORDER BY sort ASC
limit 1
</select>
</mapper>

View File

@ -701,8 +701,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="pageWorkOrderNew" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
select distinct ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,oi.cashier_confirm,oi.cashier_confirm_remark,oi.accounting_confirm,oi.accounting_confirm_remark
select distinct ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as
realPayMoney
,oi.pay_type,oi.order_status as
orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,oi.cashier_confirm,oi.cashier_confirm_remark,oi.cashier_confirm_time ,oi.accounting_confirm,oi.accounting_confirm_remark
from inspection_info ins
left join order_info oi on oi.id = ins.inspection_order_id
left join system_users su on su.id = ins.user_id
@ -725,7 +727,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND TIMESTAMPDIFF(YEAR, ins.car_register_date, CURDATE()) &lt; #{query.carYear} + 1)
</if>
<if test="query.payType!=null and query.payType!=''">
and oi.pay_type = #{query.payType}
and oi.pay_type = #{query.payType}
</if>
<if test="query.startTime!=null and query.startTime!=''">
and ins.start_time between #{query.startTime} and #{query.endTime}
@ -733,13 +735,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.datetimeRange != null">
and ins.start_time between #{query.datetimeRange[0]} and #{query.datetimeRange[1]}
</if>
<if test="query.payStatus == 0">
and (oi.pay_money is null OR oi.pay_type = 'sz')
</if>
<if test="query.payStatus == 1">
and oi.pay_time is not null AND oi.pay_type != 'sz'
</if>
order by ins.start_time desc
<if test="query.payStatus == 0">
and (oi.pay_money is null OR oi.pay_type = 'sz')
</if>
<if test="query.payStatus == 1">
and oi.pay_time is not null AND oi.pay_type != 'sz'
</if>
<if test="query.payStatus == 2">
and oi.cashier_confirm = 1
and (oi.accounting_confirm is null or oi.accounting_confirm != 1)
</if>
order by ins.start_time desc
</select>
<select id="workOrderDataNew" resultType="java.util.Map">
select ifnull(sum(case when oi.pay_type != 'sz' then oi.pay_money else 0 end), 0) as payMoneySum

View File

@ -140,7 +140,8 @@
iss.emergency_contact_phone,
iss.driver_license_type,
iss.folder_id,
iss.unique_code
iss.unique_code,
iss.tenant_id
FROM inspection_staff iss
inner join system_users su on iss.user_id = su.id
<where>

View File

@ -100,7 +100,7 @@
*
FROM
`order_info`
where user_id =#{userId} and order_status!= '0'
where user_id =#{userId}
<if test="status!=null and status!='' ">
and order_status = #{status}
</if>
@ -141,7 +141,12 @@
left join order_info oi on oi.id = info.inspection_order_id
LEFT JOIN base_company company ON company.tenant_id = info.tenant_id AND company.service_codes LIKE '%jiance%' AND company.deleted = '0'
WHERE info.user_id = #{userId}
and info.status = #{status}
<if test="status ==0 ">
and info.status in (0,2)
</if>
<if test="status ==1 ">
and info.status in (1)
</if>
GROUP BY info.id
order by info.create_time desc
</select>
@ -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
<if test="tenantId != null">
and oi.tenant_id = #{tenantId}
</if>
ORDER BY comment_time desc
</select>
<select id="pageOrderListSystem" resultType="cn.iocoder.yudao.module.payment.entity.OrderInfo">

View File

@ -82,9 +82,9 @@
<if test="vo.userId != null "> and sys_user.id = #{vo.userId}</if>
<if test="vo.orderId != null "> and order_id = #{vo.orderId}</if>
<if test="vo.phonenumber != null and vo.phonenumber != ''"> and phonenumber like concat('%', #{vo.phonenumber}, '%')</if>
<if test="params.beginStartTime != null and params.beginStartTime != '' and params.endStartTime != null and params.endStartTime != ''"> and start_time between #{params.beginStartTime} and #{params.endStartTime}</if>
<if test="params.beginExpirationTime != null and params.beginExpirationTime != '' and params.endExpirationTime != null and params.endExpirationTime != ''"> and expiration_time between #{params.beginExpirationTime} and #{params.endExpirationTime}</if>
<if test="params.beginUseTime != null and params.beginUseTime != '' and params.endUseTime != null and params.endUseTime != ''"> and use_time between #{params.beginUseTime} and #{params.endUseTime}</if>
<if test="vo.beginStartTime != null and vo.beginStartTime != '' and vo.endStartTime != null and vo.endStartTime != ''"> and start_time between #{vo.beginStartTime} and #{vo.endStartTime}</if>
<if test="vo.beginExpirationTime != null and vo.beginExpirationTime != '' and vo.endExpirationTime != null and vo.endExpirationTime != ''"> and expiration_time between #{vo.beginExpirationTime} and #{params.endExpirationTime}</if>
<if test="vo.beginUseTime != null and vo.beginUseTime != '' and vo.endUseTime != null and vo.endUseTime != ''"> and use_time between #{vo.beginUseTime} and #{vo.endUseTime}</if>
<if test="vo.couponStatus != null and vo.couponStatus != ''">
<choose>
<when test="vo.couponStatus=='0'.toString()">

View File

@ -416,7 +416,11 @@ public class AppSysLoginController {
public CommonResult getAppInfo()
{
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (loginUser == null) {
throw new RuntimeException("请登录");
}
AdminUserDO user = userService.getUser(loginUser.getId());
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
List<RoleDO> roleList = roleService.getRoleList(roleIdsByUserId);
Map<String,Object> ajax = new HashMap<>();

View File

@ -57,4 +57,6 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
List<UserDTO> selectByRoleIds(@Param("roleIds") List<Integer> roleIds);
List<UserDTO> selectByRoleCodes(@Param("codes") List<String> codes);
List<UserDTO> selectByRoleCodesAndTenantId(@Param("codes") List<String> codes, @Param("tenantId") Long tenantId);
}

View File

@ -204,4 +204,12 @@ public interface RoleService {
* @return
*/
List<UserDTO> getUserListByCodes(List<String> codes);
/**
* 根据角色code查询用户
*
* @param codes 角色code数组
* @return
*/
List<UserDTO> getUserListByCodesAndTenantId(List<String> codes, Long tenantId);
}

View File

@ -412,6 +412,17 @@ public class RoleServiceImpl implements RoleService {
return userRoleMapper.selectByRoleCodes(codes);
}
/**
* 根据角色code查询用户
*
* @param codes 角色code数组
* @return
*/
@Override
public List<UserDTO> getUserListByCodesAndTenantId(List<String> codes, Long tenantId) {
return userRoleMapper.selectByRoleCodesAndTenantId(codes, tenantId);
}
/**
* 获得自身的代理对象解决 AOP 生效问题
*

View File

@ -109,4 +109,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) AND sur.deleted = 0
) AND deleted = 0
</select>
<select id="selectByRoleCodesAndTenantId" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO">
SELECT
*
FROM
system_users
WHERE
id IN (
SELECT
user_id
FROM
system_user_role sur
WHERE
sur.role_id IN (
SELECT
id
FROM
system_role
WHERE
code IN
<foreach item="item" collection="codes" open="(" separator="," close=")">
#{item}
</foreach>
AND tenant_id = #{tenantId}
) AND sur.deleted = 0
) AND deleted = 0
</select>
</mapper>