bug fix
This commit is contained in:
@@ -10,6 +10,8 @@ import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.ShippingAddressRequestVo;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -35,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("book/buyorder")
|
||||
@RequestMapping("book/buyOrder")
|
||||
public class BuyOrderController {
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@@ -56,8 +58,6 @@ public class BuyOrderController {
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
@Autowired
|
||||
private UserRecordService userRecordService;
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@@ -65,6 +65,9 @@ public class BuyOrderController {
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -86,7 +89,7 @@ public class BuyOrderController {
|
||||
*/
|
||||
@RequestMapping("/buySave")
|
||||
@Transactional
|
||||
public R buySave(@RequestBody BuyOrderEntity buyOrder) throws IOException {
|
||||
public R buySave(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
// 获取订单详情
|
||||
List<BuyOrderDetail> products = buyOrder.getProducts();
|
||||
// 订单总金额
|
||||
@@ -165,7 +168,7 @@ public class BuyOrderController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BuyOrderEntity buyOrder) {
|
||||
public R update(@RequestBody BuyOrder buyOrder) {
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -180,68 +183,61 @@ public class BuyOrderController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* 获取订单详情
|
||||
*
|
||||
* @param orderId 订单 ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/appGetOrderInfo/{type}")
|
||||
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime() / 1000);
|
||||
List<BuyOrderDetail> orderDetail = null;
|
||||
if ("1".equals(type)) {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", orderId));
|
||||
} else {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", orderId));
|
||||
}
|
||||
for (BuyOrderDetail buyOrderDetail : orderDetail) {
|
||||
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET)
|
||||
public R appGetOrderInfo(@RequestParam("orderId") Integer orderId) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(orderId);
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ShopProductEntity prod = shopProductService.getById(buyOrderDetail.getProductId());
|
||||
if (prod != null) {
|
||||
buyOrderDetail.setImage(prod.getProductImages());
|
||||
}
|
||||
}
|
||||
return R.ok().put("result", buyOrder);
|
||||
}
|
||||
|
||||
List<BuyOrderDetail> resultOrder = new ArrayList<BuyOrderDetail>();
|
||||
Set<String> sn_no = new HashSet<String>();
|
||||
for (BuyOrderDetail buyOrderDetail : orderDetail) {
|
||||
resultOrder.add(buyOrderDetail);
|
||||
// sn_no.add(buyOrderDetail.getExpressOrderId());
|
||||
}
|
||||
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
.eq("orderSn", buyOrder.getOrderSn())
|
||||
.eq("userid", buyOrder.getUserId())
|
||||
.eq("orderdid", buyOrder.getOrderId())
|
||||
.last("LIMIT 1"));
|
||||
Integer id = null;
|
||||
if (userRecordEntity != null) {
|
||||
id = userRecordEntity.getId();
|
||||
}
|
||||
buyOrder.setProducts(resultOrder);
|
||||
Date createDate = buyOrder.getCreateTime();
|
||||
return R.ok().put("buyOrder", buyOrder).put("CreateTime", createDate).put("userRecordid", id);
|
||||
@RequestMapping(value = "/modifyOrderAddress", method = RequestMethod.POST)
|
||||
public R modifyOrderAddress(@RequestBody ShippingAddressRequestVo addressRequestVo) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(addressRequestVo.getOrderId());
|
||||
buyOrder.setProvince(addressRequestVo.getProvince());
|
||||
buyOrder.setCity(addressRequestVo.getCity());
|
||||
buyOrder.setDistrict(addressRequestVo.getCounty());
|
||||
buyOrder.setShippingUser(addressRequestVo.getName());
|
||||
buyOrder.setUserPhone(addressRequestVo.getMobile());
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
* 查询订单快递
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return R
|
||||
*/
|
||||
// @RequestMapping("/queryFMS")
|
||||
// public R queryFMS(@RequestParam Map<String, String> params) {
|
||||
// List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||||
// List<JSONObject> jsonList = new ArrayList<>();
|
||||
// JSONObject jsonObj = null;
|
||||
// for (BuyOrderDetailEntity detail : detailList) {
|
||||
// jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||||
// if (Objects.isNull(jsonObj)) {
|
||||
// return R.ok("暂未查到物流信息!");
|
||||
// }
|
||||
// jsonObj.put("ShipperName", detail.getShipperName());
|
||||
// jsonList.add(jsonObj);
|
||||
//
|
||||
// }
|
||||
// return R.ok().put("rntStr", jsonList);
|
||||
// }
|
||||
@RequestMapping(value = "/queryExpress", method = RequestMethod.GET)
|
||||
public R queryExpress(@RequestParam("orderId") Integer orderId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
List<ExpressQueryResponseVo> result = new ArrayList<>();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
|
||||
vo.setOrderDetailId(buyOrderDetail.getId());
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(buyOrderDetail.getExpressCompanyCode(), buyOrderDetail.getExpressBillNo());
|
||||
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
|
||||
vo.setTraces(expressQueryResponse.getTraces());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查可合并的订单信息
|
||||
@@ -270,15 +266,13 @@ public class BuyOrderController {
|
||||
* 分包发货
|
||||
*
|
||||
* @param expressCompanyCode 快递公司编码
|
||||
* @param userAddressId 用户地址 ID
|
||||
* @param buyOrderDetailId 订单详情列表
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
|
||||
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestParam("userAddressId") Integer userAddressId,
|
||||
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, userAddressId, buyOrderDetailId);
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, buyOrderDetailId);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
@@ -318,7 +312,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal useCouponAmount(BuyOrderEntity buyOrder) {
|
||||
private BigDecimal useCouponAmount(BuyOrder buyOrder) {
|
||||
Integer couponId = buyOrder.getCouponId();
|
||||
if (couponId != null) {
|
||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||||
@@ -339,7 +333,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getShoppingAmount(BuyOrderEntity buyOrder) {
|
||||
private BigDecimal getShoppingAmount(BuyOrder buyOrder) {
|
||||
return buyOrder.getOrderMoney() == null ? BigDecimal.ZERO : buyOrder.getShippingMoney();
|
||||
}
|
||||
|
||||
@@ -366,7 +360,7 @@ public class BuyOrderController {
|
||||
* @param user
|
||||
* @param totalPrice
|
||||
*/
|
||||
private void recordTransaction(BuyOrderEntity buyOrder, MyUserEntity user, BigDecimal totalPrice) {
|
||||
private void recordTransaction(BuyOrder buyOrder, MyUserEntity user, BigDecimal totalPrice) {
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setRemark("订单编号为 - " + buyOrder.getOrderSn());
|
||||
transactionDetailsEntity.setUserId(user.getId());
|
||||
@@ -384,7 +378,7 @@ public class BuyOrderController {
|
||||
* @param products
|
||||
* @param buyOrder
|
||||
*/
|
||||
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrderEntity buyOrder) {
|
||||
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrder buyOrder) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderDetail::getProductId).collect(Collectors.toList());
|
||||
for (Integer productId : productIds) {
|
||||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
@@ -400,7 +394,7 @@ public class BuyOrderController {
|
||||
* @param buyOrder
|
||||
* @param buyOrderDetail
|
||||
*/
|
||||
private void handleBuyCart(BuyOrderEntity buyOrder, BuyOrderDetail buyOrderDetail) {
|
||||
private void handleBuyCart(BuyOrder buyOrder, BuyOrderDetail buyOrderDetail) {
|
||||
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetail.getProductId()));
|
||||
if (orderCartList.size() > 0) {
|
||||
|
||||
@@ -117,11 +117,11 @@ public class UserFollowUpController {
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
String orderSn = userRecord.getOrderSn();
|
||||
BuyOrderEntity buyOrderEntity =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn",orderSn).last("LIMIT 1")
|
||||
);
|
||||
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
Integer bookid = userRecord.getBookid();
|
||||
Integer userid = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
@@ -134,8 +134,8 @@ public class UserFollowUpController {
|
||||
// return R.error("您已评价过");
|
||||
// }
|
||||
|
||||
buyOrderEntity.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrderEntity);
|
||||
buyOrder.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
if (userFollowUpEntity.getImages()!=null) {
|
||||
|
||||
List<Map<String,String>> imageList = (ArrayList<Map<String,String>>)userFollowUpEntity.getImages();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class UserRecordController {
|
||||
public Object commodityComments(Integer userid, String orderSn, Integer bookid, String comment) {
|
||||
|
||||
|
||||
BuyOrderEntity buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", orderSn).last("LIMIT 1").eq("order_status", "3")
|
||||
//状态3为已收货
|
||||
// .eq("order_status","3")
|
||||
@@ -172,11 +172,11 @@ public class UserRecordController {
|
||||
UserRecordEntity userRecordEntity = new UserRecordEntity();
|
||||
|
||||
|
||||
if (!ToolObject.isNullOrEmpty(buyOrderEntity)) {
|
||||
if (!ToolObject.isNullOrEmpty(buyOrder)) {
|
||||
return error("您已评价过了,请勿重复评论");
|
||||
//
|
||||
} else {
|
||||
userRecordEntity.setId(buyOrderEntity.getOrderId());
|
||||
userRecordEntity.setId(buyOrder.getOrderId());
|
||||
userRecordEntity.setContent(comment);
|
||||
//商品评价
|
||||
userRecordEntity.setBookid(bookid);
|
||||
@@ -199,11 +199,11 @@ public class UserRecordController {
|
||||
@RequestMapping("/UserRecordcomment")
|
||||
public R commodity(@RequestBody UserRecordEntity recordEntity) {
|
||||
//todo 已收货限制字段,只可评价一次
|
||||
BuyOrderEntity buyOrderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>()
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", recordEntity.getOrderSn())
|
||||
);
|
||||
|
||||
Integer orderId = buyOrderEntity.getOrderId();
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
Integer orderId1 = detailEntity.getOrderId();
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,8 +14,8 @@ import java.util.List;
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@Mapper
|
||||
public interface BuyOrderDao extends BaseMapper<BuyOrderEntity> {
|
||||
public interface BuyOrderDao extends BaseMapper<BuyOrder> {
|
||||
|
||||
public List<BuyOrderEntity> queryListByOrderIds(Integer[] ids);
|
||||
public List<BuyOrder> queryListByOrderIds(Integer[] ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
@TableName("buy_order")
|
||||
public class BuyOrderEntity implements Serializable {
|
||||
public class BuyOrder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
@@ -83,7 +83,7 @@ public class BuyOrderDetail implements Serializable {
|
||||
/**
|
||||
* 面单html
|
||||
*/
|
||||
private String expressBill;
|
||||
private String expressBillTemplate;
|
||||
/**
|
||||
* 商品图片地址
|
||||
*/
|
||||
@@ -96,4 +96,8 @@ public class BuyOrderDetail implements Serializable {
|
||||
* 快递单号
|
||||
*/
|
||||
private String expressBillNo;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String expressCompanyCode;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,29 @@ public class ExpressOrder {
|
||||
*/
|
||||
private int userId;
|
||||
/**
|
||||
* 用户地址 ID
|
||||
* 省份
|
||||
*/
|
||||
private int userAddressId;
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 区县
|
||||
*/
|
||||
private String county;
|
||||
/**
|
||||
* 收件人姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 收件人电话
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 收件人详细地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 快递查询返回结果 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/17
|
||||
*/
|
||||
@Data
|
||||
public class ExpressQueryResponse implements Serializable {
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
private String EBusinessID;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private boolean Success;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
private String Reason;
|
||||
/**
|
||||
* 状态
|
||||
* 普通物流状态:
|
||||
* 0-暂无轨迹信息
|
||||
* 1-已揽收
|
||||
* 2-在途中
|
||||
* 3-签收
|
||||
* 4-问题件
|
||||
* 5-转寄
|
||||
* 6-清关
|
||||
*/
|
||||
private String State;
|
||||
/**
|
||||
* 轨迹
|
||||
*/
|
||||
private List<Trace> Traces;
|
||||
}
|
||||
17
src/main/java/com/peanut/modules/book/entity/Trace.java
Normal file
17
src/main/java/com/peanut/modules/book/entity/Trace.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class Trace {
|
||||
/**
|
||||
* 轨迹时间
|
||||
*/
|
||||
private Date AcceptTime;
|
||||
/**
|
||||
* 轨迹描述
|
||||
*/
|
||||
private String AcceptStation;
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.ActivityEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.peanut.modules.book.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
public interface BuyOrderService extends IService<BuyOrderEntity> {
|
||||
public interface BuyOrderService extends IService<BuyOrder> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params) throws Exception;
|
||||
|
||||
@@ -32,9 +32,7 @@ public interface BuyOrderService extends IService<BuyOrderEntity> {
|
||||
* 订单拆分发货
|
||||
*
|
||||
* @param expressCompanyCode 快递公司代码
|
||||
* @param userAddressId 用户地址 ID
|
||||
* @param buyOrderDetailId 订单详情 ID 列表
|
||||
* @throws Exception exception
|
||||
*/
|
||||
void createSplitPackageOrder(String expressCompanyCode, Integer userAddressId, List<Integer> buyOrderDetailId) throws Exception;
|
||||
void createSplitPackageOrder(String expressCompanyCode, List<Integer> buyOrderDetailId);
|
||||
}
|
||||
@@ -2,22 +2,19 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import com.peanut.modules.book.entity.UserAddress;
|
||||
import com.peanut.modules.book.vo.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.ExpressOrderResponseVo;
|
||||
import com.peanut.modules.book.entity.ExpressQueryResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public interface ExpressOrderService extends IService<ExpressOrder> {
|
||||
/**
|
||||
* 下单生成面单
|
||||
*
|
||||
* @param userAddress
|
||||
* @param expressOrder
|
||||
* @throws Exception
|
||||
*/
|
||||
Map<String, String> placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder);
|
||||
ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder);
|
||||
|
||||
ExpressQueryResponseVo queryExpressOrder(String ShipperCode, String LogisticCode);
|
||||
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.entity.ExpressCommodity;
|
||||
import com.peanut.modules.book.vo.ExpressOrderResponseVo;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -26,22 +27,22 @@ import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("buyOrderService")
|
||||
public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity> implements BuyOrderService {
|
||||
public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> implements BuyOrderService {
|
||||
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
@Autowired
|
||||
private ExpressFeeService expressFeeService;
|
||||
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
@Autowired
|
||||
CountyService countyService;
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
@@ -51,7 +52,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) throws Exception {
|
||||
|
||||
IPage<BuyOrderEntity> page;
|
||||
IPage<BuyOrder> page;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String startTime = null;
|
||||
String endTime = null;
|
||||
@@ -61,8 +62,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
if (ObjectUtils.isEmpty(params.get("orderStatus"))) {
|
||||
page = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<BuyOrderEntity>().eq("user_phone", params.get("key")).
|
||||
new Query<BuyOrder>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<BuyOrder>().eq("user_phone", params.get("key")).
|
||||
or().like("order_sn", params.get("key")).or().like("shipping_user", params.get("key"))
|
||||
.apply(startTime != null, "date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')", startTime)
|
||||
.apply(endTime != null, "date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time")
|
||||
@@ -70,8 +71,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
);
|
||||
} else {
|
||||
page = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<BuyOrderEntity>().eq("order_status", params.get("orderStatus")).eq("user_phone", params.get("key"))
|
||||
new Query<BuyOrder>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<BuyOrder>().eq("order_status", params.get("orderStatus")).eq("user_phone", params.get("key"))
|
||||
.or().like("order_sn", params.get("key")).or().like("shipping_user", params.get("key"))
|
||||
.apply(startTime != null, "date_format (create_time,'%Y-%m-%d') >= date_format ({0},'%Y-%m-%d')", startTime)
|
||||
.apply(endTime != null, "date_format (create_time,'%Y-%m-%d') <= date_format ({0},'%Y-%m-%d')", endTime).orderByDesc("create_time")
|
||||
@@ -79,8 +80,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
|
||||
List<BuyOrderEntity> records = page.getRecords();
|
||||
for (BuyOrderEntity record : records) {
|
||||
List<BuyOrder> records = page.getRecords();
|
||||
for (BuyOrder record : records) {
|
||||
Integer userId = record.getUserId();
|
||||
MyUserEntity myUserEntity = myUserService.getById(userId);
|
||||
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
||||
@@ -105,7 +106,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
// 交易成功 2
|
||||
|
||||
// 交易失败 9
|
||||
BuyOrderEntity orderEntity = this.getOne(new QueryWrapper<BuyOrderEntity>().eq("user_id", userId)
|
||||
BuyOrder orderEntity = this.getOne(new QueryWrapper<BuyOrder>().eq("user_id", userId)
|
||||
.eq("order_sn", orderSn));
|
||||
if (type.equals("0")) {
|
||||
orderEntity.setOrderStatus("1");
|
||||
@@ -130,18 +131,18 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
public List checkOrder(Integer[] orderIds) {
|
||||
|
||||
// 查询出所有的订单信息(携带订单商品)
|
||||
List<BuyOrderEntity> orderList = new ArrayList<>();
|
||||
List<BuyOrderEntity> buyOrderList = this.list(
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1")
|
||||
List<BuyOrder> orderList = new ArrayList<>();
|
||||
List<BuyOrder> buyOrderList = this.list(
|
||||
new QueryWrapper<BuyOrder>().eq("del_flag", "0").eq("order_status", "1")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList) {
|
||||
for (BuyOrder order : buyOrderList) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
}
|
||||
// 清洗数据 (与前端传来的id对比后)
|
||||
List<BuyOrderEntity> washOrderList = new ArrayList<>();
|
||||
for (BuyOrderEntity order : orderList) {
|
||||
List<BuyOrder> washOrderList = new ArrayList<>();
|
||||
for (BuyOrder order : orderList) {
|
||||
for (int o : orderIds) {
|
||||
if (o == order.getOrderId()) {
|
||||
washOrderList.add(order);
|
||||
@@ -151,7 +152,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
Map<Integer, Object> map = new HashMap<>();
|
||||
// 使用清洗后的List获得其中有多少个用户
|
||||
for (BuyOrderEntity o : washOrderList) {
|
||||
for (BuyOrder o : washOrderList) {
|
||||
map.put(o.getUserId(), o);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
@@ -159,8 +160,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
List<UserOrderVo> userOrderVoList = new ArrayList<>();
|
||||
for (int key : keys) {
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for (BuyOrderEntity o : buyOrderList) {
|
||||
List<BuyOrder> orderEntityList = new ArrayList<>();
|
||||
for (BuyOrder o : buyOrderList) {
|
||||
if (o.getUserId().equals(key)) {
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
@@ -195,16 +196,16 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
public Page checkOrder(Map<String, Object> params) {
|
||||
|
||||
// 查询所有订单信息
|
||||
List<BuyOrderEntity> orderList = new ArrayList<>();
|
||||
List<BuyOrder> orderList = new ArrayList<>();
|
||||
List<UserOrderVo> userOrderVoList = new ArrayList<>();
|
||||
// 返回的list
|
||||
List<UserOrderVo> rntList = new ArrayList<>();
|
||||
Page<UserOrderVo> rntPage = new Page<>();
|
||||
IPage<BuyOrderEntity> buyOrderList = this.page(
|
||||
new Query<BuyOrderEntity>().getPage(params),
|
||||
new QueryWrapper<BuyOrderEntity>().eq("del_flag", "0").eq("order_status", "1").eq("is_send", "0")
|
||||
IPage<BuyOrder> buyOrderList = this.page(
|
||||
new Query<BuyOrder>().getPage(params),
|
||||
new QueryWrapper<BuyOrder>().eq("del_flag", "0").eq("order_status", "1").eq("is_send", "0")
|
||||
);
|
||||
for (BuyOrderEntity order : buyOrderList.getRecords()) {
|
||||
for (BuyOrder order : buyOrderList.getRecords()) {
|
||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("order_id", order.getOrderId())));
|
||||
orderList.add(order);
|
||||
@@ -212,7 +213,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
// 获取有订单的所有用户
|
||||
Map<Integer, Object> map = new HashMap<>();
|
||||
|
||||
for (BuyOrderEntity order : orderList) {
|
||||
for (BuyOrder order : orderList) {
|
||||
map.put(order.getUserId(), order);
|
||||
}
|
||||
//获取map的所有key转为list
|
||||
@@ -220,8 +221,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
|
||||
for (int key : keys) {
|
||||
UserOrderVo userOrderVo = new UserOrderVo();
|
||||
List<BuyOrderEntity> orderEntityList = new ArrayList<>();
|
||||
for (BuyOrderEntity o : buyOrderList.getRecords()) {
|
||||
List<BuyOrder> orderEntityList = new ArrayList<>();
|
||||
for (BuyOrder o : buyOrderList.getRecords()) {
|
||||
if (o.getUserId().equals(key)) {
|
||||
userOrderVo.setUserName(o.getShippingUser());
|
||||
userOrderVo.setTel(o.getUserPhone());
|
||||
@@ -244,7 +245,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSplitPackageOrder(String expressCompanyCode, Integer userAddressId, List<Integer> buyOrderDetailId) {
|
||||
public void createSplitPackageOrder(String expressCompanyCode, List<Integer> buyOrderDetailId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", buyOrderDetailId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
@@ -262,9 +263,13 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
}
|
||||
|
||||
// 获取用户地址
|
||||
UserAddress address = userAddressService.getById(userAddressId);
|
||||
Integer orderId = buyOrderDetailList.get(0).getOrderId();
|
||||
BuyOrder buyOrder = getById(orderId);
|
||||
QueryWrapper<CountyEntity> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
||||
CountyEntity county = countyService.getOne(countyQueryWrapper);
|
||||
// 计算快递费用
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(expressCompanyCode, totalWeight, address.getRegionCode());
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(expressCompanyCode, totalWeight, county.getRegionCode());
|
||||
ExpressOrder expressOrder = new ExpressOrder();
|
||||
expressOrder.setOrderId(buyOrderDetailList.get(0).getOrderId());
|
||||
expressOrder.setExpressFee(expressFee);
|
||||
@@ -272,11 +277,20 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
expressOrder.setTotalWeight(totalWeight);
|
||||
expressOrder.setCommodity(commodityList);
|
||||
expressOrder.setExpressCompanyCode(expressCompanyCode);
|
||||
expressOrder.setName(buyOrder.getShippingUser());
|
||||
expressOrder.setMobile(buyOrder.getUserPhone());
|
||||
expressOrder.setProvince(buyOrder.getProvince());
|
||||
expressOrder.setCity(buyOrder.getCity());
|
||||
expressOrder.setCounty(buyOrder.getDistrict());
|
||||
expressOrder.setAddress(buyOrder.getAddress());
|
||||
// 生成快递面单
|
||||
Map<String, String> result = expressOrderService.placeExpressOrder(address, expressOrder);
|
||||
ExpressOrderResponseVo response = expressOrderService.placeExpressOrder(expressOrder);
|
||||
String expressBillNo = response.getOrder().getLogisticCode();
|
||||
String expressBillTemplate = response.getPrintTemplate();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
buyOrderDetail.setExpressBill(result.get("expressBill"));
|
||||
buyOrderDetail.setExpressBillNo(result.get("expressBillNo"));
|
||||
buyOrderDetail.setExpressBillNo(expressBillNo);
|
||||
buyOrderDetail.setExpressBillTemplate(expressBillTemplate);
|
||||
buyOrderDetail.setExpressCompanyCode(expressCompanyCode);
|
||||
}
|
||||
buyOrderDetailService.saveBatch(buyOrderDetailList);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.HttpClientUtils;
|
||||
import com.peanut.common.utils.KdUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.modules.book.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ExpressOrderRequestVo;
|
||||
import com.peanut.modules.book.vo.ExpressOrderResponseVo;
|
||||
import com.peanut.modules.book.vo.ExpressQueryResponseVo;
|
||||
import com.peanut.modules.book.vo.ExpressUserInfoVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import com.peanut.modules.book.entity.ExpressQueryResponse;
|
||||
import com.peanut.modules.book.service.ExpressOrderService;
|
||||
import com.peanut.modules.book.vo.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -41,18 +37,9 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
@Value("${express.sender.address}")
|
||||
private String senderAddress;
|
||||
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> placeExpressOrder(UserAddress userAddress, ExpressOrder expressOrder) {
|
||||
public ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder) {
|
||||
ExpressOrderRequestVo orderRequestVo = new ExpressOrderRequestVo();
|
||||
// 订单号
|
||||
orderRequestVo.setOrderCode(expressOrder.getOrderId().toString());
|
||||
@@ -74,20 +61,25 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
sender.setExpAreaName(senderExpAreaName);
|
||||
sender.setAddress(senderAddress);
|
||||
// 收货人
|
||||
ExpressUserInfoVo receiver = buildReceiverBasedOnUserAddress(userAddress);
|
||||
ExpressUserInfoVo receiver = new ExpressUserInfoVo();
|
||||
receiver.setName(expressOrder.getName());
|
||||
receiver.setMobile(expressOrder.getMobile());
|
||||
receiver.setProvinceName(expressOrder.getProvince());
|
||||
receiver.setCityName(expressOrder.getCity());
|
||||
receiver.setAddress(expressOrder.getAddress());
|
||||
orderRequestVo.setSender(sender);
|
||||
orderRequestVo.setReceiver(receiver);
|
||||
orderRequestVo.setCommodity(expressOrder.getCommodity());
|
||||
orderRequestVo.setWeight(expressOrder.getTotalWeight().doubleValue());
|
||||
orderRequestVo.setRemark(expressOrder.getRemark());
|
||||
String RequestData = JSONObject.toJSONString(orderRequestVo);
|
||||
String requestData = JSONObject.toJSONString(orderRequestVo);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", RequestData);
|
||||
params.put("RequestData", requestData);
|
||||
params.put("EBusinessID", Constants.EXPRESS_BUSINESS_ID);
|
||||
params.put("RequestType", Constants.EXPRESS_REQUEST_TYPE_PLACE_ORDER);
|
||||
try {
|
||||
String dataSign = KdUtils.encrypt(RequestData, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
String dataSign = KdUtils.encrypt(requestData, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -96,44 +88,29 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
params.put("DataType", "2");
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_PLACE_ORDER_URL, params);
|
||||
ExpressOrderResponseVo responseVo = JSONObject.parseObject(response, ExpressOrderResponseVo.class);
|
||||
String expressBillNo = responseVo.getOrder().getLogisticCode();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("expressBillNo", expressBillNo);
|
||||
result.put("template", responseVo.getPrintTemplate());
|
||||
return result;
|
||||
return responseVo;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressQueryResponseVo queryExpressOrder(String ShipperCode, String LogisticCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ExpressUserInfoVo buildReceiverBasedOnUserAddress(UserAddress userAddress) {
|
||||
ExpressUserInfoVo vo = new ExpressUserInfoVo();
|
||||
vo.setName(userAddress.getConsigneeName());
|
||||
vo.setMobile(userAddress.getConsigneePhone());
|
||||
vo.setAddress(userAddress.getDetailAddress());
|
||||
String regionCode = userAddress.getRegionCode();
|
||||
QueryWrapper<CountyEntity> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", regionCode);
|
||||
CountyEntity county = countyService.getOne(countyQueryWrapper);
|
||||
vo.setExpAreaName(county.getCountyName());
|
||||
String cityRegionCode;
|
||||
if (regionCode.startsWith("11") || regionCode.startsWith("12") || regionCode.startsWith("31") || regionCode.startsWith("50")) {
|
||||
cityRegionCode = regionCode.substring(0, 2).concat("0000");
|
||||
} else {
|
||||
cityRegionCode = regionCode.substring(0, 4).concat("00");
|
||||
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode) {
|
||||
ExpressQueryRequestVo requestVo = new ExpressQueryRequestVo();
|
||||
requestVo.setLogisticCode(logisticCode);
|
||||
requestVo.setShipperCode(shipperCode);
|
||||
String requestData = JSONObject.toJSONString(requestVo);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", requestData);
|
||||
params.put("EBusinessID", Constants.EXPRESS_BUSINESS_ID);
|
||||
params.put("RequestType", Constants.EXPRESS_REQUEST_TYPE_QUERY);
|
||||
try {
|
||||
String dataSign = KdUtils.encrypt(requestData, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
QueryWrapper<CityEntity> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("region_code", cityRegionCode);
|
||||
CityEntity city = cityService.getOne(cityQueryWrapper);
|
||||
vo.setCityName(city.getCityName());
|
||||
String provinceRegionCode = regionCode.substring(0, 2).concat("0000");
|
||||
QueryWrapper<ProvinceEntity> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("region_code", provinceRegionCode);
|
||||
ProvinceEntity province = provinceService.getOne(provinceQueryWrapper);
|
||||
vo.setProvinceName(province.getProvName());
|
||||
return vo;
|
||||
params.put("DateType", "2");
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_QUERY_URL, params);
|
||||
return JSONObject.parseObject(response, ExpressQueryResponse.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.PayWechatOrderDao;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.PayWechatOrderEntity;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.PayWechatOrderService;
|
||||
@@ -35,9 +35,9 @@ public class PayWechatOrderServiceImpl extends ServiceImpl<PayWechatOrderDao, Pa
|
||||
|
||||
@Override
|
||||
public void add(String orderSn, String prepayId) {
|
||||
QueryWrapper<BuyOrderEntity> wrapper = new QueryWrapper<>();
|
||||
QueryWrapper<BuyOrder> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("order_sn", orderSn);
|
||||
BuyOrderEntity buyOrder = buyOrderService.getOne(wrapper);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(wrapper);
|
||||
PayWechatOrderEntity entity = new PayWechatOrderEntity();
|
||||
entity.setCustomerId(buyOrder.getUserId());
|
||||
entity.setCreateTime(new Date());
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import com.peanut.modules.book.entity.Trace;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/17
|
||||
* @CreateTime: 2023/10/18
|
||||
*/
|
||||
@Data
|
||||
public class ExpressQueryResponseVo {
|
||||
/**
|
||||
* 订单详情 ID
|
||||
*/
|
||||
private Long orderDetailId;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 轨迹
|
||||
*/
|
||||
private List<Trace> Traces;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,60 @@ public class ExpressResponseOrderVo {
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String OrderCode;
|
||||
/**
|
||||
* 快递公司代码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 大头笔(官网文档)
|
||||
*/
|
||||
private String MarkDestination;
|
||||
/**
|
||||
* 签回单单号
|
||||
*/
|
||||
private String SignWaybillCode;
|
||||
/**
|
||||
* 始发地区域编码
|
||||
*/
|
||||
private String OriginCode;
|
||||
/**
|
||||
* 事发地名称
|
||||
*/
|
||||
private String OriginName;
|
||||
/**
|
||||
* 目的地区域编码
|
||||
*/
|
||||
private String DestinatioCode;
|
||||
/**
|
||||
* 目的地名称
|
||||
*/
|
||||
private String DestinatioName;
|
||||
/**
|
||||
* 分拣编码
|
||||
*/
|
||||
private String SortingCode;
|
||||
/**
|
||||
* 邮包编码
|
||||
*/
|
||||
private String PackageCode;
|
||||
/**
|
||||
* 集包地
|
||||
*/
|
||||
private String PackageName;
|
||||
/**
|
||||
* 目的地分拨
|
||||
*/
|
||||
private String DestinationAllocationCentre;
|
||||
/**
|
||||
* 配送产品类型
|
||||
*/
|
||||
private String TransType;
|
||||
/**
|
||||
* 运输方式
|
||||
*/
|
||||
private String TransportType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 修改地址 Vo
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/18
|
||||
*/
|
||||
@Data
|
||||
public class ShippingAddressRequestVo {
|
||||
/**
|
||||
* 订单 ID
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 县
|
||||
*/
|
||||
private String county;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 收货人姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String mobile;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -32,5 +32,5 @@ public class UserOrderVo {
|
||||
private String isMerge = "";
|
||||
|
||||
|
||||
public List<BuyOrderEntity> orderList;
|
||||
public List<BuyOrder> orderList;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.peanut.modules.mq.Consumer;
|
||||
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -21,7 +21,7 @@ public class OrderCancelConsumer {
|
||||
|
||||
@RabbitListener(queues = DelayQueueConfig.ORDER_CANCEL_DEAD_LETTER_QUEUE)
|
||||
public void orderConsumer(String orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
BuyOrder buyOrder = buyOrderService.getById(orderId);
|
||||
if(buyOrder == null){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,11 @@ import com.peanut.modules.pay.IOSPay.model.entities.IosPayOrderEntity;
|
||||
|
||||
import com.peanut.modules.pay.IOSPay.service.IapVerifyReceiptService;
|
||||
import com.peanut.modules.pay.IOSPay.service.OrderService;
|
||||
import com.peanut.modules.pay.IOSPay.vo.FailureVo;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.math.BigDecimal;
|
||||
@@ -88,7 +86,7 @@ public class AppController {
|
||||
return Result.error("凭证不能为空");
|
||||
|
||||
IapResponseDTO receipt = iapVerifyReceiptService.verifyIapReceipt(dto.getReceiptData(), dto.isSandBox());
|
||||
BuyOrderEntity order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
|
||||
BuyOrder order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
|
||||
order2.setPaymentDate(new Date());
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.peanut.modules.pay.IOSPay.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.pay.IOSPay.model.dto.IapRequestDTO;
|
||||
import com.peanut.modules.pay.IOSPay.model.entities.IosPayOrderEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.app.service.UserService;
|
||||
import com.peanut.modules.book.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.service.BookBuyConfigService;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
@@ -129,7 +129,7 @@ public class OrderServiceImpl extends ServiceImpl<PayIOSOrderMapper,IosPayOrderE
|
||||
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(null == order.getProductID() ? "0" : order.getProductID()));
|
||||
vo.setRealMoney(null == bookBuyConfigEntity ? "0" : bookBuyConfigEntity.getRealMoney());
|
||||
|
||||
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", order.getOrderid()));
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", order.getOrderid()));
|
||||
if (null != orderEntity) {
|
||||
vo.setPaymentMethod(orderEntity.getPaymentMethod());
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@ import com.peanut.modules.pay.alipay.config.AliPayUtil;
|
||||
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
|
||||
import com.peanut.modules.pay.alipay.service.AliPayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
@@ -74,7 +72,7 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
aliNotifyDto.setCustomerid(payDto.getCustomerId());
|
||||
aliNotifyDto.setRelevanceoid(payDto.getRelevanceoid());
|
||||
payZfbOrderService.save(aliNotifyDto);
|
||||
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn",payDto.getRelevanceoid()).eq("del_flag","0"));
|
||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn",payDto.getRelevanceoid()).eq("del_flag","0"));
|
||||
order.setPaymentDate(new Date());
|
||||
this.buyOrderService.updateById(order);
|
||||
|
||||
@@ -184,7 +182,7 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
if ("order".equals(subject)) {
|
||||
|
||||
System.out.println("=====到order更新字段==================================================================================================================");
|
||||
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
|
||||
System.out.println("======orderEntity=========="+orderEntity);
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
System.out.println("======realMoney=========="+realMoney);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ApplePayServiceImpl implements ApplePayService {
|
||||
//如果验证后的订单号与app端传来的订单号一致并且状态为已支付状态则处理自己的业务
|
||||
if (transactionID.equals(transactionId) && "PURCHASED".equals(in_app_ownership_type)) {
|
||||
//===================处理自己的业务 ============================
|
||||
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", transactionId ));
|
||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", transactionId ));
|
||||
PayWechatOrderEntity wechat = new PayWechatOrderEntity();
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public class ApplePayServiceImpl implements ApplePayService {
|
||||
}
|
||||
if ("order".equals(order.getOrderType())) {
|
||||
|
||||
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", wechat.getOrderId()));
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", wechat.getOrderId()));
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
//更新 订单 记录
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ public class WeChatPayController {
|
||||
@RequestMapping(value = "/placeAnOrder/shoppingPay")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R newShoppingPay(@RequestBody WechatPaymentInfo paymentInfo) {
|
||||
QueryWrapper<BuyOrderEntity> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_sn", paymentInfo.getOrderSn());
|
||||
BuyOrderEntity order = buyOrderService.getOne(queryWrapper);
|
||||
BuyOrder order = buyOrderService.getOne(queryWrapper);
|
||||
// 判断订单是否已经过期
|
||||
if (order.getOrderStatus().equals("5")) {
|
||||
return R.error("订单支付超时");
|
||||
@@ -121,10 +121,10 @@ public class WeChatPayController {
|
||||
Map<String, Object> resourceMap = WechatPayValidator.decryptFromResource(resource, wechatPayConfig.getApiV3Key(), 1);
|
||||
String orderNo = resourceMap.get("out_trade_no").toString();
|
||||
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
|
||||
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
|
||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||
// 1.根据订单id获取订单信息
|
||||
if ("order".equals(order.getOrderType())) {
|
||||
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
|
||||
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
// 查询订单的所有 book_id
|
||||
List<Integer> orderBookIdList = shopProductBookService.getOrderBookId(order.getOrderSn());
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.peanut.modules.book.dao.BuyOrderDao">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.peanut.modules.book.entity.BuyOrderEntity" id="buyOrderMap">
|
||||
<resultMap type="com.peanut.modules.book.entity.BuyOrder" id="buyOrderMap">
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="orderSn" column="order_sn" />
|
||||
<result property="userId" column="user_id" />
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<!-- </resultMap>-->
|
||||
|
||||
<select id="queryListByOrderIds" resultType="com.peanut.modules.book.entity.BuyOrderEntity">
|
||||
<select id="queryListByOrderIds" resultType="com.peanut.modules.book.entity.BuyOrder">
|
||||
select
|
||||
*,
|
||||
buy_order_detail.order_id,
|
||||
|
||||
Reference in New Issue
Block a user