Browse Source

feat(goods): 增加用户维度的商品授权功能

- 新增用户维度的商品授权相关实体类、控制器和服务
- 实现用户维度商品授权的保存、查询等核心业务逻辑
- 优化商品授权信息的获取,支持按不同维度进行查询
- 重构订单创建流程,增加品牌类别和自定义区域信息
- 修复微信用户转换为公众号用户的相关问题
muti_db
Yen 8 months ago
parent
commit
1f8a985620
  1. 1
      src/main/java/com/qs/serve/controller/AdminPortalController.java
  2. 31
      src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSupplierExtRegionVo.java
  3. 37
      src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierMapper.java
  4. 1
      src/main/java/com/qs/serve/modules/goods/controller/GoodsImminentBatchController.java
  5. 6
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsAccreditBo.java
  6. 7
      src/main/java/com/qs/serve/modules/goods/entity/vo/GoodsAccreditVo.java
  7. 115
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java
  8. 29
      src/main/java/com/qs/serve/modules/oms/entity/OmsOrder.java
  9. 106
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java
  10. 12
      src/main/java/com/qs/serve/modules/wx/api/WxSvcUserApi.java
  11. 2
      src/main/java/com/qs/serve/modules/wx/service/WxUserService.java
  12. 9
      src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java

1
src/main/java/com/qs/serve/controller/AdminPortalController.java

@ -221,7 +221,6 @@ public class AdminPortalController {
return R.ok(sysUserLoginService.login(param)); return R.ok(sysUserLoginService.login(param));
} }
/** /**
* 登录接口 * 登录接口
* @return * @return

31
src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSupplierExtRegionVo.java

@ -0,0 +1,31 @@
package com.qs.serve.modules.bms.entity.vo;
import lombok.Data;
/**
* @author YenHex
* @since 2024/11/22
*/
@Data
public class BmsSupplierExtRegionVo {
private String id;
private String name;
private String code;
private String bookCode;
private String salRegionCode;
private String salRegionName;
private String salRegionCode2;
private String salRegionName2;
private String salRegionCode3;
private String salRegionName3;
private String bigRegion;
private String bizRegionCode;
private String bizRegionName;
private String bizRegionCode2;
private String bizRegionName2;
private String bizRegionCode3;
private String bizRegionName3;
}

37
src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierMapper.java

@ -3,6 +3,7 @@ package com.qs.serve.modules.bms.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.bms.entity.BmsSupplier; import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.entity.vo.BmsSupplierExtRegionVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
@ -19,6 +20,42 @@ public interface BmsSupplierMapper extends BaseMapper<BmsSupplier> {
@InterceptorIgnore(tenantLine = "1") @InterceptorIgnore(tenantLine = "1")
List<BmsSupplier> selectSupplierList(@Param("query") BmsSupplier bmsSupplier); List<BmsSupplier> selectSupplierList(@Param("query") BmsSupplier bmsSupplier);
/**
* 客户档案管理区域信息
* @param supplierId
* @return
*/
@Select("select DISTINCT " +
"su.id, " +
"su.`name`, " +
"su.`code`, " +
"book_code, " +
"re.code as sal_region_code, " +
"re.name as sal_region_name, " +
"re2.code as sal_region_code2, " +
"re2.name as sal_region_name2, " +
"re3.code as sal_region_code3, " +
"re3.name as sal_region_name3, " +
"biz1.area as big_region, " +
"biz1.`code` as biz_region_code, " +
"biz1.`name` as biz_region_name, " +
"biz2.`code` as biz_region_code2, " +
"biz2.`name` as biz_region_name2, " +
"biz3.`code` as biz_region_code3, " +
"biz3.`name` as biz_region_name3 " +
"from bms_supplier su " +
"left join bms_region re on re.id = su.region_first " +
"left join bms_region re2 on re2.id = su.region_second " +
"left join bms_region re3 on re3.id = su.region_third " +
"left join bms_region2 biz1 on biz1.id = su.region2_first " +
"left join bms_region2 biz2 on biz2.id = su.region2_second " +
"left join bms_region2 biz3 on biz3.id = su.region2_third " +
"where su.del_flag = 0 " +
"and su.`id` = #{id} ")
@InterceptorIgnore(tenantLine = "1")
BmsSupplierExtRegionVo getBmsSupplierExtRegionVo(@Param("id") String supplierId);
/** /**
* *
* @param query * @param query

1
src/main/java/com/qs/serve/modules/goods/controller/GoodsImminentBatchController.java

@ -141,7 +141,6 @@ public class GoodsImminentBatchController {
*/ */
@DeleteMapping("/deleteById/{ids}") @DeleteMapping("/deleteById/{ids}")
@SysLog(module = SystemModule.GOODS, title = "临期批次", biz = BizType.DELETE) @SysLog(module = SystemModule.GOODS, title = "临期批次", biz = BizType.DELETE)
@PreAuthorize("hasRole('goods:imminentBatch:delete')")
public R<?> deleteById(@PathVariable("ids") String ids){ public R<?> deleteById(@PathVariable("ids") String ids){
List<Long> idsLong = StringUtils.splitIdLong(ids); List<Long> idsLong = StringUtils.splitIdLong(ids);
boolean result = goodsImminentBatchService.removeByIds(idsLong); boolean result = goodsImminentBatchService.removeByIds(idsLong);

6
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsAccreditBo.java

@ -40,6 +40,12 @@ public class GoodsAccreditBo {
/** 不能选的客户 */ /** 不能选的客户 */
private List<String> notInSupplierIds; private List<String> notInSupplierIds;
/** 只能选的客户 */
private List<String> onlyUserIds;
/** 不能选的客户 */
private List<String> notInUserIds;
/** 是否局部更新 */ /** 是否局部更新 */
private boolean onlyPastUpdate = false; private boolean onlyPastUpdate = false;

7
src/main/java/com/qs/serve/modules/goods/entity/vo/GoodsAccreditVo.java

@ -3,6 +3,8 @@ package com.qs.serve.modules.goods.entity.vo;
import com.qs.serve.modules.bms.entity.BmsRegion; import com.qs.serve.modules.bms.entity.BmsRegion;
import com.qs.serve.modules.bms.entity.BmsRegion2; import com.qs.serve.modules.bms.entity.BmsRegion2;
import com.qs.serve.modules.bms.entity.BmsSupplier; import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.sys.entity.dto.SysUserSimpleVo;
import com.qs.serve.modules.sys.entity.dto.SysUserVo;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -38,5 +40,10 @@ public class GoodsAccreditVo {
/** 不可下单 客户 */ /** 不可下单 客户 */
private List<BmsSupplier> notInSupplierList; private List<BmsSupplier> notInSupplierList;
/** 可下单 客户 */
private List<SysUserSimpleVo> onlyUserList;
/** 不可下单 客户 */
private List<SysUserSimpleVo> notInUserList;
} }

115
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java

@ -28,6 +28,7 @@ import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo;
import com.qs.serve.modules.goods.mapper.*; import com.qs.serve.modules.goods.mapper.*;
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; import com.qs.serve.modules.goods.service.GoodsAccreditItemService;
import com.qs.serve.modules.sys.entity.SysUser; import com.qs.serve.modules.sys.entity.SysUser;
import com.qs.serve.modules.sys.entity.dto.SysUserSimpleVo;
import com.qs.serve.modules.sys.mapper.SysUserMapper; import com.qs.serve.modules.sys.mapper.SysUserMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -429,6 +430,8 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
boolean b4 = CollUtil.isNotEmpty(param.getNotInBizRegionIds()); boolean b4 = CollUtil.isNotEmpty(param.getNotInBizRegionIds());
boolean b5 = CollUtil.isNotEmpty(param.getOnlySupplierIds()); boolean b5 = CollUtil.isNotEmpty(param.getOnlySupplierIds());
boolean b6 = CollUtil.isNotEmpty(param.getNotInSupplierIds()); boolean b6 = CollUtil.isNotEmpty(param.getNotInSupplierIds());
boolean b7 = CollUtil.isNotEmpty(param.getOnlyUserIds());
boolean b8 = CollUtil.isNotEmpty(param.getNotInUserIds());
//清空历史 //清空历史
if(!param.isOnlyPastUpdate()){ if(!param.isOnlyPastUpdate()){
@ -442,6 +445,8 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
targetType = "bizRegion"; targetType = "bizRegion";
}else if (b5 || b6){ }else if (b5 || b6){
targetType = "supplier"; targetType = "supplier";
}else if (b7 || b8){
targetType = "user";
}else { }else {
targetType = "saleRegion"; targetType = "saleRegion";
} }
@ -453,7 +458,9 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
); );
} }
// 根据参数中的条件判断是否需要更新商品授权的空标志位
if(!b1 && !b2 && !b3 && !b4 && !b5 && !b6){ if(!b1 && !b2 && !b3 && !b4 && !b5 && !b6){
// 如果参数中没有任何有效的ID列表,则将空标志位设置为1
if(goodsAccredit.getId()!=null){ if(goodsAccredit.getId()!=null){
goodsAccredit.setEmptyFlag(1); goodsAccredit.setEmptyFlag(1);
this.updateById(goodsAccredit); this.updateById(goodsAccredit);
@ -559,68 +566,164 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
goodsAccreditItemService.saveBatch(list); goodsAccreditItemService.saveBatch(list);
} }
if(b7){
List<SysUser> userList = sysUserMapper.selectBatchIds(param.getNotInSupplierIds());
List<GoodsAccreditItem> list = userList.stream().map(a->{
GoodsAccreditItem item = new GoodsAccreditItem();
item.setAccId(accId);
item.setAccType(0);
item.setTargetType("user");
item.setTargetCode(a.getCode());
item.setTargetName(a.getName());
item.setTargetId(a.getId());
return item;
}).collect(Collectors.toList());
goodsAccreditItemService.saveBatch(list);
} }
if(b8){
List<SysUser> userList = sysUserMapper.selectBatchIds(param.getNotInSupplierIds());
List<GoodsAccreditItem> list = userList.stream().map(a->{
GoodsAccreditItem item = new GoodsAccreditItem();
item.setAccId(accId);
item.setAccType(1);
item.setTargetType("user");
item.setTargetCode(a.getCode());
item.setTargetName(a.getName());
item.setTargetId(a.getId());
return item;
}).collect(Collectors.toList());
goodsAccreditItemService.saveBatch(list);
}
}
/**
* 根据类别IDSPU ID和SKU ID获取商品授权信息
* @param cateId 类别ID
* @param spuId SPU ID
* @param skuId SKU ID
* @return 返回商品授权信息对象如果没有找到则返回null
*/
@Override @Override
public GoodsAccreditVo getById(String cateId, String spuId, String skuId) { public GoodsAccreditVo getById(String cateId, String spuId, String skuId) {
// 获取商品授权基本信息
GoodsAccredit accredit = this.getGoodsAccredit(new GoodsAccreditBo(cateId,spuId,skuId)); GoodsAccredit accredit = this.getGoodsAccredit(new GoodsAccreditBo(cateId,spuId,skuId));
GoodsAccreditVo accreditVo = new GoodsAccreditVo(); GoodsAccreditVo accreditVo = new GoodsAccreditVo();
// 如果授权信息存在且有有效的ID,则进一步处理
if(accredit!=null&&accredit.getId()!=null){ if(accredit!=null&&accredit.getId()!=null){
// 查询该授权下的所有授权项
List<GoodsAccreditItem> accreditItemList = goodsAccreditItemService List<GoodsAccreditItem> accreditItemList = goodsAccreditItemService
.list(new LambdaQueryWrapper<GoodsAccreditItem>().eq(GoodsAccreditItem::getAccId,accredit.getId())); .list(new LambdaQueryWrapper<GoodsAccreditItem>().eq(GoodsAccreditItem::getAccId,accredit.getId()));
// 将授权项按目标类型分组
Map<String,List<GoodsAccreditItem>> accMap = accreditItemList.stream() Map<String,List<GoodsAccreditItem>> accMap = accreditItemList.stream()
.collect(Collectors.groupingBy(GoodsAccreditItem::getTargetType)); .collect(Collectors.groupingBy(GoodsAccreditItem::getTargetType));
// 分别获取供应商、业务区,销售区域,用户,的授权项列表
List<GoodsAccreditItem> list1 = accMap.get("supplier"); List<GoodsAccreditItem> list1 = accMap.get("supplier");
List<GoodsAccreditItem> list2 = accMap.get("bizRegion"); List<GoodsAccreditItem> list2 = accMap.get("bizRegion");
List<GoodsAccreditItem> list3 = accMap.get("saleRegion"); List<GoodsAccreditItem> list3 = accMap.get("saleRegion");
List<GoodsAccreditItem> list4 = accMap.get("user");
// 处理供应商授权项
if(CollUtil.isNotEmpty(list1)){ if(CollUtil.isNotEmpty(list1)){
// 将供应商授权项按授权类型分组
Map<Integer,List<GoodsAccreditItem>> listMap = list1.stream() Map<Integer,List<GoodsAccreditItem>> listMap = list1.stream()
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); .collect(Collectors.groupingBy(GoodsAccreditItem::getAccType));
// 分别处理仅限和除外的供应商授权项
List<GoodsAccreditItem> onlyList = listMap.get(0); List<GoodsAccreditItem> onlyList = listMap.get(0);
List<GoodsAccreditItem> notInList = listMap.get(1); List<GoodsAccreditItem> notInList = listMap.get(1);
if(CollUtil.isNotEmpty(onlyList)){ if(CollUtil.isNotEmpty(onlyList)){
// 获取仅限供应商ID列表并查询供应商信息
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setOnlySupplierList(supplierMapper.selectBatchIds(ids)); accreditVo.setOnlySupplierList(supplierMapper.selectBatchIds(ids));
} }
if(CollUtil.isNotEmpty(notInList)){ if(CollUtil.isNotEmpty(notInList)){
// 获取除外供应商ID列表并查询供应商信息
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setNotInSupplierList(supplierMapper.selectBatchIds(ids)); accreditVo.setNotInSupplierList(supplierMapper.selectBatchIds(ids));
} }
} }
// 处理业务区域授权项
if(CollUtil.isNotEmpty(list2)){ if(CollUtil.isNotEmpty(list2)){
// 将业务区域授权项按授权类型分组
Map<Integer,List<GoodsAccreditItem>> listMap = list2.stream() Map<Integer,List<GoodsAccreditItem>> listMap = list2.stream()
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); .collect(Collectors.groupingBy(GoodsAccreditItem::getAccType));
// 分别处理仅限和除外的业务区域授权项
List<GoodsAccreditItem> onlyList = listMap.get(0); List<GoodsAccreditItem> onlyList = listMap.get(0);
List<GoodsAccreditItem> notInList = listMap.get(1); List<GoodsAccreditItem> notInList = listMap.get(1);
if(CollUtil.isNotEmpty(onlyList)){ if(CollUtil.isNotEmpty(onlyList)){
// 获取仅限业务区域ID列表并查询区域信息
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setOnlyBizRegionList(region2Mapper.selectBatchIds(ids)); accreditVo.setOnlyBizRegionList(region2Mapper.selectBatchIds(ids));
} }
if(CollUtil.isNotEmpty(notInList)){ if(CollUtil.isNotEmpty(notInList)){
// 获取除外业务区域ID列表并查询区域信息
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setNotInBizRegionList(region2Mapper.selectBatchIds(ids)); accreditVo.setNotInBizRegionList(region2Mapper.selectBatchIds(ids));
} }
} }
// 处理销售区域授权项
if(CollUtil.isNotEmpty(list3)){ if(CollUtil.isNotEmpty(list3)){
// 将销售区域授权项按授权类型分组
Map<Integer,List<GoodsAccreditItem>> listMap = list3.stream() Map<Integer,List<GoodsAccreditItem>> listMap = list3.stream()
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); .collect(Collectors.groupingBy(GoodsAccreditItem::getAccType));
// 分别处理仅限和除外的销售区域授权项
List<GoodsAccreditItem> onlyList = listMap.get(0); List<GoodsAccreditItem> onlyList = listMap.get(0);
List<GoodsAccreditItem> notInList = listMap.get(1); List<GoodsAccreditItem> notInList = listMap.get(1);
if(CollUtil.isNotEmpty(onlyList)){ if(CollUtil.isNotEmpty(onlyList)){
// 获取仅限销售区域ID列表并查询区域信息
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setOnlySaleRegionList(regionMapper.selectBatchIds(ids)); accreditVo.setOnlySaleRegionList(regionMapper.selectBatchIds(ids));
} }
if(CollUtil.isNotEmpty(notInList)){ if(CollUtil.isNotEmpty(notInList)){
// 获取除外销售区域ID列表并查询区域信息
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
accreditVo.setNotInSaleRegionList(regionMapper.selectBatchIds(ids)); accreditVo.setNotInSaleRegionList(regionMapper.selectBatchIds(ids));
} }
} }
// 处理用户授权项
if(CollUtil.isNotEmpty(list4)){
// 将销售区域授权项按授权类型分组
Map<Integer,List<GoodsAccreditItem>> listMap = list4.stream()
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType));
// 分别处理仅限和除外的销售区域授权项
List<GoodsAccreditItem> onlyList = listMap.get(0);
List<GoodsAccreditItem> notInList = listMap.get(1);
if(CollUtil.isNotEmpty(onlyList)){
// 获取仅限销售区域ID列表并查询区域信息
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
List<SysUserSimpleVo> userSimpleVos = sysUserMapper.selectBatchIds(ids).stream()
.map(a->a.toSimpleVo(true)).collect(Collectors.toList());
accreditVo.setOnlyUserList(userSimpleVos);
}
if(CollUtil.isNotEmpty(notInList)){
// 获取除外销售区域ID列表并查询区域信息
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList());
List<SysUserSimpleVo> userSimpleVos = sysUserMapper.selectBatchIds(ids).stream()
.map(a->a.toSimpleVo(true)).collect(Collectors.toList());
accreditVo.setNotInUserList(userSimpleVos);
}
}
// 返回构建好的商品授权信息对象
return accreditVo; return accreditVo;
} }
// 如果没有找到授权信息,则返回null
return null; return null;
} }
@ -814,11 +917,19 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
return false; return false;
} }
/**
* 根据商品类别IDSPU ID或SKU ID获取商品授权信息
* @param param 包含商品类别IDSPU ID或SKU ID的查询参数对象
* @return 返回商品授权信息对象如果找不到则返回null
*/
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){
GoodsAccredit accredit = null; GoodsAccredit accredit = null;
// 根据类别ID查询商品授权信息
if(param.getCategoryId()!=null){ if(param.getCategoryId()!=null){
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>()
.eq(GoodsAccredit::getCategoryId,param.getCategoryId()),false); .eq(GoodsAccredit::getCategoryId,param.getCategoryId()),false);
// 如果未找到对应的授权信息,则根据类别ID创建新的授权信息
if(accredit==null){ if(accredit==null){
GoodsCategory category = categoryMapper.selectById(param.getCategoryId()); GoodsCategory category = categoryMapper.selectById(param.getCategoryId());
accredit = new GoodsAccredit(); accredit = new GoodsAccredit();
@ -826,9 +937,11 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
accredit.setCode(category.getCode()); accredit.setCode(category.getCode());
accredit.setName(category.getName()); accredit.setName(category.getName());
} }
// 根据SPU ID查询商品授权信息
}else if (param.getSpuId()!=null){ }else if (param.getSpuId()!=null){
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>()
.eq(GoodsAccredit::getSpuId,param.getSpuId()),false); .eq(GoodsAccredit::getSpuId,param.getSpuId()),false);
// 如果未找到对应的授权信息,则根据SPU ID创建新的授权信息
if(accredit==null){ if(accredit==null){
GoodsSpu spu = goodsSpuMapper.selectById(param.getSpuId()); GoodsSpu spu = goodsSpuMapper.selectById(param.getSpuId());
accredit = new GoodsAccredit(); accredit = new GoodsAccredit();
@ -836,9 +949,11 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
accredit.setCode(spu.getSpuCode()); accredit.setCode(spu.getSpuCode());
accredit.setName(spu.getName()); accredit.setName(spu.getName());
} }
// 根据SKU ID查询商品授权信息
}else if (param.getSkuId()!=null){ }else if (param.getSkuId()!=null){
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>()
.eq(GoodsAccredit::getSkuId,param.getSkuId()),false); .eq(GoodsAccredit::getSkuId,param.getSkuId()),false);
// 如果未找到对应的授权信息,则根据SKU ID创建新的授权信息
if(accredit==null){ if(accredit==null){
GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId()); GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId());
accredit = new GoodsAccredit(); accredit = new GoodsAccredit();

29
src/main/java/com/qs/serve/modules/oms/entity/OmsOrder.java

@ -176,6 +176,35 @@ public class OmsOrder implements Serializable {
@JsonProperty @JsonProperty
private Boolean delFlag; private Boolean delFlag;
/**
* 拓展查询条件
*/
@TableField(condition = SqlCondition.LIKE)
private String cusSaleRegion;
@TableField(condition = SqlCondition.LIKE)
private String cusSaleRegion2;
@TableField(condition = SqlCondition.LIKE)
private String cusSaleRegion3;
@TableField(condition = SqlCondition.LIKE)
private String cusSaleRegionAll;
@TableField(condition = SqlCondition.LIKE)
private String cusSaleRegionCodes;
@TableField(condition = SqlCondition.LIKE)
private String cusBigRegion;
@TableField(condition = SqlCondition.LIKE)
private String cusProvince;
@TableField(condition = SqlCondition.LIKE)
private String cusCity;
@TableField(condition = SqlCondition.LIKE)
private String cusArea;
@TableField(condition = SqlCondition.LIKE)
private String cusBizRegionAll;
@TableField(condition = SqlCondition.LIKE)
private String cusBizRegionCodes;
@TableField(condition = SqlCondition.LIKE)
private String allBands;
/** 订单明细项 */ /** 订单明细项 */
@TableField(exist = false) @TableField(exist = false)
private List<?> orderItems; private List<?> orderItems;

106
src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

@ -1,5 +1,6 @@
package com.qs.serve.modules.oms.service.impl; package com.qs.serve.modules.oms.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qs.serve.common.framework.redis.RedisService; import com.qs.serve.common.framework.redis.RedisService;
@ -9,6 +10,7 @@ import com.qs.serve.common.util.*;
import com.qs.serve.modules.bms.entity.BmsRegion; import com.qs.serve.modules.bms.entity.BmsRegion;
import com.qs.serve.modules.bms.entity.BmsSupplier; import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.entity.BmsSupplierAddress; import com.qs.serve.modules.bms.entity.BmsSupplierAddress;
import com.qs.serve.modules.bms.entity.vo.BmsSupplierExtRegionVo;
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; import com.qs.serve.modules.bms.mapper.BmsRegionMapper;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.bms.service.BmsSupplierAddressService; import com.qs.serve.modules.bms.service.BmsSupplierAddressService;
@ -17,6 +19,7 @@ import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto;
import com.qs.serve.modules.goods.entity.dto.InventoryCusPrice; import com.qs.serve.modules.goods.entity.dto.InventoryCusPrice;
import com.qs.serve.modules.goods.entity.so.InventoryCusPriceQuery; import com.qs.serve.modules.goods.entity.so.InventoryCusPriceQuery;
import com.qs.serve.modules.goods.entity.vo.GoodSkuVo; import com.qs.serve.modules.goods.entity.vo.GoodSkuVo;
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper;
import com.qs.serve.modules.goods.mapper.GoodsCategoryRuleMapper; import com.qs.serve.modules.goods.mapper.GoodsCategoryRuleMapper;
import com.qs.serve.modules.goods.mapper.GoodsSkuMapper; import com.qs.serve.modules.goods.mapper.GoodsSkuMapper;
import com.qs.serve.modules.goods.service.*; import com.qs.serve.modules.goods.service.*;
@ -72,6 +75,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
private GoodsSkuMapper goodsSkuMapper; private GoodsSkuMapper goodsSkuMapper;
private GoodsSkuService goodsSkuService; private GoodsSkuService goodsSkuService;
private GoodsSpuService goodsSpuService; private GoodsSpuService goodsSpuService;
private GoodsCategoryMapper goodsCategoryMapper;
private GoodsCategoryRuleMapper goodsCategoryRuleMapper; private GoodsCategoryRuleMapper goodsCategoryRuleMapper;
private GoodsCustomerPriceService goodsCustomerPriceService; private GoodsCustomerPriceService goodsCustomerPriceService;
@ -267,6 +271,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
order.setSupplierId(param.getSupplierId()); order.setSupplierId(param.getSupplierId());
order.setSupplierName(supplier.getSupplierName()); order.setSupplierName(supplier.getSupplierName());
order.setSupplierCode(supplier.getSupplierCode()); order.setSupplierCode(supplier.getSupplierCode());
this.appendCusRegion(supplier, order);
} }
order.setCdOrderRemark(param.getCdOrderRemark()); order.setCdOrderRemark(param.getCdOrderRemark());
//if(StringUtils.hasText(param.getUserId())){ //if(StringUtils.hasText(param.getUserId())){
@ -282,6 +287,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
//通过当前函数获取当前账套对于的skuID,默认全部转化为开平(001)的sku //通过当前函数获取当前账套对于的skuID,默认全部转化为开平(001)的sku
List<Long> spuIds = param.getOrderItems().stream().map(OmsOrderModifyParam.OmsOrderItemModifyBo::getSpuId).collect(Collectors.toList()); List<Long> spuIds = param.getOrderItems().stream().map(OmsOrderModifyParam.OmsOrderItemModifyBo::getSpuId).collect(Collectors.toList());
spuIds.add(0L);//兼容空订单,防止空指针 spuIds.add(0L);//兼容空订单,防止空指针
this.appendBrandCategory(order, spuIds);
List<GoodsSpu> spuList = goodsSpuService.listByIds(spuIds); List<GoodsSpu> spuList = goodsSpuService.listByIds(spuIds);
Map<Long, GoodsSpu> goodsSpuMap = new HashMap<>(spuList.size()); Map<Long, GoodsSpu> goodsSpuMap = new HashMap<>(spuList.size());
for (GoodsSpu goodsSpu : spuList) { for (GoodsSpu goodsSpu : spuList) {
@ -602,6 +608,9 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
order.setUserName(user.getName()); order.setUserName(user.getName());
order.setUserCode(user.getCode()); order.setUserCode(user.getCode());
order.setUserPhone(user.getMobile()); order.setUserPhone(user.getMobile());
this.appendCusRegion(supplier, order);
if (createOrderParam != null) { if (createOrderParam != null) {
order.setBillType(createOrderParam.getBillType()); order.setBillType(createOrderParam.getBillType());
order.setUrgentFlag(createOrderParam.getUrgentFlag()); order.setUrgentFlag(createOrderParam.getUrgentFlag());
@ -714,7 +723,14 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
this.handleCategoryRule(categoryRule, orderItems); this.handleCategoryRule(categoryRule, orderItems);
// 更新品牌相关参数
List<Long> spuIds = orderItems.stream().map(OmsOrderItem::getSpuId).collect(Collectors.toList());
this.appendBrandCategory(order, spuIds);
this.updateById(order);
// 保存明细
omsOrderItemService.saveBatch(orderItems); omsOrderItemService.saveBatch(orderItems);
//清空勾选的购物车 //清空勾选的购物车
List<Long> cartIds = confirmOrder.getShoppingCarts().stream() List<Long> cartIds = confirmOrder.getShoppingCarts().stream()
.filter(a -> a.getId() != null) .filter(a -> a.getId() != null)
@ -725,6 +741,96 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
return order; return order;
} }
/**
* 根据商品SPU ID列表补充订单的品牌类别信息
* 此方法旨在通过SPU ID获取对应的顶级分类ID并进一步获取分类名称最终将这些信息汇总到订单对象中
* @param order 订单对象用于存储品牌类别信息
* @param spuIds 商品SPU ID列表用于查询商品的顶级分类
*/
private void appendBrandCategory(OmsOrder order, List<Long> spuIds) {
if(CollUtil.isNotEmpty(spuIds)){
List<String> cateIds = goodsSpuService.list(new LambdaQueryWrapper<GoodsSpu>()
.in(GoodsSpu::getId, spuIds)
.select(GoodsSpu::getCategoryFirst))
.stream()
.map(GoodsSpu::getCategoryFirst)
.collect(Collectors.toList());
if(CollUtil.isNotEmpty(cateIds)){
String cateNames = goodsCategoryMapper.selectBatchIds(cateIds)
.stream().map(GoodsCategory::getName).collect(Collectors.joining(","));
order.setAllBands(cateNames);
}
}
}
/**
* 将供应商的自定义区域信息附加到订单中
* 此方法用于从供应商信息中提取客户相关的区域数据并将其填充到订单对象中
* 这有助于在订单处理过程中考虑供应商的特定区域需求或特性
* @param supplier 供应商对象包含供应商的详细信息
* @param order 订单对象将要附加区域信息的目标
*/
private void appendCusRegion(BmsSupplier supplier, OmsOrder order) {
try {
// 获取供应商的扩展区域信息
BmsSupplierExtRegionVo regionVo = bmsSupplierMapper.getBmsSupplierExtRegionVo(supplier.getId());
if (regionVo == null) {
log.warn("Supplier ID {} does not have any extended region information", supplier.getId());
return;
}
// 设置销售区域信息
order.setCusSaleRegion(regionVo.getSalRegionName());
order.setCusSaleRegion2(regionVo.getSalRegionName2());
order.setCusSaleRegion3(regionVo.getSalRegionName3());
order.setCusSaleRegionAll(appendRegions(regionVo.getSalRegionName(), regionVo.getSalRegionName2(), regionVo.getSalRegionName3()));
order.setCusSaleRegionCodes(appendCodes(regionVo.getSalRegionCode(), regionVo.getSalRegionCode2(), regionVo.getSalRegionCode3()));
// 设置业务区域信息
order.setCusBigRegion(regionVo.getBigRegion());
order.setCusProvince(regionVo.getBizRegionName());
order.setCusCity(regionVo.getBizRegionName2());
order.setCusArea(regionVo.getBizRegionName3());
order.setCusBizRegionAll(appendRegions(regionVo.getBizRegionName(), regionVo.getBizRegionName2(), regionVo.getBizRegionName3()));
order.setCusBizRegionCodes(appendCodes(regionVo.getBizRegionCode(), regionVo.getBizRegionCode2(), regionVo.getBizRegionCode3()));
} catch (Exception e) {
log.error("Error appending customer region information for supplier ID {}: {}", supplier.getId(), e.getMessage(), e);
}
}
/**
* 辅助方法拼接三个区域名称
* @param region1 第一个区域名称
* @param region2 第二个区域名称
* @param region3 第三个区域名称
* @return 拼接后的区域名称字符串
*/
private String appendRegions(String region1, String region2, String region3) {
StringBuilder sb = new StringBuilder();
if (region1 != null) sb.append(region1);
if (region2 != null) sb.append(",").append(region2);
if (region3 != null) sb.append(",").append(region3);
return sb.toString();
}
/**
* 辅助方法拼接三个区域代码
* @param code1 第一个区域代码
* @param code2 第二个区域代码
* @param code3 第三个区域代码
* @return 拼接后的区域代码字符串
*/
private String appendCodes(String code1, String code2, String code3) {
StringBuilder sb = new StringBuilder();
if (code1 != null) sb.append(code1);
if (code2 != null) sb.append(",").append(code2);
if (code3 != null) sb.append(",").append(code3);
return sb.toString();
}
@Override @Override
public List<OmsSpuAssesInfo> getSpuAssess(OmsSpuAssesInfoBo param) { public List<OmsSpuAssesInfo> getSpuAssess(OmsSpuAssesInfoBo param) {

12
src/main/java/com/qs/serve/modules/wx/api/WxSvcUserApi.java

@ -60,10 +60,14 @@ public class WxSvcUserApi {
/** /**
* 用户信息 * 用户信息
* @param noChange 不做转化CRM系统公众号用户绑定信息
* @return
*/ */
@GetMapping("/info") @GetMapping("/info")
public R<?> info(){ public R<?> info(String noChange){
WxUser wxUser = wxUserService.getCurrentWxUser(true); boolean notChangeCms = noChange!=null&&noChange.equals("true");
log.debug("notChangeCms{}, nochage:{}",notChangeCms,noChange);
WxUser wxUser = wxUserService.getCurrentWxUser(true, !notChangeCms);
SysUserVo sysUserVo = null; SysUserVo sysUserVo = null;
if(StringUtils.hasText(wxUser.getSysUserId())){ if(StringUtils.hasText(wxUser.getSysUserId())){
SysUser sysUser = sysUserService.getById(wxUser.getSysUserId()); SysUser sysUser = sysUserService.getById(wxUser.getSysUserId());
@ -82,13 +86,13 @@ public class WxSvcUserApi {
} }
} }
if(wxUser.getAppType()!=null&&wxUser.getAppType().equals(3)){ if(wxUser.getAppType()!=null && wxUser.getAppType().equals(3) && !notChangeCms){
//企业微信转化为公众号用户 //企业微信转化为公众号用户
WxUser wxUser1 = wxUserService.getOne(new LambdaQueryWrapper<WxUser>() WxUser wxUser1 = wxUserService.getOne(new LambdaQueryWrapper<WxUser>()
.eq(WxUser::getSysUserId,wxUser.getSysUserId()) .eq(WxUser::getSysUserId,wxUser.getSysUserId())
.eq(WxUser::getAppType,2),false); .eq(WxUser::getAppType,2),false);
if(wxUser1==null){ if(wxUser1==null){
Assert.throwEx("请前往公众号绑定信息"); Assert.throwEx("请前往CMS公众号绑定信息");
} }
wxUser1.setSysUserInfo(sysUserVo); wxUser1.setSysUserInfo(sysUserVo);
return R.ok(wxUser1); return R.ok(wxUser1);

2
src/main/java/com/qs/serve/modules/wx/service/WxUserService.java

@ -22,6 +22,8 @@ public interface WxUserService extends IService<WxUser> {
*/ */
WxUser getCurrentWxUser(boolean updateSub); WxUser getCurrentWxUser(boolean updateSub);
WxUser getCurrentWxUser(boolean updateSub,boolean changePubUser);
void syncSubscribe(); void syncSubscribe();
List<WxUser> getByUnionId(String unionId); List<WxUser> getByUnionId(String unionId);

9
src/main/java/com/qs/serve/modules/wx/service/impl/WxUserServiceImpl.java

@ -116,13 +116,20 @@ public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> impleme
@Override @Override
public WxUser getCurrentWxUser( boolean updateSub) { public WxUser getCurrentWxUser( boolean updateSub) {
return getCurrentWxUser(updateSub,true);
}
@Override
public WxUser getCurrentWxUser(boolean updateSub, boolean changePubUser) {
String token = ServletUtils.getHeader(GySysConst.APP_TOKEN_PROP); String token = ServletUtils.getHeader(GySysConst.APP_TOKEN_PROP);
String wxUserKey = StringUtils.format(RedisCacheKeys.WX_KEY_USER,token); String wxUserKey = StringUtils.format(RedisCacheKeys.WX_KEY_USER,token);
String wxUserId = redisService.getString(wxUserKey); String wxUserId = redisService.getString(wxUserKey);
String appId = AuthContextUtils.getAppId(); String appId = AuthContextUtils.getAppId();
WxUser wxUser = this.getById(wxUserId); WxUser wxUser = this.getById(wxUserId);
if(updateSub&&!wxUser.getId().equals("1") if(updateSub&&!wxUser.getId().equals("1")
&&(wxUser.getAppType().equals(1)||wxUser.getAppType().equals(2))){ &&(wxUser.getAppType().equals(1)||wxUser.getAppType().equals(2))
&&changePubUser
){
try { try {
WxMpService wxMpService = wxMpConfig.wxMpService().switchoverTo(appId); WxMpService wxMpService = wxMpConfig.wxMpService().switchoverTo(appId);
WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxUser.getOpenId(), GySysConst.LANG_ZH_CN); WxMpUser wxMpUser = wxMpService.getUserService().userInfo(wxUser.getOpenId(), GySysConst.LANG_ZH_CN);

Loading…
Cancel
Save