后台功能更新

This commit is contained in:
yan.y 2025-01-06 19:24:56 +08:00
parent 4e81ac3a92
commit 00f9642f2b
19 changed files with 264 additions and 6 deletions

View File

@ -7,6 +7,8 @@ import com.linln.admin.orders.domain.PetGoods;
import com.linln.admin.orders.service.GoodsService;
import com.linln.admin.orders.service.PetGoodsService;
import com.linln.admin.orders.validator.GoodsValid;
import com.linln.admin.users.service.PetBaseInfoService;
import com.linln.admin.users.service.PetService;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.EntityBeanUtil;
import com.linln.common.utils.ResultVoUtil;
@ -39,6 +41,9 @@ public class GoodsController {
@Resource
private PetGoodsService petGoodsService;
@Resource
private PetBaseInfoService petBaseInfoService;
/**
* 列表页面
*/
@ -91,8 +96,12 @@ public class GoodsController {
petList.add(cat);
PetBaseInfo dog = new PetBaseInfo();
dog.setPetType(2);
List<PetBaseInfo> catPetBaseList = petBaseInfoService.findPetBaseList(1);
List<PetBaseInfo> dogPetBaseList = petBaseInfoService.findPetBaseList(2);
model.addAttribute("goods", goods);
model.addAttribute("petList", petList);
model.addAttribute("cats", catPetBaseList);
model.addAttribute("dogs", dogPetBaseList);
return "/orders/goods/goodsToLinkPet";
}
@ -106,16 +115,19 @@ public class GoodsController {
int petType = goods.getPetType();
int catWeight = goods.getCatWeight() == null ? 0 : goods.getCatWeight();
int dogWeight = goods.getDogWeight() == null ? 0 : goods.getDogWeight();
int catPzId = goods.getCatWeight() == null ? 0 : goods.getCatPz();
int dogPzId = goods.getDogWeight() == null ? 0 : goods.getDogPz();
int hair = goods.getHair();
goods = goodsService.getById(goods.getId());
PetGoods petGoods = new PetGoods();
petGoods.setAssortment(0);
petGoods.setSize(0);
petGoods.setPetType(petType);
if (petType == 1) {
petGoods.setWeight(catWeight);
petGoods.setAssortment(catPzId);
} else {
petGoods.setWeight(dogWeight);
petGoods.setAssortment(dogPzId);
}
petGoods.setHair(hair);
petGoods.setGoodsId(goods.getId());

View File

@ -70,6 +70,24 @@ public class OrderMainController {
model.addAttribute("page", list);
return "/orders/orderMain/index";
}
/**
* 列表页面
*/
@GetMapping("/pay/index")
@RequiresPermissions("orders:orderMain:index")
public String payIndex(Model model, PayOrder payOrder) {
// 创建匹配器进行动态查询匹配
ExampleMatcher matcher = ExampleMatcher.matching();
// 获取数据列表
Example<PayOrder> example = Example.of(payOrder, matcher);
Page<PayOrder> list = orderMainService.getPayOrderPageList(example);
// 封装数据
model.addAttribute("list", list.getContent());
model.addAttribute("page", list);
return "/orders/pay/index";
}
/**
* 跳转到添加页面

View File

@ -63,5 +63,9 @@ public class Goods implements Serializable {
@Transient
private Integer catWeight;
@Transient
private Integer catPz;
@Transient
private Integer dogWeight;
@Transient
private Integer dogPz;
}

View File

@ -31,6 +31,8 @@ public class OrderMain implements Serializable {
private Long id;
// 订单ID
private String orderId;
// 支付订单ID
private String payOrderId;
// 用户ID
private Long uid;
// 订单状态
@ -108,6 +110,8 @@ public class OrderMain implements Serializable {
private Long addrId;
@Transient
private String addr;
@Transient
private String payDj;
public OrderMain() {
}

View File

@ -0,0 +1,56 @@
package com.linln.admin.orders.domain;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import lombok.Data;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @author gion
* @date 2024/04/29
*/
@Data
@Entity
@Table(name="pay_orders")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class PayOrder implements Serializable {
// 主键ID
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
// 订单ID
private String orderId;
// 订单名称
private String orderName;
//订单价格
private Double orderPrice;
//订单状态
private Byte orderStatus;
//三方支付ID
private String payId;
//充值ID
private Integer rechargeId;
//用户ID
private Long uid;
// 订单创建时间
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
// 订单更新时间
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@CreatedDate
private Date createDate;
@LastModifiedDate
private Date updateDate;
// 数据状态
private Byte status = StatusEnum.OK.getCode();
}

View File

@ -29,7 +29,7 @@ public class PetBaseInfo implements Serializable {
private Long id;
// 宠物类型
private Integer petType;
// 宠物名称
// 宠物品种
private String assortment;
// 长毛短毛 1长毛 2短毛
private Integer hair;

View File

@ -28,6 +28,9 @@ public class PetGoods implements Serializable {
private Long id;
// 品种ID
private Integer assortment;
//品种描述
@Transient
private String assortmentDesc;
// 宠物类型
private Integer petType;
// 宠物体重

View File

@ -0,0 +1,15 @@
package com.linln.admin.orders.repository;
import com.linln.admin.orders.domain.CarOrder;
import com.linln.admin.orders.domain.PayOrder;
import com.linln.modules.system.repository.BaseRepository;
/**
* @author gion
* @date 2024/04/29
*/
public interface PayOrderRepository extends BaseRepository<PayOrder, Long> {
PayOrder getPayOrdersByOrderId(String orderId);
}

View File

@ -3,9 +3,14 @@ package com.linln.admin.orders.repository;
import com.linln.admin.orders.domain.PetBaseInfo;
import com.linln.modules.system.repository.BaseRepository;
import java.util.List;
/**
* @author gion
* @date 2024/04/29
*/
public interface PetBaseInfoRepository extends BaseRepository<PetBaseInfo, Long> {
List<PetBaseInfo> findAllByPetType(Integer petType);
}

View File

@ -1,9 +1,6 @@
package com.linln.admin.orders.service;
import com.linln.admin.orders.domain.Car;
import com.linln.admin.orders.domain.OrderDetail;
import com.linln.admin.orders.domain.OrderMain;
import com.linln.admin.orders.domain.OrderSub;
import com.linln.admin.orders.domain.*;
import com.linln.common.enums.StatusEnum;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
@ -25,6 +22,7 @@ public interface OrderMainService {
* @return 返回分页数据
*/
Page<OrderMain> getPageList(Example<OrderMain> example);
Page<PayOrder> getPayOrderPageList(Example<PayOrder> example);
/**
* 根据ID查询数据

View File

@ -60,6 +60,9 @@ public class OrderMainServiceImpl implements OrderMainService {
@Resource
private UsersAmountRecordsService usersAmountRecordsService;
@Resource
private PayOrderRepository payOrderRepository;
/**
* 根据ID查询数据
* @param id 主键ID
@ -96,6 +99,13 @@ public class OrderMainServiceImpl implements OrderMainService {
return orderMainPage;
}
@Override
public Page<PayOrder> getPayOrderPageList(Example<PayOrder> example) {
// 创建分页对象
PageRequest page = PageSort.pageRequest("createTime", Sort.Direction.DESC);
return payOrderRepository.findAll(example, page);
}
private void getOrderMainInfo(OrderMain orderMain) {
if (StrUtil.isNotBlank(orderMain.getPetInfos())) {
return;
@ -158,6 +168,23 @@ public class OrderMainServiceImpl implements OrderMainService {
}
orderMain.setVipDiscountAmount(Math.max(vipDiscountAmount, 0));
}
if (orderMain.getPayOrderId() != null) {
PayOrder payOrder = payOrderRepository.getPayOrdersByOrderId(orderMain.getOrderId());
if (payOrder != null) {
if (payOrder.getOrderStatus() == 1) {
orderMain.setPayDj("已支付");
} else if (payOrder.getOrderStatus() == 2) {
orderMain.setPayDj("已退款");
} else {
orderMain.setPayDj("未支付");
}
} else {
orderMain.setPayDj("未支付");
}
} else {
orderMain.setPayDj("未支付");
}
orderMain.setGoodsDiscountAmount(couponsOriginPrice * 10 - orderSubs.stream().map(OrderSub::getGoodsDiscountAmount).reduce(0, Integer::sum));
orderMain.setUserServiceAddr("姓名:" + userServiceAddr.getName() + "<br>联系电话:" + userServiceAddr.getMobile() + "<br>地址:" + userServiceAddr.getAddr());
}

View File

@ -47,6 +47,7 @@ public class PetGoodsServiceImpl implements PetGoodsService {
Page<PetGoods> petGoodsPage = petGoodsRepository.findAll(example, page);
List<PetGoods> content = petGoodsPage.getContent();
for (PetGoods petGoods : content) {
petGoods.setAssortmentDesc(petGoods.getAssortment() == 0 ? "" : InitLoadDataService.PET_BASE_INFO_MAP.get(Long.parseLong(petGoods.getAssortment().toString())).getAssortment());
petGoods.setGoods(InitLoadDataService.GOODS_MAP.get(petGoods.getGoodsId()));
}
return petGoodsPage;

View File

@ -21,6 +21,8 @@ public interface PetBaseInfoService {
*/
Page<PetBaseInfo> getPageList(Example<PetBaseInfo> example);
List<PetBaseInfo> findPetBaseList(Integer petType);
/**
* 根据ID查询数据
* @param id 主键ID

View File

@ -47,6 +47,11 @@ public class PetBaseInfoServiceImpl implements PetBaseInfoService {
return petBaseInfoRepository.findAll(example, page);
}
@Override
public List<PetBaseInfo> findPetBaseList(Integer petType) {
return petBaseInfoRepository.findAllByPetType(petType);
}
/**
* 保存数据
* @param petBaseInfo 实体对象

View File

@ -51,6 +51,24 @@
</select>
</div>
</div>
<div class="layui-form-item" id="catPz">
<label class="layui-form-label">宠物品种</label>
<div class="layui-input-inline">
<select class="timo-search-select" name="catPz" mo-selected="0">
<option value="0"></option>
<option th:each="c,PetBaseInfo:${cats}" th:value="${c.id}" th:text="${c.assortment}"></option>
</select>
</div>
</div>
<div class="layui-form-item" id="dogPz" style="display: none">
<label class="layui-form-label">宠物品种</label>
<div class="layui-input-inline">
<select class="timo-search-select" name="dogPz" o-selected="0">
<option value="0"></option>
<option th:each="c,PetBaseInfo:${dogs}" th:value="${c.id}" th:text="${c.assortment}"></option>
</select>
</div>
</div>
<div class="layui-form-item timo-finally">
<button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
<button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
@ -67,10 +85,14 @@
var petType = data.value
if (petType === "1") {
$("#catWeight").show()
$("#catPz").show()
$("#dogWeight").hide()
$("#dogPz").hide()
} else {
$("#catWeight").hide()
$("#catPz").hide()
$("#dogWeight").show()
$("#dogPz").show()
}
});
});

View File

@ -81,6 +81,7 @@
<th>洗护时长</th>
<th>付款状态</th>
<th>支付类型</th>
<th>定金付款状态</th>
<th>总金额</th>
<th>支付金额</th>
<th>会员折扣金额</th>
@ -89,6 +90,7 @@
<th>优惠券ID</th>
<th>优惠券名称</th>
<th>订单ID</th>
<th>支付订单号</th>
</tr>
</thead>
<tbody>
@ -114,6 +116,7 @@
<td th:text="${item.projectionServiceTime}">洗护时长</td>
<td th:text="${#dicts.payStatus(item.payStatus)}">付款状态</td>
<td th:text="${#dicts.payType(item.payType)}">支付类型</td>
<td th:text="${item.payDj}">定金付款状态</td>
<td th:text="${item.totalAmount}">总金额</td>
<td th:text="${item.payAmount / 10.0}">支付金额</td>
<td th:text="${item.vipDiscountAmount / 10.0}">会员折扣金额</td>
@ -122,6 +125,7 @@
<td th:text="${item.ucid}">优惠券ID</td>
<td th:text="${item.coupons?.name}">优惠券名称</td>
<td th:text="${item.orderId}">订单ID</td>
<td th:text="${item.payOrderId}">支付订单号</td>
<!--<td>
<a class="open-popup" data-title="编辑订单" th:attr="data-url=@{'/orders/orderMain/edit/'+${item.id}}" data-size="auto" href="#">编辑</a>

View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
>
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body class="timo-layout-page">
<div class="layui-card">
<div class="layui-card-header timo-card-header">
<span><i class="fa fa-bars"></i> 支付订单管理</span>
<i class="layui-icon layui-icon-refresh refresh-btn"></i>
</div>
<div class="layui-card-body">
<div class="layui-row timo-card-screen">
<div class="pull-left layui-form-pane timo-search-box">
<div class="layui-form timo-compile layui-form-item">
<!--<label class="layui-form-label">状态</label>
<div class="layui-input-block timo-search-status">
<select class="timo-search-select" name="status" mo:dict="SEARCH_STATUS"
mo-selected="${param.status}"></select>
</div>-->
<label class="layui-form-label">订单ID</label>
<div class="layui-input-block">
<input type="text" name="orderId" th:value="${param.orderId}" placeholder="请输入订单ID"
autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">用户ID</label>
<div class="layui-input-block">
<input type="text" name="uid" th:value="${param.uid}" placeholder="请输入用户ID"
autocomplete="off" class="layui-input">
</div>
<button class="layui-btn timo-search-btn">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
<div class="timo-table-wrap">
<table class="layui-table timo-table">
<thead>
<tr>
<th>订单ID</th>
<th>用户ID</th>
<th>订单名称</th>
<th>订单金额</th>
<th>订单状态</th>
<th>支付ID</th>
<th>充值商品ID</th>
<th>创建时间</th>
</tr>
</thead>
<tbody>
<tr th:each="item:${list}">
<td th:text="${item.orderId}">订单ID</td>
<td th:text="${item.uid}">用户ID</td>
<td th:text="${item.orderName}">订单名称</td>
<td th:text="${item.orderStatus == 3 ? item.orderPrice / 10.0 : item.orderPrice}">订单金额</td>
<td th:text="${#dicts.payOrderStatus(item.orderStatus)}">订单状态</td>
<td th:text="${item.payId}">订单名称</td>
<td th:text="${item.rechargeId}">充值商品ID</td>
<td th:text="${item.createTime}">订单创建时间</td>
</tr>
</tbody>
</table>
</div>
<div th:replace="/common/fragment :: page"></div>
</div>
</div>
<script th:replace="/common/template :: script"></script>
</body>
</html>

View File

@ -43,6 +43,7 @@
<i class="layui-icon layui-icon-ok"></i></label>
</th>
<th>id</th>
<th>宠物品种</th>
<th>宠物类型</th>
<th>宠物体重</th>
<th>宠物毛发</th>
@ -59,6 +60,7 @@
<td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
<i class="layui-icon layui-icon-ok"></i></label></td>
<td th:text="${item.id}">id</td>
<td th:text="${item.assortmentDesc}">宠物品种</td>
<td th:text="${#dicts.petType(item.petType)}">宠物类型</td>
<td th:if="${item.petType == 1}" th:text="${#dicts.petCatWeight(item.weight)}">宠物体重</td>
<td th:if="${item.petType == 2}" th:text="${#dicts.petDogWeight(item.weight)}">宠物体重</td>

View File

@ -242,6 +242,14 @@ public class DictUtil {
String label = "USER_COUPONS_STATUS";
return DictUtil.keyValue(label, String.valueOf(status));
}
/**
* 封装数据状态字典
* @param status 状态
*/
public static String payOrderStatus(Byte status){
String label = "PAY_ORDER_STATUS";
return DictUtil.keyValue(label, String.valueOf(status));
}
/**
* 清除缓存中指定的数据