202506211807
This commit is contained in:
parent
266742ca2d
commit
395170f9b4
|
|
@ -7,6 +7,18 @@
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.9</version>
|
<version>3.8.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>21</source>
|
||||||
|
<target>21</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>ruoyi-system</artifactId>
|
<artifactId>ruoyi-system</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -134,8 +135,6 @@ public class AppletController extends BaseController {
|
||||||
private IGoodsOrderCursorService goodsOrderCursorService;
|
private IGoodsOrderCursorService goodsOrderCursorService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 创建服务订单
|
// * 创建服务订单
|
||||||
// *
|
// *
|
||||||
|
|
@ -1194,6 +1193,7 @@ public class AppletController extends BaseController {
|
||||||
// return error("查询商品详情失败:" + e.getMessage());
|
// return error("查询商品详情失败:" + e.getMessage());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务商品详细信息
|
* 获取服务商品详细信息
|
||||||
*
|
*
|
||||||
|
|
@ -1235,6 +1235,7 @@ public class AppletController extends BaseController {
|
||||||
return AppletControllerUtil.appletError("查询商品详情失败:" + e.getMessage());
|
return AppletControllerUtil.appletError("查询商品详情失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取广告图片列表
|
* 获取广告图片列表
|
||||||
*
|
*
|
||||||
|
|
@ -1478,8 +1479,14 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其他业务字段
|
// 其他业务字段
|
||||||
userInfo.put("commission","0.00");
|
//userInfo.put("commission","0.00");
|
||||||
//userInfo.put("commission", user.getCommission().toString() != null ? user.getCommission().toString() : "0.00");
|
if (user.getType().equals("2")) {
|
||||||
|
userInfo.put("commission", user.getCommission().toString() != null ? user.getCommission().toString() : "0.00");
|
||||||
|
userInfo.put("total_comm", user.getTotalComm().toString() != null ? user.getTotalComm().toString() : "0.00");
|
||||||
|
userInfo.put("propose", user.getPropose().toString() != null ? user.getPropose().toString() : "0.00");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
userInfo.put("integral", user.getIntegral() != null ? user.getIntegral() : 0);
|
userInfo.put("integral", user.getIntegral() != null ? user.getIntegral() : 0);
|
||||||
userInfo.put("is_stop", user.getIsStop() != null ? user.getIsStop() : 1);
|
userInfo.put("is_stop", user.getIsStop() != null ? user.getIsStop() : 1);
|
||||||
userInfo.put("job_number", user.getJobNumber());
|
userInfo.put("job_number", user.getJobNumber());
|
||||||
|
|
@ -1490,11 +1497,11 @@ public class AppletController extends BaseController {
|
||||||
userInfo.put("openid", user.getOpenid());
|
userInfo.put("openid", user.getOpenid());
|
||||||
userInfo.put("prohibit_time", user.getProhibitTime());
|
userInfo.put("prohibit_time", user.getProhibitTime());
|
||||||
userInfo.put("prohibit_time_str", null);
|
userInfo.put("prohibit_time_str", null);
|
||||||
userInfo.put("propose", user.getPropose().toString() != null ? user.getPropose().toString() : "0.00");
|
|
||||||
userInfo.put("remember_token", user.getRememberToken());
|
userInfo.put("remember_token", user.getRememberToken());
|
||||||
userInfo.put("status", user.getStatus() != null ? user.getStatus() : 1);
|
userInfo.put("status", user.getStatus() != null ? user.getStatus() : 1);
|
||||||
userInfo.put("tpd", 0); // 默认值
|
userInfo.put("tpd", 0); // 默认值
|
||||||
userInfo.put("total_comm","0.00");
|
// userInfo.put("total_comm","0.00");
|
||||||
// userInfo.put("total_comm", user.getTotalComm().toString() != null ? user.getTotalComm().toString() : "0.00");
|
// userInfo.put("total_comm", user.getTotalComm().toString() != null ? user.getTotalComm().toString() : "0.00");
|
||||||
userInfo.put("total_integral", user.getTotalIntegral() != null ? user.getTotalIntegral() : 100);
|
userInfo.put("total_integral", user.getTotalIntegral() != null ? user.getTotalIntegral() : 100);
|
||||||
userInfo.put("type", user.getType() != null ? user.getType().toString() : "1");
|
userInfo.put("type", user.getType() != null ? user.getType().toString() : "1");
|
||||||
|
|
@ -2368,6 +2375,7 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户优惠券列表
|
* 查询用户优惠券列表
|
||||||
*
|
*
|
||||||
|
|
@ -2377,117 +2385,192 @@ public class AppletController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/coupon/my/lst")
|
@PostMapping("/api/coupon/my/lst")
|
||||||
public AjaxResult getMyCouponList(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
public AjaxResult getMyCouponList(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
try {
|
|
||||||
// 1. 验证用户登录状态
|
// 3. 验证用户登录状态
|
||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
if (!(Boolean) userValidation.get("valid")) {
|
if (!(Boolean) userValidation.get("valid")) {
|
||||||
return error("用户未登录或token无效");
|
return error("用户未登录或token无效");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取用户信息
|
// 4. 获取用户信息
|
||||||
Users user = (Users) userValidation.get("user");
|
Users user = (Users) userValidation.get("user");
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return error("用户信息获取失败");
|
return error("用户信息获取失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 解析查询参数
|
Long userId = user.getId(); // 获取当前用户id
|
||||||
Long status = parseParamToLong(params.get("status"), "状态参数格式错误");
|
Integer status = params.get("status") != null ? Integer.parseInt(params.get("status").toString()) : null;
|
||||||
Long productId = parseParamToLong(params.get("product_id"), "商品ID参数格式错误");
|
String productId = params.get("product_id") != null ? params.get("product_id").toString() : null;
|
||||||
Integer price = parseParamToInteger(params.get("price"), "价格参数格式错误");
|
BigDecimal totalPrice = params.get("price") != null ? new BigDecimal(params.get("price").toString()) : null;
|
||||||
|
// 过期的优惠券标记为已过期
|
||||||
|
CouponUser couponUser = new CouponUser();
|
||||||
|
couponUser.setStatus(1L);
|
||||||
|
couponUser.setUid(user.getId());
|
||||||
|
List<CouponUser> couponUserList = couponUserService.selectCouponUserNoList(couponUser);
|
||||||
|
for (CouponUser c: couponUserList){
|
||||||
|
c.setStatus(3L);
|
||||||
|
couponUserService.updateCouponUser(c);
|
||||||
|
}
|
||||||
|
//安状态进行赋值
|
||||||
|
//待领取优惠券
|
||||||
|
if (status==4){
|
||||||
|
Coupons coupons = new Coupons();
|
||||||
|
coupons.setSearchValue("12");
|
||||||
|
List<Coupons> couponsList = couponsService.selectCouponsList(coupons);
|
||||||
|
if (!couponsList.isEmpty()){
|
||||||
|
return AppletControllerUtil.appletSuccess(AppletControllerUtil.buildCouponDataList(couponsList,serviceCateService,serviceGoodsService));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
CouponUser couponUserData = new CouponUser();
|
||||||
|
couponUserData.setStatus(Long.valueOf(status));
|
||||||
|
couponUserData.setUid(user.getId());
|
||||||
|
// if (productIdStr!=null){
|
||||||
|
// couponUserData.setProductId(productIdStr);
|
||||||
|
// }
|
||||||
|
// if (totalPrice!=null){
|
||||||
|
// couponUserData.setMinPrice(totalPrice);
|
||||||
|
// }
|
||||||
|
|
||||||
// 4. 查询用户的所有优惠券
|
// List<CouponUser> couponUserList,
|
||||||
CouponUser couponUserQuery = new CouponUser();
|
// IServiceCateService serviceCateService, IServiceGoodsService serviceGoodsService,Long productId,Long totalPrice
|
||||||
couponUserQuery.setUid(user.getId());
|
|
||||||
List<CouponUser> couponUserList = couponUserService.selectCouponUserList(couponUserQuery);
|
|
||||||
|
|
||||||
// 5. 根据状态筛选优惠券
|
List<CouponUser> couponUserDataList = couponUserService.selectCouponUserList(couponUserData);
|
||||||
long currentTime = System.currentTimeMillis() / 1000; // 当前时间戳(秒)
|
if (couponUserDataList!=null){
|
||||||
List<CouponUser> filteredList = new ArrayList<>();
|
return AppletControllerUtil.appletSuccess(AppletControllerUtil.buildCouponUserList(couponUserDataList,serviceCateService,serviceGoodsService,productId,totalPrice));
|
||||||
|
|
||||||
if (status == null) {
|
|
||||||
// 如果未指定状态,返回所有优惠券
|
|
||||||
filteredList = couponUserList;
|
|
||||||
} else if (status == 1L) {
|
|
||||||
// 未使用的优惠券
|
|
||||||
for (CouponUser coupon : couponUserList) {
|
|
||||||
if (coupon.getStatus() != 2L && !isExpired(coupon, currentTime)) {
|
|
||||||
filteredList.add(coupon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (status == 2L) {
|
|
||||||
// 已使用的优惠券
|
|
||||||
for (CouponUser coupon : couponUserList) {
|
|
||||||
if (coupon.getStatus() != null && coupon.getStatus() == 2L) {
|
|
||||||
filteredList.add(coupon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (status == 3L) {
|
|
||||||
// 已过期的优惠券
|
|
||||||
for (CouponUser coupon : couponUserList) {
|
|
||||||
if (isExpired(coupon, currentTime)) {
|
|
||||||
filteredList.add(coupon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (status == 4L) {
|
|
||||||
// 待领取的优惠券 - 只返回手动领取(type=2)且剩余数量大于0的优惠券
|
|
||||||
Coupons couponsQuery = new Coupons();
|
|
||||||
couponsQuery.setStatus(1L); // 启用状态
|
|
||||||
couponsQuery.setType(2L); // 手动领取类型
|
|
||||||
List<Coupons> availableCoupons = couponsService.selectCouponsList(couponsQuery);
|
|
||||||
|
|
||||||
for (Coupons coupon : availableCoupons) {
|
|
||||||
// 检查剩余数量大于0且用户可领取
|
|
||||||
if (coupon.getCount() != null && coupon.getCount() > 0 &&
|
|
||||||
isCouponAvailableToReceive(coupon, user.getId(), currentTime)) {
|
|
||||||
// 创建一个临时的CouponUser对象,包含完整的优惠券信息
|
|
||||||
CouponUser tempCouponUser = new CouponUser();
|
|
||||||
tempCouponUser.setCouponId(coupon.getId());
|
|
||||||
tempCouponUser.setUid(user.getId());
|
|
||||||
tempCouponUser.setStatus(0L); // 待领取状态
|
|
||||||
tempCouponUser.setCouponTitle(coupon.getTitle());
|
|
||||||
tempCouponUser.setCouponPrice(coupon.getPrice() != null ? coupon.getPrice().intValue() : 0);
|
|
||||||
tempCouponUser.setMinPrice(coupon.getMinPrice() != null ? coupon.getMinPrice().longValue() : 0L);
|
|
||||||
tempCouponUser.setCateId(coupon.getCateId());
|
|
||||||
tempCouponUser.setProductId(coupon.getProductId());
|
|
||||||
tempCouponUser.setReceiveType(coupon.getReceiveType() != null ? coupon.getReceiveType().toString() : "1");
|
|
||||||
|
|
||||||
// 设置有效期
|
|
||||||
if (coupon.getCouponTime() != null) {
|
|
||||||
// 如果有固定的有效期天数,计算失效时间
|
|
||||||
long loseTime = currentTime + (coupon.getCouponTime() * 24 * 60 * 60);
|
|
||||||
tempCouponUser.setLoseTime(String.valueOf(loseTime));
|
|
||||||
} else if (coupon.getEndTime() != null) {
|
|
||||||
// 如果有结束时间,使用结束时间作为失效时间
|
|
||||||
tempCouponUser.setLoseTime(String.valueOf(coupon.getEndTime()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredList.add(tempCouponUser);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// 按is_use排序
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 商品ID筛选
|
|
||||||
if (productId != null) {
|
|
||||||
filteredList = filteredList.stream()
|
|
||||||
.filter(coupon -> productId.equals(coupon.getProductId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. 价格筛选
|
|
||||||
List<CouponUser> priceFilteredList = AppletControllerUtil.filterCouponsByPrice(filteredList, price);
|
|
||||||
|
|
||||||
// 8. 使用工具类处理数据格式化
|
|
||||||
List<Map<String, Object>> resultList = AppletControllerUtil.buildCouponUserList(
|
|
||||||
priceFilteredList, serviceCateService);
|
|
||||||
|
|
||||||
return success(resultList);
|
// ... existing code ...
|
||||||
|
// /**
|
||||||
|
// * 查询用户优惠券列表
|
||||||
|
// *
|
||||||
|
// * @param params 请求参数,包含status(优惠券状态)、product_id(指定商品ID)、price(最低价格)
|
||||||
|
// * @param request HTTP请求对象
|
||||||
|
// * @return 返回用户优惠券列表
|
||||||
|
// */
|
||||||
|
// @PostMapping("/api/coupon/my/lst")
|
||||||
|
// public AjaxResult getMyCouponList(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
// try {
|
||||||
|
// // 1. 验证用户登录状态
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
// if (!(Boolean) userValidation.get("valid")) {
|
||||||
|
// return error("用户未登录或token无效");
|
||||||
|
// }
|
||||||
|
|
||||||
} catch (Exception e) {
|
// // 2. 获取用户信息
|
||||||
System.err.println("查询用户优惠券列表异常:" + e.getMessage());
|
// Users user = (Users) userValidation.get("user");
|
||||||
return error("查询优惠券列表失败:" + e.getMessage());
|
// if (user == null) {
|
||||||
}
|
// return error("用户信息获取失败");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// // 3. 解析查询参数
|
||||||
|
// Long status = parseParamToLong(params.get("status"), "状态参数格式错误");
|
||||||
|
// Long productId = parseParamToLong(params.get("product_id"), "商品ID参数格式错误");
|
||||||
|
// Integer price = parseParamToInteger(params.get("price"), "价格参数格式错误");
|
||||||
|
|
||||||
|
// // 4. 查询用户的所有优惠券
|
||||||
|
// CouponUser couponUserQuery = new CouponUser();
|
||||||
|
// couponUserQuery.setUid(user.getId());
|
||||||
|
// List<CouponUser> couponUserList = couponUserService.selectCouponUserList(couponUserQuery);
|
||||||
|
|
||||||
|
// // 5. 根据状态筛选优惠券
|
||||||
|
// long currentTime = System.currentTimeMillis() / 1000; // 当前时间戳(秒)
|
||||||
|
// List<CouponUser> filteredList = new ArrayList<>();
|
||||||
|
|
||||||
|
// if (status == null) {
|
||||||
|
// // 如果未指定状态,返回所有优惠券
|
||||||
|
// filteredList = couponUserList;
|
||||||
|
// } else if (status == 1L) {
|
||||||
|
// // 未使用的优惠券
|
||||||
|
// for (CouponUser coupon : couponUserList) {
|
||||||
|
// if (coupon.getStatus() != 2L && !isExpired(coupon, currentTime)) {
|
||||||
|
// filteredList.add(coupon);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (status == 2L) {
|
||||||
|
// // 已使用的优惠券
|
||||||
|
// for (CouponUser coupon : couponUserList) {
|
||||||
|
// if (coupon.getStatus() != null && coupon.getStatus() == 2L) {
|
||||||
|
// filteredList.add(coupon);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (status == 3L) {
|
||||||
|
// // 已过期的优惠券
|
||||||
|
// for (CouponUser coupon : couponUserList) {
|
||||||
|
// if (isExpired(coupon, currentTime)) {
|
||||||
|
// filteredList.add(coupon);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (status == 4L) {
|
||||||
|
// // 待领取的优惠券 - 只返回手动领取(type=2)且剩余数量大于0的优惠券
|
||||||
|
// Coupons couponsQuery = new Coupons();
|
||||||
|
// couponsQuery.setStatus(1L); // 启用状态
|
||||||
|
// couponsQuery.setType(2L); // 手动领取类型
|
||||||
|
// List<Coupons> availableCoupons = couponsService.selectCouponsList(couponsQuery);
|
||||||
|
|
||||||
|
// for (Coupons coupon : availableCoupons) {
|
||||||
|
// // 检查剩余数量大于0且用户可领取
|
||||||
|
// if (coupon.getCount() != null && coupon.getCount() > 0 &&
|
||||||
|
// isCouponAvailableToReceive(coupon, user.getId(), currentTime)) {
|
||||||
|
// // 创建一个临时的CouponUser对象,包含完整的优惠券信息
|
||||||
|
// CouponUser tempCouponUser = new CouponUser();
|
||||||
|
// tempCouponUser.setCouponId(coupon.getId());
|
||||||
|
// tempCouponUser.setUid(user.getId());
|
||||||
|
// tempCouponUser.setStatus(0L); // 待领取状态
|
||||||
|
// tempCouponUser.setCouponTitle(coupon.getTitle());
|
||||||
|
// tempCouponUser.setCouponPrice(coupon.getPrice() != null ? coupon.getPrice().intValue() : 0);
|
||||||
|
// tempCouponUser.setMinPrice(coupon.getMinPrice() != null ? coupon.getMinPrice().longValue() : 0L);
|
||||||
|
// tempCouponUser.setCateId(coupon.getCateId());
|
||||||
|
// tempCouponUser.setProductId(coupon.getProductId());
|
||||||
|
// tempCouponUser.setReceiveType(coupon.getReceiveType() != null ? coupon.getReceiveType().toString() : "1");
|
||||||
|
|
||||||
|
// // 设置有效期
|
||||||
|
// if (coupon.getCouponTime() != null) {
|
||||||
|
// // 如果有固定的有效期天数,计算失效时间
|
||||||
|
// long loseTime = currentTime + (coupon.getCouponTime() * 24 * 60 * 60);
|
||||||
|
// tempCouponUser.setLoseTime(String.valueOf(loseTime));
|
||||||
|
// } else if (coupon.getEndTime() != null) {
|
||||||
|
// // 如果有结束时间,使用结束时间作为失效时间
|
||||||
|
// tempCouponUser.setLoseTime(String.valueOf(coupon.getEndTime()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// filteredList.add(tempCouponUser);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 6. 商品ID筛选
|
||||||
|
// if (productId != null) {
|
||||||
|
// filteredList = filteredList.stream()
|
||||||
|
// .filter(coupon -> productId.equals(coupon.getProductId()))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 7. 价格筛选
|
||||||
|
// List<CouponUser> priceFilteredList = AppletControllerUtil.filterCouponsByPrice(filteredList, price);
|
||||||
|
|
||||||
|
// // 8. 使用工具类处理数据格式化
|
||||||
|
// List<Map<String, Object>> resultList = AppletControllerUtil.buildCouponUserList(
|
||||||
|
// priceFilteredList, serviceCateService);
|
||||||
|
|
||||||
|
// return success(resultList);
|
||||||
|
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// System.err.println("查询用户优惠券列表异常:" + e.getMessage());
|
||||||
|
// return error("查询优惠券列表失败:" + e.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析参数为Long类型
|
* 解析参数为Long类型
|
||||||
|
|
@ -3127,9 +3210,9 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序下单时用户订阅消息推送接口(前端不传值,后端返回固定结构)
|
* 小程序下单时用户订阅消息推送接口(前端不传值,后端返回固定结构)
|
||||||
|
*
|
||||||
* @return 订阅消息推送ID分类结果
|
* @return 订阅消息推送ID分类结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/api/public/massge/notice")
|
@GetMapping("/api/public/massge/notice")
|
||||||
|
|
@ -4351,7 +4434,6 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 商品下单接口
|
// * 商品下单接口
|
||||||
// * POST /api/service/create/order
|
// * POST /api/service/create/order
|
||||||
|
|
@ -4427,9 +4509,6 @@ public class AppletController extends BaseController {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建服务订单(支持多商品批量下单)
|
* 创建服务订单(支持多商品批量下单)
|
||||||
*
|
*
|
||||||
|
|
@ -4504,6 +4583,17 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
// 判断商品类型并创建相应订单
|
// 判断商品类型并创建相应订单
|
||||||
if (serviceGoods.getType() == 2) {
|
if (serviceGoods.getType() == 2) {
|
||||||
|
// 创建服务订单
|
||||||
|
String coupon_id = orderParams.get("coupon_id") != null ? orderParams.get("coupon_id").toString() : "";
|
||||||
|
if (coupon_id!=null){
|
||||||
|
CouponUser coupon = couponUserService.selectCouponUserById(Long.valueOf(coupon_id));
|
||||||
|
if (coupon==null){
|
||||||
|
return AppletControllerUtil.appletWarning("优惠券不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 创建商品订单
|
// 创建商品订单
|
||||||
GoodsOrder goodsOrder = new GoodsOrder();
|
GoodsOrder goodsOrder = new GoodsOrder();
|
||||||
goodsOrder.setType(2);
|
goodsOrder.setType(2);
|
||||||
|
|
@ -4653,7 +4743,7 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
if (hasGoodsOrder && totalAmount.compareTo(BigDecimal.ZERO) > 0) {
|
if (hasGoodsOrder && totalAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
// 使用工具类简化微信支付参数组装
|
// 使用工具类简化微信支付参数组装
|
||||||
Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), mainOrderId, new BigDecimal(0.01), orderList.size(),"https://4d983d7f.r3.cpolar.top/api/goods/pay/notify");
|
Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), mainOrderId, new BigDecimal(0.01), orderList.size(), "https://2d684c7a.r5.cpolar.xyz/api/goods/pay/notify");
|
||||||
//Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), mainOrderId, totalAmount, orderList.size());
|
//Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), mainOrderId, totalAmount, orderList.size());
|
||||||
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
||||||
Map<String, Object> responseData = new HashMap<>();
|
Map<String, Object> responseData = new HashMap<>();
|
||||||
|
|
@ -4682,9 +4772,9 @@ public class AppletController extends BaseController {
|
||||||
return error("创建订单失败:" + e.getMessage());
|
return error("创建订单失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 尾款结算
|
* 尾款结算
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("api/service/order/pay/total/price")
|
@PostMapping("api/service/order/pay/total/price")
|
||||||
public AjaxResult apiServiceOrderPayTotalPprice(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
public AjaxResult apiServiceOrderPayTotalPprice(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
|
@ -4702,7 +4792,7 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证必要参数
|
// 3. 验证必要参数
|
||||||
if (params == null || params.get("id") == null ) {
|
if (params == null || params.get("order_id") == null || params.get("worker_id") == null) {
|
||||||
return error("参数不能为空");
|
return error("参数不能为空");
|
||||||
}
|
}
|
||||||
Long worker_id = Long.valueOf(params.get("worker_id").toString());
|
Long worker_id = Long.valueOf(params.get("worker_id").toString());
|
||||||
|
|
@ -4729,7 +4819,7 @@ public class AppletController extends BaseController {
|
||||||
String.valueOf(order_id),
|
String.valueOf(order_id),
|
||||||
new BigDecimal(0.01),
|
new BigDecimal(0.01),
|
||||||
1,
|
1,
|
||||||
"https://4d983d7f.r3.cpolar.top/api/order/amount/pay/notify");
|
"https://2d684c7a.r5.cpolar.xyz/api/order/amount/pay/notify");
|
||||||
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
||||||
Map<String, Object> responseData = new HashMap<>();
|
Map<String, Object> responseData = new HashMap<>();
|
||||||
responseData.put("mainOrderId", order_id);
|
responseData.put("mainOrderId", order_id);
|
||||||
|
|
@ -4746,9 +4836,9 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上门费支付接口
|
* 上门费支付接口
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("api/service/order/pay_fee")
|
@PostMapping("api/service/order/pay_fee")
|
||||||
|
|
@ -4779,7 +4869,7 @@ public class AppletController extends BaseController {
|
||||||
String.valueOf(orderLog.getId()),
|
String.valueOf(orderLog.getId()),
|
||||||
new BigDecimal(0.01),
|
new BigDecimal(0.01),
|
||||||
1,
|
1,
|
||||||
"https://4d983d7f.r3.cpolar.top/api/door/fee/pay/notify");
|
"https://2d684c7a.r5.cpolar.xyz/api/door/fee/pay/notify");
|
||||||
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
||||||
Map<String, Object> responseData = new HashMap<>();
|
Map<String, Object> responseData = new HashMap<>();
|
||||||
responseData.put("mainOrderId", String.valueOf(orderLog.getId()));
|
responseData.put("mainOrderId", String.valueOf(orderLog.getId()));
|
||||||
|
|
@ -4801,12 +4891,8 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定金支付接口
|
* 定金支付接口
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("/api/service/order/pay/deposit")
|
@PostMapping("/api/service/order/pay/deposit")
|
||||||
|
|
@ -4837,7 +4923,7 @@ public class AppletController extends BaseController {
|
||||||
String.valueOf(orderLog.getId()),
|
String.valueOf(orderLog.getId()),
|
||||||
new BigDecimal(0.01),
|
new BigDecimal(0.01),
|
||||||
1,
|
1,
|
||||||
"https://4d983d7f.r3.cpolar.top/api/deposit/pay/notify");
|
"https://2d684c7a.r5.cpolar.xyz/api/deposit/pay/notify");
|
||||||
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
||||||
Map<String, Object> responseData = new HashMap<>();
|
Map<String, Object> responseData = new HashMap<>();
|
||||||
responseData.put("mainOrderId", String.valueOf(orderLog.getId()));
|
responseData.put("mainOrderId", String.valueOf(orderLog.getId()));
|
||||||
|
|
@ -4861,7 +4947,6 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个商品支付
|
* 单个商品支付
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("api/goods/order/once_pay")
|
@PostMapping("api/goods/order/once_pay")
|
||||||
public AjaxResult apiGoodsOrderOncePay(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
public AjaxResult apiGoodsOrderOncePay(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
|
@ -4892,7 +4977,7 @@ public class AppletController extends BaseController {
|
||||||
//修改成功就开始走支付功能
|
//修改成功就开始走支付功能
|
||||||
if (flg > 0) {
|
if (flg > 0) {
|
||||||
goodsOrder.setMainOrderId(goodsOrder.getMainOrderId());
|
goodsOrder.setMainOrderId(goodsOrder.getMainOrderId());
|
||||||
Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), goodsOrder.getMainOrderId(), new BigDecimal(0.01), 1, "https://4d983d7f.r3.cpolar.top/api/goods/pay/notify");
|
Map<String, Object> payResult = wechatPayUtil.createBatchOrderAndPay(user.getOpenid(), goodsOrder.getMainOrderId(), new BigDecimal(0.01), 1, "https://2d684c7a.r5.cpolar.xyz/api/goods/pay/notify");
|
||||||
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
if (payResult != null && Boolean.TRUE.equals(payResult.get("success"))) {
|
||||||
Map<String, Object> responseData = new HashMap<>();
|
Map<String, Object> responseData = new HashMap<>();
|
||||||
responseData.put("mainOrderId", goodsOrder.getMainOrderId());
|
responseData.put("mainOrderId", goodsOrder.getMainOrderId());
|
||||||
|
|
@ -5430,9 +5515,6 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付尾款回调到页面的数据
|
* 支付尾款回调到页面的数据
|
||||||
* 返回结构见json.txt
|
* 返回结构见json.txt
|
||||||
|
|
@ -6584,6 +6666,8 @@ public class AppletController extends BaseController {
|
||||||
return AppletControllerUtil.appletError("参数错误");
|
return AppletControllerUtil.appletError("参数错误");
|
||||||
}
|
}
|
||||||
// 1. 计算金额
|
// 1. 计算金额
|
||||||
|
BigDecimal GoodsAllPrice = BigDecimal.ZERO;
|
||||||
|
BigDecimal ServiceAllPrice = BigDecimal.ZERO;
|
||||||
BigDecimal totalPrice = BigDecimal.ZERO;
|
BigDecimal totalPrice = BigDecimal.ZERO;
|
||||||
List<Map<String, Object>> craftList = (List<Map<String, Object>>) params.get("craft");
|
List<Map<String, Object>> craftList = (List<Map<String, Object>>) params.get("craft");
|
||||||
if (craftList != null) {
|
if (craftList != null) {
|
||||||
|
|
@ -6599,6 +6683,7 @@ public class AppletController extends BaseController {
|
||||||
BigDecimal price = new BigDecimal(craft.get("price").toString());
|
BigDecimal price = new BigDecimal(craft.get("price").toString());
|
||||||
Integer count = craft.get("count") == null ? 1 : Integer.parseInt(craft.get("count").toString());
|
Integer count = craft.get("count") == null ? 1 : Integer.parseInt(craft.get("count").toString());
|
||||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
||||||
|
ServiceAllPrice = ServiceAllPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6617,6 +6702,7 @@ public class AppletController extends BaseController {
|
||||||
BigDecimal price = new BigDecimal(material.get("price").toString());
|
BigDecimal price = new BigDecimal(material.get("price").toString());
|
||||||
Integer count = material.get("count") == null ? 1 : Integer.parseInt(material.get("count").toString());
|
Integer count = material.get("count") == null ? 1 : Integer.parseInt(material.get("count").toString());
|
||||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
||||||
|
GoodsAllPrice = GoodsAllPrice.add(price.multiply(BigDecimal.valueOf(count)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6677,6 +6763,8 @@ public class AppletController extends BaseController {
|
||||||
order.setLogJson(jsonObject.toJSONString());
|
order.setLogJson(jsonObject.toJSONString());
|
||||||
// order.setTotalPrice(totalPrice);
|
// order.setTotalPrice(totalPrice);
|
||||||
// order.setUpdatedAt(new Date());
|
// order.setUpdatedAt(new Date());
|
||||||
|
order.setGoodPrice(GoodsAllPrice);
|
||||||
|
order.setServicePrice(ServiceAllPrice);
|
||||||
int update = orderService.updateOrder(order);
|
int update = orderService.updateOrder(order);
|
||||||
if (update > 0) {
|
if (update > 0) {
|
||||||
OrderLog log = new OrderLog();
|
OrderLog log = new OrderLog();
|
||||||
|
|
@ -6697,6 +6785,7 @@ public class AppletController extends BaseController {
|
||||||
} else {
|
} else {
|
||||||
log.setReductionPrice(BigDecimal.ZERO);
|
log.setReductionPrice(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
log.setWorkerCost(ServiceAllPrice);
|
||||||
log.setLogId(GenerateCustomCode.generCreateOrder("EST"));
|
log.setLogId(GenerateCustomCode.generCreateOrder("EST"));
|
||||||
log.setWorkerLogId(order.getWorkerId());
|
log.setWorkerLogId(order.getWorkerId());
|
||||||
log.setWorkerId(order.getWorkerId());
|
log.setWorkerId(order.getWorkerId());
|
||||||
|
|
@ -6879,12 +6968,125 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束订单
|
||||||
|
* POST
|
||||||
|
* 参数:{"id":订单id}
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/worker/order/end")
|
||||||
|
public AjaxResult workerOrderEnd(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
// 1. 参数校验
|
||||||
|
if (params.get("id") == null) {
|
||||||
|
return AjaxResult.error("系统错误");
|
||||||
|
}
|
||||||
|
Long id = Long.valueOf(params.get("id").toString());
|
||||||
|
Order orderInfo = orderService.selectOrderById(id);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
return AjaxResult.error("订单不存在");
|
||||||
|
}
|
||||||
|
Users workerInfo = usersService.selectUsersById(orderInfo.getWorkerId());
|
||||||
|
if (workerInfo == null) {
|
||||||
|
return AjaxResult.error("师傅记录不存在");
|
||||||
|
}
|
||||||
|
// 2. 状态判断
|
||||||
|
String msg = null;
|
||||||
|
switch (orderInfo.getStatus().intValue()) {
|
||||||
|
case 1:
|
||||||
|
msg = "还未接单,不能结束订单";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg = "服务还在进行中,不能提前结束订单";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
msg = "订单已完成";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
msg = "订单已取消";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
msg = "订单已结束";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (msg != null) {
|
||||||
|
return AjaxResult.error(msg);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 3.1 更新订单状态为7(已结束)
|
||||||
|
Order updateOrder = new Order();
|
||||||
|
updateOrder.setId(id);
|
||||||
|
updateOrder.setStatus(7L);
|
||||||
|
orderService.updateOrder(updateOrder);
|
||||||
|
|
||||||
|
// 3.2 插入订单日志
|
||||||
|
OrderLog log = new OrderLog();
|
||||||
|
log.setOid(orderInfo.getId());
|
||||||
|
log.setOrderId(orderInfo.getOrderId());
|
||||||
|
log.setTitle("结束订单");
|
||||||
|
log.setType(BigDecimal.valueOf(10));
|
||||||
|
log.setContent("{\"name\":\"师傅提前结束订单\"}");
|
||||||
|
//Long workerId = getCurrentWorkerId(request); // 需实现
|
||||||
|
log.setWorkerId(workerInfo.getId());
|
||||||
|
log.setCreatedAt(new Date());
|
||||||
|
log.setUpdatedAt(new Date());
|
||||||
|
orderLogService.insertOrderLog(log);
|
||||||
|
|
||||||
|
// 3.3 查询是否有上门费(type=2, paid=2)
|
||||||
|
OrderLog doorPriceLogself = new OrderLog();
|
||||||
|
doorPriceLogself.setOid(orderInfo.getId());
|
||||||
|
doorPriceLogself.setType(BigDecimal.valueOf(2));
|
||||||
|
doorPriceLogself.setPaid(2L);
|
||||||
|
doorPriceLogself.setWorkerId(workerInfo.getId());
|
||||||
|
OrderLog doorPriceLog = orderLogService.selectOneByOidTypeWorkerIdPaid(doorPriceLogself);
|
||||||
|
if (doorPriceLog != null && doorPriceLog.getPrice() != null) {
|
||||||
|
// 师傅等级信息
|
||||||
|
//Users workerInfo = usersService.selectUsersById(workerId);
|
||||||
|
WorkerLevel levelInfo = workerLevelService.selectWorkerLevelByLevel(Long.valueOf(workerInfo.getLevel()));
|
||||||
|
// 更新师傅佣金
|
||||||
|
BigDecimal price = doorPriceLog.getPrice();
|
||||||
|
Users updateUser = new Users();
|
||||||
|
updateUser.setId(workerInfo.getId());
|
||||||
|
updateUser.setCommission(workerInfo.getCommission().add(price));
|
||||||
|
updateUser.setTotalComm(workerInfo.getTotalComm().add(price));
|
||||||
|
usersService.updateUsers(updateUser);
|
||||||
|
// 插入师傅金额记录
|
||||||
|
WorkerMoneyLog moneyLog = new WorkerMoneyLog();
|
||||||
|
moneyLog.setWorkerId(workerInfo.getId());
|
||||||
|
moneyLog.setOid(orderInfo.getId());
|
||||||
|
moneyLog.setOrderId(orderInfo.getOrderId());
|
||||||
|
moneyLog.setPrice(price);
|
||||||
|
moneyLog.setType(1);
|
||||||
|
moneyLog.setServicePrice(BigDecimal.ZERO);
|
||||||
|
moneyLog.setReductionPrice(BigDecimal.ZERO);
|
||||||
|
moneyLog.setCr(Math.toIntExact(levelInfo != null ? levelInfo.getCr() : null));
|
||||||
|
moneyLog.setMergin(BigDecimal.ZERO);
|
||||||
|
moneyLog.setDoorPrice(price);
|
||||||
|
moneyLog.setCreatedAt(new Date());
|
||||||
|
moneyLog.setUpdatedAt(new Date());
|
||||||
|
workerMoneyLogService.insertWorkerMoneyLog(moneyLog);
|
||||||
|
}
|
||||||
|
// 3.4 解绑虚拟号
|
||||||
|
if (orderInfo.getMiddlePhone() != null) {
|
||||||
|
VoiceResponseResult unbind = YunXinPhoneUtilAPI.httpsPrivacyUnbind(orderInfo.getWorkerPhone(), orderInfo.getUserPhone(), orderInfo.getMiddlePhone());
|
||||||
|
if (unbind.getResult().equals("000000")) {
|
||||||
|
Order phoneUpdate = new Order();
|
||||||
|
phoneUpdate.setId(orderInfo.getId());
|
||||||
|
phoneUpdate.setMiddlePhone(null);
|
||||||
|
phoneUpdate.setUserPhone(null);
|
||||||
|
phoneUpdate.setWorkerPhone(null);
|
||||||
|
orderService.updateOrder(phoneUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success("订单结束成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("订单结束失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 云信交互式语音通知呼叫结果推送回调接口
|
* 云信交互式语音通知呼叫结果推送回调接口
|
||||||
* 用于接收云信平台推送的交互式语音通知呼叫结果。
|
* 用于接收云信平台推送的交互式语音通知呼叫结果。
|
||||||
|
*
|
||||||
* @param requestBody 云信平台推送的JSON字符串
|
* @param requestBody 云信平台推送的JSON字符串
|
||||||
* @return 必须返回{"resultCode":"200"},否则云信认为推送失败
|
* @return 必须返回{"resultCode":"200"},否则云信认为推送失败
|
||||||
*/
|
*/
|
||||||
|
|
@ -6908,12 +7110,10 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 云信交互式小号呼叫结果推送结果推送回调接口
|
* 云信交互式小号呼叫结果推送结果推送回调接口
|
||||||
* 用于接收云信平台推送的交互式语音通知呼叫结果。
|
* 用于接收云信平台推送的交互式语音通知呼叫结果。
|
||||||
|
*
|
||||||
* @param requestBody 云信平台推送的JSON字符串
|
* @param requestBody 云信平台推送的JSON字符串
|
||||||
* @return 必须返回{"resultCode":"200"},否则云信认为推送失败
|
* @return 必须返回{"resultCode":"200"},否则云信认为推送失败
|
||||||
*/
|
*/
|
||||||
|
|
@ -6938,7 +7138,7 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 抢单大厅 - 获取可抢订单列表
|
* 抢单大厅 - 获取可抢订单列表
|
||||||
*
|
* <p>
|
||||||
* 功能说明:
|
* 功能说明:
|
||||||
* - 查询状态为1(待接单)的订单
|
* - 查询状态为1(待接单)的订单
|
||||||
* - 支持分页查询
|
* - 支持分页查询
|
||||||
|
|
@ -7143,8 +7343,6 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品订单游标接口
|
* 商品订单游标接口
|
||||||
*
|
*
|
||||||
|
|
@ -7500,6 +7698,7 @@ public class AppletController extends BaseController {
|
||||||
"<return_msg><![CDATA[" + message + "]]></return_msg>" +
|
"<return_msg><![CDATA[" + message + "]]></return_msg>" +
|
||||||
"</xml>";
|
"</xml>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置默认配置信息
|
* 设置默认配置信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ public class PayNotifyController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IWorkerMarginLogService workerMarginLogService;
|
private IWorkerMarginLogService workerMarginLogService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWorkerMoneyLogService workerMoneyLogService;
|
||||||
/**
|
/**
|
||||||
* 商品支付回调接口
|
* 商品支付回调接口
|
||||||
*
|
*
|
||||||
|
|
@ -406,7 +408,8 @@ public class PayNotifyController extends BaseController {
|
||||||
|
|
||||||
// 7. 处理订单支付成功后的业务逻辑
|
// 7. 处理订单支付成功后的业务逻辑
|
||||||
handleOrderAmountPaymentSuccess(order, paymentInfo);
|
handleOrderAmountPaymentSuccess(order, paymentInfo);
|
||||||
calculateCommissionMoney(order.getOrderId(), order.getUid(),order.getWorkerId());
|
calculateCommissionAndRecord(order.getOrderId(),order.getWorkerId());
|
||||||
|
//calculateCommissionMoney(order.getOrderId(), order.getUid(),order.getWorkerId());
|
||||||
logger.info("订单金额支付回调处理成功,订单号:{}", outTradeNo);
|
logger.info("订单金额支付回调处理成功,订单号:{}", outTradeNo);
|
||||||
return buildSuccessResponse();
|
return buildSuccessResponse();
|
||||||
|
|
||||||
|
|
@ -835,60 +838,75 @@ public class PayNotifyController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
public Map<String, Object> calculateCommissionAndRecord(
|
||||||
* 分佣
|
String orderId,
|
||||||
*
|
Long workerId
|
||||||
|
|
||||||
* @return 商品标题
|
|
||||||
*/
|
|
||||||
public Map<String, Object> calculateCommissionMoney(String orderId,long oid, Long workerId
|
|
||||||
) {
|
) {
|
||||||
// 结果
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
BigDecimal totalPrice = BigDecimal.ZERO;
|
BigDecimal totalCommission = BigDecimal.ZERO; // 师傅最终佣金
|
||||||
BigDecimal margin = BigDecimal.ZERO;
|
BigDecimal margin = BigDecimal.ZERO; // 质保金
|
||||||
BigDecimal reduction = BigDecimal.ZERO;
|
BigDecimal reduction = BigDecimal.ZERO; // 优惠金额
|
||||||
BigDecimal servicePrice = BigDecimal.ZERO;
|
BigDecimal servicePrice = BigDecimal.ZERO; // 服务费用
|
||||||
BigDecimal doorPrice = BigDecimal.ZERO;
|
BigDecimal materialPrice = BigDecimal.ZERO; // 材料费用(如有可补充)
|
||||||
|
BigDecimal doorPrice = BigDecimal.ZERO; // 上门费
|
||||||
|
BigDecimal cr = BigDecimal.ZERO; // 师傅等级分佣比例
|
||||||
|
|
||||||
// 1. 查询订单日志
|
logger.info("【分佣计算】开始计算,orderId={}, workerId={}", orderId, workerId);
|
||||||
|
|
||||||
|
// 1. 查询订单日志(type=2,5,paid=2,give_up=null)
|
||||||
OrderLog orderLogQuery = new OrderLog();
|
OrderLog orderLogQuery = new OrderLog();
|
||||||
orderLogQuery.setOrderId(orderId);
|
orderLogQuery.setOrderId(orderId);
|
||||||
List<OrderLog> orderLogList = orderLogService.selectOrderLogList(orderLogQuery);
|
List<OrderLog> orderLogList = orderLogService.selectOrderLogList(orderLogQuery);
|
||||||
//List<OrderLog> orderLogList = orderLogService.selectOrderLogListByWorker(orderId, workerId);
|
logger.info("【分佣计算】查询订单日志完成,日志数量={}", orderLogList.size());
|
||||||
|
|
||||||
// 2. 查询订单和商品
|
// 2. 查询订单和商品
|
||||||
Order order = orderService.selectOrderById(oid);
|
Order order = orderService.selectOrderByOrderId(orderId);
|
||||||
|
logger.info("【分佣计算】查询订单完成,order={}", order != null ? order.getId() : null);
|
||||||
ServiceGoods product = null;
|
ServiceGoods product = null;
|
||||||
if (order != null && order.getProductId() != null) {
|
if (order != null && order.getProductId() != null) {
|
||||||
product = serviceGoodsService.selectServiceGoodsById(order.getProductId());
|
product = serviceGoodsService.selectServiceGoodsById(order.getProductId());
|
||||||
|
logger.info("【分佣计算】查询商品完成,productId={}", product != null ? product.getId() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 查询师傅信息
|
// 3. 查询师傅信息
|
||||||
Users worker = usersService.selectUsersById(workerId);
|
Users worker = usersService.selectUsersById(workerId);
|
||||||
|
logger.info("【分佣计算】查询师傅信息完成,worker={}", worker != null ? worker.getId() : null);
|
||||||
|
|
||||||
// 4. 计算佣金、上门费、优惠金额
|
// 4. 计算各项费用
|
||||||
for (OrderLog log : orderLogList) {
|
for (OrderLog log : orderLogList) {
|
||||||
|
logger.info("【分佣计算】处理日志,logId={}, type={}, workerCost={}, reductionPrice={}",
|
||||||
|
log.getId(), log.getType(), log.getWorkerCost(), log.getReductionPrice());
|
||||||
if (log.getType() != null && log.getType().intValue() == 5) {
|
if (log.getType() != null && log.getType().intValue() == 5) {
|
||||||
// type=5 评估报价
|
// type=5 评估报价
|
||||||
WorkerLevel levelInfo = workerLevelService.selectWorkerLevelByLevel(Long.valueOf(worker.getLevel()));
|
WorkerLevel levelInfo = workerLevelService.selectWorkerLevelByLevel(Long.valueOf(worker.getLevel()));
|
||||||
BigDecimal cr = (levelInfo != null && levelInfo.getCr() != null) ? new BigDecimal(levelInfo.getCr()).divide(new BigDecimal(100)) : BigDecimal.ZERO;
|
logger.info("【分佣计算】查询师傅等级,level={}, cr={}", worker.getLevel(), levelInfo != null ? levelInfo.getCr() : null);
|
||||||
totalPrice = totalPrice.add(log.getWorkerCost().multiply(cr).setScale(2, BigDecimal.ROUND_HALF_UP));
|
if (levelInfo != null && levelInfo.getCr() != null) {
|
||||||
|
cr = new BigDecimal(levelInfo.getCr()).divide(new BigDecimal(100));
|
||||||
|
}
|
||||||
|
// 师傅分佣
|
||||||
|
BigDecimal commission = log.getWorkerCost().multiply(cr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
totalCommission = totalCommission.add(commission);
|
||||||
|
logger.info("【分佣计算】type=5,分佣金额={}, 当前总佣金={}", commission, totalCommission);
|
||||||
|
// 服务费用
|
||||||
servicePrice = log.getWorkerCost().add(log.getReductionPrice() != null ? log.getReductionPrice() : BigDecimal.ZERO);
|
servicePrice = log.getWorkerCost().add(log.getReductionPrice() != null ? log.getReductionPrice() : BigDecimal.ZERO);
|
||||||
|
logger.info("【分佣计算】type=5,服务费用={}", servicePrice);
|
||||||
}
|
}
|
||||||
if (log.getType() != null && log.getType().intValue() == 2) {
|
if (log.getType() != null && log.getType().intValue() == 2) {
|
||||||
// type=2 上门费
|
// type=2 上门费
|
||||||
totalPrice = totalPrice.add(log.getWorkerCost());
|
totalCommission = totalCommission.add(log.getWorkerCost());
|
||||||
doorPrice = log.getWorkerCost();
|
doorPrice = log.getWorkerCost();
|
||||||
|
logger.info("【分佣计算】type=2,上门费={}, 当前总佣金={}", doorPrice, totalCommission);
|
||||||
}
|
}
|
||||||
if (log.getReductionPrice() != null) {
|
if (log.getReductionPrice() != null) {
|
||||||
reduction = reduction.add(log.getReductionPrice());
|
reduction = reduction.add(log.getReductionPrice());
|
||||||
|
logger.info("【分佣计算】累计优惠金额={}", reduction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 判断是否需要扣除质保金
|
// 5. 判断是否需要扣除质保金
|
||||||
if (product != null && product.getMargin() != null && worker != null && worker.getMargin() != null
|
if (product != null && product.getMargin() != null && worker != null && worker.getMargin() != null
|
||||||
&& product.getMargin().compareTo(worker.getMargin()) > 0) {
|
&& product.getMargin().compareTo(worker.getMargin()) > 0) {
|
||||||
|
logger.info("【分佣计算】需要扣除质保金,商品margin={}, 师傅margin={}", product.getMargin(), worker.getMargin());
|
||||||
// 查系统配置
|
// 查系统配置
|
||||||
SiteConfig config = siteConfigService.selectSiteConfigByName("config_one");
|
SiteConfig config = siteConfigService.selectSiteConfigByName("config_one");
|
||||||
BigDecimal marginPercent = BigDecimal.ZERO;
|
BigDecimal marginPercent = BigDecimal.ZERO;
|
||||||
|
|
@ -898,12 +916,16 @@ public class PayNotifyController extends BaseController {
|
||||||
if (json.containsKey("margin")) {
|
if (json.containsKey("margin")) {
|
||||||
marginPercent = new BigDecimal(json.getString("margin")).divide(new BigDecimal(100));
|
marginPercent = new BigDecimal(json.getString("margin")).divide(new BigDecimal(100));
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception e) {
|
||||||
|
logger.error("【分佣计算】解析质保金配置异常", e);
|
||||||
}
|
}
|
||||||
margin = totalPrice.multiply(marginPercent).setScale(2, BigDecimal.ROUND_HALF_UP);
|
}
|
||||||
|
margin = totalCommission.multiply(marginPercent).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
logger.info("【分佣计算】初步计算质保金={}, 配置比例={}", margin, marginPercent);
|
||||||
// 超过质保金,则扣少点
|
// 超过质保金,则扣少点
|
||||||
if (worker.getMargin().add(margin).compareTo(product.getMargin()) > 0) {
|
if (worker.getMargin().add(margin).compareTo(product.getMargin()) > 0) {
|
||||||
margin = product.getMargin().subtract(worker.getMargin());
|
margin = product.getMargin().subtract(worker.getMargin());
|
||||||
|
logger.info("【分佣计算】质保金超限,实际扣除={}", margin);
|
||||||
}
|
}
|
||||||
// 插入质保金明细
|
// 插入质保金明细
|
||||||
WorkerMarginLog marginLog = new WorkerMarginLog();
|
WorkerMarginLog marginLog = new WorkerMarginLog();
|
||||||
|
|
@ -911,23 +933,166 @@ public class PayNotifyController extends BaseController {
|
||||||
marginLog.setUid(workerId);
|
marginLog.setUid(workerId);
|
||||||
marginLog.setOrderId(order != null ? order.getOrderId() : null);
|
marginLog.setOrderId(order != null ? order.getOrderId() : null);
|
||||||
marginLog.setPrice(margin);
|
marginLog.setPrice(margin);
|
||||||
// marginLog.setCreatedAt(new Date());
|
|
||||||
// marginLog.setUpdatedAt(new Date());
|
|
||||||
workerMarginLogService.insertWorkerMarginLog(marginLog);
|
workerMarginLogService.insertWorkerMarginLog(marginLog);
|
||||||
|
logger.info("【分佣计算】插入质保金明细完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 返回
|
// 6. 计算最终佣金
|
||||||
result.put("commission", totalPrice);
|
BigDecimal finalCommission = totalCommission.subtract(margin);
|
||||||
result.put("margin", margin);
|
logger.info("【分佣计算】最终佣金={}", finalCommission);
|
||||||
result.put("reduction", reduction);
|
|
||||||
result.put("service_price", servicePrice);
|
// 7. 更新师傅账户(佣金、佣金总额、质保金)
|
||||||
result.put("door_price", doorPrice);
|
if (worker != null) {
|
||||||
|
BigDecimal newCommission = (worker.getCommission() != null ? worker.getCommission() : BigDecimal.ZERO).add(finalCommission);
|
||||||
|
BigDecimal newTotalComm = (worker.getTotalComm() != null ? worker.getTotalComm() : BigDecimal.ZERO).add(finalCommission);
|
||||||
|
BigDecimal newMargin = (worker.getMargin() != null ? worker.getMargin() : BigDecimal.ZERO).add(margin);
|
||||||
|
|
||||||
|
worker.setCommission(newCommission);
|
||||||
|
worker.setTotalComm(newTotalComm);
|
||||||
|
worker.setMargin(newMargin);
|
||||||
|
usersService.updateUsers(worker);
|
||||||
|
logger.info("【分佣计算】更新师傅账户完成,commission={}, total_comm={}, margin={}", newCommission, newTotalComm, newMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 插入师傅金额记录
|
||||||
|
WorkerMoneyLog moneyLog = new WorkerMoneyLog();
|
||||||
|
moneyLog.setWorkerId(workerId);
|
||||||
|
moneyLog.setOid(order.getId());
|
||||||
|
moneyLog.setOrderId(order != null ? order.getOrderId() : null);
|
||||||
|
moneyLog.setPrice(finalCommission);
|
||||||
|
moneyLog.setType(1); // 1=收入
|
||||||
|
moneyLog.setServicePrice(servicePrice);
|
||||||
|
moneyLog.setReductionPrice(reduction);
|
||||||
|
moneyLog.setCr(cr.multiply(new BigDecimal(100)).intValue()); // 百分比
|
||||||
|
moneyLog.setMergin(margin);
|
||||||
|
moneyLog.setDoorPrice(doorPrice);
|
||||||
|
workerMoneyLogService.insertWorkerMoneyLog(moneyLog);
|
||||||
|
logger.info("【分佣计算】插入师傅金额记录完成");
|
||||||
|
|
||||||
|
// 9. 组装返回
|
||||||
|
result.put("commission", finalCommission); // 师傅最终佣金
|
||||||
|
result.put("margin", margin); // 质保金
|
||||||
|
result.put("service_price", servicePrice); // 服务费用
|
||||||
|
result.put("material_price", materialPrice); // 材料费用(如有可补充)
|
||||||
|
result.put("reduction", reduction); // 优惠金额
|
||||||
|
result.put("door_price", doorPrice); // 上门费
|
||||||
|
result.put("cr", cr); // 师傅分佣比例
|
||||||
|
|
||||||
|
// 10. 公式说明
|
||||||
|
result.put("formula", "最终佣金 = (服务项目金额 * 师傅等级分佣比例 + 上门费) - 质保金\n"
|
||||||
|
+ "质保金 = 总佣金 * 配置质保金比例,且不超过商品margin-师傅margin\n"
|
||||||
|
+ "服务费用 = 评估报价worker_cost + reduction_price\n"
|
||||||
|
+ "上门费 = type=2的worker_cost\n"
|
||||||
|
+ "优惠金额 = 所有reduction_price之和");
|
||||||
|
|
||||||
|
logger.info("【分佣计算】计算结束,返回结果={}", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 分佣
|
||||||
|
// *
|
||||||
|
//
|
||||||
|
// * @return 商品标题
|
||||||
|
// */
|
||||||
|
// public Map<String, Object> calculateCommissionMoney(String orderId,long oid, Long workerId
|
||||||
|
// ) {
|
||||||
|
// // 结果
|
||||||
|
// Map<String, Object> result = new HashMap<>();
|
||||||
|
// BigDecimal totalPrice = BigDecimal.ZERO;
|
||||||
|
// BigDecimal margin = BigDecimal.ZERO;
|
||||||
|
// BigDecimal reduction = BigDecimal.ZERO;
|
||||||
|
// BigDecimal servicePrice = BigDecimal.ZERO;
|
||||||
|
// BigDecimal doorPrice = BigDecimal.ZERO;
|
||||||
|
//
|
||||||
|
// // 1. 查询订单日志
|
||||||
|
// OrderLog orderLogQuery = new OrderLog();
|
||||||
|
// orderLogQuery.setOrderId(orderId);
|
||||||
|
// List<OrderLog> orderLogList = orderLogService.selectOrderLogList(orderLogQuery);
|
||||||
|
// //List<OrderLog> orderLogList = orderLogService.selectOrderLogListByWorker(orderId, workerId);
|
||||||
|
//
|
||||||
|
// // 2. 查询订单和商品
|
||||||
|
// Order order = orderService.selectOrderById(oid);
|
||||||
|
// ServiceGoods product = null;
|
||||||
|
// if (order != null && order.getProductId() != null) {
|
||||||
|
// product = serviceGoodsService.selectServiceGoodsById(order.getProductId());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 3. 查询师傅信息
|
||||||
|
// Users worker = usersService.selectUsersById(workerId);
|
||||||
|
//
|
||||||
|
// // 4. 计算佣金、上门费、优惠金额
|
||||||
|
// for (OrderLog log : orderLogList) {
|
||||||
|
// BigDecimal workerCost =new BigDecimal(0);
|
||||||
|
// if (log.getWorkerCost() != null) {
|
||||||
|
// workerCost = log.getWorkerCost();
|
||||||
|
// }
|
||||||
|
// if (log.getType() != null && log.getType().intValue() == 5) {
|
||||||
|
// // type=5 评估报价
|
||||||
|
// WorkerLevel levelInfo = workerLevelService.selectWorkerLevelByLevel(Long.valueOf(worker.getLevel()));
|
||||||
|
// BigDecimal cr = (levelInfo != null && levelInfo.getCr() != null) ? new BigDecimal(levelInfo.getCr()).divide(new BigDecimal(100)) : BigDecimal.ZERO;
|
||||||
|
// totalPrice = totalPrice.add(workerCost.multiply(cr).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
// servicePrice = workerCost.add(log.getReductionPrice() != null ? log.getReductionPrice() : BigDecimal.ZERO);
|
||||||
|
// }
|
||||||
|
// if (log.getType() != null && log.getType().intValue() == 2) {
|
||||||
|
// // type=2 上门费
|
||||||
|
// totalPrice = totalPrice.add(log.getWorkerCost());
|
||||||
|
// doorPrice = log.getWorkerCost();
|
||||||
|
// }
|
||||||
|
// if (log.getReductionPrice() != null) {
|
||||||
|
// reduction = reduction.add(log.getReductionPrice());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 5. 判断是否需要扣除质保金
|
||||||
|
// if (product != null && product.getMargin() != null && worker != null && worker.getMargin() != null
|
||||||
|
// && product.getMargin().compareTo(worker.getMargin()) > 0) {
|
||||||
|
// // 查系统配置
|
||||||
|
// SiteConfig config = siteConfigService.selectSiteConfigByName("config_one");
|
||||||
|
// BigDecimal marginPercent = BigDecimal.ZERO;
|
||||||
|
// if (config != null && config.getValue() != null) {
|
||||||
|
// try {
|
||||||
|
// JSONObject json = JSONObject.parseObject(config.getValue());
|
||||||
|
// if (json.containsKey("margin")) {
|
||||||
|
// marginPercent = new BigDecimal(json.getString("margin")).divide(new BigDecimal(100));
|
||||||
|
// }
|
||||||
|
// } catch (Exception ignore) {}
|
||||||
|
// }
|
||||||
|
// margin = totalPrice.multiply(marginPercent).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// // 超过质保金,则扣少点
|
||||||
|
// if (worker.getMargin().add(margin).compareTo(product.getMargin()) > 0) {
|
||||||
|
// margin = product.getMargin().subtract(worker.getMargin());
|
||||||
|
// }
|
||||||
|
// // 插入质保金明细
|
||||||
|
// WorkerMarginLog marginLog = new WorkerMarginLog();
|
||||||
|
// marginLog.setOid(order.getId());
|
||||||
|
// marginLog.setUid(workerId);
|
||||||
|
// marginLog.setOrderId(order != null ? order.getOrderId() : null);
|
||||||
|
// marginLog.setPrice(margin);
|
||||||
|
//// marginLog.setCreatedAt(new Date());
|
||||||
|
//// marginLog.setUpdatedAt(new Date());
|
||||||
|
// workerMarginLogService.insertWorkerMarginLog(marginLog);
|
||||||
|
// //修改师傅质保金和分佣情况
|
||||||
|
// worker.setCommission(totalPrice);
|
||||||
|
// // hpinnworkerzhe.setTotalComm();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 6. 返回
|
||||||
|
// result.put("commission", totalPrice);
|
||||||
|
// result.put("margin", margin);
|
||||||
|
// result.put("reduction", reduction);
|
||||||
|
// result.put("service_price", servicePrice);
|
||||||
|
// result.put("door_price", doorPrice);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取商品标题
|
* 获取商品标题
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ public class WXsendMsgUtil {
|
||||||
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + getAccessToken();
|
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + getAccessToken();
|
||||||
ResponseEntity<String> responseEntity =
|
ResponseEntity<String> responseEntity =
|
||||||
restTemplate.postForEntity(url, wxMssVo, String.class);
|
restTemplate.postForEntity(url, wxMssVo, String.class);
|
||||||
|
System.out.println("0001responseEntity.getBody():" + responseEntity.getBody());
|
||||||
return responseEntity.getBody();
|
return responseEntity.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,10 @@ public class CouponUser extends BaseEntity
|
||||||
@Excel(name = "1:未使用 2:已使用 3:已失效")
|
@Excel(name = "1:未使用 2:已使用 3:已失效")
|
||||||
private Long status;
|
private Long status;
|
||||||
|
|
||||||
|
private Boolean isUse;
|
||||||
|
private String suitTitle;
|
||||||
|
private String tag;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
|
|
@ -262,6 +266,30 @@ public class CouponUser extends BaseEntity
|
||||||
this.uname = uname;
|
this.uname = uname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getIsUse() {
|
||||||
|
return isUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsUse(Boolean isUse) {
|
||||||
|
this.isUse = isUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuitTitle() {
|
||||||
|
return suitTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuitTitle(String suitTitle) {
|
||||||
|
this.suitTitle = suitTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ public interface CouponUserMapper
|
||||||
*/
|
*/
|
||||||
public List<CouponUser> selectCouponUserList(CouponUser couponUser);
|
public List<CouponUser> selectCouponUserList(CouponUser couponUser);
|
||||||
|
|
||||||
|
public List<CouponUser> selectCouponUserNoList(CouponUser couponUser);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增优惠券领取记录
|
* 新增优惠券领取记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public interface OrderLogMapper
|
||||||
*/
|
*/
|
||||||
public OrderLog selectDataTheFirstNew(Long oid);
|
public OrderLog selectDataTheFirstNew(Long oid);
|
||||||
public int selectCountOrderLogByOrderId(String orderId);
|
public int selectCountOrderLogByOrderId(String orderId);
|
||||||
|
public OrderLog selectOneByOidTypeWorkerIdPaid(OrderLog orderLog);
|
||||||
|
|
||||||
|
|
||||||
public List<OrderLog> selectOrderLogByOrderId(String orderId);
|
public List<OrderLog> selectOrderLogByOrderId(String orderId);
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ public interface ICouponUserService
|
||||||
*/
|
*/
|
||||||
public List<CouponUser> selectCouponUserList(CouponUser couponUser);
|
public List<CouponUser> selectCouponUserList(CouponUser couponUser);
|
||||||
|
|
||||||
|
public List<CouponUser> selectCouponUserNoList(CouponUser couponUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增优惠券领取记录
|
* 新增优惠券领取记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public interface IOrderLogService
|
||||||
public OrderLog selectOrderLogById(Long id);
|
public OrderLog selectOrderLogById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
public OrderLog selectOneByOidTypeWorkerIdPaid(OrderLog orderLog);
|
||||||
/**
|
/**
|
||||||
* 查询最新一条日志记录
|
* 查询最新一条日志记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,10 @@ public class CouponUserServiceImpl implements ICouponUserService
|
||||||
{
|
{
|
||||||
return couponUserMapper.selectCouponUserList(couponUser);
|
return couponUserMapper.selectCouponUserList(couponUser);
|
||||||
}
|
}
|
||||||
|
public List<CouponUser> selectCouponUserNoList(CouponUser couponUser) {
|
||||||
|
|
||||||
|
return couponUserMapper.selectCouponUserNoList(couponUser);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 新增优惠券领取记录
|
* 新增优惠券领取记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,9 @@ public class OrderLogServiceImpl implements IOrderLogService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OrderLog selectOneByOidTypeWorkerIdPaid(OrderLog orderLog){
|
||||||
|
return orderLogMapper.selectOneByOidTypeWorkerIdPaid(orderLog);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 查询最新一条日志记录
|
* 查询最新一条日志记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select count(0) from coupon_user where coupon_id=#{couponId}
|
select count(0) from coupon_user where coupon_id=#{couponId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCouponUserNoList" parameterType="CouponUser" resultMap="CouponUserResult">
|
||||||
|
<include refid="selectCouponUserVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="status != null "> and status = #{status}</if>
|
||||||
|
<if test="uid != null "> and uid = #{uid}</if>
|
||||||
|
and lose_time != '永久有效'
|
||||||
|
and NOW() > DATE_FORMAT(lose_time, '%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectCouponUserList" parameterType="CouponUser" resultMap="CouponUserResult">
|
<select id="selectCouponUserList" parameterType="CouponUser" resultMap="CouponUserResult">
|
||||||
<include refid="selectCouponUserVo"/>
|
<include refid="selectCouponUserVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -39,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="couponId != null "> and coupon_id = #{couponId}</if>
|
<if test="couponId != null "> and coupon_id = #{couponId}</if>
|
||||||
<if test="couponTitle != null and couponTitle != ''"> and coupon_title = #{couponTitle}</if>
|
<if test="couponTitle != null and couponTitle != ''"> and coupon_title = #{couponTitle}</if>
|
||||||
<if test="couponPrice != null "> and coupon_price = #{couponPrice}</if>
|
<if test="couponPrice != null "> and coupon_price = #{couponPrice}</if>
|
||||||
<if test="minPrice != null "> and min_price = #{minPrice}</if>
|
<if test="minPrice != null "> and min_price > #{minPrice}</if>
|
||||||
<if test="addTime != null "> and add_time = #{addTime}</if>
|
<if test="addTime != null "> and add_time = #{addTime}</if>
|
||||||
<if test="loseTime != null and loseTime != ''"> and lose_time = #{loseTime}</if>
|
<if test="loseTime != null and loseTime != ''"> and lose_time = #{loseTime}</if>
|
||||||
<if test="useTime != null "> and use_time = #{useTime}</if>
|
<if test="useTime != null "> and use_time = #{useTime}</if>
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@
|
||||||
select id, title, price, min_price, start_time, end_time, count, is_permanent, status, coupon_time, product_id, type, receive_type, sort, cate_id, user_ids, created_at, updated_at, deleted_at from coupons
|
select id, title, price, min_price, start_time, end_time, count, is_permanent, status, coupon_time, product_id, type, receive_type, sort, cate_id, user_ids, created_at, updated_at, deleted_at from coupons
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectCouponsList" parameterType="Coupons" resultMap="CouponsResult">
|
<select id="selectCouponsList" parameterType="Coupons" resultMap="CouponsResult">
|
||||||
<include refid="selectCouponsVo"/>
|
<include refid="selectCouponsVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -61,6 +65,9 @@
|
||||||
<if test="type != null "> and type = #{type}</if>
|
<if test="type != null "> and type = #{type}</if>
|
||||||
<if test="sort != null and sort != ''"> and sort = #{sort}</if>
|
<if test="sort != null and sort != ''"> and sort = #{sort}</if>
|
||||||
<if test="isPermanent != null and isPermanent != ''"> and is_permanent = #{isPermanent}</if>
|
<if test="isPermanent != null and isPermanent != ''"> and is_permanent = #{isPermanent}</if>
|
||||||
|
<if test="searchValue != null and searchValue != ''">
|
||||||
|
and type in (1,2)
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="priceMin != null and priceMax != null">
|
<if test="priceMin != null and priceMax != null">
|
||||||
and price BETWEEN #{priceMin} AND #{priceMax}
|
and price BETWEEN #{priceMin} AND #{priceMax}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectOneByOidTypeWorkerIdPaid" parameterType="OrderLog" resultMap="OrderLogResult">
|
||||||
|
<include refid="selectOrderLogVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="oid != null "> and oid = #{oid}</if>
|
||||||
|
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
|
||||||
|
<if test="type != null "> and type = #{type}</if>
|
||||||
|
<if test="deposit != null "> and deposit = #{deposit}</if>
|
||||||
|
<if test="depPaid != null "> and dep_paid = #{depPaid}</if>
|
||||||
|
<if test="depPayTime != null "> and dep_pay_time = #{depPayTime}</if>
|
||||||
|
<if test="depLogId != null and depLogId != ''"> and dep_log_id = #{depLogId}</if>
|
||||||
|
<if test="price != null "> and price = #{price}</if>
|
||||||
|
<if test="paid != null "> and paid = #{paid}</if>
|
||||||
|
<if test="workerId != null "> and worker_id = #{workerId}</if>
|
||||||
|
</where>
|
||||||
|
order by updated_at DESC limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectCountOrderLogByOrderId" parameterType="String" resultType="Integer">
|
<select id="selectCountOrderLogByOrderId" parameterType="String" resultType="Integer">
|
||||||
select count(*) from order_log where order_id = #{orderId}
|
select count(*) from order_log where order_id = #{orderId}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue