2025008071805

This commit is contained in:
张潘 2025-08-11 18:57:41 +08:00
parent 514248dae7
commit 76464fd668
4 changed files with 1148 additions and 20 deletions

View File

@ -73,6 +73,7 @@ public class GoodsOrderController extends BaseController
startPage(); startPage();
List<GoodsOrder> list = goodsOrderService.selectGoodsOrdergrouBymAIDList(goodsOrder); List<GoodsOrder> list = goodsOrderService.selectGoodsOrdergrouBymAIDList(goodsOrder);
for(GoodsOrder goodsOrderdata:list){ for(GoodsOrder goodsOrderdata:list){
goodsOrderdata.setOrderId(goodsOrderdata.getMainOrderId());
ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId()); ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId());
if(serviceGoods!=null){ if(serviceGoods!=null){
@ -459,26 +460,36 @@ public class GoodsOrderController extends BaseController
return error("快递公司不存在"); return error("快递公司不存在");
} }
// 更新订单信息 // // 更新订单信息
existingOrder.setDeliveryId(goodsOrder.getDeliveryId()); // existingOrder.setDeliveryId(goodsOrder.getDeliveryId());
existingOrder.setDeliveryNum(goodsOrder.getDeliveryNum()); // existingOrder.setDeliveryNum(goodsOrder.getDeliveryNum());
existingOrder.setSendTime(goodsOrder.getSendTime()); // existingOrder.setSendTime(goodsOrder.getSendTime());
existingOrder.setStatus(3L); // 设置为已发货状态 // existingOrder.setStatus(3L); // 设置为已发货状态
if (goodsOrder.getMark() != null && !goodsOrder.getMark().trim().isEmpty()) { // if (goodsOrder.getMark() != null && !goodsOrder.getMark().trim().isEmpty()) {
existingOrder.setMark(goodsOrder.getMark()); // existingOrder.setMark(goodsOrder.getMark());
// }
GoodsOrder updatedOrder = new GoodsOrder();
updatedOrder.setMainOrderId(existingOrder.getMainOrderId());
List<GoodsOrder> goodsOrderList = goodsOrderService.selectGoodsOrderList(updatedOrder);
int count = 0;
for (GoodsOrder goodsOrderdata : goodsOrderList) {
goodsOrderdata.setDeliveryId(goodsOrder.getDeliveryId());
goodsOrderdata.setDeliveryNum(goodsOrder.getDeliveryNum());
goodsOrderdata.setSendTime(goodsOrder.getSendTime());
goodsOrderdata.setStatus(3L); // 设置为已发货状态
count+= goodsOrderService.updateGoodsOrder(goodsOrderdata);
} }
// 更新订单 // 更新订单
int result = goodsOrderService.updateGoodsOrder(existingOrder);
if (result > 0) {
if (count > 0) {
// 添加发货日志 // 添加发货日志
JSONObject logData = new JSONObject(); JSONObject logData = new JSONObject();
logData.put("wlgs", siteDelivery.getTitle()); logData.put("wlgs", siteDelivery.getTitle());
logData.put("wldh", goodsOrder.getDeliveryNum()); logData.put("wldh", goodsOrder.getDeliveryNum());
OrderUtil.addgoodsorderlog( OrderUtil.addgoodsorderlog(
existingOrder.getId(), existingOrder.getId(),
existingOrder.getOrderId(), existingOrder.getMainOrderId(),
"订单已发货", "订单已发货",
"2", "2",
logData, logData,

View File

@ -237,13 +237,32 @@ public class OrderController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:Order:query')") @PreAuthorize("@ss.hasPermi('system:Order:query')")
@GetMapping("/receive-records/{orderId}") @GetMapping("/receive-records/{orderId}")
public AjaxResult getReceiveRecords(@PathVariable("orderId") String orderId) { public AjaxResult getReceiveRecords(@PathVariable("orderId") String orderId) {
System.out.println("=== 获取接单记录 ===");
System.out.println("订单ID: " + orderId);
List<OrderLog> list = orderLogService.selectOrderLogByOrderId(orderId); List<OrderLog> list = orderLogService.selectOrderLogByOrderId(orderId);
System.out.println("查询到的日志记录数量: " + (list != null ? list.size() : "null"));
if (list != null && !list.isEmpty()) {
System.out.println("第一条记录: " + list.get(0));
for (OrderLog orderLogdata : list) { for (OrderLog orderLogdata : list) {
System.out.println("处理日志记录: ID=" + orderLogdata.getId() + ", 标题=" + orderLogdata.getTitle());
if (orderLogdata.getWorkerId() != null) {
Users users = usersService.selectUsersById(orderLogdata.getWorkerId()); Users users = usersService.selectUsersById(orderLogdata.getWorkerId());
if (users != null) { if (users != null) {
orderLogdata.setWorkerName(users.getName()); orderLogdata.setWorkerName(users.getName());
System.out.println("设置师傅姓名: " + users.getName());
} else {
System.out.println("未找到师傅信息workerId: " + orderLogdata.getWorkerId());
}
} else {
System.out.println("日志记录没有师傅ID");
} }
} }
} else {
System.out.println("没有找到订单日志记录");
}
return success(list); return success(list);
} }
@ -407,4 +426,16 @@ public class OrderController extends BaseController {
List<Users> list = usersService.selectUsersList(users); List<Users> list = usersService.selectUsersList(users);
return getDataTable(list); return getDataTable(list);
} }
/**
* 获取所有工人列表用于订单处理
*/
@PreAuthorize("@ss.hasPermi('system:Order:edit')")
@GetMapping("/getWorkerList")
public AjaxResult getWorkerList() {
Users users = new Users();
users.setType("2"); // 工人类型
List<Users> list = usersService.selectUsersList(users);
return AjaxResult.success(list);
}
} }

View File

@ -105,6 +105,7 @@ public class CartOrderUtil {
order.setDeduction(BigDecimal.ZERO); order.setDeduction(BigDecimal.ZERO);
order.setBigtype(serviceGoods.getServicetype()); order.setBigtype(serviceGoods.getServicetype());
order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单 order.setReceiveType(Long.valueOf(dispatchtype)); // 自由抢单
int insertResult = orderService.insertOrder(order); int insertResult = orderService.insertOrder(order);
if (insertResult <= 0) { if (insertResult <= 0) {
result.put("success", false); result.put("success", false);
@ -210,7 +211,7 @@ public class CartOrderUtil {
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put("name", "订单创建成功"); jsonObject.put("name", "订单创建成功");
//添加记录日志Long oid,String orderId,String title,String type,String content,Long ordertype //添加记录日志Long oid,String orderId,String title,String type,String content,Long ordertype
OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L); OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getMainOrderId(),"订单生成","1",jsonObject,2L);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
@ -274,6 +275,7 @@ public class CartOrderUtil {
goodsOrder.setPayPrice(itemPrice); goodsOrder.setPayPrice(itemPrice);
goodsOrder.setStatus(1L); // 待支付 goodsOrder.setStatus(1L); // 待支付
goodsOrder.setMainOrderId(maincorid); goodsOrder.setMainOrderId(maincorid);
//goodsOrder.setIsmany(1L);
int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder); int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder);
if (insertResult <= 0) { if (insertResult <= 0) {
result.put("success", false); result.put("success", false);
@ -284,11 +286,11 @@ public class CartOrderUtil {
result.put("orderId", goodsOrder.getOrderId()); result.put("orderId", goodsOrder.getOrderId());
result.put("productName", serviceGoods.getTitle()); result.put("productName", serviceGoods.getTitle());
result.put("allprice", itemPrice.toString()); result.put("allprice", itemPrice.toString());
PayBeforeUtil payBeforeUtil = new PayBeforeUtil(); // PayBeforeUtil payBeforeUtil = new PayBeforeUtil();
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put("name", "订单创建成功"); jsonObject.put("name", "订单创建成功");
OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L); //OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L);
String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, goodsOrder.getOrderId(), null, goodsOrder.getProductId(), 11L, goodsOrder.getSku(), null, null, null, null,2L, null, null); //String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, goodsOrder.getOrderId(), null, goodsOrder.getProductId(), 11L, goodsOrder.getSku(), null, null, null, null,2L, null, null);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
logger.error("商品类购物车下单异常:", e); logger.error("商品类购物车下单异常:", e);
@ -297,4 +299,82 @@ public class CartOrderUtil {
return result; return result;
} }
} }
// /**
// * 商品类购物车下单
// * @param user 用户
// * @param cart 购物车
// * @param serviceGoods 商品
// * @param userAddress 地址
// * @param goodsOrderService 商品订单service
// * @return 下单结果Map
// */
// public static Map<String, Object> createGoodsOrderFromCartMain(Users user, GoodsCart cart, ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid,Long isself) {
// Map<String, Object> result = new HashMap<>();
// try {
// BigDecimal itemPrice=BigDecimal.ZERO;
// String skuStr = cart.getSku();
// if (skuStr != null && !skuStr.trim().isEmpty()) {
// try {
// JSONObject skuJson = JSONObject.parseObject(skuStr);
// if (skuJson.containsKey("price")) {
// BigDecimal skuPrice = new BigDecimal(skuJson.getString("price"));
// itemPrice = skuPrice.multiply(BigDecimal.valueOf(cart.getGoodNum()));
// } else {
// // 没有price字段回退用商品price
// itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(cart.getGoodNum()));
// }
// } catch (Exception e) {
// // 解析失败回退用商品price
// itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(cart.getGoodNum()));
// }
// } else {
// // sku为空直接用商品price
// itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(cart.getGoodNum()));
// }
// GoodsOrder goodsOrder = new GoodsOrder();
// goodsOrder.setType(2);
// goodsOrder.setOrderId(GenerateCustomCode.generCreateOrder("B"));
// goodsOrder.setUid(user.getId());
// goodsOrder.setUname(user.getName());
// goodsOrder.setProductId(serviceGoods.getId());
// goodsOrder.setProductName(serviceGoods.getTitle());
// goodsOrder.setNum(cart.getGoodNum());
// goodsOrder.setSku(cart.getSku());
// goodsOrder.setIsforservice(serviceGoods.getIsforservice());
// goodsOrder.setForserviceid(serviceGoods.getForserviceid());
// goodsOrder.setMark(cart.getReamk());
// goodsOrder.setIsself(isself);
// goodsOrder.setAddressId(userAddress.getId());
// goodsOrder.setName(userAddress.getName());
// goodsOrder.setPhone(userAddress.getPhone());
// goodsOrder.setAddress(userAddress.getAddressInfo());
// goodsOrder.setTotalPrice(itemPrice);
// goodsOrder.setGoodPrice(serviceGoods.getPrice());
// goodsOrder.setPayPrice(itemPrice);
// goodsOrder.setStatus(1L); // 待支付
// goodsOrder.setMainOrderId(maincorid);
// goodsOrder.setIsmany(1L);
// int insertResult = goodsOrderService.insertGoodsOrder(goodsOrder);
// if (insertResult <= 0) {
// result.put("success", false);
// result.put("msg", "商品订单创建失败");
// return result;
// }
// result.put("success", true);
// result.put("orderId", goodsOrder.getOrderId());
// result.put("productName", serviceGoods.getTitle());
// result.put("allprice", itemPrice.toString());
// PayBeforeUtil payBeforeUtil = new PayBeforeUtil();
// com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
// jsonObject.put("name", "订单创建成功");
// OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单生成","1",jsonObject,2L);
// String payBeforeId = payBeforeUtil.createPayBefore(user, itemPrice, goodsOrder.getOrderId(), null, goodsOrder.getProductId(), 11L, goodsOrder.getSku(), null, null, null, null,2L, null, null);
// return result;
// } catch (Exception e) {
// logger.error("商品类购物车下单异常:", e);
// result.put("success", false);
// result.put("msg", "商品类购物车下单异常:" + e.getMessage());
// return result;
// }
// }
} }

File diff suppressed because it is too large Load Diff