refactor code

This commit is contained in:
Cauchy
2023-10-16 14:55:34 +08:00
parent 5d0633d1bb
commit 08cc5c3a3d
67 changed files with 695 additions and 3053 deletions

View File

@@ -78,33 +78,6 @@ public class BuyOrderController {
return R.ok().put("page", page);
}
/**
* @param params
* @return 听书未购买页面展示
* (销量最多的书,最先放最前面展示。最新上线的书,预售的书,放最前面展示
* @throws Exception
*/
@RequestMapping("/lists")
public R lists(@RequestParam Map<String, Object> params) throws Exception {
if ("all".equals(params.get("orderStatus"))) {
params.remove("orderStatus");
}
PageUtils page = buyOrderService.queryPages(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{orderId}")
public R info(@PathVariable("orderId") Integer orderId) {
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
return R.ok().put("buyOrder", buyOrder);
}
/**
* 下单
*
@@ -202,74 +175,13 @@ public class BuyOrderController {
return R.ok();
}
/**
* 列表
*/
@RequestMapping("/appUserGetlist")
public R appUserGetlist(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderService.queryPage1(params);
return R.ok().put("page", page);
}
/**
* app 端 取消订单
*/
@RequestMapping("/appDelete")
@Transactional
public R appDelete(@RequestParam("orderId") Integer orderId) {
//1. 判断订单状态
BuyOrderEntity byId = buyOrderService.getById(orderId);
if (byId != null) {
//2. 判断当前订单是否存在优惠券 进行 回显
Integer couponId = byId.getCouponId();
if (couponId != null) {
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
byId1.setUseStatus(0);
couponHistoryService.updateById(byId1);
}
// 库存回滚
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
.eq("order_id", byId.getOrderId()));
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
Integer productId = buyOrderDetailEntity.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
shopProductService.updateById(product);
}
buyOrderService.removeById(orderId);
}
return R.ok();
}
@RequestMapping("/randomOrderCode")
@Transactional
public R randomOrderCode(@RequestBody BuyOrderEntity buyOrder) {
return R.ok();
}
/**
* 充值专用订单生成接口
*/
@RequestMapping("/rechargeSave")
@Transactional
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder) {
String timeId = IdWorker.getTimeId().substring(0, 32);
buyOrder.setOrderSn(timeId);
buyOrderService.save(buyOrder);
return R.ok().put("orderSn", timeId);
}
/**
* 信息
*/
@RequestMapping("/appGetOrderInfo/{type}")
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime()/1000);
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime() / 1000);
List<BuyOrderDetailEntity> orderDetail = null;
if ("1".equals(type)) {
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
@@ -307,36 +219,6 @@ public class BuyOrderController {
return R.ok().put("buyOrder", buyOrder).put("CreateTime", createDate).put("userRecordid", id);
}
/**
* 计算快递费用
*/
@RequestMapping("/getTransPrice/{area}")
public R getTransPrice(@PathVariable String area, @RequestParam Map<String, Object> productMap) {
Map<String, Object> params = new HashMap<>();
params.put("kdCode", "YD");
params.put("area", area);
int price = this.buyOrderService.getProductGoodsType(params, productMap);
return R.ok().put("price", price);
}
/**
* 后台发货按钮
*
* @Param shipperCode 快递公司编码
* @Param sendType 0订单列表发货 1商品列表发货
* @Param type 合并发货/拆分发货
* @Param ids 订单id串
*/
@RequestMapping("/delivery/{shipperCode}")
public R delivery(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] ids) {
buyOrderService.sendFMS(ids, shipperCode, shipperName);
return R.ok();
}
/**
* 及时查询快递信息
*/
@@ -381,44 +263,22 @@ public class BuyOrderController {
}
/**
* 批量发货功能
* 分包发货
*
* @param orderDetailIds 订单详情
* @return
* @param expressCompanyCode 快递公司编码
* @param userAddressId 用户地址 ID
* @param productIds 商品 ID 列表
* @return R
*/
@RequestMapping("/blendSendFMS/{shipperCode}")
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] orderDetailIds) {
buyOrderService.blendSendFMS(orderDetailIds, shipperCode, shipperName);
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestParam("userAddressId") Integer userAddressId,
@RequestBody List<Integer> productIds) {
buyOrderService.createSplitPackageOrder(expressCompanyCode, userAddressId, productIds);
return R.ok();
}
/**
* 后台取消订单接口
*/
@RequestMapping("/cancelFMS")
public R cancelFMS(@RequestParam Map<String, Object> params) {
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
params.get("expNo").toString());
return R.ok().put("paramsTEXT", params);
}
/**
* 去重查询可打印面单
*
* @param params
* @return
*/
@RequestMapping("/querySheetPage")
public R querySheetPage(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderDetailService.querySheet(params);
return R.ok().put("page", page);
}
/**
* 获取商品实际价格
*
@@ -548,7 +408,7 @@ public class BuyOrderController {
private MessagePostProcessor messagePostProcessor() {
return message -> {
//设置有效期30分钟
message.getMessageProperties().setExpiration(String.valueOf(30*60*1000));
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
return message;
};
}