This commit is contained in:
wuchunlei
2024-05-24 15:50:32 +08:00
14 changed files with 300 additions and 74 deletions

View File

@@ -311,12 +311,6 @@ public class BuyOrderController {
}
// 2. 微信支付,需要预支付
if (Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())) {
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getOrderId(),
messagePostProcessor()
);
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(orderSn);
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
@@ -324,6 +318,12 @@ public class BuyOrderController {
paymentInfo.setAppName(buyOrder.getAppName());
wxpayService.prepay(paymentInfo);
}
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
buyOrder.getOrderId(),
messagePostProcessor()
);
Map<String, Object> result = new HashMap<>();
result.put("orderSn", buyOrder.getOrderSn());
result.put("money", totalPrice);
@@ -542,17 +542,21 @@ public class BuyOrderController {
@RequestMapping("/rechargeSave")
@Transactional
public R rechargeSave(@RequestBody BuyOrder buyOrder) throws IOException {
buyOrder.setOrderStatus("0");
buyOrder.setOrderType("point");
String timeId = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(timeId);
buyOrderService.save(buyOrder);
//下单微信支付预付款订单
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, timeId));
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
paymentInfo.setAppName(buyOrder.getAppName());
wxpayService.prepay(paymentInfo);
if(Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())){
BuyOrder buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, timeId));
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
paymentInfo.setAppName(buyOrder.getAppName());
wxpayService.prepay(paymentInfo);
}
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,

View File

@@ -1,54 +0,0 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.ShopStore;
import com.peanut.modules.book.service.ShopStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("book/shopStore")
public class ShopStoreController {
@Autowired
private ShopStoreService shopStoreService;
/**
* 获取小店列表
*/
@RequestMapping("/getStoreList")
public R getStoreList(@RequestBody Map params){
MPJLambdaWrapper<ShopStore> wrapper = new MPJLambdaWrapper();
if (params.containsKey("name")&&!"".equals(params.get("name").toString())){
wrapper.like(ShopStore::getName,params.get("name").toString());
}
Page<ShopStore> page = shopStoreService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page);
}
@RequestMapping(path = "/getStoreById")
public R getStoreById(String id) {
return R.ok().put("result",shopStoreService.getById(id));
}
@RequestMapping(path = "/saveOrUpdateStore")
public R saveOrUpdateStore(@RequestBody ShopStore store) {
shopStoreService.saveOrUpdate(store);
return R.ok();
}
@RequestMapping(path = "/delStore")
public R delStore(String id) {
shopStoreService.removeById(id);
return R.ok();
}
}

View File

@@ -1,7 +1,7 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopStore;
import com.peanut.modules.common.entity.ShopStore;
public interface ShopStoreService extends IService<ShopStore> {
}

View File

@@ -1,13 +1,13 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.ShopStoreDao;
import com.peanut.modules.book.entity.ShopStore;
import com.peanut.modules.common.dao.ShopStoreDao;
import com.peanut.modules.common.entity.ShopStore;
import com.peanut.modules.book.service.ShopStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("shopStore")
@Service("bookShopStore")
public class ShopStoreServiceImpl extends ServiceImpl<ShopStoreDao, ShopStore> implements ShopStoreService {
}

View File

@@ -1,7 +1,7 @@
package com.peanut.modules.book.dao;
package com.peanut.modules.common.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.book.entity.ShopStore;
import com.peanut.modules.common.entity.ShopStore;
import org.apache.ibatis.annotations.Mapper;
@Mapper

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ShopStoreToProductDao extends MPJBaseMapper<ShopStoreToProductEntity> {
}

View File

@@ -1,4 +1,4 @@
package com.peanut.modules.book.entity;
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -28,6 +28,8 @@ public class ShopStore implements Serializable {
*/
private Date createTime;
private Integer sort;
@TableLogic
private Integer delFlag;

View File

@@ -0,0 +1,34 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("shop_store_to_product")
public class ShopStoreToProductEntity {
@TableId
private Integer id;
private Integer storeId;
private Integer productId;
private Integer sort;
private Date createTime;
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private ShopStore shopStore;
@TableField(exist = false)
private ShopProduct shopProduct;
}

View File

@@ -1,8 +1,12 @@
package com.peanut.modules.master.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.service.ShopStoreService;
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
import com.peanut.modules.common.entity.ShopStore;
import com.peanut.modules.master.service.PayPaymentOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -0,0 +1,91 @@
package com.peanut.modules.master.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.master.service.ShopStoreService;
import com.peanut.modules.common.entity.ShopStore;
import com.peanut.modules.master.service.ShopStoreToProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController("masterShopStore")
@RequestMapping("master/shopStore")
public class ShopStoreController {
@Autowired
private ShopStoreService shopStoreService;
@Autowired
private ShopStoreToProductService shopStoreToProductService;
/**
* 获取小店列表
*/
@RequestMapping("/getStoreList")
public R getStoreList(@RequestBody Map params){
MPJLambdaWrapper<ShopStore> wrapper = new MPJLambdaWrapper();
if (params.containsKey("name")&&!"".equals(params.get("name").toString())){
wrapper.like(ShopStore::getName,params.get("name").toString());
}
Page<ShopStore> page = shopStoreService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page);
}
@RequestMapping(path = "/getStoreById")
public R getStoreById(@RequestBody Map<String,Integer> map) {
int id = map.get("id");
return R.ok().put("result",shopStoreService.getById(id));
}
@RequestMapping(path = "/saveOrUpdateStore")
public R saveOrUpdateStore(@RequestBody ShopStore store) {
shopStoreService.saveOrUpdate(store);
return R.ok();
}
@RequestMapping(path = "/delStore")
public R delStore(@RequestBody Map<String,Integer> map) {
int id = map.get("id");
return shopStoreService.delStore(id);
}
@RequestMapping("/getStoreProductList")
public R getStoreProductList(@RequestBody Map<String,Integer> map){
List<ShopStoreToProductEntity> storeId = shopStoreToProductService.getStoreProductList(map.get("storeId"));
return R.ok().put("list",storeId);
}
@RequestMapping("/getCanBindProductList")
public R getCanBindProductList(@RequestBody ParamTo param){
Page canBindProductList = shopStoreToProductService.getCanBindProductList(param);
return R.ok().put("page",canBindProductList);
}
@RequestMapping("/bindStoreAndProduct")
public R bindStoreAndProduct(@RequestBody Map<String,Integer> map){
return shopStoreToProductService.bindStoreAndProduct(map.get("storeId"),map.get("productId"));
}
@RequestMapping("/unbindStoreAndProduct")
public R unbindStoreAndProduct(@RequestBody Map<String,Integer> map){
shopStoreToProductService.getBaseMapper().deleteById(map.get("id"));
return R.ok();
}
@RequestMapping("/editStoreProductSort")
public R editStoreProductSort(@RequestBody Map<String,Integer> map){
return shopStoreToProductService.editStoreProductSort(map);
}
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ShopStore;
public interface ShopStoreService extends IService<ShopStore> {
R delStore(int id);
}

View File

@@ -0,0 +1,21 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
import com.peanut.modules.common.to.ParamTo;
import java.util.List;
import java.util.Map;
public interface ShopStoreToProductService extends IService<ShopStoreToProductEntity> {
List<ShopStoreToProductEntity> getStoreProductList(int id);
Page getCanBindProductList(ParamTo param);
R bindStoreAndProduct(int storeId,int productId);
R editStoreProductSort(Map<String,Integer> map);
}

View File

@@ -0,0 +1,30 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.R;
import com.peanut.modules.common.dao.ShopStoreDao;
import com.peanut.modules.common.dao.ShopStoreToProductDao;
import com.peanut.modules.common.entity.ShopStore;
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
import com.peanut.modules.master.service.ShopStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service("masterShopStore")
public class ShopStoreServiceImpl extends ServiceImpl<ShopStoreDao, ShopStore> implements ShopStoreService {
@Autowired
private ShopStoreToProductDao shopStoreToProductDao;
@Override
public R delStore(int id) {
Integer integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper<ShopStoreToProductEntity>().eq(ShopStoreToProductEntity::getStoreId, id));
if(integer>0){
return R.error("请先清空后,再操作");
}
this.removeById(id);
return R.ok();
}
}

View File

@@ -0,0 +1,76 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.R;
import com.peanut.modules.common.dao.ShopProductDao;
import com.peanut.modules.common.dao.ShopStoreDao;
import com.peanut.modules.common.dao.ShopStoreToProductDao;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.master.service.ShopStoreToProductService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("masterShopStoreToProductService")
public class ShopStoreToProductServiceImpl extends ServiceImpl<ShopStoreToProductDao, ShopStoreToProductEntity> implements ShopStoreToProductService {
@Autowired
private ShopStoreDao shopStoreDao;
@Autowired
private ShopProductDao shopProductDao;
@Override
public List<ShopStoreToProductEntity> getStoreProductList(int id) {
List<ShopStoreToProductEntity> shopStoreToProductEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopStoreToProductEntity>()
.eq(ShopStoreToProductEntity::getStoreId, id).orderByAsc(ShopStoreToProductEntity::getSort));
for (ShopStoreToProductEntity s : shopStoreToProductEntities){
s.setShopStore(shopStoreDao.selectById(s.getStoreId()));
s.setShopProduct(shopProductDao.selectById(s.getProductId()));
}
return shopStoreToProductEntities;
}
@Override
public Page<ShopProduct> getCanBindProductList(ParamTo param) {
List<Integer> collect = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopStoreToProductEntity>()
.eq(ShopStoreToProductEntity::getStoreId, param.getId()))
.stream().map(ShopStoreToProductEntity::getProductId).collect(Collectors.toList());
LambdaQueryWrapper<ShopProduct> shopProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
shopProductLambdaQueryWrapper.like(StringUtils.isNotBlank(param.getKeywords()),ShopProduct::getProductName,param.getKeywords());
shopProductLambdaQueryWrapper.notIn(ShopProduct::getProductId,collect);
Page<ShopProduct> shopProductPage = shopProductDao.selectPage(new Page<>(param.getPage(), param.getLimit()), shopProductLambdaQueryWrapper);
return shopProductPage;
}
@Override
public R bindStoreAndProduct(int storeId, int productId) {
//check
ShopStoreToProductEntity one = this.getOne(new LambdaQueryWrapper<ShopStoreToProductEntity>()
.eq(ShopStoreToProductEntity::getStoreId, storeId)
.eq(ShopStoreToProductEntity::getProductId, productId));
if (one!=null){
return R.error("重复绑定");
}
ShopStoreToProductEntity shopStoreToProductEntity = new ShopStoreToProductEntity();
shopStoreToProductEntity.setStoreId(storeId);
shopStoreToProductEntity.setProductId(productId);
this.save(shopStoreToProductEntity);
return R.ok().put("result",shopStoreToProductEntity);
}
@Override
public R editStoreProductSort(Map<String, Integer> map) {
ShopStoreToProductEntity info = this.getById(map.get("id"));
info.setSort(map.get("sort"));
this.updateById(info);
return R.ok().put("result",info);
}
}