ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserShopFallbackFactory.java
@@ -24,6 +24,16 @@ return R.fail("根据userId获取appUserShopList失败:" + cause.getMessage()); } @Override public R insert(AppUserShop appUserShop) { return R.fail("后台门店-保存用户门店关系失败:" + cause.getMessage()); } @Override public R delete(Integer id, Long originalUserId) { return R.fail("后台修改门店-删除用户门店关系失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserShopClient.java
@@ -22,4 +22,9 @@ @GetMapping("/appUserShop/getUserShopListByUserId") public R<List<AppUserShop>> getUserShopListByUserId(@RequestParam("userId") Long userId); @PostMapping("/appUserShop/insert") R insert(@RequestBody AppUserShop appUserShop); @DeleteMapping("/appUserShop/delete") R delete(@RequestParam("id")Integer id, @RequestParam("userId")Long userId); } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/ApplyForAdmission.java
@@ -1,5 +1,6 @@ package com.ruoyi.account.api.model; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -19,7 +20,7 @@ private static final long serialVersionUID = 1L; @ApiModelProperty(value = "主键") @TableId("id") @TableId(value = "id") private int id; @ApiModelProperty(value = "申请用户id") ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java
@@ -95,7 +95,18 @@ @TableField("sort") private Integer sort; /** * 后台商品列表查询所需字段 */ @ApiModelProperty(value = "用于店铺名称模糊查询") @TableField(exist = false) private String shopName; @ApiModelProperty(value = "用于按店铺ID精确查询") @TableField(exist = false) private Integer shopId; @ApiModelProperty(value = "分类名称") @TableField(exist = false) private String categoryName; @TableField(exist = false) @ApiModelProperty(value = "指定门店") ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/SeckillActivityInfo.java
@@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -48,9 +49,9 @@ @TableField("max_num") private Integer maxNum; @ApiModelProperty(value = "适用会员类型") /* @ApiModelProperty(value = "适用会员类型") @TableField("vip_ids") private String vipIds; private String vipIds;*/ @ApiModelProperty(value = "活动开始日期") @TableField("start_time") @@ -68,8 +69,12 @@ @TableField("is_shelves") private Integer isShelves; @ApiModelProperty(value = "活动价格") @TableField(exist = false) private List<GoodsSeckill> goodsSeckills; private BigDecimal sellingPrice; @TableField(exist = false) private GoodsSeckill goodsSeckills; @TableField(exist = false) private Goods goods; ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java
@@ -152,6 +152,8 @@ private String receiverBankChannelNo; @TableField(exist = false) private String fullAddress; @TableField(exist = false) private Double distance; ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/PhoneClientFallbackFactory.java
New file @@ -0,0 +1,28 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Phone; import com.ruoyi.other.api.feignClient.GoodsEvaluateClient; import com.ruoyi.other.api.feignClient.PhoneClient; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.openfeign.FallbackFactory; /** * @author zhibing.pu * @Date 2024/11/27 19:57 */ @Slf4j public class PhoneClientFallbackFactory implements FallbackFactory<PhoneClient> { @Override public PhoneClient create(Throwable cause) { return new PhoneClient(){ @Override public R insert(Phone phone) { return R.fail("后台审核通过添加店铺客服失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
@@ -79,6 +79,11 @@ public R<Map<String, Object>> getIncomeAnalysis(ShopAnalysisDTO shopAnalysisDTO) { return R.fail("获取店铺收益失败:" + cause.getMessage()); } @Override public R insert(Shop shop) { return R.fail("后台审核通过添加店铺失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/PhoneClient.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.other.api.feignClient; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Phone; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.factory.GoodsEvaluateClientFallbackFactory; import com.ruoyi.other.api.factory.PhoneClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** * @author zhibing.pu * @Date 2024/11/27 19:56 */ @FeignClient(contextId = "PhoneClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = PhoneClientFallbackFactory.class) public interface PhoneClient { @PostMapping("/phone/insert") R insert(@RequestBody Phone phone); } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -85,4 +85,7 @@ @PostMapping("/shop/getIncomeAnalysis") R<Map<String, Object>> getIncomeAnalysis(@RequestBody ShopAnalysisDTO shopAnalysisDTO); @PostMapping("/shop/insert") R insert(@RequestBody Shop shop); } ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -9,5 +9,6 @@ com.ruoyi.other.api.factory.RegionClientFallbackFactory com.ruoyi.other.api.factory.ShopBalanceStatementClientFallbackFactory com.ruoyi.other.api.factory.GoodsEvaluateClientFallbackFactory com.ruoyi.other.api.factory.PhoneClientFallbackFactory ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysConfigController.java
@@ -74,6 +74,22 @@ config.setCreateBy(SecurityUtils.getUsername()); return toAjax(configService.insertConfig(config)); } /** * 修改积分参数配置 */ @Log(title = "参数管理", businessType = BusinessType.UPDATE) @PutMapping("/editPointConfig") public AjaxResult editPointConfig(@RequestParam("configId")Long configId, @RequestParam("configValue")String configValue) { if(configId!=6||configId!=8){ return AjaxResult.error("请选择积分配置id"); } SysConfig config=new SysConfig(); config.setConfigId(configId); config.setConfigValue(configValue); config.setUpdateBy(SecurityUtils.getUsername()); return toAjax(configService.updateConfig(config)); } /** * 修改参数配置 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
@@ -107,11 +107,6 @@ */ @Override public int updateConfig(SysConfig config) { SysConfig temp = configMapper.selectConfigById(config.getConfigId()); if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) { redisService.deleteObject(getCacheKey(temp.getConfigKey())); } int row = configMapper.updateConfig(config); if (row > 0) { redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserShopController.java
@@ -1,6 +1,7 @@ package com.ruoyi.account.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.account.mapper.AppUserMapper; import com.ruoyi.account.mapper.AppUserShopMapper; @@ -98,4 +99,19 @@ .eq(AppUserShop::getRoleType, 1)); return R.ok(!CollectionUtils.isEmpty(list)); } @PostMapping("/appUserShop/insert") R insert(@RequestBody AppUserShop appUserShop){ appUserShopService.save(appUserShop); return R.ok(); } @DeleteMapping("/appUserShop/delete") R delete(@RequestParam("id") Integer id,@RequestParam("userId") Long originalUserId){ QueryWrapper<AppUserShop> wrapper = new QueryWrapper<>(); wrapper.eq("shop_id", id); wrapper.eq("app_user_id", originalUserId); appUserShopService.remove(wrapper); return R.ok(); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserApplyForAdmissionController.java
@@ -1,15 +1,24 @@ package com.ruoyi.account.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.ApplyForAdmission; import com.ruoyi.account.dto.ApplyForAdmissionDTO; import com.ruoyi.account.dto.ApplyForAdmissionListDTO; import com.ruoyi.account.dto.ApplyReviewDTO; import com.ruoyi.account.service.UserApplyForAdmissionService; import com.ruoyi.account.vo.ApplyForAdmissionDetailVO; import com.ruoyi.account.vo.ApplyForAdmissionListVO; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Goods; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.time.LocalDateTime; @Api(tags = {"申请入驻"}) @RestController @@ -34,4 +43,31 @@ return R.ok(userApplyForAdmissionService.read()); } /** * 入驻审核 */ @GetMapping("/list") @ApiOperation(value = "获取申请列表",tags = {"后台管理-商家管理-入驻申请"}) public R<IPage<ApplyForAdmissionListVO>> manageList(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum, @ApiParam("每一页数据大小")@RequestParam(defaultValue = "10") Integer pageSize, ApplyForAdmissionListDTO applyListDTO ) { IPage<ApplyForAdmissionListVO> page = userApplyForAdmissionService.getApplyList(pageNum, pageSize, applyListDTO.getShopName(),applyListDTO.getShopManager(),applyListDTO.getPhone(),applyListDTO.getStatus()); return R.ok(page); } @GetMapping("/detail/{id}") @ApiOperation("获取申请详情") public R<ApplyForAdmissionDetailVO> getApplyDetail(@PathVariable Integer id) { ApplyForAdmissionDetailVO detail = userApplyForAdmissionService.getApplyDetail(id); return R.ok(detail); } @PostMapping("/review") @ApiOperation("入驻申请审核") public R review(@RequestBody ApplyReviewDTO applyReviewDTO) { userApplyForAdmissionService.review(applyReviewDTO); return R.ok(); } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/ApplyForAdmissionListDTO.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.account.dto; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiParam; import lombok.Data; import org.springframework.web.bind.annotation.RequestParam; @Data public class ApplyForAdmissionListDTO { @ApiModelProperty("商家名称") private String shopName; @ApiModelProperty("店长姓名") private String shopManager; @ApiModelProperty("店长手机号") private String phone; @ApiModelProperty("状态:0-待审核,1-审核通过,2-审核不通过") private Integer status; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/ApplyReviewDTO.java
New file @@ -0,0 +1,14 @@ package com.ruoyi.account.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ApplyReviewDTO { @ApiModelProperty("申请id") private Integer id; @ApiModelProperty("状态:0-待审核,1-审核通过,2-审核不通过") private Integer status; @ApiModelProperty("备注") private String remark; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/ApplyForAdmissionMapper.java
@@ -1,10 +1,19 @@ package com.ruoyi.account.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AppUserBank; import com.ruoyi.account.api.model.ApplyForAdmission; import com.ruoyi.account.vo.ApplyForAdmissionListVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @Mapper public interface ApplyForAdmissionMapper extends BaseMapper<ApplyForAdmission> { IPage<ApplyForAdmissionListVO> selectApplyList(@Param("page")Page<ApplyForAdmissionListVO> page, @Param("shopName")String shopName, @Param("shopManager")String shopManager, @Param("phone")String phone, @Param("status")Integer status); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserApplyForAdmissionService.java
@@ -1,13 +1,24 @@ package com.ruoyi.account.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.ApplyForAdmission; import com.ruoyi.account.dto.ApplyForAdmissionDTO; import com.ruoyi.account.dto.ApplyReviewDTO; import com.ruoyi.account.vo.ApplyForAdmissionDetailVO; import com.ruoyi.account.vo.ApplyForAdmissionListVO; import com.ruoyi.common.core.domain.R; public interface UserApplyForAdmissionService extends IService<ApplyForAdmission> { R apply(ApplyForAdmissionDTO applyForAdmissionDTO); ApplyForAdmission read(); IPage<ApplyForAdmissionListVO> getApplyList(Integer pageNum, Integer pageSize, String shopName, String shopManager, String phone, Integer status); ApplyForAdmissionDetailVO getApplyDetail(Integer id); void review(ApplyReviewDTO applyReviewDTO); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java
@@ -1,19 +1,31 @@ package com.ruoyi.account.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.account.api.model.ApplyForAdmission; import com.ruoyi.account.dto.ApplyForAdmissionDTO; import com.ruoyi.account.dto.ApplyReviewDTO; import com.ruoyi.account.mapper.AppUserMapper; import com.ruoyi.account.mapper.ApplyForAdmissionMapper; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.AppUserShopService; import com.ruoyi.account.service.UserApplyForAdmissionService; import com.ruoyi.account.util.tencentMap.TencentMapUtil; import com.ruoyi.account.vo.ApplyForAdmissionDetailVO; import com.ruoyi.account.vo.ApplyForAdmissionListVO; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Phone; import com.ruoyi.other.api.domain.Region; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.feignClient.PhoneClient; import com.ruoyi.other.api.feignClient.RegionClient; import com.ruoyi.other.api.feignClient.ShopClient; import com.ruoyi.system.api.model.UserShop; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +46,14 @@ private AppUserService appUserService; @Resource private RegionClient regionClient; @Resource private ShopClient shopClient; @Resource private PhoneClient phoneClient; @Autowired private AppUserShopService appUserShopService; /** * 申请入驻 @@ -69,4 +89,76 @@ .orderByDesc(ApplyForAdmission::getCreateTime) // 按申请日期降序 .last("LIMIT 1")); } @Override public IPage<ApplyForAdmissionListVO> getApplyList(Integer pageNum, Integer pageSize, String shopName, String shopManager, String phone, Integer status) { Page<ApplyForAdmissionListVO> page = new Page<>(pageNum, pageSize); return userApplyForAdmissionMapper.selectApplyList(page, shopName, shopManager, phone, status); } @Override public ApplyForAdmissionDetailVO getApplyDetail(Integer id) { ApplyForAdmission apply = userApplyForAdmissionMapper.selectById(id); if (apply == null) { throw new RuntimeException("申请记录不存在"); } ApplyForAdmissionDetailVO detail = new ApplyForAdmissionDetailVO(); BeanUtils.copyProperties(apply, detail); detail.setFullAddress(apply.getAddress() + apply.getDetailAddress()); return detail; } @Override public void review(ApplyReviewDTO applyReviewDTO) { ApplyForAdmission apply = userApplyForAdmissionMapper.selectById(applyReviewDTO.getId()); if (apply == null) { throw new RuntimeException("申请记录不存在"); } if (apply.getStatus() != 0) { throw new RuntimeException("该记录已审核过"); } if(applyReviewDTO.getStatus()==2){ //审核不通过 apply.setStatus(2); apply.setRemark(applyReviewDTO.getRemark()); apply.setUpdateTime(LocalDateTime.now()); this.updateById(apply); return; } //审核通过 apply.setStatus(1); apply.setUpdateTime(LocalDateTime.now()); this.updateById(apply); //先加入商店 Shop shop = new Shop(); BeanUtils.copyProperties(apply, shop); shop.setName(apply.getShopName()); shop.setBusinessTime(apply.getBusinessTime()); shop.setAppUserId(apply.getApplyUserId()); shop.setCreateTime(LocalDateTime.now()); R shopR = shopClient.insert(shop); if (shopR.getCode()!=200){ throw new RuntimeException("添加店铺失败"); } Integer shopId = (Integer) shopR.getData(); //加入usershop AppUserShop userShop = new AppUserShop(); userShop.setAppUserId(apply.getApplyUserId()); userShop.setShopId(shopId); appUserShopService.save(userShop); //加入客服手机号 Phone phone = new Phone(); phone.setType(2);//门店 phone.setPhoneOne(apply.getServiceTel()); phone.setShopId(shop.getId()); R phoneR = phoneClient.insert(phone); if (phoneR.getCode()!=200){ throw new RuntimeException("添加店铺客服电话失败"); } } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/ApplyForAdmissionDetailVO.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.account.vo; import lombok.Data; import java.time.LocalDateTime; @Data public class ApplyForAdmissionDetailVO { private String shopName; private String businessTime; private String shopManager; private String phone; private String serviceTel; private String homePicture; private String detailsPicture; private String certification; private String fullAddress; private String status; private LocalDateTime createTime; private String remark; private LocalDateTime updateTime; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/ApplyForAdmissionListVO.java
New file @@ -0,0 +1,14 @@ package com.ruoyi.account.vo; import lombok.Data; @Data public class ApplyForAdmissionListVO { private Integer id; private String shopName; private String businessTime; private String shopManager; private String phone; private String fullAddress; // 商家地址+详细地址 private String status; } ruoyi-service/ruoyi-account/src/main/resources/mapper/account/ApplyForAdmissionMapper.xml
@@ -3,4 +3,24 @@ <mapper namespace="com.ruoyi.account.mapper.ApplyForAdmissionMapper"> <select id="selectApplyList" resultType="com.ruoyi.account.vo.ApplyForAdmissionListVO"> SELECT id, shop_name, business_time, shop_manager, phone, CONCAT(address, detail_address) AS full_address, status FROM t_apply_for_admission <where> <if test='shopName != null and shopName !="" '> AND shop_name LIKE CONCAT('%', #{shopName}, '%') </if> <if test='shopManager != null and shopManager !="" '> AND shop_manager LIKE CONCAT('%', #{shopManager}, '%') </if> <if test='phone != null and phone !="" '> AND phone LIKE CONCAT('%', #{phone}, '%') </if> <if test='status != null '> AND status = #{status} </if> </where> ORDER BY create_time DESC </select> </mapper> ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -301,7 +301,7 @@ @PutMapping("/cancelOrder/{orderId}") @ApiOperation(value = "取消订单操作", tags = {"管理后台-订单管理"}) @ApiOperation(value = "取消订单操作", tags = {"后台-订单管理"}) public R cancelOrder(@PathVariable("orderId") Long orderId) { return orderService.cancelOrder(orderId); } @@ -322,8 +322,8 @@ @GetMapping("/getOrderPageList") @ApiOperation(value = "获取订单列表", tags = {"管理后台-订单管理", }) public R<PageInfo<OrderPageListVo>> getOrderPageList(OrderPageList orderPageList) { @ApiOperation(value = "获取订单列表", tags = {"后台-订单管理", }) public R<PageInfo<OrderManagePageListVO>> getOrderPageList(OrderPageList orderPageList) { return R.ok(orderService.getOrderPageList(orderPageList)); } @@ -545,7 +545,7 @@ */ @GetMapping("/exportExpress") public void exportExpress(HttpServletResponse response, OrderPageList orderPage) { //搜索条件,用户姓名 /* //搜索条件,用户姓名 if (StringUtils.isNotEmpty(orderPage.getUserName())) { List<AppUser> data = appUserClient.getAppUserByNameNoFilter(orderPage.getUserName()).getData(); List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); @@ -559,7 +559,7 @@ } else { orderPage.setAppUserIds(collect); } } }*/ //搜索条件,用户电话 if (StringUtils.isNotEmpty(orderPage.getPhone())) { List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(orderPage.getPhone()).getData(); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
@@ -31,7 +31,7 @@ * @param orderPageList * @return */ List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList); List<OrderManagePageListVO> getOrderPageList(PageInfo<OrderManagePageListVO> pageInfo, @Param("item") OrderPageList orderPageList); OrderStatistics getOrderStatistics(@Param("startTime")String startTime, @Param("endTime") String endTime, @Param("shopId") Integer shopId); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
@@ -37,7 +37,7 @@ * @param orderPageList * @return */ PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList); PageInfo<OrderManagePageListVO> getOrderPageList(OrderPageList orderPageList); /** * 获取导出订单列表数据 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -256,27 +256,7 @@ * @return */ @Override public PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) { /* Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); if (2 == sysUser.getRoleType()) { orderPageList.setShopId(sysUser.getObjectId()); } //搜索条件,用户姓名 if (StringUtils.isNotEmpty(orderPageList.getUserName())) { List<AppUser> data = appUserClient.getAppUserByNameNoFilter(orderPageList.getUserName()).getData(); List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); if (CollectionUtils.isEmpty(collect)) { return new PageInfo<>(); } if (null != orderPageList.getAppUserIds()) { List<Long> appUserIds = orderPageList.getAppUserIds(); appUserIds.addAll(collect); orderPageList.setAppUserIds(appUserIds); } else { orderPageList.setAppUserIds(collect); } } public PageInfo<OrderManagePageListVO> getOrderPageList(OrderPageList orderPageList) { //搜索条件,用户电话 if (StringUtils.isNotEmpty(orderPageList.getPhone())) { List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(orderPageList.getPhone()).getData(); @@ -301,32 +281,25 @@ } PageInfo<OrderPageListVo> pageInfo = new PageInfo<>(orderPageList.getPageCurr(), orderPageList.getPageSize()); PageInfo<OrderManagePageListVO> pageInfo = new PageInfo<>(orderPageList.getPageCurr(), orderPageList.getPageSize()); List<OrderPageListVo> list = this.baseMapper.getOrderPageList(pageInfo, orderPageList); for (OrderPageListVo orderPageListVo : list) { List<OrderManagePageListVO> list = this.baseMapper.getOrderPageList(pageInfo, orderPageList); for (OrderManagePageListVO orderPageListVo : list) { Long appUserId = orderPageListVo.getAppUserId(); AppUser appUser = appUserClient.getAppUserById(appUserId); if (null != appUser) { orderPageListVo.setUserName(appUser.getName()); orderPageListVo.setPhone(appUser.getPhone()); } String expressJson = orderPageListVo.getExpressJson(); if (StringUtils.isNotEmpty(expressJson) && !expressJson.equals("NULL")) { JSONObject jsonObject = null; try { jsonObject = JSONObject.parseObject(expressJson); String companyName = ExpressCompanyMap.getCompanyNameByCode(jsonObject.getString("com")); orderPageListVo.setExpressCompany(companyName); orderPageListVo.setExpressNum(jsonObject.getString("num")); } catch (Exception e) { } //店铺名称 Shop shop = shopClient.getShopById(orderPageListVo.getShopId()).getData(); if (null != shop) { orderPageListVo.setShopName(shop.getName()); } } return pageInfo.setRecords(list);*/ return null; return pageInfo.setRecords(list); } /** @@ -391,12 +364,10 @@ @Override public R cancelOrder(Long orderId) { Order order = this.getById(orderId); if (Arrays.asList(5, 6, 7).contains(order.getOrderStatus())) { if (Arrays.asList(4,5,8).contains(order.getOrderStatus())) { return R.fail("无效的操作"); } if (null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())) { return R.fail("订单取消失败"); } order.setOrderStatus(5); R r = refundPayMoney(order); if (200 == r.getCode()) { @@ -557,6 +528,8 @@ orderInfo.setOrderNumber(order.getOrderNumber()); orderInfo.setOrderStatus(order.getOrderStatus()); orderInfo.setCreateTime(order.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); orderInfo.setPointDeductionAmount(order.getPointDeductionAmount()); AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); if (null != appUser) { orderInfo.setUserName(appUser.getName()); @@ -573,19 +546,16 @@ orderInfo.setPaymentAmount(order.getPaymentAmount()); List<OrderGood> orderGoods = orderGoodMapper.selectList(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, orderId).eq(OrderGood::getDelFlag, 0)); int sum = orderGoods.stream().mapToInt(OrderGood::getNum).sum(); orderInfo.setGoodsNum(sum); List<Object> goodsJson = new ArrayList<>(); for (OrderGood orderGood : orderGoods) { Goods goods = JSON.parseObject(orderGood.getGoodJson(), Goods.class); Map<String, Object> map = new HashMap<>(); map.put("name", goods.getName()); map.put("imgUrl", goods.getHomePagePicture()); map.put("number", orderGood.getNum()); goodsJson.add(map); OrderGood orderGood = orderGoodMapper.selectOne(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, orderId).eq(OrderGood::getDelFlag, 0)); orderInfo.setGoodsNum(1); orderInfo.setGoodsJson(orderGood.getGoodJson()); if (null != orderGood.getSeckillJson()&& !"".equals(orderGood.getSeckillJson())) { orderInfo.setSeckillJson(orderGood.getSeckillJson()); orderInfo.setActivityName("秒杀活动"); } orderInfo.setGoodsJson(JSON.toJSONString(goodsJson)); orderInfo.setPoint(order.getPoint()); if (null != order.getAfterSaleTime()) { orderInfo.setAfterSaleTime(order.getAfterSaleTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderInfoVo.java
@@ -17,65 +17,43 @@ public class OrderInfoVo { @ApiModelProperty("订单id") private String id; @ApiModelProperty("售后订单id") private String refundPassId; @ApiModelProperty("订单编号") private String orderNumber; @ApiModelProperty("下单时间") private String createTime; @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") @ApiModelProperty("订单状态(3待使用4已完成5已取消8已评价)") private Integer orderStatus; @ApiModelProperty("下单用户") private String userName; @ApiModelProperty("联系电话") private String phone; @ApiModelProperty("订单类型") private String orderType; @ApiModelProperty("核销门店") @ApiModelProperty("门店名称") private String shopName; @ApiModelProperty("支付方式(1=微信,2=余额,3=积分)") @ApiModelProperty("支付方式(1=微信,2=余额,3=积分,4=组合支付)") private Integer paymentMethod; @ApiModelProperty("订单总金额") private BigDecimal totalAmount; @ApiModelProperty("支付积分") private Integer point; @ApiModelProperty("优惠券") private String couponName; @ApiModelProperty("抵扣金额") private BigDecimal discountAmount; @ApiModelProperty("快递费") private BigDecimal expressAmount; @ApiModelProperty("支付金额") private BigDecimal paymentAmount; @ApiModelProperty("获得积分") private Integer getPoint; @ApiModelProperty("收件人") private String recipient; @ApiModelProperty("收件地址") private String address; @ApiModelProperty("物流信息") private MapTrackKD100Vo express; @ApiModelProperty("抵扣金额") private BigDecimal pointDeductionAmount; @ApiModelProperty("商品数量") private Integer goodsNum; @ApiModelProperty("商品信息") private String goodsJson; @ApiModelProperty("秒杀活动信息") private String seckillJson; @ApiModelProperty("核销时间") private String writeOffTime; @ApiModelProperty("服务技师") private String technicianName; @ApiModelProperty("核销人") private String canceller; @ApiModelProperty("分佣金额") private BigDecimal subcommission; @ApiModelProperty("售后截止时间") private String afterSaleTime; @ApiModelProperty("活动名称") private String activityName; @ApiModelProperty("核销码BASE64") private String writeOffCode; @ApiModelProperty("快递公司") private String expressCompany; @ApiModelProperty("快递单号") private String expressNumber; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderManagePageListVO.java
New file @@ -0,0 +1,54 @@ package com.ruoyi.order.vo; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; @Data @ApiModel public class OrderManagePageListVO { @ApiModelProperty("订单id") private Long id; @ApiModelProperty("订单编号") @Excel(name = "订单编号") private String orderNumber; @ApiModelProperty(value = "下单时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; @ApiModelProperty(value = "下单用户id") private Long appUserId; @ApiModelProperty(value = "下单用户") private String userName; @ApiModelProperty(value = "用户手机号") private String phone; @ApiModelProperty(value = "商品名称") private String goodName; @ApiModelProperty(value = "店铺id") private Integer shopId; @ApiModelProperty(value = "店铺名称") private String shopName; @ApiModelProperty("支付方式(1微信3积分4组合)") private Integer payMethod; @ApiModelProperty("总金额") private BigDecimal totalAmount; @ApiModelProperty("支付金额") private BigDecimal paymentAmount; @ApiModelProperty("支付积分") private Integer point; @ApiModelProperty("订单状态(3待使用4已完成5已取消6已退款7售后中8已评价)") @Excel(name = "订单状态", readConverterExp = "3=待使用,4=已完成,5=已取消,6=已退款,7=售后中,8=已评价") private Integer orderStatus; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageList.java
@@ -19,25 +19,27 @@ public class OrderPageList extends BasePage { @ApiModelProperty("订单编号") public String code; @ApiModelProperty("下单用户") private String userName; @ApiModelProperty("联系电话") private String phone; @ApiModelProperty("商品类型(1=服务,2=单品-自提,3=单品-快递)") private Integer goodsType; @ApiModelProperty("支付方式(1=微信,2=余额,3=积分)") @ApiModelProperty("商品名称") private String goodsName; @ApiModelProperty("所属店铺") private Integer shopId; @ApiModelProperty("支付方式(1=微信,3=积分,4=组合支付)") private Integer paymentType; @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") @ApiModelProperty("订单状态(3待使用4已完成5已取消8已评价)") private Integer status; @ApiModelProperty("开始时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "开始时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime startTime; @ApiModelProperty("结束时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime endTime; private Integer shopId; private List<Long> appUserIds; List<Long> appUserIds; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java
@@ -8,6 +8,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; /** * @author zhibing.pu @@ -45,5 +46,6 @@ @ApiModelProperty(value = "实际支付价格") private BigDecimal paymentAmount; List<Long> appUserIds; } ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -50,43 +50,34 @@ <select id="getOrderPageList" resultType="com.ruoyi.order.vo.OrderPageListVo"> <select id="getOrderPageList" resultType="com.ruoyi.order.vo.OrderManagePageListVO"> select id, order_number as code, DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as createTime, DATE_FORMAT(after_sale_time, '%Y-%m-%d %H:%i:%s') as afterSaleTime, app_user_id as appUserId, CASE WHEN order_type = 1 THEN 1 WHEN order_type = 2 and distribution_mode = 1 THEN 2 ELSE 3 END as goodsType, pay_method as paymentType, total_amount as orderMoney, point, order_status as status, shop_id, distribution_mode as distributionMode, express_json, deliver_province, deliver_province_code, deliver_city, deliver_city_code from t_order where del_flag = 0 and pay_status = 2 id , order_number, order_status, DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') as create_time, pay_method, total_amount, payment_amount, point, good_name, shop_id, app_user_id from t_order where del_flag = 0 and pay_status = 2 <if test="null != item.code and '' != item.code"> and order_number like CONCAT('%', #{item.code}, '%') </if> <if test="null != item.goodsName and '' != item.goodsName"> and good_name like CONCAT('%', #{item.goodsName}, '%') </if> <if test="null != item.appUserIds and item.appUserIds.size() > 0"> and app_user_id in <foreach collection="item.appUserIds" separator="," item="tem" index="index" open="(" close=")"> #{tem} </foreach> </if> <if test="null != item.goodsType and 1 == item.goodsType"> and order_type = #{item.goodsType} </if> <if test="null != item.goodsType and 2 == item.goodsType"> and order_type = 2 and distribution_mode = 1 </if> <if test="null != item.goodsType and 3 == item.goodsType"> and order_type = 2 and distribution_mode = 2 </if> <if test="null != item.paymentType"> and pay_method = #{item.paymentType} @@ -97,8 +88,9 @@ <if test="null != item.status and 4 == item.status"> and order_status in (4, 8) </if> <if test="null != item.shopId"> and shop_id = #{item.shopId} and distribution_mode != 2 and shop_id = #{item.shopId} </if> <if test="null != item.startTime and null != item.endTime"> and create_time between #{item.startTime} and #{item.endTime} @@ -128,7 +120,7 @@ ifnull(sum(a.num), 0) from t_order_good a left join t_order b on (a.order_id = b.id) where b.del_flag = 0 and b.pay_status = 2 and b.order_status in (1, 2, 3, 4, 7, 8) and a.goods_id = #{goodsId} where b.del_flag = 0 and b.pay_status = 2 and b.order_status in ( 3, 4, 8) and a.goods_id = #{goodsId} <if test="null != type"> and a.type = #{type} </if> ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -6,17 +6,23 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.redis.annotation.DistributedLock; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.dto.AddGoodsDTO; import com.ruoyi.other.enums.GoodsStatus; import com.ruoyi.other.service.GoodsService; import com.ruoyi.other.vo.GoodsVO; import com.ruoyi.system.api.domain.SysConfig; import com.ruoyi.system.api.feignClient.SysConfigClient; import io.swagger.annotations.*; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; /** @@ -33,6 +39,8 @@ public class GoodsController extends BaseController { @Resource private GoodsService goodsService; @Resource private SysConfigClient sysConfigClient; @@ -44,11 +52,50 @@ @PostMapping("/addGoods") @ApiOperation(value = "发布商品", tags = {"管理后台-商品管理"}) public R<Void> addGoods(@RequestBody Goods goods) { /* if(goods.getPurchaseLimit()==null){ if(goods.getPurchaseLimit()==null){ goods.setPurchaseLimit(-1); } goodsService.addGoods(goods);*/ goods.setSaleNum(0); goods.setStatus(GoodsStatus.DOWN.getCode()); goods.setIntegral(getPoint(goods.getSellingPrice())); goods.setDelFlag(0); goods.setCreateTime(LocalDateTime.now()); goodsService.addGoods(goods); return R.ok(); } /** * 获取现金对应积分 */ public Integer getPoint(BigDecimal cash){ if (cash == null || cash.compareTo(BigDecimal.ZERO) < 0) { throw new IllegalArgumentException("金额不能为null或负数"); } // 获取积分兑换比例配置 R<SysConfig> info = sysConfigClient.getInfo(6L); if (info == null || info.getData() == null) { throw new RuntimeException("获取积分兑换比例配置失败"); } String configValue = info.getData().getConfigValue(); if (StringUtils.isBlank(configValue)) { throw new RuntimeException("积分兑换比例配置值为空"); } try { // 使用BigDecimal处理比例,避免精度问题 BigDecimal ratio = new BigDecimal(configValue.trim()); if (ratio.compareTo(BigDecimal.ZERO) <= 0) { throw new RuntimeException("积分兑换比例必须大于0"); } // 计算积分并四舍五入取整 return cash.multiply(ratio).intValue(); } catch (NumberFormatException e) { throw new RuntimeException("积分兑换比例配置值格式错误", e); } catch (ArithmeticException e) { throw new RuntimeException("积分计算结果溢出", e); } } /** @@ -90,20 +137,15 @@ @PutMapping("/manageGoodsUpdate") @ApiOperation(value = "商品修改", tags = {"管理后台-商品管理"}) public R<Void> manageGoodsUpdate(@RequestBody Goods goods){ /* if(goods.getPurchaseLimit()==null){ if(goods.getPurchaseLimit()==null){ goods.setPurchaseLimit(-1); } goods.setSaleNum(0); goods.setStatus(GoodsStatus.DOWN.getCode()); goods.setIntegral(getPoint(goods.getSellingPrice())); goods.setDelFlag(0); goods.setCreateTime(LocalDateTime.now()); goodsService.updateManageGoods(goods); if (goods.getType()==2){ goods.setAppointStore(2); goodsService.updateById(goods); } if (goods.getType()==1){ LambdaUpdateWrapper<Goods> goodsLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); goodsLambdaUpdateWrapper.set(Goods::getDistributionMode,null); goodsLambdaUpdateWrapper.eq(Goods::getId, goods.getId()); goodsService.update(goodsLambdaUpdateWrapper); }*/ return R.ok(); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -122,14 +122,14 @@ * 删除评价 */ @DeleteMapping("/delete/{id}") @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"}) @ApiOperation(value = "删除评论", tags = {"后台-商品管理-评价管理"}) public R<Void> delete(@PathVariable("id") Long id){ GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); goodsEvaluate.setDelFlag(1); goodsEvaluateService.updateById(goodsEvaluate); //修改订单为待评价 Order data = orderClient.getOrderById(goodsEvaluate.getOrderId()).getData(); data.setOrderStatus(data.getOldOrderStatus()); data.setOrderStatus(4);//已完成状态 orderClient.editOrder(data); return R.ok(); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java
@@ -83,6 +83,18 @@ return R.ok(); } /** * 保存店铺客服手机号 * @param phone * @return */ @PostMapping("/insert") R insert(@RequestBody Phone phone){ phoneService.save(phone); return R.ok(); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java
@@ -12,16 +12,20 @@ import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsSeckill; import com.ruoyi.other.api.domain.SeckillActivityInfo; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.feignClient.ShopClient; import com.ruoyi.other.api.vo.GetSeckillActivityInfo; import com.ruoyi.other.mapper.SeckillActivityInfoMapper; import com.ruoyi.other.service.GoodsSeckillService; import com.ruoyi.other.service.GoodsService; import com.ruoyi.other.service.SeckillActivityInfoService; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.vo.SeckillActivityDetailVO; import com.ruoyi.other.vo.SeckillActivityVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -56,10 +60,9 @@ @Resource private OrderClient orderClient; @Resource private ShopService shopService; /** * 秒杀活动列表 @@ -143,8 +146,6 @@ }else { record.setStatus(1); // 未开始 } Integer saleNum = orderClient.getGoodsSaleNum(record.getGoodsId(), 2).getData(); record.setSaleNum(saleNum); } return R.ok(IPage); } @@ -156,6 +157,7 @@ @ApiOperation(value = "新增秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> save(@RequestBody SeckillActivityInfo seckillActivityInfo) { if (seckillActivityInfo.getStartTime().isAfter(seckillActivityInfo.getEndTime()))return R.fail("开始时间不能晚于结束时间"); seckillActivityInfoService.saveSeckillActivityInfo(seckillActivityInfo); return R.ok(); } @@ -177,6 +179,7 @@ @ApiOperation(value = "修改秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> update(@RequestBody SeckillActivityInfo seckillActivityInfo) { if (seckillActivityInfo.getStartTime().isAfter(seckillActivityInfo.getEndTime()))return R.fail("开始时间不能晚于结束时间"); seckillActivityInfoService.updateSeckillActivityInfo(seckillActivityInfo); return R.ok(); } @@ -188,6 +191,8 @@ @ApiOperation(value = "删除秒杀活动", tags = {"后台管理-活动管理-秒杀活动" }) public R<Void> remove(@PathVariable Integer id) { //先删除 goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, id)); seckillActivityInfoService.removeById(id); return R.ok(); } @@ -197,16 +202,28 @@ */ @GetMapping("/getSeckillActivityDetail") @ApiOperation(value = "获取秒杀活动明细", tags = {"后台管理-活动管理-秒杀活动" }) public R<SeckillActivityInfo> getSeckillActivityDetail(Integer id) public R<SeckillActivityVO> getSeckillActivityDetail(Integer id) { SeckillActivityVO vo = new SeckillActivityVO(); SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getById(id); List<GoodsSeckill> goodsSeckills = goodsSeckillService.list(new LambdaQueryWrapper<GoodsSeckill>() .eq(GoodsSeckill::getSeckillActivityInfoId, id)); seckillActivityInfo.setGoodsSeckills(goodsSeckills); Integer goodId = seckillActivityInfo.getGoodId(); Goods goods = goodsService.getById(goodId); seckillActivityInfo.setGoods(goods); return R.ok(seckillActivityInfo); Goods goods = goodsService.getById(seckillActivityInfo.getGoodId()); GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>() .eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); vo.setId(seckillActivityInfo.getId().toString()); vo.setGoodsId(seckillActivityInfo.getGoodId()); vo.setGoodsName(goods.getName()); vo.setGoodsCategoryName(goods.getCategoryName()); vo.setSellingPrice(goods.getSellingPrice()); vo.setActivityPrice(goodsSeckill.getSellingPrice()); vo.setMaxNum(seckillActivityInfo.getMaxNum());//活动限购 vo.setStartTime(seckillActivityInfo.getStartTime()); vo.setEndTime(seckillActivityInfo.getEndTime()); return R.ok(vo); } /** ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.feignClient.AppUserShopClient; import com.ruoyi.account.api.model.AppUser; @@ -41,6 +42,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -96,6 +98,8 @@ private ReceiverBankChannelService receiverBankChannelService; @Resource private ShopScoreService shopScoreService; @Autowired private PhoneService phoneService; /** @@ -155,106 +159,33 @@ } @PostMapping @ApiOperation(value = "新增门店", tags = {"管理后台-门店管理"}) @ApiOperation(value = "新增门店", tags = {"后台-门店管理"}) @Transactional(rollbackFor = Exception.class) public R<Void> add(@RequestBody Shop shop){ /*String phone = shop.getPhone(); String phone = shop.getPhone(); AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); if (appUser == null){ return R.fail("该手机号未注册"); } *//* shop.setShopAllPoint(0); shop.setLowerLevelSharePoint(0); shop.setSharePoint(0); shop.setServerPoint(0); shop.setUsePoint(0); shop.setGiveawayAllMoney(BigDecimal.ZERO); shop.setGiveawayMoney(BigDecimal.ZERO); shop.setLowerLevelGiveawayMoney(BigDecimal.ZERO); shop.setServerGiveawayMoney(BigDecimal.ZERO);*//* shop.setCanWithdrawMoney(BigDecimal.ZERO); shop.setWithdrawMoney(BigDecimal.ZERO); shop.setOrderNumber(0); *//* shop.setServerOrderNumber(0); shop.setCustomOrderNumber(0);*//* //添加店铺用户信息 shop.setCreateTime(LocalDateTime.now()); shop.setAppUserId(appUser.getId()); String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); if(!StringUtils.hasLength(city)){ city = "510100"; } *//*shop.setProvinceCode(city.substring(0, 2) + "0000"); shop.setCityCode(city.substring(0, 4) + "00"); shop.setDistrictCode(city);*//* //添加门店 shopService.save(shop); Integer shopId = shop.getId(); appUser.setUserType(2); R<Void> editAppUserR = appUserClient.editAppUserById(appUser); if (R.isError(editAppUserR)){ throw new RuntimeException("添加失败"); //添加shopuser AppUserShop appUserShop = new AppUserShop(); appUserShop.setAppUserId(appUser.getId()); appUserShop.setShopId(shop.getId()); R appUserShopR = appUserShopClient.insert(appUserShop); if (appUserShopR.getCode()!=200){ throw new RuntimeException("添加用户门店关系失败"); } //添加门店后台账号和门店关系数据 SysUser sysUser = sysUserClient.queryUserByUserNameAndRoleType(phone, 2).getData(); if(null != sysUser){ sysUser.setAppUserId(appUser.getId()); sysUserClient.updateUser(sysUser); UserShop userShop = new UserShop(); userShop.setUserId(sysUser.getUserId()); userShop.setShopId(shopId); userShop.setRoleType(1); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); if(null == data || data.size() == 0){ userShop = new UserShop(); userShop.setUserId(sysUser.getUserId()); userShop.setShopId(shopId); userShop.setRoleType(1); userShop.setRoleId(2L); userShop.setNickName(sysUser.getNickName()); userShop.setCreateTime(LocalDateTime.now()); userShopClient.saveUserShop(userShop); } }else{ //添加管理后台账号 SysUser user = new SysUser(); user.setDeptId(1L); user.setUserName(appUser.getPhone()); user.setNickName(appUser.getName()); user.setPhonenumber(appUser.getPhone()); user.setAvatar(appUser.getAvatar()); user.setStatus("0"); user.setDelFlag("0"); user.setRoleType(2); user.setObjectId(shopId); user.setAppUserId(appUser.getId()); String s = MD5Generator.generateMD5(phone.substring(5)); user.setPassword(s); user.setCreateTime(new Date()); Long userId = sysUserClient.saveShopUser(user).getData(); UserShop userShop = new UserShop(); userShop.setUserId(userId); userShop.setShopId(shopId); userShop.setRoleType(1); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); if(null == data || data.size() == 0){ userShop = new UserShop(); userShop.setUserId(userId); userShop.setShopId(shopId); userShop.setRoleType(1); userShop.setRoleId(2L); userShop.setNickName(user.getNickName()); userShop.setCreateTime(LocalDateTime.now()); userShopClient.saveUserShop(userShop); } } // 更换下级会员绑定门店 R<List<AppUser>> lowerShopR = appUserClient.setLowerUserShop(appUser.getId(), shopId); if (R.isError(lowerShopR)){ throw new RuntimeException("更换下级会员绑定门店失败"); }*/ //添加客服phone Phone phone1 = new Phone(); phone1.setType(2);//门店 phone1.setPhoneOne(shop.getServiceTel()); phone1.setShopId(shop.getId()); phoneService.save(phone1); return R.ok(); } @@ -263,14 +194,13 @@ @ApiOperation(value = "门店详情", tags = {"管理后台-门店管理"}) public R<Shop> getDetailById(@RequestParam("id") Integer id){ Shop shop = shopService.getById(id); return R.ok(shop); } @DeleteMapping("/deleteShop") @ApiOperation(value = "删除门店", tags = {"管理后台-门店管理"}) public R<Void> deleteShop(@ApiParam("门店id") @RequestParam("id") Integer id){ /*List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getAppointStore, 1).eq(Goods::getStatus, 2)); List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getStatus, 2)); if(list1.size() > 0){ Set<Integer> collect1 = list1.stream().map(Goods::getId).collect(Collectors.toSet()); long count = goodsShopService.count(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getShopId, id).in(GoodsShop::getGoodsId, collect1)); @@ -281,121 +211,53 @@ Shop shop = shopService.getById(id); shop.setDelFlag(1); shopService.updateById(shop); // 查询有没有门店绑定这个被删除的门店 List<Shop> shops = shopService.lambdaQuery().eq(Shop::getPid, shop.getId()).list(); for (Shop shop1 : shops) { LambdaUpdateWrapper<Shop> set = new LambdaUpdateWrapper<Shop>().set(Shop::getPid, null) .eq(Shop::getId,shop1.getId()); shopService.update(set); R deleteR = appUserShopClient.delete(shop.getId(), shop.getAppUserId()); if (deleteR.getCode()!=200){ throw new RuntimeException("删除用户门店关系失败"); } //清除用户绑定当前门店 appUserClient.clearBindShop(shop.getId()); //查询门店绑定的平台账号 UserShop userShop = new UserShop(); userShop.setShopId(shop.getId()); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); if(data.size() > 0){ //删除门店后台账号和关系数据 sysUserClient.delShopUser(shop.getId(), 2); }*/ return R.ok(); } @PutMapping("/editShop") @ApiOperation(value = "门店管理-编辑门店", tags = {"管理后台-门店管理"}) public R<Void> editShop(@RequestBody Shop shop){ /*String phone = shop.getPhone(); if (!shopService.cheUserByPhone(phone)) { //修改店长 String phone = shop.getPhone(); AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); if (appUser == null){ return R.fail("该手机号未注册"); } String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); if(!StringUtils.hasLength(city)){ city = "510100"; } *//*shop.setProvinceCode(city.substring(0, 2) + "0000"); shop.setCityCode(city.substring(0, 4) + "00"); shop.setDistrictCode(city);*//* Shop old_shop = shopService.getById(shop.getId()); shopService.updateById(shop); //修改管理员 AppUser appUser = appUserClient.getAppUserById(old_shop.getAppUserId()); //删除后台用户和店铺关系数据 UserShop userShop = new UserShop(); userShop.setShopId(shop.getId()); userShop.setRoleType(1); List<UserShop> data = userShopClient.getUserShop(userShop).getData(); if(null != data && data.size() > 0){ UserShop userShop1 = data.get(0); userShopClient.delUserShop(userShop1); //如果当前后台账户关联的店铺是最后一个,删除后台账户 userShop = new UserShop(); userShop.setUserId(userShop1.getUserId()); data = userShopClient.getUserShop(userShop).getData(); if(data.size() == 0){ sysUserClient.delSysUserById(userShop1.getUserId()); } } //添加新管理员 appUser = appUserClient.getAppUserByPhone1(phone).getData(); appUser.setUserType(2); appUserClient.editAppUserById(appUser); //修改管理员 Long originalUserId = shop.getAppUserId(); //添加用户id到shop信息中 shop.setAppUserId(appUser.getId()); //删除店铺关系 R deleteR = appUserShopClient.delete(shop.getId(), originalUserId); if (deleteR.getCode()!=200){ throw new RuntimeException("删除用户门店关系失败"); } //删除客服电话 QueryWrapper<Phone> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("shop_id", shop.getId()); phoneService.remove(queryWrapper); //修改店铺 shopService.updateById(shop); //添加门店后台账号和门店关系数据 SysUser sysUser = sysUserClient.queryUserByUserName(phone).getData(); if(null != sysUser){ userShop = new UserShop(); userShop.setShopId(shop.getId()); userShop.setUserId(sysUser.getUserId()); data = userShopClient.getUserShop(userShop).getData(); if(null == data || data.size() == 0){ userShop = new UserShop(); userShop.setUserId(sysUser.getUserId()); userShop.setShopId(shop.getId()); userShop.setRoleType(1); userShop.setRoleId(2L); userShop.setNickName(sysUser.getNickName()); userShop.setCreateTime(LocalDateTime.now()); userShopClient.saveUserShop(userShop); } }else{ //添加管理后台账号 SysUser user = new SysUser(); user.setDeptId(1L); user.setUserName(appUser.getPhone()); user.setNickName(appUser.getName()); user.setPhonenumber(appUser.getPhone()); user.setAvatar(appUser.getAvatar()); user.setStatus("0"); user.setDelFlag("0"); user.setRoleType(2); user.setObjectId(shop.getId()); user.setAppUserId(appUser.getId()); user.setPassword(phone.substring(5)); user.setCreateTime(new Date()); Long userId = sysUserClient.saveShopUser(user).getData(); userShop = new UserShop(); userShop.setShopId(shop.getId()); userShop.setUserId(userId); data = userShopClient.getUserShop(userShop).getData(); if(null == data || data.size() == 0){ userShop = new UserShop(); userShop.setUserId(userId); userShop.setShopId(shop.getId()); userShop.setRoleType(1); userShop.setRoleId(2L); userShop.setNickName(appUser.getName()); userShop.setCreateTime(LocalDateTime.now()); userShopClient.saveUserShop(userShop); } }*/ //添加shopuser AppUserShop appUserShop = new AppUserShop(); appUserShop.setAppUserId(appUser.getId()); appUserShop.setShopId(shop.getId()); R appUserShopR = appUserShopClient.insert(appUserShop); if (appUserShopR.getCode()!=200){ throw new RuntimeException("添加用户门店关系失败"); } //添加客服phone Phone phone1 = new Phone(); phone1.setType(2);//门店 phone1.setPhoneOne(shop.getServiceTel()); phone1.setShopId(shop.getId()); phoneService.save(phone1); return R.ok(); } public static void main(String[] args) { @@ -406,59 +268,12 @@ @PutMapping("/freezingOrThawing") @ApiOperation(value = "门店管理-冻结/解冻门店", tags = {"管理后台-门店管理"}) public R freezingOrThawing(@RequestParam("id") Integer id, @RequestParam("status") Integer status){ /* Shop shop = shopService.getById(id); Shop shop = shopService.getById(id); if(shop.getStatus().equals(status)){ return R.fail("不能重复操作"); } shop.setStatus(status); shopService.updateById(shop); //处理员工等数据 if(status == 1){ UserShop userSh = new UserShop(); userSh.setShopId(id); List<UserShop> data = userShopClient.getUserShop(userSh).getData(); for (UserShop datum : data) { SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); sysUser.setStatus("0"); sysUserClient.updateUser(sysUser); } }else{ //查询门店所有关联数据 UserShop userSh = new UserShop(); userSh.setShopId(id); List<UserShop> data = userShopClient.getUserShop(userSh).getData(); for (UserShop datum : data) { //查询用户关联的其他店铺 UserShop userShop = new UserShop(); userShop.setUserId(datum.getUserId()); List<UserShop> data1 = userShopClient.getUserShop(userShop).getData(); List<UserShop> collect = data1.stream().filter(s -> !s.getShopId().equals(id)).collect(Collectors.toList()); if(collect.size() == 0){ //如果没有其他店铺,则将用户禁用 SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); sysUser.setStatus("1"); sysUserClient.updateUser(sysUser); }else{ List<Integer> shopIds = collect.stream().map(UserShop::getShopId).collect(Collectors.toList()); List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1) .in(Shop::getId, shopIds)); //如果用户关联的其他门店都禁用了,将用户禁用 if(list.size() == 0){ SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); sysUser.setStatus("1"); sysUserClient.updateUser(sysUser); }else{ //修改默认门店 SysUser sysUser = sysUserClient.getSysUser(datum.getUserId()).getData(); if(sysUser.getObjectId().equals(id)){ sysUser.setObjectId(list.get(0).getId()); sysUserClient.updateUser(sysUser); } } } } }*/ return R.ok(); } @@ -469,9 +284,9 @@ @ApiOperation(value = "门店列表", tags = {"管理后台-门店管理"}) public R<IPage<Shop>> list(@ApiParam("页码") @RequestParam("pageNum") Integer pageNum,@ApiParam("每一页数据大小") @RequestParam("pageSize") Integer pageSize,Shop shop){ IPage<Shop> shopIPage = shopService.getShopList(pageNum, pageSize, shop); /*for (Shop record : shopIPage.getRecords()) { record.setLaveUsePoint(record.getLavePoint()); }*/ for (Shop record : shopIPage.getRecords()) { record.setFullAddress(record.getAddress()+record.getDetailAddress()); } return R.ok(shopIPage); } @@ -905,6 +720,13 @@ return R.ok(shopService.getMap(queryWrapper)); } @PostMapping("/insert") R insert(@RequestBody Shop shop){ shopService.save(shop); return R.ok(shop.getId()); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
@@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.domain.ShopBalanceStatement; @@ -110,21 +112,29 @@ } @GetMapping("/shop/list") @ApiOperation(value = "提现申请列表", notes = "提现申请列表", tags = {"门店后台"}) @ApiOperation(value = "提现申请列表", notes = "提现申请列表", tags = {"门店后台","后台"}) public R<IPage<ShopWithdraw>> shoplist(@ApiParam("页码") @RequestParam Integer pageNum, @ApiParam("每一页数据大小") Integer pageSize, @ApiParam("门店id")Integer shopId, @ApiParam("手机号") String phone, @ApiParam("审核状态(0=待审核,1=审核通过,2=审核失败)")Integer auditStatus) { Page<ShopWithdraw> page = shopWithdrawService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<ShopWithdraw>() .eq(ShopWithdraw::getShopId,shopId) .eq(auditStatus!=null,ShopWithdraw::getAuditStatus,auditStatus) .orderByDesc(ShopWithdraw::getCreateTime) ); //添加转账的银行卡号和账户姓名 List<ShopWithdraw> records = page.getRecords(); for (ShopWithdraw record : records) { //模糊查询手机号 List<Long> collect=null; if (StringUtils.isNotEmpty(phone)) { List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(phone).getData(); collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); if (CollectionUtils.isEmpty(collect)) { return R.ok(new PageInfo<>()); } } Page<ShopWithdraw> page = shopWithdrawService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<ShopWithdraw>() .eq(shopId!=null,ShopWithdraw::getShopId,shopId) .eq(auditStatus!=null,ShopWithdraw::getAuditStatus,auditStatus) .in(collect!=null,ShopWithdraw::getCreateUserId,collect) .orderByDesc(ShopWithdraw::getCreateTime) ); return R.ok(page); } @@ -163,7 +173,7 @@ */ @GetMapping("/shop/with") @ApiOperation(value = "提现申请", notes = "提现申请列表", tags = {"门店后台"}) @ApiOperation(value = "提现申请", notes = "提现申请", tags = {"门店后台"}) public R shopwith(@RequestParam BigDecimal money){ LoginUser loginUser = tokenService.getLoginUser(); SysUser sysUser = sysUserClient.getSysUser(loginUser.getUserid()).getData(); @@ -238,7 +248,7 @@ * 审核 */ @PostMapping("/audit") @ApiOperation("审核") @ApiOperation("提现审核") public R<Void> audit(@RequestBody ShopWithdraw shopWithdraw) { LoginUser loginUser = tokenService.getLoginUser(); @@ -249,6 +259,7 @@ Shop shop = shopService.getById(shopWithdraw1.getShopId()); BigDecimal money = shopWithdraw1.getMoney(); if(1 == shopWithdraw.getAuditStatus()){ //通过 //先检查账户余额是否充足 AccountBalanceQueryResult accountBalanceQueryResult = TransferUtil.accountBalanceQuery(); if(null == accountBalanceQueryResult){ @@ -277,13 +288,15 @@ shopWithdraw1.setStatus(1); } if(2 == shopWithdraw.getAuditStatus()){ //审核不通过 //回退金额和添加变动明细 BigDecimal balance = shop.getBalance(); BigDecimal canWithdrawMoney = shop.getCanWithdrawMoney(); BigDecimal withdrawMoney = shop.getWithdrawMoney(); BigDecimal withdrawAuditMoney = shop.getWithdrawAuditMoney(); shop.setBalance(balance.add(money).setScale(2, RoundingMode.HALF_EVEN)); shop.setCanWithdrawMoney(canWithdrawMoney.add(money).setScale(2, RoundingMode.HALF_EVEN)); shop.setWithdrawMoney(withdrawMoney.subtract(money).setScale(2, RoundingMode.HALF_EVEN)); //审核中的金额减少 shop.setWithdrawAuditMoney(withdrawAuditMoney.subtract(money).setScale(2, RoundingMode.HALF_EVEN)); shopService.updateById(shop); //添加门店变动明细 ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); @@ -297,6 +310,8 @@ shopBalanceStatement.setObjectId(shopWithdraw.getId()); shopBalanceStatementService.save(shopBalanceStatement); } shopWithdraw1.setAuditStatus(shopWithdraw.getAuditStatus()); shopWithdraw1.setAuditUserId(loginUser.getUserid()); shopWithdraw1.setAuditTime(LocalDateTime.now()); @@ -304,7 +319,7 @@ shopWithdrawService.updateById(shopWithdraw1); return R.ok(); } /** @@ -318,35 +333,46 @@ String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); ShopWithdraw shopWithdraw = shopWithdrawService.getById(merchantOrderNo); if(203 == status || 205 == status){ //到账 if(1 == shopWithdraw.getStatus()){ shopWithdraw.setStatus(2); shopWithdraw.setArrivalTime(LocalDateTime.now()); shopWithdrawService.updateById(shopWithdraw); } //更新店铺审核中的金额,和提现金额 Shop shop = shopService.getById(shopWithdraw.getShopId()); shop.setWithdrawAuditMoney(shop.getWithdrawAuditMoney().subtract(shopWithdraw.getMoney()));//审核中金额 shop.setWithdrawMoney(shop.getWithdrawMoney().add(shopWithdraw.getMoney()));//提现金额 shopService.updateById(shop); JSONObject jsonObject = new JSONObject(); jsonObject.put("statusCode", 2001); return jsonObject; }else{ //回退金额和添加变动明细 BigDecimal money = shopWithdraw.getMoney().setScale(2, RoundingMode.HALF_EVEN); Shop shop = shopService.getById(shopWithdraw.getShopId()); BigDecimal balance = shop.getBalance(); BigDecimal canWithdrawMoney = shop.getCanWithdrawMoney(); BigDecimal withdrawMoney = shop.getWithdrawMoney(); shop.setBalance(balance.add(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN)); shop.setCanWithdrawMoney(canWithdrawMoney.add(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN)); shop.setWithdrawMoney(withdrawMoney.subtract(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN)); BigDecimal withdrawAuditMoney = shop.getWithdrawAuditMoney(); shop.setBalance(balance.add(money).setScale(2, RoundingMode.HALF_EVEN)); shop.setCanWithdrawMoney(canWithdrawMoney.add(money).setScale(2, RoundingMode.HALF_EVEN)); //审核中的金额减少 shop.setWithdrawAuditMoney(withdrawAuditMoney.subtract(money).setScale(2, RoundingMode.HALF_EVEN)); shopService.updateById(shop); //添加门店变动明细 ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop.getId()); shopBalanceStatement.setType(4); shopBalanceStatement.setHistoricalBalance(balance); shopBalanceStatement.setVariableAmount(shopWithdraw.getMoney()); shopBalanceStatement.setVariableAmount(money); shopBalanceStatement.setBalance(shop.getBalance()); shopBalanceStatement.setCreateUserId(shopWithdraw.getAuditUserId()); shopBalanceStatement.setCreateTime(LocalDateTime.now()); shopBalanceStatement.setObjectId(shopWithdraw.getId()); shopBalanceStatementService.save(shopBalanceStatement); shopWithdraw.setStatus(3); shopWithdraw.setRemark(singlePayCallbackResult.getErrorCodeDesc()); shopWithdrawService.updateById(shopWithdraw); ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -266,40 +266,43 @@ @Override public IPage<Goods> getManageGoodsList(Page<Goods> page, Goods goods) { IPage<Goods> goodsIPage = goodsMapper.selectManageGoodsList(page, goods); goodsIPage.getRecords().forEach(goods1 -> { /* goodsIPage.getRecords().forEach(goods1 -> { Integer data = orderClient.getGoodsSaleNum(goods1.getId(), 1).getData(); goods1.setSaleNum(data); }); });*/ return goodsIPage; } @Override @Transactional(rollbackFor = Exception.class) public void addGoods(Goods goods) { /* goods.setSaleNum(0); goods.setStatus(GoodsStatus.DOWN.getCode()); goodsMapper.insert(goods); // 指定门店 Integer appointStore = goods.getAppointStore(); if (null != appointStore && appointStore == 1){ List<GoodsShop> goodsShopList = goods.getGoodsShopList(); if (CollectionUtils.isEmpty(goodsShopList)){ throw new NullPointerException("请选择指定门店"); } saveGoodsShopList(goodsShopList, goods.getId()); }*/ //保存商品门店关系 GoodsShop goodsShop = new GoodsShop(); goodsShop.setGoodsId(goods.getId()); goodsShop.setShopId(goods.getShopId()); Shop shop = shopMapper.selectById(goods.getShopId()); goodsShop.setShopName(shop.getName()); goodsShop.setOwnerName(shop.getShopManager()); goodsShop.setPhone(shop.getPhone()); goodsShop.setAddress(shop.getAddress()); goodsShopService.save(goodsShop); //判断是否参加秒杀活动 } @Override public void updateManageGoods(Goods goods) { /* this.updateById(goods); this.updateById(goods); //修改个别字段 this.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getId, goods.getId()).set(Goods::getSellingPrice, goods.getSellingPrice()) .set(Goods::getIntegral, goods.getIntegral())); // 指定门店 List<GoodsShop> goodsShopList = goods.getGoodsShopList(); saveGoodsShopList(goodsShopList, goods.getId());*/ // 保存门店 saveGoodsShop(goods.getShopId(),goods.getId()); } @@ -309,16 +312,16 @@ private void saveGoodsShopList(List<GoodsShop> goodsShopList, Integer goodsId) { private void saveGoodsShop(Integer shopId, Integer goodsId) { goodsShopService.remove(new LambdaQueryWrapper<GoodsShop>() .eq(GoodsShop::getGoodsId, goodsId)); if (!CollectionUtils.isEmpty(goodsShopList)){ for (GoodsShop goodsShop : goodsShopList) { goodsShop.setGoodsId(goodsId); goodsShop.setId(null); } } goodsShopService.saveBatch(goodsShopList); GoodsShop goodsShop = new GoodsShop(); goodsShop.setGoodsId(goodsId); goodsShop.setShopId(shopId); goodsShop.setId(null); goodsShopService.save(goodsShop); } @Override @@ -327,20 +330,18 @@ if (goods == null){ return null; } // 指定门店 List<GoodsShop> goodsShops = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>() // 获取指定门店 GoodsShop goodsShop = goodsShopService.getOne(new LambdaQueryWrapper<GoodsShop>() .eq(GoodsShop::getGoodsId, goodsId)); for (GoodsShop goodsShop : goodsShops) { Shop shop = shopMapper.selectById(goodsShop.getShopId()); if(null != shop){ goodsShop.setShopName(shop.getName()); goodsShop.setOwnerName(shop.getShopManager()); goodsShop.setPhone(shop.getPhone()); goodsShop.setAddress(shop.getAddress()); } goods.setShopId(goodsShop.getShopId()); Shop shop = shopService.getById(goodsShop.getShopId()); if(null != shop){ goodsShop.setShopName(shop.getName()); goodsShop.setPhone(shop.getPhone()); goodsShop.setAddress(shop.getAddress()); goodsShop.setOwnerName(shop.getShopManager()); } // goods.setGoodsShopList(goodsShops); goods.setGoodsShop(goodsShop); return goods; } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java
@@ -1,10 +1,13 @@ package com.ruoyi.other.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.PageUtils; import com.ruoyi.common.core.utils.ServletUtils; import com.ruoyi.common.core.utils.StringUtils; @@ -22,11 +25,14 @@ import com.ruoyi.other.util.GeodesyUtil; import com.ruoyi.other.vo.SeckillActivityDetailVO; import com.ruoyi.other.vo.SeckillActivityVO; import com.ruoyi.system.api.domain.SysConfig; import com.ruoyi.system.api.feignClient.SysConfigClient; import com.ruoyi.system.api.model.LoginUser; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -56,6 +62,8 @@ private AppUserClient appUserClient; @Resource private GoodsSeckillService goodsSeckillService; @Resource private SysConfigClient sysConfigClient; @Resource private GoodsService goodsService; @Resource @@ -188,42 +196,76 @@ @Transactional(rollbackFor = Exception.class) public void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) { Integer goodId = seckillActivityInfo.getGoodId(); String startTime = seckillActivityInfo.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String endTime = seckillActivityInfo.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0) .eq(SeckillActivityInfo::getIsShelves, 1).last(" and ('" + startTime + "' between start_time and end_time or '" + endTime + "' between start_time and end_time)")); if(0 < count){ //检查该商品是否有秒杀活动 SeckillActivityInfo one = this.getOne(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0)); if(null!=one){ throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在"); } seckillActivityInfo.setId(null); seckillActivityInfo.setCreateTime(LocalDateTime.now()); seckillActivityInfo.setDelFlag(0); seckillActivityInfo.setIsShelves(0);//下架状态 this.baseMapper.insert(seckillActivityInfo); List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); for (GoodsSeckill goodsSeckill : goodsSeckills) { goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1); goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1); goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()); } goodsSeckillService.saveBatch(goodsSeckills); //添加价格积分 GoodsSeckill goodsSeckill = new GoodsSeckill(); goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()); goodsSeckill.setSellingPrice(seckillActivityInfo.getSellingPrice()); Integer point =getPoint(seckillActivityInfo.getSellingPrice()); goodsSeckill.setIntegral(point); goodsSeckillService.save(goodsSeckill); } /** * 获取现金对应积分 */ public Integer getPoint(BigDecimal cash){ if (cash == null || cash.compareTo(BigDecimal.ZERO) < 0) { throw new IllegalArgumentException("金额不能为null或负数"); } // 获取积分兑换比例配置 R<SysConfig> info = sysConfigClient.getInfo(6L); if (info == null || info.getData() == null) { throw new RuntimeException("获取积分兑换比例配置失败"); } String configValue = info.getData().getConfigValue(); if (StringUtils.isBlank(configValue)) { throw new RuntimeException("积分兑换比例配置值为空"); } try { // 使用BigDecimal处理比例,避免精度问题 BigDecimal ratio = new BigDecimal(configValue.trim()); if (ratio.compareTo(BigDecimal.ZERO) <= 0) { throw new RuntimeException("积分兑换比例必须大于0"); } // 计算积分并四舍五入取整 return cash.multiply(ratio).intValue(); } catch (NumberFormatException e) { throw new RuntimeException("积分兑换比例配置值格式错误", e); } catch (ArithmeticException e) { throw new RuntimeException("积分计算结果溢出", e); } } @Override @Transactional(rollbackFor = Exception.class) public void updateSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) { Integer goodId = seckillActivityInfo.getGoodId(); String startTime = seckillActivityInfo.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String endTime = seckillActivityInfo.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0) .eq(SeckillActivityInfo::getIsShelves, 1).last(" and ('" + startTime + "' between start_time and end_time or '" + endTime + "' between start_time and end_time)")); if(1 < count){ throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在"); SeckillActivityInfo one = this.getOne(new LambdaQueryWrapper<SeckillActivityInfo>() .eq(SeckillActivityInfo::getId, seckillActivityInfo.getId()).eq(SeckillActivityInfo::getDelFlag, 0)); if(null==one){ throw new RuntimeException("该秒杀活动不存在"); } this.baseMapper.updateById(seckillActivityInfo); goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); for (GoodsSeckill goodsSeckill : goodsSeckills) { goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1); goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1); goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()); } goodsSeckillService.saveBatch(goodsSeckills); this.baseMapper.updateById(seckillActivityInfo);//修改限购数量、开始时间、结束时间 //修改价格积分 Integer point =getPoint(seckillActivityInfo.getSellingPrice()); UpdateWrapper<GoodsSeckill> wrapper = new UpdateWrapper<>(); wrapper.eq("seckill_activity_info_id", seckillActivityInfo.getId()) .set("selling_price", seckillActivityInfo.getSellingPrice()) .set("integral", point); goodsSeckillService.update(wrapper); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java
@@ -42,6 +42,9 @@ @ApiModelProperty(value = "划线价") private BigDecimal originalPrice; @ApiModelProperty(value = "活动售价") private BigDecimal activityPrice; @ApiModelProperty(value = "基础售价") private BigDecimal sellingPrice; @@ -60,6 +63,11 @@ @ApiModelProperty(value = "状态:1未开始 2已开始 3已结束") private Integer status; @ApiModelProperty(value = "店铺id") private Integer shopId; @ApiModelProperty(value = "店铺名称") private String shopName; @ApiModelProperty(value = "展示状态:0下架中 1上架中") private Integer showStatus; ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -20,40 +20,37 @@ </select> <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods"> SELECT tg.* tg.*, ts.name AS shop_name, ts.id AS shop_id, tgc.name AS category_name FROM t_goods tg LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id t_goods tg LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id LEFT JOIN t_goods_shop tgs ON tg.id = tgs.goods_id LEFT JOIN t_shop ts ON tgs.shop_id = ts.id <where> tg.del_flag = 0 tg.del_flag = 0 <if test="goods.id != null"> and tg.id = #{goods.id} AND tg.id = #{goods.id} </if> <if test="goods.name != null and goods.name != ''"> and tg.`name` like concat('%',#{goods.name},'%') </if> <if test="goods.type != null"> and tg.type = #{goods.type} AND tg.`name` LIKE CONCAT('%', #{goods.name}, '%') </if> <if test="goods.goodsCategoryId != null"> and tg.goods_category_id = #{goods.goodsCategoryId} AND tg.goods_category_id = #{goods.goodsCategoryId} </if> <if test="goods.status != null"> and tg.`status` = #{goods.status} AND tg.`status` = #{goods.status} </if> <if test="goods.payMethod != null and goods.payMethod == 1 "> and tg.`cash_payment` = 1 and (tg.`point_payment` = 0 or tg.`point_payment` is null) <if test="goods.shopName != null and goods.shopName != ''"> AND ts.`name` LIKE CONCAT('%', #{goods.shopName}, '%') </if> <if test="goods.payMethod != null and goods.payMethod == 2 "> and tg.`point_payment` = 1 and (tg.`cash_payment` = 0 or tg.`cash_payment` is null) <if test="goods.shopId != null"> AND ts.id = #{goods.shopId} </if> <if test="goods.payMethod != null and goods.payMethod == 3 "> and (tg.`point_payment` = 1 and tg.`cash_payment` = 1 ) </if> </where> order by tg.sort desc ORDER BY tg.sort DESC </select> ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
@@ -58,18 +58,26 @@ tg.id goodsId, tg.`name` goodsName, tg.introduction, tg.sale_num saleNum, tgc.`name` goodsCategoryName, tsai.max_num maxNum, tg.home_page_picture, tgse.selling_price activityPrice, tg.selling_price sellingPrice, tg.original_price, tsai.start_time, tsai.end_time, tsai.is_shelves showStatus tsai.is_shelves showStatus, tgs.shop_id shopId, ts.name shopName FROM t_seckill_activity_info tsai LEFT JOIN t_goods tg ON tsai.good_id = tg.id LEFT JOIN t_goods_category tgc ON tgc.id = tg.goods_category_id LEFT JOIN t_goods_shop tgs ON tg.id = tgs.goods_id LEFT JOIN t_shop ts ON tgs.shop_id = ts.id LEFT JOIN t_goods_seckill tgse ON tsai.id = tgse.seckill_activity_info_id WHERE tsai.del_flag = 0 <if test="goods.id != null"> AND tsai.id = #{goods.id} @@ -83,6 +91,9 @@ <if test="goods.categoryName != null and goods.categoryName != ''"> AND tgc.name = #{goods.categoryName} </if> <if test="goods.shopId != null"> AND tgs.shop_id = #{goods.shopId} </if> <if test="goods.status != null and goods.status ==1"> AND tsai.start_time <![CDATA[>]]> NOW() </if>