Browse Source

小程序基础接口已完成,还有一些BUG需要处理。

cangku
delicacylee 3 years ago
parent
commit
47ab7756d7
  1. 3
      hiver-admin/src/main/resources/application.yml
  2. 2
      hiver-core/src/main/java/cc/hiver/core/base/HiverBaseMallEntity.java
  3. 5
      hiver-core/src/main/java/cc/hiver/core/common/constant/MallConstant.java
  4. 22
      hiver-core/src/main/java/cc/hiver/core/vo/thorui/SelectVo.java
  5. 58
      hiver-core/src/main/java/cc/hiver/core/vo/thorui/TreeVo.java
  6. 2
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/CompanyController.java
  7. 17
      hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/Shop.java
  8. 2
      hiver-modules/hiver-app/src/main/resources/mapper/ShopMapper.xml
  9. 10
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java
  10. 24
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomAddressController.java
  11. 61
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsBrandController.java
  12. 25
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsCartController.java
  13. 41
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsCategoryController.java
  14. 32
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsController.java
  15. 142
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java
  16. 185
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java
  17. 85
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java
  18. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/GoodsBrandDao.java
  19. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/MallDao.java
  20. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SalesOrderDao.java
  21. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SalesOrderItemDao.java
  22. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java
  23. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SupplierDao.java
  24. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/UserMallDao.java
  25. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/MallMapper.java
  26. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomAddress.java
  27. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Goods.java
  28. 45
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Mall.java
  29. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PopularUrl.java
  30. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SalesOrder.java
  31. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SalesOrderItem.java
  32. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopUser.java
  33. 44
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java
  34. 31
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/UserMall.java
  35. 39
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/CartItemDTO.java
  36. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/GoodsStockDto.java
  37. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/form/GoodsForm.java
  38. 43
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/form/SalesOrderForm.java
  39. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/CustomAddressQueryCriteria.java
  40. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/GoodsPageQuery.java
  41. 22
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SalesOrderQueryCriteria.java
  42. 18
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SupplierQueryCriteria.java
  43. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/GoodsPageVO.java
  44. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/QueryVo.java
  45. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SalesOrderVo.java
  46. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/CartService.java
  47. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/GoodsBrandService.java
  48. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/MallService.java
  49. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesOrderItemService.java
  50. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesOrderService.java
  51. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java
  52. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java
  53. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/UserMallService.java
  54. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/GoodsCategoryService.java
  55. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/IMallService.java
  56. 99
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/CartServiceImpl.java
  57. 29
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/GoodsBrandServiceImpl.java
  58. 23
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/MallServiceImpl.java
  59. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesOrderItemServiceImpl.java
  60. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesOrderServiceImpl.java
  61. 28
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java
  62. 33
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java
  63. 28
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/UserMallServiceImpl.java
  64. 48
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsCategoryServiceImpl.java
  65. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsServiceImpl.java
  66. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsStockServiceImpl.java
  67. 17
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/IMallServiceImpl.java
  68. 35
      hiver-modules/hiver-mall/src/main/resources/mapper/GoodsMapper.xml
  69. 20
      hiver-modules/hiver-mall/src/main/resources/mapper/GoodsStockMapper.xml
  70. 18
      hiver-modules/hiver-mall/src/main/resources/mapper/MallMapper.xml

3
hiver-admin/src/main/resources/application.yml

@ -65,8 +65,9 @@ spring:
# Redis 若设有密码自行添加配置password
redis:
host: 154.8.162.157
# host: 127.0.0.1
# 数据库索引 默认0
database: 1
database: 0
port: 6379
# 超时时间 Duration类型 3秒
timeout: 3S

2
hiver-core/src/main/java/cc/hiver/core/base/HiverBaseMallEntity.java

@ -35,7 +35,7 @@ public abstract class HiverBaseMallEntity implements Serializable {
private String id = SnowFlakeUtil.nextId().toString();
@ApiModelProperty("店铺id")
private String mallId;
private String shopId;
@ApiModelProperty("办公区域")
private String region;

5
hiver-core/src/main/java/cc/hiver/core/common/constant/MallConstant.java

@ -45,4 +45,9 @@ public interface MallConstant {
* 会员购物车缓存KEY前缀
*/
String MEMBER_CART_PREFIX = "MEMBER:CART:";
/**
* 订单前缀
*/
String ORDER_PREFIX = "XD";
}

22
hiver-core/src/main/java/cc/hiver/core/vo/thorui/SelectVo.java

@ -0,0 +1,22 @@
package cc.hiver.core.vo.thorui;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel("tui-select模型")
@Data
@NoArgsConstructor
public class SelectVo {
public SelectVo(String text, String value) {
this.text = text;
this.value = value;
}
@ApiModelProperty("选项键名")
private String text;
@ApiModelProperty("选项键值")
private String value;
}

58
hiver-core/src/main/java/cc/hiver/core/vo/thorui/TreeVo.java

@ -0,0 +1,58 @@
package cc.hiver.core.vo.thorui;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@ApiModel("tui-tree-view模型")
@Data
@NoArgsConstructor
public class TreeVo {
public TreeVo(String text, String value) {
this.text = text;
this.value = value;
}
public TreeVo(String text, String value, String src) {
this.text = text;
this.value = value;
}
public TreeVo(String text, String value, List<TreeVo> children) {
this.text = text;
this.value = value;
}
public TreeVo(String text, String value, String src, List<TreeVo> children) {
this.text = text;
this.value = value;
this.children = children;
}
public TreeVo(String text, String value, String src, Boolean collapsed, List<TreeVo> children) {
this.text = text;
this.value = value;
this.collapsed = collapsed;
this.children = children;
}
@ApiModelProperty("键名")
private String text;
@ApiModelProperty("键值")
private String value;
@ApiModelProperty(value = "图片")
private String src;
@ApiModelProperty(value = "是否打开")
private Boolean collapsed = false;
@ApiModelProperty(value = "子项")
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
private List<TreeVo> children;
}

2
hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/CompanyController.java

@ -35,7 +35,7 @@ import java.util.List;
*/
@Slf4j
@RestController
@Api(tags = "供应商接口")
@Api(tags = "公司接口")
@RequestMapping(value = "/hiver/app/company/")
public class CompanyController {
@Autowired

17
hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/Shop.java

@ -16,6 +16,8 @@ limitations under the License.
package cc.hiver.app.entity;
import cc.hiver.core.base.HiverBaseEntity;
import cc.hiver.core.vo.UserVo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -25,6 +27,8 @@ import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
* 店铺实体类
@ -76,4 +80,17 @@ public class Shop extends HiverBaseEntity {
@ApiModelProperty(value = "是否默认商铺")
private Integer defaulted;
@ApiModelProperty(value = "所属区域")
private String region;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "店员列表")
private String clerks;
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "店铺对应店员")
private List<UserVo> users;
}

2
hiver-modules/hiver-app/src/main/resources/mapper/ShopMapper.xml

@ -5,7 +5,7 @@
SELECT DISTINCT m.*
FROM t_shop m
LEFT JOIN t_shop_user um ON m.id = um.shop_id
WHERE um.user_id = #{userId} AND m.status = 0
WHERE m.status = 0 AND (um.user_id = #{userId} OR m.shop_owner_id = #{userId} OR m.shop_manger_id = #{userId})
ORDER BY m.defaulted DESC
</select>
</mapper>

10
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java

@ -12,6 +12,7 @@ import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.entity.*;
import cc.hiver.core.service.UserService;
import cc.hiver.mall.pojo.vo.MallUserVo;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -82,11 +83,14 @@ public class CommonController {
if(userService.findByUsername(user.getUsername()) != null) {
throw new HiverException(("该用户名已被注册"));
}
if(userService.findByEmail(user.getEmail()) != null) {
throw new HiverException(("该邮箱地址已被注册"));
}
// Username/UID 邀请码
user.setInviteCode(u.getId()).setDepartmentId(null).setDepartmentTitle("").setDescription("");
String newEncryptPass = new BCryptPasswordEncoder().encode(user.getPassword());
user.setPassword(newEncryptPass);
User result = userService.save(user);
userService.save(user);
return ResultUtil.success("添加成功");
}
@ -95,7 +99,9 @@ public class CommonController {
public Result edit(User u) {
User old = userService.get(u.getId());
old.setNickname(u.getNickname()).setEmail(u.getEmail()).setAddress(u.getAddress())
.setStreet(u.getStreet()).setSex(u.getSex()).setAvatar(u.getAvatar());
.setStreet(u.getStreet()).setSex(u.getSex());
if(StrUtil.isNotBlank(u.getAvatar()))
old.setAvatar(u.getAvatar());
userService.update(old);
return ResultUtil.success("修改成功");
}

24
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CustomAddressController.java

@ -2,8 +2,10 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.mall.entity.CustomAddress;
import cc.hiver.mall.service.CustomAddressService;
import cc.hiver.mall.pojo.query.CustomAddressQueryCriteria;
@ -15,6 +17,9 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Slf4j
@RestController
@Api(tags = "客户地址接口")
@ -24,6 +29,12 @@ public class CustomAddressController {
@Autowired
private CustomAddressService customAddressService;
@Autowired
private SecurityUtil securityUtil;
@PersistenceContext
private EntityManager entityManager;
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "根据条件获得分页")
public Result<Page<CustomAddress>> queryAll(CustomAddressQueryCriteria criteria, PageVo pageVo) {
@ -41,6 +52,11 @@ public class CustomAddressController {
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "保存数据")
public Result<CustomAddress> save(CustomAddress entity) {
User u = securityUtil.getCurrUser();
// 清除持久上下文环境 避免后面语句导致持久化
entityManager.detach(u);
u.setPassword(null);
entity.setUserId(u.getId());
CustomAddress address = customAddressService.save(entity);
return new ResultUtil<CustomAddress>().setData(address);
}
@ -48,7 +64,13 @@ public class CustomAddressController {
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "更新数据")
public Result<CustomAddress> edit(CustomAddress entity) {
CustomAddress address = customAddressService.update(entity);
CustomAddress data = customAddressService.findById(entity.getId());
data.setConsigneeName(entity.getConsigneeName());
data.setConsigneeArea(entity.getConsigneeArea());
data.setConsigneeMobile(entity.getConsigneeMobile());
data.setAddress(entity.getAddress());
data.setZipCode(entity.getZipCode());
CustomAddress address = customAddressService.update(data);
return new ResultUtil<CustomAddress>().setData(address);
}

61
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsBrandController.java

@ -1,22 +1,19 @@
package cc.hiver.mall.controller;
import cc.hiver.core.base.HiverBaseController;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.GoodsBrand;
import cc.hiver.mall.pojo.vo.QueryVo;
import cc.hiver.mall.service.GoodsBrandService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品品牌控制器
@ -28,20 +25,48 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "商品品牌接口")
@RequestMapping(value = "/hiver/app/brand/")
@Transactional
public class GoodsBrandController extends HiverBaseController<GoodsBrand, String> {
public class GoodsBrandController {
@Autowired
private GoodsBrandService goodsBrandService;
@Override
public HiverBaseService<GoodsBrand, String> getService() {
return goodsBrandService;
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "获得商品品牌列表")
public Result<List<GoodsBrand>> getAll(QueryVo queryVo) {
List<GoodsBrand> list = goodsBrandService.findAllByShopId(queryVo.getShopId());
return new ResultUtil<List<GoodsBrand>>().setData(list);
}
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "商品品牌详情")
public Result<GoodsBrand> get(@PathVariable String id) {
GoodsBrand data = goodsBrandService.findById(id);
return new ResultUtil<GoodsBrand>().setData(data);
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "新增商品品牌")
public Result<GoodsBrand> save(GoodsBrand entity) {
GoodsBrand data = goodsBrandService.save(entity);
return new ResultUtil<GoodsBrand>().setData(data);
}
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "修改商品品牌")
public Result<GoodsBrand> edit(GoodsBrand entity) {
GoodsBrand data = goodsBrandService.findById(entity.getId());
if(StrUtil.isNotBlank(entity.getLogoUrl()))
data.setLogoUrl(entity.getLogoUrl());
data.setStatus(entity.getStatus());
goodsBrandService.update(data);
return new ResultUtil<GoodsBrand>().setData(data);
}
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
@ApiOperation(value = "多条件分页获取品牌列表")
public Result<Page<GoodsBrand>> getByCondition(GoodsBrand goodsBrand,
PageVo pageVo) {
Page<GoodsBrand> page = goodsBrandService.findByCondition(goodsBrand, PageUtil.initPage(pageVo));
return new ResultUtil<Page<GoodsBrand>>().setData(page);
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ApiOperation(value = "删除商品品牌")
public Result delByIds(@RequestParam String[] ids) {
for (String id : ids) {
goodsBrandService.delete(id);
}
return ResultUtil.success("批量通过id删除数据成功");
}
}

25
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsCartController.java

@ -24,6 +24,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
@ -49,15 +50,15 @@ public class GoodsCartController {
@RequestMapping(value = "/get", method = RequestMethod.GET)
@ApiOperation(value = "查询购物车")
public Result<List<CartItemDTO>> getCart() {
List<CartItemDTO> result = cartService.listCartItems(securityUtil.getCurrUser().getId());
public Result<List<CartItemDTO>> getCart(@Param("购买人") String buyUserId) {
List<CartItemDTO> result = cartService.listCartItems(securityUtil.getCurrUser().getId(), buyUserId);
return new ResultUtil<List<CartItemDTO>>().setData(result);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ApiOperation(value = "删除购物车")
public Result deleteCart() {
boolean result = cartService.deleteCart(securityUtil.getCurrUser().getId());
public Result deleteCart(@Param("购买人") String buyUserId) {
boolean result = cartService.deleteCart(securityUtil.getCurrUser().getId(), buyUserId);
if(result) {
return ResultUtil.success("删除成功");
} else {
@ -67,15 +68,15 @@ public class GoodsCartController {
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ApiOperation(value = "添加购物车商品")
public Result addCartItem(String skuId) {
cartService.addCartItem(skuId, securityUtil.getCurrUser().getId());
public Result addCartItem(String skuId, Integer buyNum, String buyUserId) {
cartService.addCartItem(skuId, buyNum, securityUtil.getCurrUser().getId(), buyUserId);
return ResultUtil.success();
}
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "更新购物车商品")
public Result updateCartItem(CartItemDTO cartItem) {
boolean result = cartService.updateCartItem(cartItem, securityUtil.getCurrUser().getId());
public Result updateCartItem(CartItemDTO cartItem, Integer buyNum, String buyUserId) {
boolean result = cartService.updateCartItem(cartItem, buyNum, securityUtil.getCurrUser().getId(), buyUserId);
if(result) {
return ResultUtil.success("更新成功");
} else {
@ -85,8 +86,8 @@ public class GoodsCartController {
@RequestMapping(value = "/item/delete", method = RequestMethod.POST)
@ApiOperation(value = "删除购物车商品")
public <T> Result<T> removeCartItem(String goodsStockId) {
boolean result = cartService.removeCartItem(goodsStockId, securityUtil.getCurrUser().getId());
public <T> Result<T> removeCartItem(String goodsStockId, String buyUserId) {
boolean result = cartService.removeCartItem(goodsStockId, securityUtil.getCurrUser().getId(), buyUserId);
if(result) {
return ResultUtil.success("删除成功");
} else {
@ -96,8 +97,8 @@ public class GoodsCartController {
@RequestMapping(value = "/_check", method = RequestMethod.POST)
@ApiOperation(value = "全选/全不选购物车商品")
public Result check(@ApiParam("全选/全不选") boolean checked) {
boolean result = cartService.checkAll(checked, securityUtil.getCurrUser().getId());
public Result check(@ApiParam("全选/全不选") boolean checked, @Param("购买人") String buyUserId) {
boolean result = cartService.checkAll(checked, securityUtil.getCurrUser().getId(), buyUserId);
if(result) {
return ResultUtil.success("设置成功");
} else {

41
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsCategoryController.java

@ -1,8 +1,10 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.vo.Option;
import cc.hiver.core.vo.thorui.TreeVo;
import cc.hiver.mall.entity.GoodsCategory;
import cc.hiver.mall.entity.GoodsCategoryAttribute;
import cc.hiver.mall.pojo.vo.GoodsCategoryVO;
@ -23,7 +25,7 @@ import java.util.List;
@Slf4j
@RestController
@Api(tags = "商品分类接口")
@RequestMapping(value = "/hiver/app/goodsCategory/")
@RequestMapping(value = "/hiver/app/category/")
@Transactional
public class GoodsCategoryController {
@Autowired
@ -34,25 +36,32 @@ public class GoodsCategoryController {
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(value = "根据parentId获得商品分类列表")
public Result<List<GoodsCategoryVO>> list(@ApiParam("上级分类ID") String parentId) {
List<GoodsCategoryVO> list = goodsCategoryService.listCategory(parentId);
public Result<List<GoodsCategoryVO>> list(@ApiParam("上级分类ID") String parentId, @ApiParam("商铺ID") String shopId) {
List<GoodsCategoryVO> list = goodsCategoryService.listCategory(parentId, shopId);
return new ResultUtil<List<GoodsCategoryVO>>().setData(list);
}
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "获得商品分类列表")
public Result<List<GoodsCategoryVO>> getAll() {
List<GoodsCategoryVO> list = goodsCategoryService.listCategory(null);
public Result<List<GoodsCategoryVO>> getAll(@ApiParam("商铺ID") String shopId) {
List<GoodsCategoryVO> list = goodsCategoryService.listCategory(null, shopId);
return new ResultUtil<List<GoodsCategoryVO>>().setData(list);
}
@RequestMapping(value = "/options", method = RequestMethod.GET)
@ApiOperation(value = "商品分类级联列表")
public Result<List<Option>> listCategoryOptions() {
List<Option> list = goodsCategoryService.listCategoryOptions();
public Result<List<Option>> listCategoryOptions(@ApiParam("商铺ID") String shopId) {
List<Option> list = goodsCategoryService.listCategoryOptions(shopId);
return new ResultUtil<List<Option>>().setData(list);
}
@RequestMapping(value = "/tree", method = RequestMethod.GET)
@ApiOperation(value = "商品分类级联列表")
public Result<List<TreeVo>> listCategoryTree(@ApiParam("商铺ID") String shopId) {
List<TreeVo> list = goodsCategoryService.listCategoryTree(shopId);
return new ResultUtil<List<TreeVo>>().setData(list);
}
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "商品分类详情")
public Result<GoodsCategory> get(@PathVariable String id) {
@ -63,6 +72,12 @@ public class GoodsCategoryController {
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "新增商品分类")
public Result<String> save(GoodsCategory entity) {
if(entity.getParentId() == CommonConstant.PARENT_ID) {
entity.setLevel(0);
} else {
GoodsCategory parent = goodsCategoryService.getById(entity.getParentId());
entity.setLevel(parent.getLevel()+1);
}
String id = goodsCategoryService.saveCategory(entity);
return ResultUtil.success(id);
}
@ -70,7 +85,17 @@ public class GoodsCategoryController {
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "修改商品分类")
public Result<String> edit(GoodsCategory entity) {
String id = goodsCategoryService.saveCategory(entity);
GoodsCategory data = goodsCategoryService.getById(entity.getId());
data.setIconUrl(entity.getIconUrl());
data.setParentId(entity.getParentId());
if(entity.getParentId() == CommonConstant.PARENT_ID) {
entity.setLevel(0);
} else {
GoodsCategory parent = goodsCategoryService.getById(entity.getParentId());
entity.setLevel(parent.getLevel()+1);
}
data.setStatus(entity.getStatus());
String id = goodsCategoryService.saveCategory(data);
return ResultUtil.success(id);
}

32
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/GoodsController.java

@ -27,20 +27,6 @@ public class GoodsController {
@Autowired
private GoodsService goodsService;
@RequestMapping(value = "/listGoodsPages", method = RequestMethod.POST)
@ApiOperation(value = "商品分页列表")
public Result<IPage<GoodsPageVO>> listGoodsPages(GoodsPageQuery queryParams) {
IPage<GoodsPageVO> result = goodsService.listGoodsPages(queryParams);
return new ResultUtil<IPage<GoodsPageVO>>().setData(result);
}
@RequestMapping(value = "/getGoodsDetail/{id}", method = RequestMethod.GET)
@ApiOperation(value = "商品详情")
public Result<GoodsDetailVO> getGoodsDetail(@ApiParam("商品ID") @PathVariable String id) {
GoodsDetailVO goodsDetailVO = goodsService.getGoodsDetail(id);
return new ResultUtil<GoodsDetailVO>().setData(goodsDetailVO);
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "新增商品")
public Result addSpu(GoodsForm formData) {
@ -74,15 +60,29 @@ public class GoodsController {
}
}
@RequestMapping(value = "/listGoodsPages", method = RequestMethod.POST)
@ApiOperation(value = "商品分页列表[服务端]")
public Result<IPage<GoodsPageVO>> listGoodsPages(GoodsPageQuery queryParams) {
IPage<GoodsPageVO> result = goodsService.listGoodsPages(queryParams);
return new ResultUtil<IPage<GoodsPageVO>>().setData(result);
}
@RequestMapping(value = "/getGoodsDetail/{id}", method = RequestMethod.GET)
@ApiOperation(value = "获得商品详情[服务端]")
public Result<GoodsDetailVO> getGoodsDetail(@ApiParam("商品ID") @PathVariable String id) {
GoodsDetailVO goodsDetailVO = goodsService.getGoodsDetail(id);
return new ResultUtil<GoodsDetailVO>().setData(goodsDetailVO);
}
@RequestMapping(value = "/listMallGoodsPages", method = RequestMethod.POST)
@ApiOperation(value = "商品分页列表")
@ApiOperation(value = "商品分页列表[客户端]")
public Result listMallGoodsPages(GoodsPageQuery queryParams) {
IPage<MallGoodsPageVO> result = goodsService.listMallGoodsPages(queryParams);
return new ResultUtil<IPage<MallGoodsPageVO>>().setData(result);
}
@RequestMapping(value = "/getMallGoodsDetail/{id}", method = RequestMethod.GET)
@ApiOperation(value = "获取商品详情")
@ApiOperation(value = "获取商品详情[客户端]")
public Result<MallGoodsDetailVO> getMallGoodsDetail(@ApiParam("商品ID") @PathVariable String id) {
MallGoodsDetailVO mallGoodsDetailVO = goodsService.getMallGoodsDetail(id);
return new ResultUtil<MallGoodsDetailVO>().setData(mallGoodsDetailVO);

142
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java

@ -1,12 +1,17 @@
package cc.hiver.mall.controller;
import cc.hiver.app.entity.Shop;
import cc.hiver.app.service.ShopService;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.Mall;
import cc.hiver.mall.entity.UserMall;
import cc.hiver.mall.service.MallService;
import cc.hiver.mall.service.UserMallService;
import cc.hiver.core.entity.User;
import cc.hiver.core.service.UserService;
import cc.hiver.core.vo.UserVo;
import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.service.ShopUserService;
import cc.hiver.mall.service.mybatis.IMallService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -14,7 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@RestController
@ -23,61 +33,121 @@ import java.util.List;
@Transactional
public class MallController {
@Autowired
private MallService mallService;
private ShopService shopService;
@Autowired
private UserMallService userMallService;
private ShopUserService shopUserService;
@Autowired
private IMallService iMallService;
@Autowired
private UserService userService;
@Autowired
private SecurityUtil securityUtil;
@PersistenceContext
private EntityManager entityManager;
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "通过id获取")
public Result<Mall> get(@PathVariable String id) {
Mall data = mallService.findById(id);
return new ResultUtil<Mall>().setData(data);
public Result<Shop> get(@PathVariable String id) {
Shop data = shopService.findById(id);
List<UserVo> users = iMallService.findByShopId(id);
data.setUsers(users);
return new ResultUtil<Shop>().setData(data);
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "保存数据")
public Result<Mall> save(Mall entity) {
Mall mall = mallService.save(entity);
return new ResultUtil<Mall>().setData(mall);
public Result<Shop> save(Shop entity) {
User u = securityUtil.getCurrUser();
// 清除持久上下文环境 避免后面语句导致持久化
entityManager.detach(u);
u.setPassword(null);
// 设置创建人
entity.setShopOwnerId(u.getUsername());
// 设置店长
User user = userService.findByUsername(entity.getShopMangerId());
entity.setShopMangerId(user.getId());
// 保存商铺记录
Shop shop = shopService.save(entity);
// 清空之前的记录
shopUserService.deleteAllByShopId(entity.getId());
// 判断是否包含店员
if(StrUtil.isNotBlank(entity.getClerks()))
{
List<String> usernames = new ArrayList<>();
if(entity.getClerks().indexOf(",") > -1) {
usernames = Arrays.stream(entity.getClerks().split(",")).collect(Collectors.toList());
} else {
usernames.add(entity.getClerks());
}
// 保存店员记录
for (String username : usernames) {
ShopUser shopUser = new ShopUser();
User clerk = userService.findByUsername(username);
shopUser.setUserId(clerk.getId());
shopUser.setShopId(entity.getId());
shopUser.setType(2);
shopUserService.save(shopUser);
}
}
if (shop.getDefaulted() == 1) {
// 将其他设置为非默认
iMallService.updateOtherShopDefaulted(shop.getId(), u.getId());
}
return new ResultUtil<Shop>().setData(shop);
}
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "更新数据")
public Result<Mall> edit(Mall entity) {
Mall mall = mallService.update(entity);
return new ResultUtil<Mall>().setData(mall);
public Result<Shop> edit(Shop entity) {
Shop data = shopService.findById(entity.getId());
// 设置店长
User user = userService.findByUsername(entity.getShopMangerId());
data.setShopMangerId(user.getId());
data.setDefaulted(entity.getDefaulted());
data.setShopArea(entity.getShopArea());
data.setShopAddress(entity.getShopAddress());
data.setRemark(entity.getRemark());
Shop shop = shopService.update(data);
// 清空之前的记录
shopUserService.deleteAllByShopId(entity.getId());
// 判断是否包含店员
if(StrUtil.isNotBlank(entity.getClerks()))
{
List<String> usernames = new ArrayList<>();
if(entity.getClerks().indexOf(",") > -1) {
usernames = Arrays.stream(entity.getClerks().split(",")).collect(Collectors.toList());
} else {
usernames.add(entity.getClerks());
}
// 保存店员记录
for (String username : usernames) {
ShopUser shopUser = new ShopUser();
User clerk = userService.findByUsername(username);
shopUser.setUserId(clerk.getId());
shopUser.setShopId(entity.getId());
shopUser.setType(2);
shopUserService.save(shopUser);
}
}
if (shop.getDefaulted() == 1) {
// 将其他设置为非默认
iMallService.updateOtherShopDefaulted(shop.getId(), data.getShopOwnerId());
}
return new ResultUtil<Shop>().setData(shop);
}
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ApiOperation(value = "批量通过ids删除")
public Result delByIds(@RequestParam String[] ids) {
for (String id : ids) {
mallService.delete(id);
shopService.delete(id);
shopUserService.deleteAllByShopId(id);
}
return ResultUtil.success("批量通过id删除数据成功");
}
@RequestMapping(value = "/set", method = RequestMethod.POST)
@ApiOperation(value = "设置用户对应商铺")
public Result save(String mallId, List<String> userIds) {
userMallService.deleteAllByMallId(mallId);
for(String userId : userIds) {
UserMall userMall = new UserMall();
userMall.setMallId(mallId);
userMall.setUserId(userId);
userMallService.save(userMall);
}
return ResultUtil.success();
}
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "根据会员id获得商铺列表")
public Result getAllByUserId(String userId) {
List<Mall> list = iMallService.findByUserId(userId);
return ResultUtil.data(list);
}
}

185
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java

@ -0,0 +1,185 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.constant.MallConstant;
import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.OrderXd;
import cc.hiver.core.service.OrderService;
import cc.hiver.mall.entity.CustomAddress;
import cc.hiver.mall.entity.GoodsBrand;
import cc.hiver.mall.entity.SalesOrder;
import cc.hiver.mall.entity.SalesOrderItem;
import cc.hiver.mall.pojo.dto.CartItemDTO;
import cc.hiver.mall.pojo.form.SalesOrderForm;
import cc.hiver.mall.pojo.query.SalesOrderQueryCriteria;
import cc.hiver.mall.pojo.vo.SalesOrderVo;
import cc.hiver.mall.service.CartService;
import cc.hiver.mall.service.CustomAddressService;
import cc.hiver.mall.service.SalesOrderItemService;
import cc.hiver.mall.service.SalesOrderService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
@Slf4j
@RestController
@Api(tags = "销售订单接口")
@RequestMapping(value = "/hiver/app/sales/")
@Transactional
public class SalesOrderController {
@Autowired
private CartService cartService;
@Autowired
private SalesOrderService salesOrderService;
@Autowired
private OrderService orderService;
@Autowired
private CustomAddressService customAddressService;
@Autowired
private SalesOrderItemService salesOrderItemService;
@Autowired
private SecurityUtil securityUtil;
@RequestMapping(value = "/create", method = RequestMethod.GET)
@ApiOperation(value = "创建订单")
public Result<SalesOrder> create(@Param("购买人") String buyUserId) {
if(StrUtil.isNotBlank(buyUserId)) {
// 处理中订单只能有一个
SalesOrder salesOrder = salesOrderService.findByBuyUserIdAndUserIdAndStatus(securityUtil.getCurrUser().getId(), buyUserId, 0);
if (salesOrder != null) {
return new ResultUtil<SalesOrder>().setData(salesOrder);
} else {
SalesOrder newSalesOrder = new SalesOrder();
newSalesOrder.setSn(MallConstant.ORDER_PREFIX + newSalesOrder.getId());
newSalesOrder.setBuyUserId(buyUserId);
newSalesOrder.setUserId(securityUtil.getCurrUser().getId());
CustomAddress customAddress = customAddressService.findById(buyUserId);
newSalesOrder.setConsigneeName(customAddress.getConsigneeName());
salesOrderService.save(newSalesOrder);
return new ResultUtil<SalesOrder>().setData(newSalesOrder);
}
} else {
throw new HiverException(("请选择客户"));
}
}
@RequestMapping(value = "/buy", method = RequestMethod.POST)
@ApiOperation(value = "下单操作")
@Transactional
public Result buy(@RequestBody SalesOrderForm salesOrderForm) {
SalesOrder salesOrder = salesOrderService.findByBuyUserIdAndUserIdAndStatus(salesOrderForm.getBuyUserID(), securityUtil.getCurrUser().getId(), 0);
if(salesOrder != null) {
String buyUserId = salesOrder.getBuyUserId();
salesOrder.setConsigneeName(salesOrderForm.getBuyUserName());
salesOrder.setConsigneeMobile(salesOrderForm.getConsigneeMobile());
salesOrder.setConsigneeArea(salesOrderForm.getConsigneeArea());
salesOrder.setAddress(salesOrderForm.getAddress());
salesOrder.setStatus(1);
BigDecimal total = new BigDecimal(0);
Integer num = 0;
for(CartItemDTO item : salesOrderForm.getBuyGoods())
{
if(item.getChecked() && item.getCount() > 0) {
SalesOrderItem salesOrderItem = new SalesOrderItem();
salesOrderItem.setSalesOrderId(salesOrder.getId());
salesOrderItem.setSn(item.getSn());
salesOrderItem.setName(item.getName());
salesOrderItem.setPicUrl(item.getPicUrl());
salesOrderItem.setGoodsId(item.getGoodsId());
salesOrderItem.setGoodsName(item.getGoodsName());
salesOrderItem.setPrice(item.getPrice());
salesOrderItem.setWholesalePrice(item.getWholesalePrice());
salesOrderItem.setPurchasePrice(item.getPurchasePrice());
salesOrderItem.setStockId(item.getId());
salesOrderItem.setCount(item.getCount());
BigDecimal p = item.getPrice().multiply(new BigDecimal(item.getCount()));
total = total.add(p);
num += item.getCount();
salesOrderItem.setTotalAmount(p);
salesOrderItemService.save(salesOrderItem);
}
}
salesOrder.setTotalAmount(total);
salesOrderService.update(salesOrder);
// 写入抢单表
OrderXd order = new OrderXd();
order.setOrderId(salesOrder.getSn());
order.setOrderAddress(salesOrder.getConsigneeArea());
order.setOrderStreet(salesOrder.getAddress());
order.setOrderDescribe("");
order.setOrderNum(num);
order.setOrderStatus(1);
order.setTimeout("0");
order.setOrderBkge(0);
order.setMobile(salesOrder.getConsigneeMobile());
order.setRegion(salesOrderForm.getRegion());
orderService.save(order);
cartService.deleteCart(securityUtil.getCurrUser().getId(), buyUserId);
return ResultUtil.success();
} else {
return ResultUtil.error("购物车信息不存在");
}
}
@RequestMapping(value = "/status", method = RequestMethod.POST)
@ApiOperation(value = "修改订单状态")
public Result updateStatus(String orderId, Integer status) {
SalesOrder salesOrder = salesOrderService.findById(orderId);
salesOrder.setStatus(status);
salesOrderService.update(salesOrder);
if(status == 9) {
// 9时撤销
OrderXd orderXd = orderService.findByOrderId(salesOrder.getSn());
orderXd.setOrderStatus(9);
orderService.update(orderXd);
}
return ResultUtil.success();
}
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ApiOperation(value = "批量通过ids删除")
public Result delByIds(@RequestParam String[] ids) {
for (String id : ids) {
SalesOrder salesOrder = salesOrderService.findById(id);
String buyUserId = salesOrder.getBuyUserId();
salesOrderService.delete(id);
cartService.deleteCart(securityUtil.getCurrUser().getId(), buyUserId);
}
return ResultUtil.success("批量通过id删除数据成功");
}
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "根据条件获得分页")
public Result<Page<SalesOrder>> queryAll(SalesOrderQueryCriteria criteria, PageVo pageVo) {
Page<SalesOrder> users = salesOrderService.queryAll(criteria, PageUtil.initPage(pageVo));
return new ResultUtil<Page<SalesOrder>>().setData(users);
}
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "获得订单详细")
public Result<SalesOrderVo> get(@PathVariable String id) {
SalesOrderVo salesOrderVo = new SalesOrderVo();
SalesOrder salesOrder = salesOrderService.findById(id);
salesOrderVo.setSalesOrder(salesOrder);
salesOrderVo.setSalesOrderItems(salesOrderItemService.findAllBySalesOrderId(id));
salesOrderVo.setOrderXd(orderService.findByOrderId(salesOrder.getSn()));
return new ResultUtil<SalesOrderVo>().setData(salesOrderVo);
}
}

85
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SupplierControlller.java

@ -0,0 +1,85 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import cc.hiver.mall.service.SupplierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Slf4j
@RestController
@Api(tags = "供应商接口")
@RequestMapping(value = "/hiver/app/supplier/")
@Transactional
public class SupplierControlller {
@Autowired
private SupplierService supplierService;
@Autowired
private SecurityUtil securityUtil;
@PersistenceContext
private EntityManager entityManager;
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "根据条件获得分页")
public Result<Page<Supplier>> queryAll(SupplierQueryCriteria criteria, PageVo pageVo) {
Page<Supplier> users = supplierService.queryAll(criteria, PageUtil.initPage(pageVo));
return new ResultUtil<Page<Supplier>>().setData(users);
}
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "通过id获取")
public Result<Supplier> get(@PathVariable String id) {
Supplier data = supplierService.findById(id);
return new ResultUtil<Supplier>().setData(data);
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "保存数据")
public Result<Supplier> save(Supplier entity) {
User u = securityUtil.getCurrUser();
// 清除持久上下文环境 避免后面语句导致持久化
entityManager.detach(u);
u.setPassword(null);
entity.setUserId(u.getId());
Supplier address = supplierService.save(entity);
return new ResultUtil<Supplier>().setData(address);
}
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ApiOperation(value = "更新数据")
public Result<Supplier> edit(Supplier entity) {
Supplier data = supplierService.findById(entity.getId());
data.setConsigneeName(entity.getConsigneeName());
data.setConsigneeArea(entity.getConsigneeArea());
data.setConsigneeMobile(entity.getConsigneeMobile());
data.setAddress(entity.getAddress());
data.setZipCode(entity.getZipCode());
Supplier address = supplierService.update(data);
return new ResultUtil<Supplier>().setData(address);
}
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ApiOperation(value = "批量通过ids删除")
public Result delByIds(@RequestParam String[] ids) {
for (String id : ids) {
supplierService.delete(id);
}
return ResultUtil.success("批量通过id删除数据成功");
}
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/GoodsBrandDao.java

@ -3,5 +3,8 @@ package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.GoodsBrand;
import java.util.List;
public interface GoodsBrandDao extends HiverBaseDao<GoodsBrand, String> {
List<GoodsBrand> findAllByShopId(String shopId);
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/MallDao.java

@ -1,7 +0,0 @@
package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.Mall;
public interface MallDao extends HiverBaseDao<Mall, String> {
}

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SalesOrderDao.java

@ -4,4 +4,5 @@ import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.SalesOrder;
public interface SalesOrderDao extends HiverBaseDao<SalesOrder, String> {
SalesOrder findByBuyUserIdAndUserIdAndStatus(String buyUserId, String userId, Integer status);
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SalesOrderItemDao.java

@ -3,5 +3,8 @@ package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.SalesOrderItem;
import java.util.List;
public interface SalesOrderItemDao extends HiverBaseDao<SalesOrderItem, String> {
List<SalesOrderItem> findAllBySalesOrderId(String salesOrderId);
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/ShopUserDao.java

@ -0,0 +1,8 @@
package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.ShopUser;
public interface ShopUserDao extends HiverBaseDao<ShopUser, String> {
void deleteAllByShopId(String shopId);
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/SupplierDao.java

@ -0,0 +1,7 @@
package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.Supplier;
public interface SupplierDao extends HiverBaseDao<Supplier, String> {
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/UserMallDao.java

@ -1,8 +0,0 @@
package cc.hiver.mall.dao;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.UserMall;
public interface UserMallDao extends HiverBaseDao<UserMall, String> {
void deleteAllByMallId(String mallId);
}

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/MallMapper.java

@ -1,6 +1,7 @@
package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.Mall;
import cc.hiver.app.entity.Shop;
import cc.hiver.core.vo.UserVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -8,12 +9,28 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MallMapper extends BaseMapper<Mall> {
public interface MallMapper extends BaseMapper<Shop> {
/**
* 通过用户id获取
*
* @param userId
* @return
*/
List<Mall> findByUserId(@Param("userId") String userId);
List<Shop> findByUserId(@Param("userId") String userId);
/**
* 通过商铺获得店员列表
*
* @param shopId
* @return
*/
List<UserVo> findByShopId(@Param("shopId") String shopId);
/**
* 更新其他默认状态
*
* @param shopId
* @param userId
*/
void updateOtherShopDefaulted(@Param("shopId") String shopId, @Param("userId") String userId);
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/CustomAddress.java

@ -30,9 +30,6 @@ public class CustomAddress extends HiverBaseEntity {
@ApiModelProperty(value = "收货人联系方式")
private String consigneeMobile;
@ApiModelProperty(value = "收货人公司")
private String consigneeCompany;
@ApiModelProperty(value = "收货人所属区域")
private String consigneeArea;
@ -41,4 +38,7 @@ public class CustomAddress extends HiverBaseEntity {
@ApiModelProperty(value = "邮编")
private String zipCode;
@ApiModelProperty(value = "类型")
private String type;
}

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Goods.java

@ -19,7 +19,7 @@ import java.math.BigDecimal;
@DynamicInsert
@DynamicUpdate
@Table(name = "t_goods")
@TableName("t_goods")
@TableName(value = "t_goods", autoResultMap = true)
@ApiModel(value = "商品表")
public class Goods extends HiverBaseMallEntity {
private static final long serialVersionUID = 1L;
@ -55,7 +55,7 @@ public class Goods extends HiverBaseMallEntity {
private String videoUrl;
@ApiModelProperty(value = "商品图册")
private String[] album;
private String album;
@ApiModelProperty(value = "单位")
private String unit;

45
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Mall.java

@ -1,45 +0,0 @@
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseMallEntity;
import cc.hiver.core.common.constant.CommonConstant;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_mall")
@TableName("t_mall")
@ApiModel(value = "商铺表")
public class Mall extends HiverBaseMallEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "商铺名称")
private String name;
@ApiModelProperty(value = "商铺简介")
private String description;
@ApiModelProperty(value = "商铺图片")
private String picUrl;
@ApiModelProperty(value = "排序值")
@Column(precision = 10, scale = 2)
private BigDecimal sortOrder;
@ApiModelProperty(value = "是否启用 0启用 -1禁用")
private Integer status = CommonConstant.STATUS_NORMAL;
@ApiModelProperty(value = "是否默认商铺")
private Integer defaulted;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/PopularUrl.java

@ -25,5 +25,5 @@ public class PopularUrl extends HiverBaseEntity {
private String url;
@ApiModelProperty(value = "商铺id")
private String mallId;
private String shopId;
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SalesOrder.java

@ -25,11 +25,14 @@ public class SalesOrder extends HiverBaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "销售单号")
private String sn = "SN" + SnowFlakeUtil.nextId().toString();
private String sn = "XD" + SnowFlakeUtil.nextId().toString();
@ApiModelProperty(value = "用户ID")
@ApiModelProperty(value = "下单用户ID")
private String userId;
@ApiModelProperty(value = "购买用户ID")
private String buyUserId;
@ApiModelProperty(value = "收货人姓名")
private String consigneeName;

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SalesOrderItem.java

@ -25,24 +25,33 @@ public class SalesOrderItem extends HiverBaseEntity {
@ApiModelProperty(value = "销售单主表id")
private String salesOrderId;
@ApiModelProperty(value = "商品编号")
@ApiModelProperty(value = "库存ID")
private String stockId;
@ApiModelProperty(value = "库存编号")
private String sn;
@ApiModelProperty(value = "商品名称")
@ApiModelProperty(value = "库存名称")
private String name;
@ApiModelProperty(value = "商品ID")
private String goodsId;
@ApiModelProperty(value = "商品规格值,以英文逗号(,)分割")
private String specIds;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品图片")
private String picUrl;
@ApiModelProperty(value = "采购价")
private BigDecimal purchasePrice = new BigDecimal(0);
@ApiModelProperty(value = "商品单价")
@ApiModelProperty(value = "加入购物车时价格,因会变动,不能作为订单计算因子,订单提交时需验价")
private BigDecimal price = new BigDecimal(0);
@ApiModelProperty(value = "批发价")
private BigDecimal wholesalePrice = new BigDecimal(0);
@ApiModelProperty(value = "商品图片")
private String picUrl;
@ApiModelProperty(value = "商品数量")
private Integer count = 0;

6
hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/ShopUser.java → hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopUser.java

@ -1,4 +1,4 @@
package cc.hiver.app.entity;
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
@ -19,7 +19,7 @@ import javax.persistence.Table;
@DynamicUpdate
@Table(name = "t_shop_user")
@TableName("t_shop_user")
@ApiModel(value = "商铺对应用户表")
@ApiModel(value = "用户管理商铺表")
public class ShopUser extends HiverBaseEntity {
private static final long serialVersionUID = 1L;
@ -29,6 +29,6 @@ public class ShopUser extends HiverBaseEntity {
@ApiModelProperty(value = "商铺id")
private String shopId;
@ApiModelProperty(value = "类型 0表示店主 1表示店长 2表示店员")
@ApiModelProperty(value = "类型 0店主 1店长 2店员")
private Integer type;
}

44
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Supplier.java

@ -0,0 +1,44 @@
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Table;
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_supplier")
@TableName("t_supplier")
@ApiModel(value = "供应商表")
public class Supplier extends HiverBaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "用户ID")
private String userId;
@ApiModelProperty(value = "供应商姓名")
private String consigneeName;
@ApiModelProperty(value = "供应商联系方式")
private String consigneeMobile;
@ApiModelProperty(value = "供应商公司")
private String consigneeCompany;
@ApiModelProperty(value = "供应商所属区域")
private String consigneeArea;
@ApiModelProperty(value = "详细地址")
private String address;
@ApiModelProperty(value = "邮编")
private String zipCode;
}

31
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/UserMall.java

@ -1,31 +0,0 @@
package cc.hiver.mall.entity;
import cc.hiver.core.base.HiverBaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Entity;
import javax.persistence.Table;
@Data
@Accessors(chain = true)
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_user_mall")
@TableName("t_user_mall")
@ApiModel(value = "用户管理商铺表")
public class UserMall extends HiverBaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "商铺id")
private String mallId;
}

39
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/CartItemDTO.java

@ -4,33 +4,46 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class CartItemDTO implements Serializable {
@ApiModelProperty(value = "商品库存ID")
private String goodsStockId;
private String id;
@ApiModelProperty(value = "商品编码")
private String sn;
@ApiModelProperty(value = "商品库存名称")
private String goodsStockName;
private String name;
@ApiModelProperty(value = "商品编码")
private String goodsStockSN;
@ApiModelProperty(value = "商品ID")
private String goodsId;
@ApiModelProperty(value = "商品图片")
private String picUrl;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品数量")
private Integer count;
@ApiModelProperty(value = "采购价")
private BigDecimal purchasePrice;
@ApiModelProperty(value = "加入购物车时价格,因会变动,不能作为订单计算因子,订单提交时需验价")
private Long price;
private BigDecimal price;
@ApiModelProperty(value = "是否选中")
private Boolean checked;
@ApiModelProperty(value = "批发价")
private BigDecimal wholesalePrice;
@ApiModelProperty(value = "商品库存数量,页面控制能选择最大数量")
private Integer stock;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "锁定库存数量")
private Integer lockedStock;
@ApiModelProperty(value = "商品图片")
private String picUrl;
@ApiModelProperty(value = "商品数量")
private Integer count;
@ApiModelProperty(value = "是否选中")
private Boolean checked;
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/GoodsStockDto.java

@ -53,6 +53,12 @@ public class GoodsStockDto {
@ApiModelProperty(value = "库存数量")
private Integer stock = 0;
@ApiModelProperty(value = "锁定库存数量")
private Integer lockedStock = 0;
@ApiModelProperty(value = "商品图片")
private String picUrl;
@ApiModelProperty(value = "商品ID")
private String goodsId;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/form/GoodsForm.java

@ -56,7 +56,7 @@ public class GoodsForm {
private String picUrl;
@ApiModelProperty("商品副图")
private String[] subPicUrls;
private String subPicUrls;
@ApiModelProperty(value = "视频地址")
private String videoUrl;

43
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/form/SalesOrderForm.java

@ -0,0 +1,43 @@
package cc.hiver.mall.pojo.form;
import cc.hiver.mall.pojo.dto.CartItemDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel("订单表单")
public class SalesOrderForm {
@ApiModelProperty("购买用户ID")
@NotNull
private String buyUserID;
@ApiModelProperty("总金额")
private BigDecimal totalPrice;
@ApiModelProperty("收货人")
private String buyUserName;
@ApiModelProperty("联系方式")
private String consigneeMobile;
@ApiModelProperty("所属地区")
private String consigneeArea;
@ApiModelProperty("详细地址")
private String address;
@ApiModelProperty("所属类型")
private String type;
@ApiModelProperty("所属区域")
private String region;
@ApiModelProperty("商品列表")
@NotNull
private List<CartItemDTO> buyGoods;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/CustomAddressQueryCriteria.java

@ -13,6 +13,6 @@ public class CustomAddressQueryCriteria implements Serializable {
@Query
private String userId;
@Query(blurry = "consignee,receivingMobile,receivingCompany")
@Query(blurry = "consigneeName,consigneeMobile")
private String blurry;
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/GoodsPageQuery.java

@ -29,8 +29,14 @@ public class GoodsPageQuery extends HiverBasePageQuery {
@ApiModelProperty("关键字")
private String keywords;
@ApiModelProperty("商铺ID")
private String shopId;
@ApiModelProperty("商品品牌ID")
private String brandId;
@ApiModelProperty("商品分类ID")
private Long categoryId;
private String categoryId;
@ApiModelProperty("排序字段名")
private String sortField;

22
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SalesOrderQueryCriteria.java

@ -0,0 +1,22 @@
package cc.hiver.mall.pojo.query;
import cc.hiver.core.common.annotation.Query;
import lombok.Data;
@Data
public class SalesOrderQueryCriteria {
@Query
private String id;
@Query
private String buyUserId;
@Query
private String userId;
@Query
private Integer status;
@Query(blurry = "sn,consigneeName,consigneeMobile")
private String blurry;
}

18
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/SupplierQueryCriteria.java

@ -0,0 +1,18 @@
package cc.hiver.mall.pojo.query;
import cc.hiver.core.common.annotation.Query;
import lombok.Data;
import java.io.Serializable;
@Data
public class SupplierQueryCriteria implements Serializable {
@Query
private String id;
@Query
private String userId;
@Query(blurry = "consigneeName,consigneeMobile,consigneeCompany")
private String blurry;
}

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/GoodsPageVO.java

@ -16,6 +16,7 @@ limitations under the License.
package cc.hiver.mall.pojo.vo;
import cc.hiver.mall.entity.GoodsStock;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ -28,6 +29,7 @@ import java.util.List;
*/
@Data
@Accessors(chain = true)
@TableName(autoResultMap = true)
public class GoodsPageVO {
@ApiModelProperty(value = "序号")
private String id;

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/QueryVo.java

@ -0,0 +1,15 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class QueryVo {
@ApiModelProperty(value = "商铺id")
private String shopId;
@ApiModelProperty(value = "所属区域")
private String region;
}

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SalesOrderVo.java

@ -0,0 +1,23 @@
package cc.hiver.mall.pojo.vo;
import cc.hiver.core.entity.OrderXd;
import cc.hiver.mall.entity.SalesOrder;
import cc.hiver.mall.entity.SalesOrderItem;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class SalesOrderVo {
@ApiModelProperty(value = "订单主表")
private SalesOrder salesOrder;
@ApiModelProperty(value = "订单子表")
private List<SalesOrderItem> salesOrderItems;
@ApiModelProperty(value = "抢单表")
private OrderXd orderXd;
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/CartService.java

@ -5,17 +5,17 @@ import cc.hiver.mall.pojo.dto.CartItemDTO;
import java.util.List;
public interface CartService {
List<CartItemDTO> listCartItems(String memberId);
List<CartItemDTO> listCartItems(String userId, String buyUserId);
boolean deleteCart(String memberId);
boolean deleteCart(String userId, String buyUserId);
boolean addCartItem(String goodsStockId, String memberId);
boolean addCartItem(String goodsStockId, Integer buyNum, String userId, String buyUserId);
boolean updateCartItem(CartItemDTO cartItem, String memberId);
boolean updateCartItem(CartItemDTO cartItem, Integer buyNum, String userId, String buyUserId);
boolean removeCartItem(String goodsStockId, String memberId);
boolean removeCartItem(String goodsStockId, String userId, String buyUserId);
boolean removeCheckedItem(String memberId);
boolean removeCheckedItem(String userId, String buyUserId);
boolean checkAll(boolean checked, String memberId);
boolean checkAll(boolean checked, String userId, String buyUserId);
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/GoodsBrandService.java

@ -2,8 +2,8 @@ package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.GoodsBrand;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* 商品品牌服务接口
@ -11,5 +11,5 @@ import org.springframework.data.domain.Pageable;
* @author Yazhi Li
*/
public interface GoodsBrandService extends HiverBaseService<GoodsBrand, String> {
Page<GoodsBrand> findByCondition(GoodsBrand goodsBrand, Pageable pageable);
List<GoodsBrand> findAllByShopId(String shopId);
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/MallService.java

@ -1,7 +0,0 @@
package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.Mall;
public interface MallService extends HiverBaseService<Mall, String> {
}

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesOrderItemService.java

@ -3,5 +3,8 @@ package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.SalesOrderItem;
import java.util.List;
public interface SalesOrderItemService extends HiverBaseService<SalesOrderItem, String> {
List<SalesOrderItem> findAllBySalesOrderId(String salesOrderId);
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesOrderService.java

@ -2,6 +2,12 @@ package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.SalesOrder;
import cc.hiver.mall.pojo.query.SalesOrderQueryCriteria;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface SalesOrderService extends HiverBaseService<SalesOrder, String> {
SalesOrder findByBuyUserIdAndUserIdAndStatus(String buyUserId, String userId, Integer status);
Page<SalesOrder> queryAll(SalesOrderQueryCriteria criteria, Pageable pageable);
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/ShopUserService.java

@ -0,0 +1,8 @@
package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.ShopUser;
public interface ShopUserService extends HiverBaseService<ShopUser, String> {
void deleteAllByShopId(String shopId);
}

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SupplierService.java

@ -0,0 +1,11 @@
package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface SupplierService extends HiverBaseService<Supplier, String> {
Page<Supplier> queryAll(SupplierQueryCriteria criteria, Pageable pageable);
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/UserMallService.java

@ -1,8 +0,0 @@
package cc.hiver.mall.service;
import cc.hiver.core.base.HiverBaseService;
import cc.hiver.mall.entity.UserMall;
public interface UserMallService extends HiverBaseService<UserMall, String> {
void deleteAllByMallId(String mallId);
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/GoodsCategoryService.java

@ -1,6 +1,7 @@
package cc.hiver.mall.service.mybatis;
import cc.hiver.core.vo.Option;
import cc.hiver.core.vo.thorui.TreeVo;
import cc.hiver.mall.entity.GoodsCategory;
import cc.hiver.mall.pojo.vo.GoodsCategoryVO;
import com.baomidou.mybatisplus.extension.service.IService;
@ -8,9 +9,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface GoodsCategoryService extends IService<GoodsCategory> {
List<GoodsCategoryVO> listCategory(String parentId);
List<GoodsCategoryVO> listCategory(String parentId, String shopId);
List<Option> listCategoryOptions();
List<Option> listCategoryOptions(String shopId);
List<TreeVo> listCategoryTree(String shopId);
String saveCategory(GoodsCategory category);
}

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/IMallService.java

@ -1,17 +1,34 @@
package cc.hiver.mall.service.mybatis;
import cc.hiver.mall.entity.Mall;
import cc.hiver.app.entity.Shop;
import cc.hiver.core.vo.UserVo;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface IMallService extends IService<Mall> {
public interface IMallService extends IService<Shop> {
/**
* 通过用户id获取
*
* @param userId
* @return
*/
List<Mall> findByUserId(@Param("userId") String userId);
List<Shop> findByUserId(@Param("userId") String userId);
/**
* 通过商铺获得店员列表
*
* @param shopId
* @return
*/
List<UserVo> findByShopId(@Param("shopId") String shopId);
/**
* 更新其他默认状态
*
* @param shopId
* @param userId
*/
void updateOtherShopDefaulted(@Param("shopId") String shopId, @Param("userId") String userId);
}

99
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/CartServiceImpl.java

@ -29,9 +29,9 @@ public class CartServiceImpl implements CartService {
private GoodsStockService goodsStockService;
@Override
public List<CartItemDTO> listCartItems(String memberId) {
if (memberId != null) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
public List<CartItemDTO> listCartItems(String userId, String buyUserId) {
if (userId != null && buyUserId != null) {
BoundHashOperations cartHashOperations = getCartHashOperations(userId, buyUserId);
List<CartItemDTO> cartItems = cartHashOperations.values();
return cartItems;
}
@ -39,86 +39,97 @@ public class CartServiceImpl implements CartService {
}
@Override
public boolean deleteCart(String memberId) {
String key = MallConstant.MEMBER_CART_PREFIX + memberId;
public boolean deleteCart(String userId, String buyUserId) {
String key = MallConstant.MEMBER_CART_PREFIX + userId + "_" + buyUserId;
redisTemplate.delete(key);
return true;
}
@Override
public boolean addCartItem(String goodsStockId, String memberId) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
public boolean addCartItem(String goodsStockId, Integer buyNum, String userId, String buyUserId) {
BoundHashOperations cartHashOperations = getCartHashOperations(userId, buyUserId);
String hKey = goodsStockId + "";
CartItemDTO cartItem;
// 购物车已存在该商品,更新商品数量
if (cartHashOperations.get(hKey) != null) {
cartItem = (CartItemDTO) cartHashOperations.get(hKey);
cartItem.setCount(cartItem.getCount() + 1); // 点击一次“加入购物车”,数量+1
cartItem.setChecked(true);
cartHashOperations.put(hKey, cartItem);
return true;
if (buyNum > 0) {
// 大于0则表示购买则加入购物车
cartItem = (CartItemDTO) cartHashOperations.get(hKey);
cartItem.setCount(buyNum); // 点击一次“加入购物车”,数量+1
cartItem.setChecked(true);
cartHashOperations.put(hKey, cartItem);
return true;
} else {
// 等于0则表示不买则删除该项目
cartHashOperations.rename(hKey);
return true;
}
}
// 购物车不存在该商品,添加商品至购物车
cartItem = new CartItemDTO();
CompletableFuture<Void> cartItemCompletableFuture = CompletableFuture.runAsync(() -> {
GoodsStockDto goodsStockDto = goodsStockService.getStockInfo(goodsStockId);
if (goodsStockDto != null) {
BeanUtil.copyProperties(goodsStockDto, cartItem);
cartItem.setStock(goodsStockDto.getStock());
cartItem.setCount(1);
cartItem.setChecked(true);
}
});
CompletableFuture.allOf(cartItemCompletableFuture).join();
Assert.isTrue(cartItem.getGoodsStockId() != null, "商品不存在");
cartHashOperations.put(hKey, cartItem);
return true;
if (buyNum > 0) {
// 大于0则表示购买加入购物车
CompletableFuture<Void> cartItemCompletableFuture = CompletableFuture.runAsync(() -> {
GoodsStockDto goodsStockDto = goodsStockService.getStockInfo(goodsStockId);
if (goodsStockDto != null) {
BeanUtil.copyProperties(goodsStockDto, cartItem);
cartItem.setStock(goodsStockDto.getStock());
cartItem.setCount(buyNum);
cartItem.setChecked(true);
}
});
CompletableFuture.allOf(cartItemCompletableFuture).join();
Assert.isTrue(cartItem.getId() != null, "商品不存在");
cartHashOperations.put(hKey, cartItem);
return true;
} else {
// 等于0则表示不购买该商品
return true;
}
}
@Override
public boolean updateCartItem(CartItemDTO cartItem, String memberId) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
String hKey = cartItem.getGoodsStockId() + "";
if (cartHashOperations.get(hKey) != null) {
CartItemDTO cacheCartItem = (CartItemDTO) cartHashOperations.get(hKey);
if (cartItem.getChecked() != null) {
public boolean updateCartItem(CartItemDTO cartItem, Integer buyNum, String memberId, String buyUserId) {
if (buyNum > 0) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId, buyUserId);
String hKey = cartItem.getId() + "";
if (cartHashOperations.get(hKey) != null) {
CartItemDTO cacheCartItem = (CartItemDTO) cartHashOperations.get(hKey);
cacheCartItem.setChecked(cartItem.getChecked());
}
if (cartItem.getCount() != null) {
cacheCartItem.setCount(cartItem.getCount());
cartHashOperations.put(hKey, cacheCartItem);
}
cartHashOperations.put(hKey, cacheCartItem);
}
return true;
}
@Override
public boolean removeCartItem(String goodsStockId, String memberId) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
public boolean removeCartItem(String goodsStockId, String userId, String buyUserId) {
BoundHashOperations cartHashOperations = getCartHashOperations(userId, buyUserId);
String hKey = goodsStockId + "";
cartHashOperations.delete(hKey);
return true;
}
@Override
public boolean removeCheckedItem(String memberId) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
public boolean removeCheckedItem(String userId, String buyUserId) {
BoundHashOperations cartHashOperations = getCartHashOperations(userId, buyUserId);
for (Object value : cartHashOperations.values()) {
CartItemDTO cartItem = (CartItemDTO) value;
if (cartItem.getChecked()) {
cartHashOperations.delete(cartItem.getGoodsStockId() + "");
cartHashOperations.delete(cartItem.getId() + "");
}
}
return true;
}
@Override
public boolean checkAll(boolean checked, String memberId) {
BoundHashOperations cartHashOperations = getCartHashOperations(memberId);
public boolean checkAll(boolean checked, String userId, String buyUserId) {
BoundHashOperations cartHashOperations = getCartHashOperations(userId, buyUserId);
for (Object value : cartHashOperations.values()) {
CartItemDTO cartItem = (CartItemDTO) value;
cartItem.setChecked(checked);
String hKey = cartItem.getGoodsStockId() + "";
String hKey = cartItem.getId() + "";
cartHashOperations.put(hKey, cartItem);
}
return true;
@ -127,8 +138,8 @@ public class CartServiceImpl implements CartService {
/**
* 获取第一层即某个用户的购物车
*/
private BoundHashOperations getCartHashOperations(String memberId) {
String cartKey = MallConstant.MEMBER_CART_PREFIX + memberId;
private BoundHashOperations getCartHashOperations(String userId, String buyUserId) {
String cartKey = MallConstant.MEMBER_CART_PREFIX + userId + "_" + buyUserId;
BoundHashOperations operations = redisTemplate.boundHashOps(cartKey);
return operations;
}

29
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/GoodsBrandServiceImpl.java

@ -4,18 +4,11 @@ import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.dao.GoodsBrandDao;
import cc.hiver.mall.entity.GoodsBrand;
import cc.hiver.mall.service.GoodsBrandService;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@ -31,25 +24,7 @@ public class GoodsBrandServiceImpl implements GoodsBrandService {
}
@Override
public Page<GoodsBrand> findByCondition(GoodsBrand goodsBrand, Pageable pageable) {
return goodsBrandDao.findAll(new Specification<GoodsBrand>() {
@Nullable
@Override
public Predicate toPredicate(Root<GoodsBrand> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
Path<String> nameField = root.get("name");
List<Predicate> list = new ArrayList<>();
// 模糊搜素
if (StrUtil.isNotBlank(goodsBrand.getName())) {
list.add(cb.like(nameField, '%' + goodsBrand.getName() + '%'));
}
Predicate[] arr = new Predicate[list.size()];
cq.where(list.toArray(arr));
return null;
}
}, pageable);
public List<GoodsBrand> findAllByShopId(String shopId) {
return goodsBrandDao.findAllByShopId(shopId);
}
}

23
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/MallServiceImpl.java

@ -1,23 +0,0 @@
package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.dao.MallDao;
import cc.hiver.mall.entity.Mall;
import cc.hiver.mall.service.MallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional
public class MallServiceImpl implements MallService {
@Autowired
private MallDao mallDao;
@Override
public HiverBaseDao<Mall, String> getRepository() {
return mallDao;
}
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesOrderItemServiceImpl.java

@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
@Transactional
@ -20,4 +22,9 @@ public class SalesOrderItemServiceImpl implements SalesOrderItemService {
public HiverBaseDao<SalesOrderItem, String> getRepository() {
return salesOrderItemDao;
}
@Override
public List<SalesOrderItem> findAllBySalesOrderId(String salesOrderId) {
return salesOrderItemDao.findAllBySalesOrderId(salesOrderId);
}
}

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesOrderServiceImpl.java

@ -1,11 +1,15 @@
package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.core.common.utils.QueryHelp;
import cc.hiver.mall.dao.SalesOrderDao;
import cc.hiver.mall.entity.SalesOrder;
import cc.hiver.mall.pojo.query.SalesOrderQueryCriteria;
import cc.hiver.mall.service.SalesOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -20,4 +24,15 @@ public class SalesOrderServiceImpl implements SalesOrderService {
public HiverBaseDao<SalesOrder, String> getRepository() {
return salesOrderDao;
}
@Override
public SalesOrder findByBuyUserIdAndUserIdAndStatus(String buyUserId, String userId, Integer status) {
return salesOrderDao.findByBuyUserIdAndUserIdAndStatus(buyUserId, userId, status);
}
@Override
public Page<SalesOrder> queryAll(SalesOrderQueryCriteria criteria, Pageable pageable) {
Page<SalesOrder> list = salesOrderDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return list;
}
}

28
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopUserServiceImpl.java

@ -0,0 +1,28 @@
package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.dao.ShopUserDao;
import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.service.ShopUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional
public class ShopUserServiceImpl implements ShopUserService {
@Autowired
private ShopUserDao shopUserDao;
@Override
public HiverBaseDao<ShopUser, String> getRepository() {
return shopUserDao;
}
@Override
public void deleteAllByShopId(String shopId) {
shopUserDao.deleteAllByShopId(shopId);
}
}

33
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SupplierServiceImpl.java

@ -0,0 +1,33 @@
package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.core.common.utils.QueryHelp;
import cc.hiver.mall.dao.SupplierDao;
import cc.hiver.mall.entity.Supplier;
import cc.hiver.mall.pojo.query.SupplierQueryCriteria;
import cc.hiver.mall.service.SupplierService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional
public class SupplierServiceImpl implements SupplierService {
@Autowired
private SupplierDao supplierDao;
@Override
public HiverBaseDao<Supplier, String> getRepository() {
return supplierDao;
}
@Override
public Page<Supplier> queryAll(SupplierQueryCriteria criteria, Pageable pageable) {
Page<Supplier> list = supplierDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return list;
}
}

28
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/UserMallServiceImpl.java

@ -1,28 +0,0 @@
package cc.hiver.mall.serviceimpl;
import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.dao.UserMallDao;
import cc.hiver.mall.entity.UserMall;
import cc.hiver.mall.service.UserMallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional
public class UserMallServiceImpl implements UserMallService {
@Autowired
private UserMallDao userMallDao;
@Override
public HiverBaseDao<UserMall, String> getRepository() {
return userMallDao;
}
@Override
public void deleteAllByMallId(String mallId) {
userMallDao.deleteAllByMallId(mallId);
}
}

48
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsCategoryServiceImpl.java

@ -2,6 +2,7 @@ package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.vo.Option;
import cc.hiver.core.vo.thorui.TreeVo;
import cc.hiver.mall.dao.mapper.GoodsCategoryMapper;
import cc.hiver.mall.entity.GoodsCategory;
import cc.hiver.mall.pojo.vo.GoodsCategoryVO;
@ -19,17 +20,18 @@ import java.util.Optional;
@Service
public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, GoodsCategory> implements GoodsCategoryService {
@Override
public List<GoodsCategoryVO> listCategory(String parentId) {
public List<GoodsCategoryVO> listCategory(String parentId, String shopId) {
List<GoodsCategory> categoryList = this.list(
new LambdaQueryWrapper<GoodsCategory>()
.eq(GoodsCategory::getStatus, CommonConstant.STATUS_NORMAL)
.eq(GoodsCategory::getShopId, shopId)
.orderByDesc(GoodsCategory::getSortOrder)
);
List<GoodsCategoryVO> list = recursionTree(parentId != null ? parentId : CommonConstant.PARENT_ID, categoryList);
List<GoodsCategoryVO> list = recursionTree(parentId != null ? parentId : CommonConstant.PARENT_ID, shopId, categoryList);
return list;
}
private static List<GoodsCategoryVO> recursionTree(String parentId, List<GoodsCategory> categoryList) {
private static List<GoodsCategoryVO> recursionTree(String parentId, String shopId, List<GoodsCategory> categoryList) {
List<GoodsCategoryVO> list = new ArrayList<>();
Optional.ofNullable(categoryList)
.ifPresent(categories ->
@ -38,7 +40,7 @@ public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, G
.forEach(category -> {
GoodsCategoryVO goodsCategoryVO = new GoodsCategoryVO();
BeanUtil.copyProperties(category, goodsCategoryVO);
List<GoodsCategoryVO> children = recursionTree(category.getId(), categoryList);
List<GoodsCategoryVO> children = recursionTree(category.getId(), shopId, categoryList);
goodsCategoryVO.setChildren(children);
list.add(goodsCategoryVO);
}));
@ -46,17 +48,18 @@ public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, G
}
@Override
public List<Option> listCategoryOptions() {
public List<Option> listCategoryOptions(String shopId) {
List<GoodsCategory> categoryList = this.list(
new LambdaQueryWrapper<GoodsCategory>()
.eq(GoodsCategory::getStatus, CommonConstant.STATUS_NORMAL)
.eq(GoodsCategory::getShopId, shopId)
.orderByAsc(GoodsCategory::getSortOrder)
);
List<Option> list = recursionCascade(CommonConstant.PARENT_ID, categoryList);
List<Option> list = recursionCascade(CommonConstant.PARENT_ID, shopId, categoryList);
return list;
}
private List<Option> recursionCascade(String parentId, List<GoodsCategory> categoryList) {
private List<Option> recursionCascade(String parentId, String shopId, List<GoodsCategory> categoryList) {
List<Option> list = new ArrayList<>();
Optional.ofNullable(categoryList)
.ifPresent(categories ->
@ -65,7 +68,36 @@ public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, G
.forEach(category -> {
Option categoryVO = new Option<>(category.getId(), category.getName());
BeanUtil.copyProperties(category, categoryVO);
List<Option> children = recursionCascade(category.getId(), categoryList);
List<Option> children = recursionCascade(category.getId(), shopId, categoryList);
categoryVO.setChildren(children);
list.add(categoryVO);
})
);
return list;
}
@Override
public List<TreeVo> listCategoryTree(String shopId) {
List<GoodsCategory> categoryList = this.list(
new LambdaQueryWrapper<GoodsCategory>()
.eq(GoodsCategory::getStatus, CommonConstant.STATUS_NORMAL)
.eq(GoodsCategory::getShopId, shopId)
.orderByAsc(GoodsCategory::getSortOrder)
);
List<TreeVo> list = recursionCascadeTree(CommonConstant.PARENT_ID, shopId, categoryList);
return list;
}
private List<TreeVo> recursionCascadeTree(String parentId, String shopId, List<GoodsCategory> categoryList) {
List<TreeVo> list = new ArrayList<>();
Optional.ofNullable(categoryList)
.ifPresent(categories ->
categories.stream().filter(category ->
category.getParentId().equals(parentId))
.forEach(category -> {
TreeVo categoryVO = new TreeVo(category.getName(), category.getId(), category.getIconUrl());
BeanUtil.copyProperties(category, categoryVO);
List<TreeVo> children = recursionCascadeTree(category.getId(), shopId, categoryList);
categoryVO.setChildren(children);
list.add(categoryVO);
})

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsServiceImpl.java

@ -94,7 +94,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
Assert.isTrue(entity != null, "商品不存在");
BeanUtil.copyProperties(entity, goodsDetailVO, "album");
goodsDetailVO.setSubPicUrls(entity.getAlbum());
if(StrUtil.isNotBlank(entity.getAlbum())) {
goodsDetailVO.setSubPicUrls(entity.getAlbum().split(","));
}
// 商品属性列表
List<GoodsAttribute> attrList = goodsAttributeService.list(new LambdaQueryWrapper<GoodsAttribute>()
@ -130,8 +132,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
if (StrUtil.isNotBlank(pmsSpu.getPicUrl())) {
album.add(pmsSpu.getPicUrl());
}
if (pmsSpu.getAlbum() != null && pmsSpu.getAlbum().length > 0) {
album.addAll(Arrays.asList(pmsSpu.getAlbum()));
if (StrUtil.isNotBlank(pmsSpu.getAlbum())) {
album.addAll(Arrays.asList(pmsSpu.getAlbum().split(",")));
goodsInfo.setAlbum(album);
}
mallGoodsDetailVO.setGoodsInfo(goodsInfo);

12
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/GoodsStockServiceImpl.java

@ -43,12 +43,6 @@ public class GoodsStockServiceImpl extends ServiceImpl<GoodsStockMapper, GoodsSt
return stockNum;
}
@Override
public GoodsStockDto getStockInfo(String id) {
GoodsStockDto goodsStockDto = this.baseMapper.getStockInfo(id);
return goodsStockDto;
}
@Override
@Transactional
public boolean lockStock(LockStockDTO lockStock) {
@ -194,4 +188,10 @@ public class GoodsStockServiceImpl extends ServiceImpl<GoodsStockMapper, GoodsSt
);
return result;
}
@Override
public GoodsStockDto getStockInfo(String id) {
GoodsStockDto goodsStockDto = this.baseMapper.getStockInfo(id);
return goodsStockDto;
}
}

17
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/IMallServiceImpl.java

@ -1,7 +1,8 @@
package cc.hiver.mall.serviceimpl.mybatis;
import cc.hiver.app.entity.Shop;
import cc.hiver.core.vo.UserVo;
import cc.hiver.mall.dao.mapper.MallMapper;
import cc.hiver.mall.entity.Mall;
import cc.hiver.mall.service.mybatis.IMallService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -10,12 +11,22 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class IMallServiceImpl extends ServiceImpl<MallMapper, Mall> implements IMallService {
public class IMallServiceImpl extends ServiceImpl<MallMapper, Shop> implements IMallService {
@Autowired
private MallMapper mallMapper;
@Override
public List<Mall> findByUserId(String userId) {
public List<Shop> findByUserId(String userId) {
return mallMapper.findByUserId(userId);
}
@Override
public List<UserVo> findByShopId(String shopId) {
return mallMapper.findByShopId(shopId);
}
@Override
public void updateOtherShopDefaulted(String shopId, String userId) {
mallMapper.updateOtherShopDefaulted(shopId, userId);
}
}

35
hiver-modules/hiver-mall/src/main/resources/mapper/GoodsMapper.xml

@ -14,20 +14,22 @@
<result property="wholesalePrice" column="wholesale_price" jdbcType="BIGINT"/>
<result property="sales" column="sales" jdbcType="INTEGER"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="album" column="album" jdbcType="OTHER"/>
<result property="album" column="album" jdbcType="VARCHAR"/>
<result property="unit" column="unit" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="detail" column="detail" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="categoryName" column="categoryName" jdbcType="VARCHAR"/>
<result property="brandName" column="brandName" jdbcType="VARCHAR"/>
<collection property="goodsStockList" column="id" select="cc.hiver.mall.dao.mapper.GoodsStockMapper.getStockInfo">
<collection property="goodsStockList" column="id" select="cc.hiver.mall.dao.mapper.GoodsStockMapper.listGoodsByGoodsId">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="specIds" column="spec_ids" jdbcType="VARCHAR"/>
<result property="purchasePrice" column="purchase_price" jdbcType="BIGINT"/>
<result property="price" column="price" jdbcType="BIGINT"/>
<result property="wholesalePrice" column="wholesale_price" jdbcType="BIGINT"/>
<result property="stock" column="stock" jdbcType="INTEGER"/>
<result property="lockedStock" column="locked_stock" jdbcType="INTEGER"/>
</collection>
@ -55,20 +57,27 @@
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND t1.name like concat('%',#{queryParams.keywords},'%')
</if>
<if test="queryParams.categoryId!=null">
<if test='queryParams.categoryId!=null and queryParams.categoryId.trim() neq ""'>
AND t1.category_id =#{queryParams.categoryId}
</if>
<if test='queryParams.brandId!=null and queryParams.brandId.trim() neq ""'>
AND t1.brand_id = #{queryParams.brandId}
</if>
<if test='queryParams.shopId!=null and queryParams.shopId.trim() neq ""'>
AND t1.shop_id = #{queryParams.shopId}
</if>
</where>
ORDER BY
t1.update_time DESC,
t1.create_time DESC
<if test='queryParams.sortField!=null and queryParams.sortField.trim() neq "" and queryParams.sortField !=null and queryParams.sort.trim() neq ""'>
#{queryParams.sortField} #{queryParams.sort} ,
</if>
t1.create_time desc
</select>
<select id="listMallGoodsPages" resultType="cc.hiver.mall.pojo.vo.MallGoodsDetailVO">
<select id="listMallGoodsPages" resultType="cc.hiver.mall.pojo.vo.MallGoodsPageVO">
SELECT
id,
NAME,
name,
pic_url,
purchase_price,
price,
@ -80,8 +89,14 @@
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND name like concat('%',#{queryParams.keywords},'%')
</if>
<if test='queryParams.categoryId!=null'>
AND category_id like concat('%',#{queryParams.categoryId},'%')
<if test='queryParams.categoryId!=null and queryParams.categoryId.trim() neq ""'>
AND category_id =#{queryParams.categoryId}
</if>
<if test='queryParams.brandId!=null and queryParams.brandId.trim() neq ""'>
AND brand_id = #{queryParams.brandId}
</if>
<if test='queryParams.shopId!=null and queryParams.shopId.trim() neq ""'>
AND shop_id = #{queryParams.shopId}
</if>
</where>
ORDER BY

20
hiver-modules/hiver-mall/src/main/resources/mapper/GoodsStockMapper.xml

@ -5,13 +5,17 @@
<mapper namespace="cc.hiver.mall.dao.mapper.GoodsStockMapper">
<!-- 根据商品ID获取商品库存单元列表 -->
<select id="listGoodsByGoodsId" resultType="cc.hiver.mall.entity.GoodsStock">
SELECT id ,
name ,
SELECT id,
name,
sn,
pic_url ,
pic_url,
spec_ids,
price ,
stock
purchase_price,
price,
wholesale_price,
stock,
locked_stock,
goods_id
FROM t_goods_stock
WHERE goods_id = #{id}
</select>
@ -23,9 +27,13 @@
t1.sn,
concat(t2.name,' ',t1.name) name,
t1.pic_url,
t1.purchase_price,
t1.price,
t1.wholesale_price,
t1.stock,
t2.name as goodsName
t1.locked_stock,
t2.name as goodsName,
goods_id
from t_goods_stock t1
left join t_goods t2 on t1.goods_id = t2.id
where t1.id = #{id}

18
hiver-modules/hiver-mall/src/main/resources/mapper/MallMapper.xml

@ -1,11 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cc.hiver.mall.dao.mapper.MallMapper">
<select id="findByUserId" resultType="cc.hiver.mall.entity.Mall">
<select id="findByUserId" resultType="cc.hiver.app.entity.Shop">
SELECT DISTINCT m.*
FROM t_mall m
LEFT JOIN t_user_mall um ON m.id = um.mall_id
FROM t_shop m
LEFT JOIN t_shop_user um ON m.id = um.shop_id
WHERE um.user_id = #{userId} AND m.status = 0
ORDER BY m.sort_order ASC
</select>
<select id="findByShopId" resultType="cc.hiver.core.vo.UserVo">
SELECT DISTINCT m.id, m.username, m.nickname
FROM t_user m
LEFT JOIN t_shop_user um ON m.id = um.user_id
WHERE um.shop_id = #{shopId} AND m.status = 0
ORDER BY m.id ASC
</select>
<delete id="updateOtherShopDefaulted" parameterType="java.lang.String">
UPDATE t_shop SET defaulted = 0 WHERE user_id = #{userId} and shop_id != #{shopId};
</delete>
</mapper>
Loading…
Cancel
Save