202507181805
This commit is contained in:
parent
2c7e315e46
commit
9f9fe430e3
|
|
@ -786,6 +786,7 @@ public class AppleMemberController extends BaseController {
|
||||||
|
|
||||||
// 7. 处理报价
|
// 7. 处理报价
|
||||||
UserDemandQuotation quoteRecord;
|
UserDemandQuotation quoteRecord;
|
||||||
|
boolean isFirstQuote = false;
|
||||||
if (existingQuotes != null && !existingQuotes.isEmpty()) {
|
if (existingQuotes != null && !existingQuotes.isEmpty()) {
|
||||||
// 已有报价,更新
|
// 已有报价,更新
|
||||||
quoteRecord = existingQuotes.getFirst();
|
quoteRecord = existingQuotes.getFirst();
|
||||||
|
|
@ -805,6 +806,13 @@ public class AppleMemberController extends BaseController {
|
||||||
quoteRecord.setWorkerimage(user.getAvatar());
|
quoteRecord.setWorkerimage(user.getAvatar());
|
||||||
quoteRecord.setCreateTime(new Date());
|
quoteRecord.setCreateTime(new Date());
|
||||||
userDemandQuotationService.insertUserDemandQuotation(quoteRecord);
|
userDemandQuotationService.insertUserDemandQuotation(quoteRecord);
|
||||||
|
isFirstQuote = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 如果是第一次报价,更新订单状态为待选择(12)
|
||||||
|
if (isFirstQuote) {
|
||||||
|
order.setStatus(12L);
|
||||||
|
orderService.updateOrder(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AppletControllerUtil.appletSuccess("报价成功");
|
return AppletControllerUtil.appletSuccess("报价成功");
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -3184,14 +3184,37 @@ public class AppletController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileData = null;
|
// 处理fileData参数 - 可能是数组或字符串
|
||||||
|
String fileData = "";
|
||||||
if (params.get("fileData") != null) {
|
if (params.get("fileData") != null) {
|
||||||
fileData = params.get("fileData").toString();
|
Object fileDataObj = params.get("fileData");
|
||||||
|
if (fileDataObj instanceof String) {
|
||||||
|
fileData = (String) fileDataObj;
|
||||||
|
} else if (fileDataObj instanceof List) {
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> attachmentList = (List<String>) fileDataObj;
|
||||||
|
if (attachmentList != null && !attachmentList.isEmpty()) {
|
||||||
|
// 限制最多9个附件
|
||||||
|
if (attachmentList.size() > 9) {
|
||||||
|
return AppletControllerUtil.appletWarning("附件数量不能超过9个");
|
||||||
|
}
|
||||||
|
// 转换为JSON数组格式的字符串
|
||||||
|
fileData = JSONObject.toJSONString(attachmentList);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("附件参数解析失败: " + e.getMessage());
|
||||||
|
fileData = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他类型,尝试转换为字符串
|
||||||
|
fileData = fileDataObj.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String remark = null;
|
String reamk = null;
|
||||||
if (params.get("remark") != null) {
|
if (params.get("reamk") != null) {
|
||||||
remark = params.get("remark").toString();
|
reamk = params.get("reamk").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 查询商品信息并验证
|
// 6. 查询商品信息并验证
|
||||||
|
|
@ -3214,10 +3237,10 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
if (existingCartItem != null) {
|
if (existingCartItem != null) {
|
||||||
// 如果已存在,更新数量和新参数
|
// 如果已存在,更新数量和新参数
|
||||||
return AppletControllerUtil.updateCartItemQuantity(existingCartItem, serviceGoods, goodsCartService, ordertype, fileData, remark);
|
return AppletControllerUtil.updateCartItemQuantity(existingCartItem, serviceGoods, goodsCartService, ordertype, fileData, reamk,sku);
|
||||||
} else {
|
} else {
|
||||||
// 如果不存在,新增购物车记录
|
// 如果不存在,新增购物车记录
|
||||||
return AppletControllerUtil.addNewCartItem(user, serviceGoods, sku, goodsCartService, ordertype, fileData, remark);
|
return AppletControllerUtil.addNewCartItem(user, serviceGoods, sku, goodsCartService, ordertype, fileData, reamk);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -3228,6 +3251,269 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除购物车商品接口(新版,参数为{"ids":[1,2,3]})
|
||||||
|
* @param param {"ids": [id1, id2, ...]}
|
||||||
|
* @param request HTTP请求对象
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/cart/delete")
|
||||||
|
public AjaxResult deleteCartItems(@RequestBody Map<String, List<Integer>> param, HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
// 1. 校验用户登录
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
if (!(Boolean) userValidation.get("valid")) {
|
||||||
|
return AppletControllerUtil.appletUnauthorized();
|
||||||
|
}
|
||||||
|
Users user = (Users) userValidation.get("user");
|
||||||
|
if (user == null) {
|
||||||
|
return AppletControllerUtil.appletWarning("用户信息获取失败");
|
||||||
|
}
|
||||||
|
if (param == null || !param.containsKey("ids") || param.get("ids") == null || param.get("ids").isEmpty()) {
|
||||||
|
return AppletControllerUtil.appletWarning("请选择要删除的购物车商品");
|
||||||
|
}
|
||||||
|
List<Integer> idList = param.get("ids");
|
||||||
|
// 查询这些购物车项,确保归属当前用户
|
||||||
|
List<GoodsCart> cartList = goodsCartService.selectGoodsCartList(new GoodsCart());
|
||||||
|
List<Integer> toDelete = new ArrayList<>();
|
||||||
|
for (GoodsCart cart : cartList) {
|
||||||
|
if (idList.contains(cart.getId()) && cart.getUid().equals(user.getId())) {
|
||||||
|
toDelete.add(cart.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toDelete.isEmpty()) {
|
||||||
|
return AppletControllerUtil.appletWarning("没有可删除的购物车商品");
|
||||||
|
}
|
||||||
|
int result = goodsCartService.deleteGoodsCartByIds(toDelete.toArray(new Integer[0]));
|
||||||
|
if (result > 0) {
|
||||||
|
return AppletControllerUtil.appletSuccess("删除成功");
|
||||||
|
} else {
|
||||||
|
return AppletControllerUtil.appletWarning("删除失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("删除购物车商品异常:" + e.getMessage());
|
||||||
|
return AppletControllerUtil.appletError("删除购物车商品失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除购物车商品接口(新版,参数为{"ids":[1,2,3]})
|
||||||
|
* @param param {"ids": [id1, id2, ...]}
|
||||||
|
* @param request HTTP请求对象
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/cart/info")
|
||||||
|
public AjaxResult apicartinfo(@RequestBody Map<String, List<Integer>> param, HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
// 1. 校验用户登录
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
if (!(Boolean) userValidation.get("valid")) {
|
||||||
|
return AppletControllerUtil.appletUnauthorized();
|
||||||
|
}
|
||||||
|
Users user = (Users) userValidation.get("user");
|
||||||
|
if (user == null) {
|
||||||
|
return AppletControllerUtil.appletWarning("用户信息获取失败");
|
||||||
|
}
|
||||||
|
if (param == null || !param.containsKey("ids") || param.get("ids") == null || param.get("ids").isEmpty()) {
|
||||||
|
return AppletControllerUtil.appletWarning("请选择要查询的购物车商品");
|
||||||
|
}
|
||||||
|
List<Integer> idList = param.get("ids");
|
||||||
|
List<Map<String, Object>> cartList = new ArrayList<>();
|
||||||
|
for (Integer id : idList) {
|
||||||
|
GoodsCart cart = goodsCartService.selectGoodsCartById(id);
|
||||||
|
if (cart != null) {
|
||||||
|
Map<String, Object> cartMap = new HashMap<>();
|
||||||
|
cartMap.put("id", cart.getId());
|
||||||
|
cartMap.put("uid", cart.getUid());
|
||||||
|
cartMap.put("goodId", cart.getGoodId());
|
||||||
|
cartMap.put("goodNum", cart.getGoodNum());
|
||||||
|
if (StringUtils.isNotBlank(cart.getSku())){
|
||||||
|
cartMap.put("sku",JSONObject.parseObject(cart.getSku()));
|
||||||
|
}else{
|
||||||
|
cartMap.put("sku", "");
|
||||||
|
}
|
||||||
|
cartMap.put("reamk", cart.getReamk());
|
||||||
|
if (StringUtils.isNotBlank(cart.getFileData())){
|
||||||
|
//cartMap.put("fileData",AppletControllerUtil.parseImagesStringToArray(cart.getFileData()));
|
||||||
|
cartMap.put("fileData", JSONArray.parseArray(cart.getFileData()));
|
||||||
|
}else{
|
||||||
|
cartMap.put("fileData", JSONArray.parseArray("[]"));
|
||||||
|
}
|
||||||
|
// cartMap.put("fileData", cart.getFileData());
|
||||||
|
cartMap.put("ordertype", cart.getOrdertype());
|
||||||
|
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(cart.getGoodId());
|
||||||
|
if (serviceGoods != null){
|
||||||
|
Map<String, Object> serviceGoodsMap = new HashMap<>();
|
||||||
|
serviceGoodsMap.put("id", serviceGoods.getId());
|
||||||
|
serviceGoodsMap.put("name", serviceGoods.getTitle());
|
||||||
|
serviceGoodsMap.put("icon",AppletControllerUtil.buildImageUrl(serviceGoods.getIcon()));
|
||||||
|
serviceGoodsMap.put("price", serviceGoods.getPrice());
|
||||||
|
cartMap.put("serviceGoods", serviceGoodsMap);
|
||||||
|
}
|
||||||
|
// //服务
|
||||||
|
// if(cart.getGoodstype()==1){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// if(cart.getGoodstype()==2){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cartMap.put("goodstype", cart.getg);
|
||||||
|
cartList.add(cartMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AppletControllerUtil.appletSuccess(cartList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("查询购物车商品异常:" + e.getMessage());
|
||||||
|
return AppletControllerUtil.appletError("查询购物车商品失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 查看购物车详情接口
|
||||||
|
// * @param id 购物车ID
|
||||||
|
// * @param request HTTP请求对象
|
||||||
|
// * @return 购物车详情
|
||||||
|
// */
|
||||||
|
// @GetMapping("/api/cart/info/{id}")
|
||||||
|
// public AjaxResult getCartInfo(@PathVariable("id") Long id, HttpServletRequest request) {
|
||||||
|
// try {
|
||||||
|
// // 校验用户登录
|
||||||
|
// String token = request.getHeader("token");
|
||||||
|
// Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
// if (!(Boolean) userValidation.get("valid")) {
|
||||||
|
// return AppletControllerUtil.appletUnauthorized();
|
||||||
|
// }
|
||||||
|
// Users user = (Users) userValidation.get("user");
|
||||||
|
// if (user == null) {
|
||||||
|
// return AppletControllerUtil.appletWarning("用户信息获取失败");
|
||||||
|
// }
|
||||||
|
// if (id == null) {
|
||||||
|
// return AppletControllerUtil.appletWarning("购物车ID不能为空");
|
||||||
|
// }
|
||||||
|
// GoodsCart cart = goodsCartService.selectGoodsCartById(Math.toIntExact(id));
|
||||||
|
// if (cart == null || !cart.getUid().equals(user.getId())) {
|
||||||
|
// return AppletControllerUtil.appletWarning("购物车不存在或无权查看");
|
||||||
|
// }
|
||||||
|
// return AppletControllerUtil.appletSuccess(cart);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// return AppletControllerUtil.appletError("查询购物车详情失败:" + e.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改购物车接口
|
||||||
|
* @param params 前端传递的需要修改的字段,必须包含id
|
||||||
|
* @param request HTTP请求对象
|
||||||
|
* @return 修改结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/cart/edit")
|
||||||
|
public AjaxResult editCart(@RequestBody Map<String, Object> params, HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
// 校验用户登录
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
Map<String, Object> userValidation = AppletLoginUtil.validateUserToken(token, usersService);
|
||||||
|
if (!(Boolean) userValidation.get("valid")) {
|
||||||
|
return AppletControllerUtil.appletUnauthorized();
|
||||||
|
}
|
||||||
|
Users user = (Users) userValidation.get("user");
|
||||||
|
if (user == null) {
|
||||||
|
return AppletControllerUtil.appletWarning("用户信息获取失败");
|
||||||
|
}
|
||||||
|
if (params == null || params.get("id") == null) {
|
||||||
|
return AppletControllerUtil.appletWarning("购物车ID不能为空");
|
||||||
|
}
|
||||||
|
Long id = Long.valueOf(params.get("id").toString());
|
||||||
|
GoodsCart cart = goodsCartService.selectGoodsCartById(Math.toIntExact(id));
|
||||||
|
if (cart == null || !cart.getUid().equals(user.getId())) {
|
||||||
|
return AppletControllerUtil.appletWarning("购物车不存在或无权修改");
|
||||||
|
}
|
||||||
|
// 只更新前端传递的字段
|
||||||
|
if (params.containsKey("num")) {
|
||||||
|
cart.setGoodNum(Long.valueOf(params.get("num").toString()));
|
||||||
|
}
|
||||||
|
// if (params.containsKey("sku")) {
|
||||||
|
// cart.setSku(params.get("sku") != null ? params.get("sku").toString() : null);
|
||||||
|
// }
|
||||||
|
String sku = null;
|
||||||
|
if (params.get("sku") != null) {
|
||||||
|
Object skuParam = params.get("sku");
|
||||||
|
if (skuParam instanceof Map) {
|
||||||
|
// 如果前端传递的是Map对象,转换为JSON字符串
|
||||||
|
try {
|
||||||
|
sku = JSON.toJSONString(skuParam);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("SKU转换JSON失败:" + e.getMessage());
|
||||||
|
sku = skuParam.toString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果前端传递的是字符串,直接使用
|
||||||
|
sku = skuParam.toString().trim();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sku = null;
|
||||||
|
}
|
||||||
|
cart.setSku(sku);
|
||||||
|
if (params.containsKey("ordertype")) {
|
||||||
|
cart.setOrdertype(params.get("ordertype") != null ? Long.valueOf(params.get("ordertype").toString()) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理fileData参数 - 可能是数组或字符串
|
||||||
|
String fileData = "";
|
||||||
|
if (params.get("fileData") != null) {
|
||||||
|
Object fileDataObj = params.get("fileData");
|
||||||
|
if (fileDataObj instanceof String) {
|
||||||
|
fileData = (String) fileDataObj;
|
||||||
|
} else if (fileDataObj instanceof List) {
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> attachmentList = (List<String>) fileDataObj;
|
||||||
|
if (attachmentList != null && !attachmentList.isEmpty()) {
|
||||||
|
// 限制最多9个附件
|
||||||
|
if (attachmentList.size() > 9) {
|
||||||
|
return AppletControllerUtil.appletWarning("附件数量不能超过9个");
|
||||||
|
}
|
||||||
|
// 转换为JSON数组格式的字符串
|
||||||
|
fileData = JSONObject.toJSONString(attachmentList);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("附件参数解析失败: " + e.getMessage());
|
||||||
|
fileData = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他类型,尝试转换为字符串
|
||||||
|
fileData = fileDataObj.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cart.setFileData(fileData);
|
||||||
|
// if (params.containsKey("fileData")) {
|
||||||
|
// cart.setFileData(params.get("fileData") != null ? params.get("fileData").toString() : null);
|
||||||
|
// }
|
||||||
|
if (params.containsKey("reamk")) {
|
||||||
|
cart.setReamk(params.get("reamk") != null ? params.get("reamk").toString() : null);
|
||||||
|
}
|
||||||
|
// 其他字段可按需补充
|
||||||
|
cart.setUpdatedAt(new Date());
|
||||||
|
int result = goodsCartService.updateGoodsCart(cart);
|
||||||
|
if (result > 0) {
|
||||||
|
return AppletControllerUtil.appletSuccess("修改成功");
|
||||||
|
} else {
|
||||||
|
return AppletControllerUtil.appletWarning("修改失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AppletControllerUtil.appletError("修改购物车失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户购物车数据,按商品类型分为商城类和服务类(不分页)
|
* 查询用户购物车数据,按商品类型分为商城类和服务类(不分页)
|
||||||
*
|
*
|
||||||
|
|
@ -3368,7 +3654,6 @@ public class AppletController extends BaseController {
|
||||||
|
|
||||||
for (GoodsCart cart : cartList) {
|
for (GoodsCart cart : cartList) {
|
||||||
Map<String, Object> cartData = new HashMap<>();
|
Map<String, Object> cartData = new HashMap<>();
|
||||||
|
|
||||||
// 基本购物车信息
|
// 基本购物车信息
|
||||||
cartData.put("id", cart.getId());
|
cartData.put("id", cart.getId());
|
||||||
cartData.put("uid", cart.getUid());
|
cartData.put("uid", cart.getUid());
|
||||||
|
|
@ -3632,7 +3917,6 @@ public class AppletController extends BaseController {
|
||||||
orderDetail.put("mark", order.getMark());
|
orderDetail.put("mark", order.getMark());
|
||||||
orderDetail.put("address_id", order.getAddressId());
|
orderDetail.put("address_id", order.getAddressId());
|
||||||
orderDetail.put("sku", order.getSku());
|
orderDetail.put("sku", order.getSku());
|
||||||
|
|
||||||
// 时间字段格式化
|
// 时间字段格式化
|
||||||
orderDetail.put("created_at", order.getCreatedAt() != null ? sdf.format(order.getCreatedAt()) : null);
|
orderDetail.put("created_at", order.getCreatedAt() != null ? sdf.format(order.getCreatedAt()) : null);
|
||||||
orderDetail.put("updated_at", order.getUpdatedAt() != null ? sdf.format(order.getUpdatedAt()) : null);
|
orderDetail.put("updated_at", order.getUpdatedAt() != null ? sdf.format(order.getUpdatedAt()) : null);
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,20 @@ public class ServiceGoodsController extends BaseController {
|
||||||
return success(serviceGoodsService.selectServiceGoodsList(serviceGoods));
|
return success(serviceGoodsService.selectServiceGoodsList(serviceGoods));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取服务内容详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:ServiceGoods:query')")
|
||||||
|
@GetMapping(value = "/selectTypeList/{type}")
|
||||||
|
public AjaxResult selectTypeList(@PathVariable("type") Integer type) {
|
||||||
|
|
||||||
|
ServiceGoods serviceGoods = new ServiceGoods();
|
||||||
|
if (type != null){
|
||||||
|
serviceGoods.setType(type);
|
||||||
|
}
|
||||||
|
return success(serviceGoodsService.selectServiceGoodsList(serviceGoods));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务内容详细信息
|
* 获取服务内容详细信息
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,11 @@ public class AppletControllerUtil {
|
||||||
if (imagePath == null || imagePath.trim().isEmpty()) {
|
if (imagePath == null || imagePath.trim().isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return CDN_BASE_URL + imagePath.trim();
|
String trimmed = imagePath.trim();
|
||||||
|
if (trimmed.contains("img.huafurenjia.cn")) {
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
return CDN_BASE_URL + trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2791,7 +2795,7 @@ public class AppletControllerUtil {
|
||||||
GoodsCart cartItem,
|
GoodsCart cartItem,
|
||||||
ServiceGoods serviceGoods,
|
ServiceGoods serviceGoods,
|
||||||
IGoodsCartService goodsCartService) {
|
IGoodsCartService goodsCartService) {
|
||||||
return updateCartItemQuantity(cartItem, serviceGoods, goodsCartService, null, null, null);
|
return updateCartItemQuantity(cartItem, serviceGoods, goodsCartService, null, null, null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2811,7 +2815,8 @@ public class AppletControllerUtil {
|
||||||
IGoodsCartService goodsCartService,
|
IGoodsCartService goodsCartService,
|
||||||
Long ordertype,
|
Long ordertype,
|
||||||
String fileData,
|
String fileData,
|
||||||
String remark) {
|
String remark,
|
||||||
|
String sku) {
|
||||||
try {
|
try {
|
||||||
// 数量加1
|
// 数量加1
|
||||||
Long newQuantity = (cartItem.getGoodNum() != null ? cartItem.getGoodNum() : 0L) + 1L;
|
Long newQuantity = (cartItem.getGoodNum() != null ? cartItem.getGoodNum() : 0L) + 1L;
|
||||||
|
|
@ -2829,6 +2834,7 @@ public class AppletControllerUtil {
|
||||||
updateCart.setFileData(fileData);
|
updateCart.setFileData(fileData);
|
||||||
updateCart.setReamk(remark);
|
updateCart.setReamk(remark);
|
||||||
updateCart.setUpdatedAt(new Date());
|
updateCart.setUpdatedAt(new Date());
|
||||||
|
updateCart.setSku(sku);
|
||||||
|
|
||||||
int updateResult = goodsCartService.updateGoodsCart(updateCart);
|
int updateResult = goodsCartService.updateGoodsCart(updateCart);
|
||||||
|
|
||||||
|
|
@ -2869,7 +2875,7 @@ public class AppletControllerUtil {
|
||||||
* @param goodsCartService 购物车服务
|
* @param goodsCartService 购物车服务
|
||||||
* @param ordertype 订单类别
|
* @param ordertype 订单类别
|
||||||
* @param fileData 附件
|
* @param fileData 附件
|
||||||
* @param remark 备注
|
|
||||||
* @return 添加结果
|
* @return 添加结果
|
||||||
*/
|
*/
|
||||||
public static AjaxResult addNewCartItem(
|
public static AjaxResult addNewCartItem(
|
||||||
|
|
@ -2879,7 +2885,7 @@ public class AppletControllerUtil {
|
||||||
IGoodsCartService goodsCartService,
|
IGoodsCartService goodsCartService,
|
||||||
Long ordertype,
|
Long ordertype,
|
||||||
String fileData,
|
String fileData,
|
||||||
String remark) {
|
String reamk) {
|
||||||
try {
|
try {
|
||||||
// 构建购物车记录
|
// 构建购物车记录
|
||||||
GoodsCart newCartItem = new GoodsCart();
|
GoodsCart newCartItem = new GoodsCart();
|
||||||
|
|
@ -2889,9 +2895,11 @@ public class AppletControllerUtil {
|
||||||
newCartItem.setGoodNum(1L); // 默认数量为1
|
newCartItem.setGoodNum(1L); // 默认数量为1
|
||||||
newCartItem.setOrdertype(ordertype);
|
newCartItem.setOrdertype(ordertype);
|
||||||
newCartItem.setFileData(fileData);
|
newCartItem.setFileData(fileData);
|
||||||
newCartItem.setReamk(remark);
|
newCartItem.setReamk(reamk);
|
||||||
newCartItem.setCreatedAt(new Date());
|
newCartItem.setCreatedAt(new Date());
|
||||||
newCartItem.setUpdatedAt(new Date());
|
newCartItem.setUpdatedAt(new Date());
|
||||||
|
newCartItem.setGoodstype(Long.valueOf(serviceGoods.getType()));
|
||||||
|
|
||||||
|
|
||||||
// 插入购物车记录
|
// 插入购物车记录
|
||||||
int insertResult = goodsCartService.insertGoodsCart(newCartItem);
|
int insertResult = goodsCartService.insertGoodsCart(newCartItem);
|
||||||
|
|
@ -3073,6 +3081,43 @@ public class AppletControllerUtil {
|
||||||
return imageData;
|
return imageData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String getStringFileData(String imageUrl) {
|
||||||
|
String fileData = "";
|
||||||
|
|
||||||
|
Object fileDataObj = imageUrl;
|
||||||
|
if (fileDataObj instanceof String) {
|
||||||
|
fileData = (String) fileDataObj;
|
||||||
|
} else if (fileDataObj instanceof List) {
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> attachmentList = (List<String>) fileDataObj;
|
||||||
|
if (attachmentList != null && !attachmentList.isEmpty()) {
|
||||||
|
// 限制最多9个附件
|
||||||
|
// 转换为JSON数组格式的字符串
|
||||||
|
return JSONObject.toJSONString(attachmentList);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return JSONObject.toJSONString("[]");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他类型,尝试转换为字符串
|
||||||
|
return fileDataObj.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送微信小程序订阅消息(自动获取accessToken)
|
* 发送微信小程序订阅消息(自动获取accessToken)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,201 @@
|
||||||
|
package com.ruoyi.system.ControllerUtil;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.system.domain.*;
|
||||||
|
import com.ruoyi.system.service.IOrderService;
|
||||||
|
import com.ruoyi.system.service.IGoodsOrderService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购物车生成订单工具类
|
||||||
|
*/
|
||||||
|
public class CartOrderUtil {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CartOrderUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务类购物车下单
|
||||||
|
* @param user 用户
|
||||||
|
* @param cart 购物车
|
||||||
|
* @param serviceGoods 商品
|
||||||
|
* @param userAddress 地址
|
||||||
|
* @param makeTime 预约时间
|
||||||
|
* @param orderService 服务订单service
|
||||||
|
* @return 下单结果Map
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> createServiceOrderFromCart(Users user, GoodsCart cart, ServiceGoods serviceGoods, UserAddress userAddress, String makeTime, IOrderService orderService, com.ruoyi.system.service.IOrderLogService orderLogService,String maincorid) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
BigDecimal itemPrice=BigDecimal.ZERO;
|
||||||
|
// 判断ordertype=2时的特殊价格逻辑
|
||||||
|
if (cart.getOrdertype() != null && cart.getOrdertype() == 2) {
|
||||||
|
String skuStr = cart.getSku();
|
||||||
|
if (skuStr != null && !skuStr.trim().isEmpty()) {
|
||||||
|
try {
|
||||||
|
com.alibaba.fastjson2.JSONObject skuJson = com.alibaba.fastjson2.JSONObject.parseObject(skuStr);
|
||||||
|
if (skuJson.containsKey("seckillprice")) {
|
||||||
|
BigDecimal seckillPrice = new BigDecimal(skuJson.getString("seckillprice"));
|
||||||
|
itemPrice = seckillPrice.multiply(BigDecimal.valueOf(cart.getGoodNum()));
|
||||||
|
} else {
|
||||||
|
// 没有seckillprice字段,回退用fixedprice
|
||||||
|
itemPrice = (serviceGoods.getFixedprice() != null ? serviceGoods.getFixedprice() : serviceGoods.getPrice()).multiply(BigDecimal.valueOf(cart.getGoodNum()));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 解析失败,回退用fixedprice
|
||||||
|
itemPrice = (serviceGoods.getFixedprice() != null ? serviceGoods.getFixedprice() : serviceGoods.getPrice()).multiply(BigDecimal.valueOf(cart.getGoodNum()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// sku为空,直接用fixedprice
|
||||||
|
itemPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其他情况用普通价格
|
||||||
|
itemPrice = serviceGoods.getPrice().multiply(BigDecimal.valueOf(cart.getGoodNum()));
|
||||||
|
}
|
||||||
|
Order order = new Order();
|
||||||
|
order.setType(1);
|
||||||
|
order.setCreateType(1);
|
||||||
|
order.setOrderId(GenerateCustomCode.generCreateOrder("B"));
|
||||||
|
order.setUid(user.getId());
|
||||||
|
order.setUname(user.getName());
|
||||||
|
order.setProductId(serviceGoods.getId());
|
||||||
|
order.setProductName(serviceGoods.getTitle());
|
||||||
|
order.setNum(cart.getGoodNum());
|
||||||
|
order.setSku(cart.getSku());
|
||||||
|
order.setReamk(cart.getReamk());
|
||||||
|
order.setFileData(cart.getFileData());
|
||||||
|
order.setOdertype(cart.getOrdertype() != null ? cart.getOrdertype().intValue() : 0);
|
||||||
|
order.setAddressId(userAddress.getId());
|
||||||
|
order.setName(userAddress.getName());
|
||||||
|
order.setPhone(userAddress.getPhone());
|
||||||
|
order.setAddress(userAddress.getAddressInfo());
|
||||||
|
if (makeTime != null && !makeTime.isEmpty()) {
|
||||||
|
String[] makeTimeArr = makeTime.split(" ");
|
||||||
|
if (makeTimeArr.length == 2) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date date = sdf.parse(makeTimeArr[0]);
|
||||||
|
order.setMakeTime(date.getTime() / 1000);
|
||||||
|
order.setMakeHour(makeTimeArr[1]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("预约时间格式错误: " + makeTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order.setTotalPrice(itemPrice);
|
||||||
|
order.setGoodPrice(serviceGoods.getPrice());
|
||||||
|
order.setServicePrice(BigDecimal.ZERO);
|
||||||
|
order.setPayPrice(itemPrice);
|
||||||
|
order.setStatus(1L);
|
||||||
|
order.setReceiveType(1L);
|
||||||
|
order.setIsAccept(0);
|
||||||
|
order.setIsComment(0);
|
||||||
|
order.setIsPause(1);
|
||||||
|
order.setMainOrderId(maincorid);
|
||||||
|
order.setDeduction(BigDecimal.ZERO);
|
||||||
|
int insertResult = orderService.insertOrder(order);
|
||||||
|
if (insertResult <= 0) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("msg", "服务订单创建失败");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 添加订单日志
|
||||||
|
OrderLog orderLog = new OrderLog();
|
||||||
|
orderLog.setOid(order.getId());
|
||||||
|
orderLog.setOrderId(order.getOrderId());
|
||||||
|
orderLog.setTitle("订单生成");
|
||||||
|
orderLog.setType(BigDecimal.valueOf(1.0));
|
||||||
|
com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
|
||||||
|
jsonObject.put("name", "订单创建成功");
|
||||||
|
orderLog.setContent(jsonObject.toJSONString());
|
||||||
|
orderLogService.insertOrderLog(orderLog);
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("orderId", order.getOrderId());
|
||||||
|
result.put("productName", serviceGoods.getTitle());
|
||||||
|
result.put("allprice", itemPrice.toString());
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("服务类购物车下单异常:", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("msg", "服务类购物车下单异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品类购物车下单
|
||||||
|
* @param user 用户
|
||||||
|
* @param cart 购物车
|
||||||
|
* @param serviceGoods 商品
|
||||||
|
* @param userAddress 地址
|
||||||
|
* @param goodsOrderService 商品订单service
|
||||||
|
* @return 下单结果Map
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> createGoodsOrderFromCart(Users user, GoodsCart cart, ServiceGoods serviceGoods, UserAddress userAddress, IGoodsOrderService goodsOrderService,String maincorid) {
|
||||||
|
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.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);
|
||||||
|
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());
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("商品类购物车下单异常:", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("msg", "商品类购物车下单异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,338 @@
|
||||||
|
package com.ruoyi.system.ControllerUtil;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
import com.ruoyi.system.domain.SiteConfig;
|
||||||
|
import com.ruoyi.system.domain.Users;
|
||||||
|
import com.ruoyi.system.domain.UsersPayBefor;
|
||||||
|
import com.ruoyi.system.service.IUsersPayBeforService;
|
||||||
|
import com.ruoyi.system.service.ISiteConfigService;
|
||||||
|
import com.ruoyi.system.service.IUsersService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预支付工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-07-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class PayBeforeUtil {
|
||||||
|
|
||||||
|
|
||||||
|
private static final IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
|
||||||
|
private static final ISiteConfigService siteConfigService = SpringUtils.getBean(ISiteConfigService.class);
|
||||||
|
private static final IUsersService usersService = SpringUtils.getBean(IUsersService.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建预支付记录
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param amount 支付金额
|
||||||
|
* @param orderId 订单号
|
||||||
|
* @param oid 订单ID
|
||||||
|
* @param serviceId 服务ID
|
||||||
|
* @param orderType 订单类型
|
||||||
|
* @param sku SKU规格信息
|
||||||
|
* @param grouporderid 拼团订单ID
|
||||||
|
* @param addressid 地址ID
|
||||||
|
* @param maketime 预约时间
|
||||||
|
* @param attachments 附件信息
|
||||||
|
* @return 预支付记录ID,失败返回null
|
||||||
|
*/
|
||||||
|
public String createPayBefore(Users user, BigDecimal amount, String orderId, Long oid,
|
||||||
|
Long serviceId, Long orderType, String sku, String grouporderid,
|
||||||
|
Long addressid, String maketime, String attachments,Long servicetype) {
|
||||||
|
try {
|
||||||
|
// 计算会员优惠和服务金抵扣
|
||||||
|
BigDecimal memberMoney = BigDecimal.ZERO;
|
||||||
|
BigDecimal serviceMoney = BigDecimal.ZERO;
|
||||||
|
BigDecimal shopMoney = BigDecimal.ZERO;
|
||||||
|
try {
|
||||||
|
SiteConfig configQuery = new SiteConfig();
|
||||||
|
configQuery.setName("config_one");
|
||||||
|
List<SiteConfig> configList = siteConfigService.selectSiteConfigList(configQuery);
|
||||||
|
if (configList != null && !configList.isEmpty()) {
|
||||||
|
String configValue = configList.get(0).getValue();
|
||||||
|
if (configValue != null && !configValue.trim().isEmpty()) {
|
||||||
|
com.alibaba.fastjson2.JSONObject configJson = com.alibaba.fastjson2.JSONObject.parseObject(configValue);
|
||||||
|
// 会员优惠
|
||||||
|
if (user.getIsmember() != null && user.getIsmember() == 1) {
|
||||||
|
Integer memberDiscount = configJson.getInteger("member_discount");
|
||||||
|
if (memberDiscount != null && memberDiscount > 0) {
|
||||||
|
BigDecimal discountRate = BigDecimal.valueOf(memberDiscount).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
|
memberMoney = amount.multiply(discountRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 服务金抵扣
|
||||||
|
if (servicetype != null && servicetype == 1) {
|
||||||
|
Integer serviceFee = configJson.getInteger("servicefee");
|
||||||
|
if (serviceFee != null && serviceFee > 0) {
|
||||||
|
Users userDb = usersService.selectUsersById(user.getId());
|
||||||
|
if (userDb != null && userDb.getServicefee() != null && userDb.getServicefee().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
BigDecimal serviceRate = BigDecimal.valueOf(serviceFee).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
|
serviceMoney = userDb.getServicefee().multiply(serviceRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 购物金抵扣(当servicetype=2时)
|
||||||
|
if (servicetype != null && servicetype == 2) {
|
||||||
|
orderType= 5L;
|
||||||
|
Integer consumption = configJson.getInteger("consumption");
|
||||||
|
if (consumption != null && consumption > 0) {
|
||||||
|
Users userDb = usersService.selectUsersById(user.getId());
|
||||||
|
if (userDb != null && userDb.getConsumption() != null && userDb.getConsumption().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
BigDecimal consumptionRate = BigDecimal.valueOf(consumption).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
|
shopMoney = userDb.getConsumption().multiply(consumptionRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
memberMoney = BigDecimal.ZERO;
|
||||||
|
serviceMoney = BigDecimal.ZERO;
|
||||||
|
shopMoney = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
UsersPayBefor payBefore = new UsersPayBefor();
|
||||||
|
payBefore.setUid(user.getId());
|
||||||
|
payBefore.setOrderid(orderId);
|
||||||
|
payBefore.setOid(oid);
|
||||||
|
payBefore.setPaycode(GenerateCustomCode.generCreateOrder("PAY"));
|
||||||
|
payBefore.setAllmoney(amount); // 原始总金额
|
||||||
|
// 微信支付金额 = 总金额 - 会员优惠 - 服务金抵扣 - 购物金抵扣
|
||||||
|
BigDecimal wxPayAmount = amount.subtract(memberMoney).subtract(serviceMoney).subtract(shopMoney);
|
||||||
|
payBefore.setWxmoney(wxPayAmount.compareTo(BigDecimal.ZERO) > 0 ? wxPayAmount : BigDecimal.ZERO);
|
||||||
|
payBefore.setShopmoney(shopMoney);
|
||||||
|
payBefore.setServicemoney(serviceMoney);
|
||||||
|
payBefore.setMtmoney(BigDecimal.ZERO);
|
||||||
|
payBefore.setYemoney(BigDecimal.ZERO);
|
||||||
|
payBefore.setCouponmoney(BigDecimal.ZERO);
|
||||||
|
payBefore.setServicetype(servicetype);
|
||||||
|
payBefore.setMembermoney(memberMoney);
|
||||||
|
payBefore.setType(orderType);
|
||||||
|
payBefore.setSku(sku != null ? sku : "");
|
||||||
|
payBefore.setServiceid(serviceId);
|
||||||
|
payBefore.setGrouporderid(grouporderid != null ? grouporderid : "");
|
||||||
|
payBefore.setAddressid(addressid);
|
||||||
|
payBefore.setMaketime(maketime != null ? maketime : "");
|
||||||
|
payBefore.setAttachments(attachments != null ? attachments : "");
|
||||||
|
payBefore.setStatus(1L); // 1待支付
|
||||||
|
payBefore.setPaytype(1L); // 默认微信支付
|
||||||
|
int result = usersPayBeforService.insertUsersPayBefor(payBefore);
|
||||||
|
if (result > 0) {
|
||||||
|
return payBefore.getOrderid();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 创建预支付记录购物车过来的
|
||||||
|
// *
|
||||||
|
// * @param user 用户信息
|
||||||
|
// * @param amount 支付金额
|
||||||
|
// * @param orderId 订单号
|
||||||
|
// * @param oid 订单ID
|
||||||
|
// * @param serviceId 服务ID
|
||||||
|
// * @param orderType 订单类型
|
||||||
|
// * @param sku SKU规格信息
|
||||||
|
// * @param grouporderid 拼团订单ID
|
||||||
|
// * @param addressid 地址ID
|
||||||
|
// * @param maketime 预约时间
|
||||||
|
// * @param attachments 附件信息
|
||||||
|
// * @return 预支付记录ID,失败返回null
|
||||||
|
// */
|
||||||
|
// public Long createPayBeforeByCar(Users user, BigDecimal amount, String orderId, Long oid,
|
||||||
|
// Long serviceId, Long orderType, String sku, String grouporderid,
|
||||||
|
// Long addressid, String maketime, String attachments) {
|
||||||
|
// try {
|
||||||
|
// // 计算会员优惠和服务金抵扣
|
||||||
|
// BigDecimal memberMoney = BigDecimal.ZERO;
|
||||||
|
// BigDecimal serviceMoney = BigDecimal.ZERO;
|
||||||
|
// try {
|
||||||
|
// SiteConfig configQuery = new SiteConfig();
|
||||||
|
// configQuery.setName("config_one");
|
||||||
|
// List<SiteConfig> configList = siteConfigService.selectSiteConfigList(configQuery);
|
||||||
|
// if (configList != null && !configList.isEmpty()) {
|
||||||
|
// String configValue = configList.get(0).getValue();
|
||||||
|
// if (configValue != null && !configValue.trim().isEmpty()) {
|
||||||
|
// com.alibaba.fastjson2.JSONObject configJson = com.alibaba.fastjson2.JSONObject.parseObject(configValue);
|
||||||
|
// // 会员优惠
|
||||||
|
// if (user.getIsmember() != null && user.getIsmember() == 1) {
|
||||||
|
// Integer memberDiscount = configJson.getInteger("member_discount");
|
||||||
|
// if (memberDiscount != null && memberDiscount > 0) {
|
||||||
|
// BigDecimal discountRate = BigDecimal.valueOf(memberDiscount).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// memberMoney = amount.multiply(discountRate);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 服务金抵扣
|
||||||
|
// Integer serviceFee = configJson.getInteger("servicefee");
|
||||||
|
// if (serviceFee != null && serviceFee > 0) {
|
||||||
|
// Users userDb = usersService.selectUsersById(user.getId());
|
||||||
|
// if (userDb != null && userDb.getServicefee() != null && userDb.getServicefee().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
// BigDecimal serviceRate = BigDecimal.valueOf(serviceFee).divide(BigDecimal.valueOf(100), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// serviceMoney = userDb.getServicefee().multiply(serviceRate);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// memberMoney = BigDecimal.ZERO;
|
||||||
|
// serviceMoney = BigDecimal.ZERO;
|
||||||
|
// }
|
||||||
|
// UsersPayBefor payBefore = new UsersPayBefor();
|
||||||
|
// payBefore.setUid(user.getId());
|
||||||
|
// payBefore.setOrderid(orderId);
|
||||||
|
// payBefore.setOid(oid);
|
||||||
|
// payBefore.setPaycode(GenerateCustomCode.generCreateOrder("PAY"));
|
||||||
|
// payBefore.setAllmoney(amount);
|
||||||
|
// payBefore.setWxmoney(amount);
|
||||||
|
// payBefore.setShopmoney(BigDecimal.ZERO);
|
||||||
|
// payBefore.setServicemoney(serviceMoney);
|
||||||
|
// payBefore.setMtmoney(BigDecimal.ZERO);
|
||||||
|
// payBefore.setYemoney(BigDecimal.ZERO);
|
||||||
|
// payBefore.setCouponmoney(BigDecimal.ZERO);
|
||||||
|
// payBefore.setServicetype(serviceId);
|
||||||
|
// payBefore.setMembermoney(memberMoney);
|
||||||
|
// payBefore.setType(orderType);
|
||||||
|
// payBefore.setSku(sku != null ? sku : "");
|
||||||
|
// payBefore.setServiceid(serviceId);
|
||||||
|
// payBefore.setGrouporderid(grouporderid != null ? grouporderid : "");
|
||||||
|
// payBefore.setAddressid(addressid);
|
||||||
|
// payBefore.setMaketime(maketime != null ? maketime : "");
|
||||||
|
// payBefore.setAttachments(attachments != null ? attachments : "");
|
||||||
|
// payBefore.setStatus(1L); // 1待支付
|
||||||
|
// payBefore.setPaytype(1L); // 默认微信支付
|
||||||
|
// int result = usersPayBeforService.insertUsersPayBefor(payBefore);
|
||||||
|
// if (result > 0) {
|
||||||
|
// return payBefore.getId();
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建预支付记录(简化版)
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param amount 支付金额
|
||||||
|
* @return 预支付记录ID,失败返回null
|
||||||
|
*/
|
||||||
|
public String createPayBefore(Users user, BigDecimal amount) {
|
||||||
|
return createPayBefore(user, amount, null, null, 0L, 0L, null, null, null, null, null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建预支付记录(基础版)
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @param amount 支付金额
|
||||||
|
* @param orderId 订单号
|
||||||
|
* @param oid 订单ID
|
||||||
|
* @param serviceId 服务ID
|
||||||
|
* @param orderType 订单类型
|
||||||
|
* @return 预支付记录ID,失败返回null
|
||||||
|
*/
|
||||||
|
public String createPayBefore(Users user, BigDecimal amount, String orderId, Long oid,
|
||||||
|
Long serviceId, Long orderType) {
|
||||||
|
return createPayBefore(user, amount, orderId, oid, serviceId, orderType, null, null, null, null, null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新预支付记录
|
||||||
|
*
|
||||||
|
* @param payBeforeId 预支付记录ID
|
||||||
|
* @param amount 新的支付金额
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
public boolean updatePayBefore(Long payBeforeId, BigDecimal amount) {
|
||||||
|
try {
|
||||||
|
UsersPayBefor payBefore = usersPayBeforService.selectUsersPayBeforById(payBeforeId);
|
||||||
|
if (payBefore == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
payBefore.setAllmoney(amount);
|
||||||
|
payBefore.setWxmoney(amount);
|
||||||
|
payBefore.setUpdateTime(new Date());
|
||||||
|
int result = usersPayBeforService.updateUsersPayBefor(payBefore);
|
||||||
|
return result > 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新预支付记录状态
|
||||||
|
*
|
||||||
|
* @param payBeforeId 预支付记录ID
|
||||||
|
* @param status 新状态
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
public boolean updatePayBeforeStatus(Long payBeforeId, Long status) {
|
||||||
|
try {
|
||||||
|
UsersPayBefor payBefore = usersPayBeforService.selectUsersPayBeforById(payBeforeId);
|
||||||
|
if (payBefore == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
payBefore.setStatus(status);
|
||||||
|
if (status == 2L) { // 支付成功
|
||||||
|
payBefore.setPaytime(new Date());
|
||||||
|
}
|
||||||
|
payBefore.setUpdateTime(new Date());
|
||||||
|
int result = usersPayBeforService.updateUsersPayBefor(payBefore);
|
||||||
|
return result > 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号查询预支付记录
|
||||||
|
*
|
||||||
|
* @param orderId 订单号
|
||||||
|
* @return 预支付记录,不存在返回null
|
||||||
|
*/
|
||||||
|
public UsersPayBefor getPayBeforeByOrderId(String orderId) {
|
||||||
|
try {
|
||||||
|
return usersPayBeforService.selectUsersPayBeforByOrderId(orderId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除预支付记录
|
||||||
|
*
|
||||||
|
* @param payBeforeId 预支付记录ID
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
public boolean deletePayBefore(Long payBeforeId) {
|
||||||
|
try {
|
||||||
|
int result = usersPayBeforService.deleteUsersPayBeforById(payBeforeId);
|
||||||
|
return result > 0;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,8 @@ public class OrderApple extends BaseEntity {
|
||||||
private Integer type;// 1
|
private Integer type;// 1
|
||||||
private Integer odertype;// 1
|
private Integer odertype;// 1
|
||||||
private Integer reamk;// 1
|
private Integer reamk;// 1
|
||||||
|
private Integer cartid;
|
||||||
|
private Integer bigtype;
|
||||||
private String fileData;
|
private String fileData;
|
||||||
private Long uid;// : 302
|
private Long uid;// : 302
|
||||||
|
|
||||||
|
|
@ -171,4 +172,21 @@ public class OrderApple extends BaseEntity {
|
||||||
public void setReamk(Integer reamk) {
|
public void setReamk(Integer reamk) {
|
||||||
this.reamk = reamk;
|
this.reamk = reamk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getBigtype() {
|
||||||
|
return bigtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBigtype(Integer bigtype) {
|
||||||
|
this.bigtype = bigtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCartid() {
|
||||||
|
return cartid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCartid(Integer cartid) {
|
||||||
|
this.cartid = cartid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ public class GoodsCart extends BaseEntity
|
||||||
@Excel(name = "类别")
|
@Excel(name = "类别")
|
||||||
private Long ordertype;
|
private Long ordertype;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
|
|
@ -160,6 +163,14 @@ public class GoodsCart extends BaseEntity
|
||||||
this.ordertype = ordertype;
|
this.ordertype = ordertype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getGoodstype() {
|
||||||
|
return goodstype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodstype(Long goodstype) {
|
||||||
|
this.goodstype = goodstype;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,16 @@ public class GoodsOrder extends BaseEntity
|
||||||
@Excel(name = "邮费")
|
@Excel(name = "邮费")
|
||||||
private BigDecimal postage;
|
private BigDecimal postage;
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
@Excel(name = "是否跳转服务")
|
||||||
|
private Integer isforservice;
|
||||||
|
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
@Excel(name = "跳转服务id")
|
||||||
|
private Integer forserviceid;
|
||||||
|
|
||||||
|
|
||||||
/** 支付时间 */
|
/** 支付时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
|
@ -531,6 +541,23 @@ public class GoodsOrder extends BaseEntity
|
||||||
this.shopadresssid = shopadresssid;
|
this.shopadresssid = shopadresssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getForserviceid() {
|
||||||
|
return forserviceid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForserviceid(Integer forserviceid) {
|
||||||
|
this.forserviceid = forserviceid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsforservice() {
|
||||||
|
return isforservice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsforservice(Integer isforservice) {
|
||||||
|
this.isforservice = isforservice;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,10 @@ public class Order extends BaseEntity
|
||||||
@Excel(name = "服务评价")
|
@Excel(name = "服务评价")
|
||||||
private int fwpj;
|
private int fwpj;
|
||||||
|
|
||||||
|
/** 通知记录 */
|
||||||
|
@Excel(name = "大分类")
|
||||||
|
private Integer bigtype;
|
||||||
|
|
||||||
|
|
||||||
/** 订单附件 */
|
/** 订单附件 */
|
||||||
@Excel(name = "订单附件")
|
@Excel(name = "订单附件")
|
||||||
|
|
@ -875,6 +879,14 @@ public class Order extends BaseEntity
|
||||||
this.cartid = cartid;
|
this.cartid = cartid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getBigtype() {
|
||||||
|
return bigtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBigtype(Integer bigtype) {
|
||||||
|
this.bigtype = bigtype;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,21 @@ private String cateName;
|
||||||
@Excel(name = "排序")
|
@Excel(name = "排序")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
@Excel(name = "是否跳转服务")
|
||||||
|
private Integer isforservice;
|
||||||
|
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
@Excel(name = "跳转服务id")
|
||||||
|
private Integer forserviceid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 物料费用 */
|
/** 物料费用 */
|
||||||
|
|
||||||
|
|
||||||
@Excel(name = "物料费用")
|
@Excel(name = "物料费用")
|
||||||
private String material;
|
private String material;
|
||||||
|
|
||||||
|
|
@ -650,6 +664,22 @@ private String cateName;
|
||||||
this.questions = questions;
|
this.questions = questions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIsforservice() {
|
||||||
|
return isforservice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsforservice(Integer isforservice) {
|
||||||
|
this.isforservice = isforservice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getForserviceid() {
|
||||||
|
return forserviceid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForserviceid(Integer forserviceid) {
|
||||||
|
this.forserviceid = forserviceid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="uid" column="uid" />
|
<result property="uid" column="uid" />
|
||||||
<result property="couponId" column="coupon_id" />
|
<result property="couponId" column="coupon_id" />
|
||||||
<result property="productId" column="product_id" />
|
<result property="productId" column="product_id" />
|
||||||
|
<result property="isforservice" column="isforservice" />
|
||||||
|
<result property="forserviceid" column="forserviceid" />
|
||||||
<result property="name" column="name" />
|
<result property="name" column="name" />
|
||||||
<result property="phone" column="phone" />
|
<result property="phone" column="phone" />
|
||||||
<result property="address" column="address" />
|
<result property="address" column="address" />
|
||||||
|
|
@ -42,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGoodsOrderVo">
|
<sql id="selectGoodsOrderVo">
|
||||||
select id, type, main_order_id, order_id, transaction_id,isself,coupon_id,shopadresssid, uid, product_id, name, phone, address, num, total_price, good_price, service_price, pay_price, deduction, postage, pay_time, status, delivery_id, delivery_num, send_time, mark, address_id, sku, created_at, updated_at, deleted_at from goods_order
|
select id, type, main_order_id, order_id, transaction_id,forserviceid,isforservice,isself,coupon_id,shopadresssid, uid, product_id, name, phone, address, num, total_price, good_price, service_price, pay_price, deduction, postage, pay_time, status, delivery_id, delivery_num, send_time, mark, address_id, sku, created_at, updated_at, deleted_at from goods_order
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGoodsOrderList" parameterType="GoodsOrder" resultMap="GoodsOrderResult">
|
<select id="selectGoodsOrderList" parameterType="GoodsOrder" resultMap="GoodsOrderResult">
|
||||||
|
|
@ -118,6 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="sku != null">sku,</if>
|
<if test="sku != null">sku,</if>
|
||||||
<if test="isself != null">isself,</if>
|
<if test="isself != null">isself,</if>
|
||||||
<if test="shopadresssid != null">shopadresssid,</if>
|
<if test="shopadresssid != null">shopadresssid,</if>
|
||||||
|
<if test="isforservice != null">isforservice,</if>
|
||||||
|
<if test="forserviceid != null">forserviceid,</if>
|
||||||
created_at,
|
created_at,
|
||||||
updated_at
|
updated_at
|
||||||
<if test="deletedAt != null">deleted_at,</if>
|
<if test="deletedAt != null">deleted_at,</if>
|
||||||
|
|
@ -151,6 +155,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="deletedAt != null">#{deletedAt},</if>
|
<if test="deletedAt != null">#{deletedAt},</if>
|
||||||
<if test="isself != null">#{isself},</if>
|
<if test="isself != null">#{isself},</if>
|
||||||
<if test="shopadresssid != null">#{shopadresssid},</if>
|
<if test="shopadresssid != null">#{shopadresssid},</if>
|
||||||
|
<if test="isforservice != null">#{isforservice},</if>
|
||||||
|
<if test="forserviceid != null">#{forserviceid},</if>
|
||||||
NOW(),
|
NOW(),
|
||||||
NOW()
|
NOW()
|
||||||
|
|
||||||
|
|
@ -188,6 +194,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
|
<if test="deletedAt != null">deleted_at = #{deletedAt},</if>
|
||||||
<if test="isself != null">isself = #{isself},</if>
|
<if test="isself != null">isself = #{isself},</if>
|
||||||
<if test="shopadresssid != null">shopadresssid = #{shopadresssid},</if>
|
<if test="shopadresssid != null">shopadresssid = #{shopadresssid},</if>
|
||||||
|
<if test="isforservice != null">isforservice = #{isforservice},</if>
|
||||||
|
<if test="forserviceid != null">forserviceid = #{forserviceid},</if>
|
||||||
updated_at=NOW()
|
updated_at=NOW()
|
||||||
|
|
||||||
</trim>
|
</trim>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
<result property="makeHour" column="make_hour"/>
|
<result property="makeHour" column="make_hour"/>
|
||||||
<result property="num" column="num"/>
|
<result property="num" column="num"/>
|
||||||
<result property="cartid" column="cartid"/>
|
<result property="cartid" column="cartid"/>
|
||||||
|
<result property="bigtype" column="bigtype"/>
|
||||||
|
|
||||||
|
|
||||||
<result property="totalPrice" column="total_price"/>
|
<result property="totalPrice" column="total_price"/>
|
||||||
<result property="goodPrice" column="good_price"/>
|
<result property="goodPrice" column="good_price"/>
|
||||||
|
|
@ -75,6 +77,7 @@
|
||||||
<result property="product_id" column="product_id"/>
|
<result property="product_id" column="product_id"/>
|
||||||
<result property="sku" column="sku"/>
|
<result property="sku" column="sku"/>
|
||||||
<result property="cartid" column="cartid"/>
|
<result property="cartid" column="cartid"/>
|
||||||
|
<result property="bigtype" column="bigtype"/>
|
||||||
|
|
||||||
<result property="status" column="status"/>
|
<result property="status" column="status"/>
|
||||||
<result property="total_price" column="total_price"/>
|
<result property="total_price" column="total_price"/>
|
||||||
|
|
@ -101,6 +104,7 @@
|
||||||
make_time,
|
make_time,
|
||||||
make_hour,
|
make_hour,
|
||||||
reamk,
|
reamk,
|
||||||
|
bigtype,
|
||||||
num,
|
num,
|
||||||
total_price,
|
total_price,
|
||||||
good_price,
|
good_price,
|
||||||
|
|
@ -175,6 +179,9 @@
|
||||||
<if test="startdate != null and enddate != null">
|
<if test="startdate != null and enddate != null">
|
||||||
and created_at BETWEEN #{startdate} AND #{enddate}
|
and created_at BETWEEN #{startdate} AND #{enddate}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bigtype != null and bigtype != null">
|
||||||
|
and bigtype = #{bigtype}
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="orderId != null and orderId != ''">
|
<if test="orderId != null and orderId != ''">
|
||||||
and order_id like concat('%', #{orderId}, '%')
|
and order_id like concat('%', #{orderId}, '%')
|
||||||
|
|
@ -370,6 +377,9 @@
|
||||||
<if test="cartid != null">
|
<if test="cartid != null">
|
||||||
cartid,
|
cartid,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bigtype != null">
|
||||||
|
bigtype,
|
||||||
|
</if>
|
||||||
|
|
||||||
created_at,
|
created_at,
|
||||||
updated_at
|
updated_at
|
||||||
|
|
@ -516,7 +526,9 @@
|
||||||
<if test="cartid != null">
|
<if test="cartid != null">
|
||||||
#{cartid},
|
#{cartid},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bigtype != null">
|
||||||
|
#{bigtype},
|
||||||
|
</if>
|
||||||
NOW(),
|
NOW(),
|
||||||
NOW()
|
NOW()
|
||||||
</trim>
|
</trim>
|
||||||
|
|
@ -534,8 +546,9 @@
|
||||||
<if test="fileData != null">
|
<if test="fileData != null">
|
||||||
file_data = #{fileData},
|
file_data = #{fileData},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="bigtype != null">
|
||||||
|
bigtype = #{bigtype},
|
||||||
|
</if>
|
||||||
<if test="orderId != null and orderId != ''">
|
<if test="orderId != null and orderId != ''">
|
||||||
order_id = #{orderId},
|
order_id = #{orderId},
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="sku" column="sku" />
|
<result property="sku" column="sku" />
|
||||||
<result property="servicetype" column="servicetype" />
|
<result property="servicetype" column="servicetype" />
|
||||||
|
|
||||||
|
<result property="isforservice" column="isforservice" />
|
||||||
|
<result property="forserviceid" column="forserviceid" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<result property="questions" column="questions" />
|
<result property="questions" column="questions" />
|
||||||
|
|
||||||
<result property="latitude" column="latitude" />
|
<result property="latitude" column="latitude" />
|
||||||
|
|
@ -53,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectServiceGoodsVo">
|
<sql id="selectServiceGoodsVo">
|
||||||
select id, title, icon, imgs, sub_title, info, price,questions, price_zn, sales,servicetype, stock, status, description, sku_type,groupnum,sku, latitude, longitude, type, cate_id, first_cate_id, second_cate_id, project, sort, material, postage, basic, margin, skill_ids, created_at, updated_at, deleted_at, isgroup, groupprice, isonce, onceprice, commissiontype, commission, dispatchtype, workerids, isfixed, fixedprice from service_goods
|
select id, title, icon, imgs,isforservice,forserviceid, sub_title, info, price,questions, price_zn, sales,servicetype, stock, status, description, sku_type,groupnum,sku, latitude, longitude, type, cate_id, first_cate_id, second_cate_id, project, sort, material, postage, basic, margin, skill_ids, created_at, updated_at, deleted_at, isgroup, groupprice, isonce, onceprice, commissiontype, commission, dispatchtype, workerids, isfixed, fixedprice from service_goods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectServiceGoodsList" parameterType="ServiceGoods" resultMap="ServiceGoodsResult">
|
<select id="selectServiceGoodsList" parameterType="ServiceGoods" resultMap="ServiceGoodsResult">
|
||||||
|
|
@ -162,7 +168,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="groupnum != null">groupnum,</if>
|
<if test="groupnum != null">groupnum,</if>
|
||||||
<if test="servicetype != null">servicetype,</if>
|
<if test="servicetype != null">servicetype,</if>
|
||||||
<if test="questions != null">questions,</if>
|
<if test="questions != null">questions,</if>
|
||||||
|
<if test="isforservice != null">isforservice,</if>
|
||||||
|
<if test="forserviceid != null">forserviceid,</if>
|
||||||
created_at,
|
created_at,
|
||||||
updated_at
|
updated_at
|
||||||
|
|
||||||
|
|
@ -208,6 +215,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="groupnum != null">#{groupnum},</if>
|
<if test="groupnum != null">#{groupnum},</if>
|
||||||
<if test="servicetype != null">#{servicetype},</if>
|
<if test="servicetype != null">#{servicetype},</if>
|
||||||
<if test="questions != null">#{questions},</if>
|
<if test="questions != null">#{questions},</if>
|
||||||
|
<if test="isforservice != null">#{isforservice},</if>
|
||||||
|
<if test="forserviceid != null">#{forserviceid},</if>
|
||||||
NOW(),
|
NOW(),
|
||||||
NOW()
|
NOW()
|
||||||
|
|
||||||
|
|
@ -250,7 +259,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="onceprice != null">onceprice = #{onceprice},</if>
|
<if test="onceprice != null">onceprice = #{onceprice},</if>
|
||||||
<if test="servicetype != null">servicetype = #{servicetype},</if>
|
<if test="servicetype != null">servicetype = #{servicetype},</if>
|
||||||
<if test="questions != null">questions = #{questions},</if>
|
<if test="questions != null">questions = #{questions},</if>
|
||||||
|
<if test="isforservice != null">isforservice = #{isforservice},</if>
|
||||||
|
<if test="forserviceid != null">forserviceid = #{forserviceid},</if>
|
||||||
<if test="commissiontype != null">commissiontype = #{commissiontype},</if>
|
<if test="commissiontype != null">commissiontype = #{commissiontype},</if>
|
||||||
<if test="commission != null">commission = #{commission},</if>
|
<if test="commission != null">commission = #{commission},</if>
|
||||||
<if test="dispatchtype != null">dispatchtype = #{dispatchtype},</if>
|
<if test="dispatchtype != null">dispatchtype = #{dispatchtype},</if>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,17 @@ export function getServiceGoods(id) {
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询服务内容详细
|
||||||
|
export function getselectTypeList(type) {
|
||||||
|
return request({
|
||||||
|
url: '/system/ServiceGoods/selectTypeList/' + type,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 查询服务内容详细
|
// 查询服务内容详细
|
||||||
export function selectServiceCateList(id) {
|
export function selectServiceCateList(id) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,23 @@
|
||||||
inactive-value="0"
|
inactive-value="0"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<!-- 新增:是否关联服务 -->
|
||||||
|
<el-form-item label="是否关联服务" prop="isforservice">
|
||||||
|
<el-radio-group v-model="form.isforservice">
|
||||||
|
<el-radio :label="1">是</el-radio>
|
||||||
|
<el-radio :label="2">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.isforservice == 1" label="关联服务" prop="forserviceid">
|
||||||
|
<el-select v-model="form.forserviceid" placeholder="请选择服务" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="item in forServiceList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.title"
|
||||||
|
:value="String(item.id)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="规格配置" name="spec">
|
<el-tab-pane label="规格配置" name="spec">
|
||||||
<el-form-item label="规格">
|
<el-form-item label="规格">
|
||||||
|
|
@ -356,7 +373,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listServiceGoods, getServiceGoods, delServiceGoods, addServiceGoods, updateServiceGoods ,changefenleiStatus,selectServiceCateList} from "@/api/system/ServiceGoods"
|
import { listServiceGoods, getServiceGoods, delServiceGoods, addServiceGoods, updateServiceGoods ,changefenleiStatus,selectServiceCateList,getselectTypeList} from "@/api/system/ServiceGoods"
|
||||||
import Editor from '@/components/Editor'
|
import Editor from '@/components/Editor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -400,8 +417,6 @@ export default {
|
||||||
subTitle: null,
|
subTitle: null,
|
||||||
status: null,
|
status: null,
|
||||||
project: null,
|
project: null,
|
||||||
createdStart: null,
|
|
||||||
createdEnd: null,
|
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
|
|
@ -425,6 +440,12 @@ export default {
|
||||||
sku: [
|
sku: [
|
||||||
{ required: true, message: "规格信息不能为空", trigger: "blur" }
|
{ required: true, message: "规格信息不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
|
isforservice: [
|
||||||
|
{ required: true, message: "请选择是否关联服务", trigger: "change" }
|
||||||
|
],
|
||||||
|
forserviceid: [
|
||||||
|
{ required: function() { return this.form && this.form.isforservice == 1 }, message: "请选择关联服务", trigger: "change" }
|
||||||
|
],
|
||||||
},
|
},
|
||||||
audioDialogVisible: false,
|
audioDialogVisible: false,
|
||||||
currentAudioUrl: '',
|
currentAudioUrl: '',
|
||||||
|
|
@ -440,11 +461,14 @@ export default {
|
||||||
specList: [ { name: '', values: [''] } ],
|
specList: [ { name: '', values: [''] } ],
|
||||||
skuTable: [],
|
skuTable: [],
|
||||||
saveTimeout: null, // 用于防抖的定时器
|
saveTimeout: null, // 用于防抖的定时器
|
||||||
|
isforservice: 2, // 默认2
|
||||||
|
forServiceList: [], // 关联服务下拉数据
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
this.getserviceCateList();
|
this.getserviceCateList();
|
||||||
|
this.getForServiceList(); // 新增
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询服务内容列表 */
|
/** 查询服务内容列表 */
|
||||||
|
|
@ -496,6 +520,8 @@ export default {
|
||||||
deletedAt: null,
|
deletedAt: null,
|
||||||
questionsArray: [], // 问答数组
|
questionsArray: [], // 问答数组
|
||||||
questions: null, // 问答JSON字符串
|
questions: null, // 问答JSON字符串
|
||||||
|
isforservice: 2,
|
||||||
|
forserviceid: null,
|
||||||
}
|
}
|
||||||
// 重置skuType为默认值
|
// 重置skuType为默认值
|
||||||
this.skuType = 1;
|
this.skuType = 1;
|
||||||
|
|
@ -588,6 +614,15 @@ export default {
|
||||||
}
|
}
|
||||||
this.open = true
|
this.open = true
|
||||||
this.title = "修改服务内容"
|
this.title = "修改服务内容"
|
||||||
|
this.form.isforservice = response.data.isforservice || 2;
|
||||||
|
// forserviceid转为字符串
|
||||||
|
this.form.forserviceid = response.data.forserviceid !== undefined && response.data.forserviceid !== null ? String(response.data.forserviceid) : null;
|
||||||
|
// 确保forserviceid在下拉数据中
|
||||||
|
this.getForServiceList(() => {
|
||||||
|
if (this.form.forserviceid && !this.forServiceList.find(item => String(item.id) === this.form.forserviceid)) {
|
||||||
|
this.form.forserviceid = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
|
|
@ -643,6 +678,14 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提交时带上isforservice和forserviceid
|
||||||
|
this.form.isforservice = this.form.isforservice || 2;
|
||||||
|
if (this.form.isforservice == 1 && this.form.forserviceid) {
|
||||||
|
this.form.forserviceid = String(this.form.forserviceid);
|
||||||
|
} else {
|
||||||
|
this.form.forserviceid = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
updateServiceGoods(this.form).then(response => {
|
updateServiceGoods(this.form).then(response => {
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
|
@ -849,6 +892,20 @@ export default {
|
||||||
this.silentSave();
|
this.silentSave();
|
||||||
}, 1000); // 1秒后进行保存
|
}, 1000); // 1秒后进行保存
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getForServiceList (cb) {
|
||||||
|
getselectTypeList(1).then(res => {
|
||||||
|
this.forServiceList = res.data || [];
|
||||||
|
if (typeof cb === 'function') cb();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// getForServiceList() {
|
||||||
|
// // 查询type=1的服务
|
||||||
|
// listServiceGoods({ type: 1, status: 1 }).then(res => {
|
||||||
|
// this.forServiceList = res.rows || [];
|
||||||
|
// });
|
||||||
|
// },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue