通过套餐生成商品并持久化数据
This commit is contained in:
6
pom.xml
6
pom.xml
@ -242,6 +242,12 @@
|
||||
<version>4.40.427.ALL</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.17</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<!-- Build Configuration -->
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/**
|
||||
* Alipay.com Inc.
|
||||
* Copyright (c) 2004-2024 All Rights Reserved.
|
||||
*/
|
||||
package com.sczx.pay.alipay.controller;
|
||||
|
||||
import com.alipay.api.domain.AppxCategoryVO;
|
||||
@ -12,6 +8,7 @@ import com.alipay.api.response.AlipayOpenAppItemTemplateQueryResponse;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.sczx.pay.alipay.po.RentRuleItem;
|
||||
import com.sczx.pay.alipay.service.ItemService;
|
||||
import com.sczx.pay.alipay.service.RentRuleItemService;
|
||||
import com.sczx.pay.alipay.vo.ItemCreateRequest;
|
||||
import com.sczx.pay.alipay.vo.OpenResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -22,11 +19,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author jishupei.jsp
|
||||
* @version : ItemController, v0.1 2024年05月11日 2:45 下午 jishupei.jsp Exp $
|
||||
*/
|
||||
@Api(tags = "普通商品模块")
|
||||
@RestController
|
||||
@RequestMapping(value = "/item")
|
||||
@ -35,6 +30,9 @@ public class ItemController {
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
@Autowired
|
||||
private RentRuleItemService rentRuleItemService;
|
||||
|
||||
/**
|
||||
* 类目查询
|
||||
* 获取叶子节点商品类目列表
|
||||
@ -131,4 +129,12 @@ public class ItemController {
|
||||
return itemService.shopQuery();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "接收套餐数据并记录商品")
|
||||
@GetMapping(value = "/sync/item")
|
||||
public Map<String,String> syncItem(@RequestParam(required = false) String brandId,@RequestParam(required = false) String carModelId,
|
||||
@RequestParam(required = false) String carRuleId,@RequestParam(required = false) String batteryRuleId) {
|
||||
return rentRuleItemService.syncItem(brandId, carModelId,carRuleId,batteryRuleId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
163
src/main/java/com/sczx/pay/alipay/po/RentCommodityConfig.java
Normal file
163
src/main/java/com/sczx/pay/alipay/po/RentCommodityConfig.java
Normal file
@ -0,0 +1,163 @@
|
||||
package com.sczx.pay.alipay.po;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租赁商品配置实体类
|
||||
*/
|
||||
public class RentCommodityConfig {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 是否自定义租赁 (0:否, 1:是)
|
||||
*/
|
||||
private String customLease;
|
||||
|
||||
/**
|
||||
* 斜率公式
|
||||
*/
|
||||
private String slopeFormula;
|
||||
|
||||
/**
|
||||
* 时间单位
|
||||
*/
|
||||
private String durationUnit;
|
||||
|
||||
/**
|
||||
* 买断价格
|
||||
*/
|
||||
private String buyoutPrice;
|
||||
|
||||
/**
|
||||
* 价格单位
|
||||
*/
|
||||
private String priceUnit;
|
||||
|
||||
/**
|
||||
* 时段价格列表
|
||||
*/
|
||||
private List<DurationPrice> durationPriceList;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCustomLease() {
|
||||
return customLease;
|
||||
}
|
||||
|
||||
public void setCustomLease(String customLease) {
|
||||
this.customLease = customLease;
|
||||
}
|
||||
|
||||
public String getSlopeFormula() {
|
||||
return slopeFormula;
|
||||
}
|
||||
|
||||
public void setSlopeFormula(String slopeFormula) {
|
||||
this.slopeFormula = slopeFormula;
|
||||
}
|
||||
|
||||
public String getDurationUnit() {
|
||||
return durationUnit;
|
||||
}
|
||||
|
||||
public void setDurationUnit(String durationUnit) {
|
||||
this.durationUnit = durationUnit;
|
||||
}
|
||||
|
||||
public String getBuyoutPrice() {
|
||||
return buyoutPrice;
|
||||
}
|
||||
|
||||
public void setBuyoutPrice(String buyoutPrice) {
|
||||
this.buyoutPrice = buyoutPrice;
|
||||
}
|
||||
|
||||
public String getPriceUnit() {
|
||||
return priceUnit;
|
||||
}
|
||||
|
||||
public void setPriceUnit(String priceUnit) {
|
||||
this.priceUnit = priceUnit;
|
||||
}
|
||||
|
||||
public List<DurationPrice> getDurationPriceList() {
|
||||
return durationPriceList;
|
||||
}
|
||||
|
||||
public void setDurationPriceList(List<DurationPrice> durationPriceList) {
|
||||
this.durationPriceList = durationPriceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时段价格实体类
|
||||
*/
|
||||
public static class DurationPrice {
|
||||
|
||||
/**
|
||||
* 时段
|
||||
*/
|
||||
private String duration;
|
||||
|
||||
/**
|
||||
* 总原价
|
||||
*/
|
||||
private String totalOriginalPrice;
|
||||
|
||||
/**
|
||||
* 总售价
|
||||
*/
|
||||
private String totalSalePrice;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public String getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(String duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getTotalOriginalPrice() {
|
||||
return totalOriginalPrice;
|
||||
}
|
||||
|
||||
public void setTotalOriginalPrice(String totalOriginalPrice) {
|
||||
this.totalOriginalPrice = totalOriginalPrice;
|
||||
}
|
||||
|
||||
public String getTotalSalePrice() {
|
||||
return totalSalePrice;
|
||||
}
|
||||
|
||||
public void setTotalSalePrice(String totalSalePrice) {
|
||||
this.totalSalePrice = totalSalePrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,179 +11,304 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
public class RentRuleItem implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 车型ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 商户商品ID
|
||||
* 外部商品ID
|
||||
*/
|
||||
private String outItemId;
|
||||
|
||||
|
||||
/**
|
||||
* 阿里商品ID
|
||||
*/
|
||||
private String aliItemId;
|
||||
|
||||
|
||||
/**
|
||||
* 外部SKU ID
|
||||
*/
|
||||
private String outSkuId;
|
||||
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
private String itemDesc;
|
||||
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
private String brandName;
|
||||
|
||||
|
||||
/**
|
||||
* 车型名称
|
||||
*/
|
||||
private String modelName;
|
||||
|
||||
|
||||
/**
|
||||
* 电池类别名称
|
||||
*/
|
||||
private String categoryName;
|
||||
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
* 租赁天数(当类型为"按天数"时使用)
|
||||
*/
|
||||
private String dictLabel;
|
||||
|
||||
private Integer rentalDays;
|
||||
|
||||
/**
|
||||
* 套餐类型
|
||||
*/
|
||||
private String rentType;
|
||||
|
||||
/**
|
||||
* 套餐名称
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
|
||||
|
||||
private String pagePath;
|
||||
/**
|
||||
* 车型照片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
|
||||
/**
|
||||
* 车型照片列表1
|
||||
*/
|
||||
private String imageList1;
|
||||
|
||||
/**
|
||||
* 车型照片列表2
|
||||
*/
|
||||
private String imageList2;
|
||||
|
||||
/**
|
||||
* 车型照片列表3
|
||||
*/
|
||||
private String imageList3;
|
||||
|
||||
/**
|
||||
* 是否支持免押(0不支持 1支持)
|
||||
*/
|
||||
private String depositFree;
|
||||
|
||||
/**
|
||||
* 押金价格(元)
|
||||
*/
|
||||
private BigDecimal depositPrice;
|
||||
|
||||
/**
|
||||
* 租车价格(元)
|
||||
*/
|
||||
private BigDecimal rentalPrice;
|
||||
|
||||
/**
|
||||
* 电池规则ID
|
||||
*/
|
||||
private Long batteryRuleId;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆规则ID
|
||||
*/
|
||||
private Long carRuleId;
|
||||
|
||||
|
||||
/**
|
||||
* 车型ID
|
||||
*/
|
||||
private Long carModelId;
|
||||
|
||||
|
||||
/**
|
||||
* 品牌ID
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
private BigDecimal rentalPrice;
|
||||
|
||||
private Integer rentalDays;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getOutItemId() {
|
||||
return outItemId;
|
||||
}
|
||||
|
||||
|
||||
public void setOutItemId(String outItemId) {
|
||||
this.outItemId = outItemId;
|
||||
}
|
||||
|
||||
|
||||
public String getAliItemId() {
|
||||
return aliItemId;
|
||||
}
|
||||
|
||||
|
||||
public void setAliItemId(String aliItemId) {
|
||||
this.aliItemId = aliItemId;
|
||||
}
|
||||
|
||||
|
||||
public String getOutSkuId() {
|
||||
return outSkuId;
|
||||
}
|
||||
|
||||
public void setOutSkuId(String outSkuId) {
|
||||
this.outSkuId = outSkuId;
|
||||
}
|
||||
|
||||
public String getItemDesc() {
|
||||
return itemDesc;
|
||||
}
|
||||
|
||||
public void setItemDesc(String itemDesc) {
|
||||
this.itemDesc = itemDesc;
|
||||
}
|
||||
|
||||
public String getBrandName() {
|
||||
return brandName;
|
||||
}
|
||||
|
||||
|
||||
public void setBrandName(String brandName) {
|
||||
this.brandName = brandName;
|
||||
}
|
||||
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getDictLabel() {
|
||||
return dictLabel;
|
||||
|
||||
public Integer getRentalDays() {
|
||||
return rentalDays;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel) {
|
||||
this.dictLabel = dictLabel;
|
||||
|
||||
public void setRentalDays(Integer rentalDays) {
|
||||
this.rentalDays = rentalDays;
|
||||
}
|
||||
|
||||
|
||||
public String getRentType() {
|
||||
return rentType;
|
||||
}
|
||||
|
||||
public void setRentType(String rentType) {
|
||||
this.rentType = rentType;
|
||||
}
|
||||
|
||||
public String getRuleName() {
|
||||
return ruleName;
|
||||
}
|
||||
|
||||
|
||||
public void setRuleName(String ruleName) {
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
|
||||
public String getImageList1() {
|
||||
return imageList1;
|
||||
}
|
||||
|
||||
public void setImageList1(String imageList1) {
|
||||
this.imageList1 = imageList1;
|
||||
}
|
||||
|
||||
public String getImageList2() {
|
||||
return imageList2;
|
||||
}
|
||||
|
||||
public void setImageList2(String imageList2) {
|
||||
this.imageList2 = imageList2;
|
||||
}
|
||||
|
||||
public String getImageList3() {
|
||||
return imageList3;
|
||||
}
|
||||
|
||||
public void setImageList3(String imageList3) {
|
||||
this.imageList3 = imageList3;
|
||||
}
|
||||
|
||||
public String getDepositFree() {
|
||||
return depositFree;
|
||||
}
|
||||
|
||||
public void setDepositFree(String depositFree) {
|
||||
this.depositFree = depositFree;
|
||||
}
|
||||
|
||||
public BigDecimal getDepositPrice() {
|
||||
return depositPrice;
|
||||
}
|
||||
|
||||
public void setDepositPrice(BigDecimal depositPrice) {
|
||||
this.depositPrice = depositPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getRentalPrice() {
|
||||
return rentalPrice;
|
||||
}
|
||||
|
||||
public void setRentalPrice(BigDecimal rentalPrice) {
|
||||
this.rentalPrice = rentalPrice;
|
||||
}
|
||||
|
||||
public Long getBatteryRuleId() {
|
||||
return batteryRuleId;
|
||||
}
|
||||
|
||||
|
||||
public void setBatteryRuleId(Long batteryRuleId) {
|
||||
this.batteryRuleId = batteryRuleId;
|
||||
}
|
||||
|
||||
|
||||
public Long getCarRuleId() {
|
||||
return carRuleId;
|
||||
}
|
||||
|
||||
|
||||
public void setCarRuleId(Long carRuleId) {
|
||||
this.carRuleId = carRuleId;
|
||||
}
|
||||
|
||||
|
||||
public Long getCarModelId() {
|
||||
return carModelId;
|
||||
}
|
||||
|
||||
|
||||
public void setCarModelId(Long carModelId) {
|
||||
this.carModelId = carModelId;
|
||||
}
|
||||
|
||||
|
||||
public Long getBrandId() {
|
||||
return brandId;
|
||||
}
|
||||
|
||||
|
||||
public void setBrandId(Long brandId) {
|
||||
this.brandId = brandId;
|
||||
}
|
||||
|
||||
public String getPagePath() {
|
||||
return pagePath;
|
||||
}
|
||||
|
||||
public void setPagePath(String pagePath) {
|
||||
this.pagePath = pagePath;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/**
|
||||
* Alipay.com Inc.
|
||||
* Copyright (c) 2004-2024 All Rights Reserved.
|
||||
*/
|
||||
package com.sczx.pay.alipay.service;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
@ -12,10 +8,7 @@ import com.sczx.pay.alipay.vo.OpenResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jishupei.jsp
|
||||
* @version : ImageUploadService, v0.1 2024年03月14日 10:38 上午 jishupei.jsp Exp $
|
||||
*/
|
||||
|
||||
public interface ImageUploadService {
|
||||
/**
|
||||
* 上传图片,返回imageId
|
||||
|
||||
@ -10,10 +10,6 @@ import com.sczx.pay.alipay.vo.OpenResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jishupei.jsp
|
||||
* @version : ItemService, v0.1 2024年05月11日 2:28 下午 jishupei.jsp Exp $
|
||||
*/
|
||||
public interface ItemService {
|
||||
/**
|
||||
* 获取叶子节点商品类目列表(默认获取类目状态为资质已开通的)
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
package com.sczx.pay.alipay.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface RentRuleItemService {
|
||||
|
||||
Map<String,String> syncItem(String brandId,String carModelId,String carRuleId,String batteryRuleId);
|
||||
}
|
||||
@ -18,17 +18,16 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
|
||||
|
||||
/**
|
||||
* @author jishupei.jsp
|
||||
* @version : ImageUploadServiceImpl, v0.1 2024年03月14日 10:41 上午 jishupei.jsp Exp $
|
||||
*/
|
||||
@Service
|
||||
public class ImageUploadServiceImpl implements ImageUploadService {
|
||||
private static final Logger logger = LogManager.getLogger(ImageUploadServiceImpl.class);
|
||||
@ -49,7 +48,8 @@ public class ImageUploadServiceImpl implements ImageUploadService {
|
||||
|
||||
// 设置图片内容
|
||||
try {
|
||||
String imageBase64 = getImageFromUrlAndConvertToBase64(imagePath);
|
||||
//String imageBase64 = getImageFromUrlAndConvertToBase64(imagePath);
|
||||
String imageBase64 = getImageFromUrlAndConvertToBase64WithResize(imagePath, 750, 750);
|
||||
FileItem imageContent = new FileItem("imageContent.jpg",Base64.getDecoder().decode(imageBase64));
|
||||
request.setImageContent(imageContent);
|
||||
} catch (IOException e) {
|
||||
@ -317,4 +317,32 @@ public class ImageUploadServiceImpl implements ImageUploadService {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public String getImageFromUrlAndConvertToBase64WithResize(String imageUrl, int width, int height) throws IOException {
|
||||
if (StringUtils.isBlank(imageUrl)) {
|
||||
throw new IllegalArgumentException("图片URL不能为空");
|
||||
}
|
||||
|
||||
URL url = new URL(imageUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.setReadTimeout(5000);
|
||||
|
||||
try (InputStream inputStream = connection.getInputStream()) {
|
||||
// 使用Thumbnailator调整图片尺寸
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
Thumbnails.of(inputStream)
|
||||
.size(width, height)
|
||||
.outputFormat("jpg")
|
||||
.toOutputStream(outputStream);
|
||||
|
||||
byte[] imageBytes = outputStream.toByteArray();
|
||||
return Base64.getEncoder().encodeToString(imageBytes);
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.alipay.api.domain.*;
|
||||
import com.alipay.api.internal.util.StringUtils;
|
||||
import com.alipay.api.request.*;
|
||||
import com.alipay.api.response.*;
|
||||
import com.sczx.pay.alipay.po.RentCommodityConfig;
|
||||
import com.sczx.pay.alipay.po.RentRuleItem;
|
||||
import com.sczx.pay.alipay.service.ImageUploadService;
|
||||
import com.sczx.pay.alipay.service.ItemService;
|
||||
@ -24,15 +25,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author jishupei.jsp
|
||||
* @version : ItemServiceImpl, v0.1 2024年05月11日 2:31 下午 jishupei.jsp Exp $
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class ItemServiceImpl implements ItemService {
|
||||
|
||||
@ -123,31 +121,56 @@ public class ItemServiceImpl implements ItemService {
|
||||
|
||||
|
||||
@Override
|
||||
public OpenResponse<String> createRentItem(RentRuleItem param) {
|
||||
public OpenResponse<String> createRentItem(RentRuleItem rentRuleItem) {
|
||||
return AlipayApiTemplate.execute(new AlipayApiCallback<String, AlipayOpenAppItemCreateResponse>() {
|
||||
|
||||
@Override
|
||||
public AlipayOpenAppItemCreateResponse process() throws AlipayApiException {
|
||||
|
||||
RentRuleItem rentRuleItem = rentRuleItemMapper.selectByIds(param.getBatteryRuleId(), param.getCarRuleId(), param.getCarModelId(), param.getBrandId());
|
||||
|
||||
//RentRuleItem rentRuleItem = rentRuleItemMapper.selectByIds(param.getBatteryRuleId(), param.getCarRuleId(), param.getCarModelId(), param.getBrandId());
|
||||
RentRuleItem rentRuleItemvo = rentRuleItem;
|
||||
// 构造请求参数以调用接口
|
||||
AlipayOpenAppItemCreateRequest request = new AlipayOpenAppItemCreateRequest();
|
||||
AlipayOpenAppItemCreateModel model = getAlipayOpenAppItemCreateModel(rentRuleItem);
|
||||
AlipayOpenAppItemCreateModel model = new AlipayOpenAppItemCreateModel();
|
||||
|
||||
|
||||
|
||||
// 设置平台类目
|
||||
model.setCategoryId("C001684401");
|
||||
// 设置商品名称由品牌、型号、电池规格、租赁类型、套餐名称拼接
|
||||
String title = rentRuleItem.getBrandName() + rentRuleItem.getModelName() +"_"+ rentRuleItem.getCategoryName() + "_" + rentRuleItem.getRentType()+rentRuleItem.getRuleName();
|
||||
rentRuleItemvo.setItemDesc(title);
|
||||
// 设置商品名称
|
||||
model.setTitle(title);
|
||||
// 设置导购描述
|
||||
model.setDesc(title);
|
||||
// 设置平台类目
|
||||
model.setCategoryId("C001684401");
|
||||
// 设置商品主图
|
||||
String imgStr = imageUploadService.uploadAndReturnId(rentRuleItem.getImage(), "ITEM_HEAD_IMG");
|
||||
model.setHeadImg(imgStr);
|
||||
rentRuleItemvo.setImage(imgStr);
|
||||
// 设置商品模版类型
|
||||
model.setItemType("2");
|
||||
|
||||
// 设置价格单元
|
||||
model.setPriceUnit("元");
|
||||
|
||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
String uuidSuffix = UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase();
|
||||
String outItemId = "OI"+timestamp + uuidSuffix;
|
||||
model.setOutItemId(outItemId);
|
||||
rentRuleItemvo.setOutItemId(outItemId);
|
||||
rentRuleItemvo.setOutSkuId(outItemId+"_sku");
|
||||
model.setPath("alipays://platformapi/startapp?appId=2021004169641281&page=pages/rentGoodsDetail/index?outItemId="+outItemId);
|
||||
rentRuleItemvo.setPagePath("alipays://platformapi/startapp?appId=2021004169641281&page=pages/rentGoodsDetail/index?outItemId="+outItemId);
|
||||
model.setSaleStatus("AVAILABLE");
|
||||
//sku_attrs
|
||||
model.setSkus(getItemSkus(rentRuleItem, model.getImageList(), model.getItemType()));
|
||||
|
||||
// 设置属性列表
|
||||
model.setAttrs(getItemAttrs(rentRuleItem, model.getImageList(), model.getItemType()));
|
||||
|
||||
|
||||
rentRuleItemMapper.insertByFourId(rentRuleItemvo);
|
||||
logger.info("属性列表:" + JSON.toJSONString(model));
|
||||
request.setBizModel(model);
|
||||
return alipaySdkUtil.execute(request);
|
||||
@ -455,19 +478,13 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 设置商家侧商品ID
|
||||
model.setOutItemId(rentRuleItem.getOutItemId());
|
||||
|
||||
// 设置商品名称由品牌、型号、电池规格、租赁类型、套餐名称拼接
|
||||
String title = rentRuleItem.getBrandName() + rentRuleItem.getModelName() +"_"+ rentRuleItem.getCategoryName() + "_" +rentRuleItem.getRentalDays()+ rentRuleItem.getDictLabel()+rentRuleItem.getRuleName();
|
||||
// 设置商品名称
|
||||
model.setTitle(title);
|
||||
// 设置商品主图
|
||||
model.setHeadImg(imageUploadService.uploadAndReturnId(rentRuleItem.getImage(), "ITEM_HEAD_IMG"));
|
||||
|
||||
|
||||
|
||||
// 设置类目ID
|
||||
model.setCategoryId("C001684401");
|
||||
|
||||
|
||||
// 设置导购描述
|
||||
model.setDesc(title);
|
||||
|
||||
|
||||
|
||||
@ -550,6 +567,9 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 商品成色
|
||||
appItemAttrVO.setAttrValue("secondHand");
|
||||
break;
|
||||
case "item_fineness_grade":
|
||||
appItemAttrVO.setAttrValue("99new");
|
||||
break;
|
||||
case "whether_support_free_deposit":
|
||||
// 是否支持免押
|
||||
appItemAttrVO.setAttrValue("1");
|
||||
@ -575,7 +595,7 @@ public class ItemServiceImpl implements ItemService {
|
||||
ItemSkuCreateVO sku = new ItemSkuCreateVO();
|
||||
|
||||
// 设置商家侧SKU ID,需要全局唯一
|
||||
sku.setOutSkuId(param.getOutItemId() + "_sku"); // 示例:基于outItemId生成
|
||||
sku.setOutSkuId(param.getOutItemId() + "_sku");
|
||||
|
||||
// 设置售卖状态
|
||||
sku.setSaleStatus("AVAILABLE");
|
||||
@ -586,7 +606,12 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 设置价格相关字段
|
||||
Long rentalPriceInCents = param.getRentalPrice().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
|
||||
sku.setSalePrice(param.getRentalPrice().toString());
|
||||
sku.setOriginalPrice(rentalPriceInCents);
|
||||
// 设置原价为租赁价格的1.2倍
|
||||
Long originalPriceInCents = new BigDecimal(rentalPriceInCents)
|
||||
.multiply(new BigDecimal("1.2"))
|
||||
.setScale(0, BigDecimal.ROUND_HALF_UP)
|
||||
.longValue();
|
||||
sku.setOriginalPrice(originalPriceInCents);
|
||||
|
||||
// 设置库存
|
||||
sku.setStockNum(String.valueOf(100L));
|
||||
@ -600,8 +625,34 @@ public class ItemServiceImpl implements ItemService {
|
||||
// 添加租赁商品属性
|
||||
ItemSkuAttrVO rentCommodityAttr = new ItemSkuAttrVO();
|
||||
rentCommodityAttr.setAttrKey("rent_commodity");
|
||||
rentCommodityAttr.setAttrValue("{\"name\":\"租完归还\",\"description\":\"套餐说明\",\"custom_lease\":\"1\",\"slope_formula\":\"DEFAULT_SLOPE_FORMULA\",\"durationUnit\":\"天\",\"buyoutPrice\":\"220\",\"priceUnit\":\"元\"}");
|
||||
rentCommodityAttr.setAttrType("custom"); // 根据实际情况设置
|
||||
rentCommodityAttr.setAttrType("custom");
|
||||
|
||||
RentCommodityConfig config = new RentCommodityConfig();
|
||||
config.setName("门店自提,租完归还");
|
||||
config.setDescription("套餐说明");
|
||||
config.setCustomLease("0");
|
||||
config.setSlopeFormula("DEFAULT_SLOPE_FORMULA");
|
||||
config.setDurationUnit("日");
|
||||
config.setBuyoutPrice("220");
|
||||
config.setPriceUnit("元");
|
||||
|
||||
// 创建时段价格列表根据基础价格创建3个时段价格
|
||||
List<RentCommodityConfig.DurationPrice> durationPriceList = new ArrayList<>();
|
||||
RentCommodityConfig.DurationPrice durationPrice = new RentCommodityConfig.DurationPrice();
|
||||
for(int i = 1; i < 4; i++){
|
||||
String val = i + "";
|
||||
durationPrice.setDuration(val);
|
||||
durationPrice.setTotalOriginalPrice(param.getRentalPrice()
|
||||
.multiply(new BigDecimal(val))
|
||||
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
||||
durationPrice.setTotalSalePrice(new BigDecimal(originalPriceInCents)
|
||||
.multiply(new BigDecimal(val))
|
||||
.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
|
||||
durationPriceList.add(durationPrice);
|
||||
}
|
||||
config.setDurationPriceList(durationPriceList);
|
||||
rentCommodityAttr.setAttrValue(JSON.toJSONString(config));
|
||||
// 根据实际情况设置
|
||||
skuAttrs.add(rentCommodityAttr);
|
||||
sku.setSkuAttrs(skuAttrs);
|
||||
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package com.sczx.pay.alipay.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.sczx.pay.alipay.po.RentRuleItem;
|
||||
import com.sczx.pay.alipay.service.ItemService;
|
||||
import com.sczx.pay.alipay.service.RentRuleItemService;
|
||||
import com.sczx.pay.alipay.vo.OpenResponse;
|
||||
import com.sczx.pay.mapper.RentRuleItemMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RentRuleItemServiceImpl implements RentRuleItemService {
|
||||
|
||||
@Autowired
|
||||
private RentRuleItemMapper rentRuleItemMapper;
|
||||
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
|
||||
@Override
|
||||
public Map<String,String> syncItem(String brandId, String carModelId, String carRuleId, String batteryRuleId) {
|
||||
RentRuleItem rentRuleItem = rentRuleItemMapper.selectByFourId(Long.valueOf(batteryRuleId), Long.valueOf(carRuleId), Long.valueOf(carModelId), Long.valueOf(brandId));
|
||||
log.info("rentRuleItem:{}", JSON.toJSONString(rentRuleItem));
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (rentRuleItem == null){
|
||||
map.put("msg","未找到此套餐信息");
|
||||
map.put("code","500");
|
||||
return map;
|
||||
}
|
||||
|
||||
OpenResponse<String> response = itemService.createRentItem(rentRuleItem);
|
||||
|
||||
|
||||
|
||||
map.put("code",response.getCode());
|
||||
map.put("msg",response.getMsg());
|
||||
map.put("subCode",response.getSubCode());
|
||||
map.put("subMsg",response.getSubMsg());
|
||||
map.put("data",response.getData());
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
}
|
||||
@ -29,12 +29,10 @@ public interface RentRuleItemMapper {
|
||||
*/
|
||||
List<RentRuleItem> selectAll();
|
||||
|
||||
/**
|
||||
* 新增车型租赁规则项
|
||||
* @param zcRentRuleItem 车型租赁规则项信息
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(RentRuleItem zcRentRuleItem);
|
||||
|
||||
RentRuleItem selectByFourId(@Param("batteryRuleId") Long batteryRuleId, @Param("carRuleId") Long carRuleId, @Param("carModelId") Long carModelId,@Param("brandId") Long brandId);
|
||||
|
||||
int insertByFourId(RentRuleItem zcRentRuleItem);
|
||||
|
||||
/**
|
||||
* 更新车型租赁规则项
|
||||
|
||||
@ -7,162 +7,311 @@
|
||||
<id property="id" column="id"/>
|
||||
<result property="outItemId" column="out_item_id"/>
|
||||
<result property="aliItemId" column="ali_item_id"/>
|
||||
<result property="outSkuId" column="out_sku_id"/>
|
||||
<result property="itemDesc" column="item_desc"/>
|
||||
<result property="brandName" column="brand_name"/>
|
||||
<result property="modelName" column="model_name"/>
|
||||
<result property="categoryName" column="category_name"/>
|
||||
<result property="dictLabel" column="dict_label"/>
|
||||
<result property="rentalDays" column="rental_days"/>
|
||||
<result property="rentType" column="rent_type"/>
|
||||
<result property="ruleName" column="rule_name"/>
|
||||
<result property="pagePath" column="page_path"/>
|
||||
<result property="image" column="image"/>
|
||||
<result property="imageList1" column="image_list1"/>
|
||||
<result property="imageList2" column="image_list2"/>
|
||||
<result property="imageList3" column="image_list3"/>
|
||||
<result property="depositFree" column="deposit_free"/>
|
||||
<result property="depositPrice" column="deposit_price"/>
|
||||
<result property="rentalPrice" column="rental_price"/>
|
||||
<result property="batteryRuleId" column="battery_rule_id"/>
|
||||
<result property="carRuleId" column="car_rule_id"/>
|
||||
<result property="carModelId" column="car_model_id"/>
|
||||
<result property="brandId" column="brand_id"/>
|
||||
<result property="rentalDays" column="rental_days"/>
|
||||
<result property="rentalPrice" column="rental_price"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 字段列表 -->
|
||||
<!-- 查询字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, out_item_id, ali_item_id, brand_name, model_name, category_name,
|
||||
dict_label, rule_name, image, battery_rule_id, car_rule_id, car_model_id, brand_id,rental_days,rental_price
|
||||
id
|
||||
,
|
||||
out_item_id,
|
||||
ali_item_id,
|
||||
out_sku_id,
|
||||
item_desc,
|
||||
brand_name,
|
||||
model_name,
|
||||
category_name,
|
||||
rental_days,
|
||||
rent_type,
|
||||
rule_name,
|
||||
page_path,
|
||||
image,
|
||||
image_list1,
|
||||
image_list2,
|
||||
image_list3,
|
||||
deposit_free,
|
||||
deposit_price,
|
||||
rental_price,
|
||||
battery_rule_id,
|
||||
car_rule_id,
|
||||
car_model_id,
|
||||
brand_id
|
||||
</sql>
|
||||
|
||||
<!-- 查询所有 -->
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
</select>
|
||||
|
||||
<!-- 根据ID查询 -->
|
||||
<select id="selectById" parameterType="Long" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 查询所有 -->
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByItemId" parameterType="Long" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
WHERE out_item_id = #{outItemId}
|
||||
</select>
|
||||
|
||||
<select id="selectByAliId" parameterType="Long" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
WHERE ali_item_id = #{aliItemId}
|
||||
</select>
|
||||
|
||||
<select id="selectByIds" parameterType="map" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
<where>
|
||||
<if test="batteryRuleId != null">
|
||||
AND battery_rule_id = #{batteryRuleId}
|
||||
</if>
|
||||
<if test="carRuleId != null">
|
||||
AND car_rule_id = #{carRuleId}
|
||||
</if>
|
||||
<if test="carModelId != null">
|
||||
AND car_model_id = #{carModelId}
|
||||
</if>
|
||||
<if test="brandId != null">
|
||||
AND brand_id = #{brandId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 插入 -->
|
||||
<!-- 插入数据 -->
|
||||
<insert id="insert" parameterType="com.sczx.pay.alipay.po.RentRuleItem">
|
||||
INSERT INTO zc_rent_rule_item (
|
||||
id,
|
||||
out_item_id,
|
||||
ali_item_id,
|
||||
brand_name,
|
||||
model_name,
|
||||
category_name,
|
||||
dict_label,
|
||||
rule_name,
|
||||
image,
|
||||
battery_rule_id,
|
||||
car_rule_id,
|
||||
car_model_id,
|
||||
rental_days,
|
||||
rental_price,
|
||||
brand_id
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{outItemId},
|
||||
#{aliItemId},
|
||||
#{brandName},
|
||||
#{modelName},
|
||||
#{categoryName},
|
||||
#{dictLabel},
|
||||
#{ruleName},
|
||||
#{image},
|
||||
#{batteryRuleId},
|
||||
#{carRuleId},
|
||||
#{carModelId},
|
||||
#{rentalDays},
|
||||
#{rentalPrice},
|
||||
#{brandId}
|
||||
)
|
||||
insert into zc_rent_rule_item
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="outItemId != null and outItemId != ''">out_item_id,</if>
|
||||
<if test="aliItemId != null and aliItemId != ''">ali_item_id,</if>
|
||||
<if test="outSkuId != null and outSkuId != ''">out_sku_id,</if>
|
||||
<if test="itemDesc != null and itemDesc != ''">item_desc,</if>
|
||||
<if test="brandName != null and brandName != ''">brand_name,</if>
|
||||
<if test="modelName != null and modelName != ''">model_name,</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="rentalDays != null">rental_days,</if>
|
||||
<if test="rentType != null and rentType != ''">rent_type,</if>
|
||||
<if test="ruleName != null and ruleName != ''">rule_name,</if>
|
||||
<if test="pagePath != null and pagePath != ''">page_path,</if>
|
||||
<if test="image != null and image != ''">image,</if>
|
||||
<if test="imageList1 != null and imageList1 != ''">image_list1,</if>
|
||||
<if test="imageList2 != null and imageList2 != ''">image_list2,</if>
|
||||
<if test="imageList3 != null and imageList3 != ''">image_list3,</if>
|
||||
<if test="depositFree != null and depositFree != ''">deposit_free,</if>
|
||||
<if test="depositPrice != null">deposit_price,</if>
|
||||
<if test="rentalPrice != null">rental_price,</if>
|
||||
<if test="batteryRuleId != null">battery_rule_id,</if>
|
||||
<if test="carRuleId != null">car_rule_id,</if>
|
||||
<if test="carModelId != null">car_model_id,</if>
|
||||
<if test="brandId != null">brand_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="outItemId != null and outItemId != ''">#{outItemId},</if>
|
||||
<if test="aliItemId != null and aliItemId != ''">#{aliItemId},</if>
|
||||
<if test="outSkuId != null and outSkuId != ''">#{outSkuId},</if>
|
||||
<if test="itemDesc != null and itemDesc != ''">#{itemDesc},</if>
|
||||
<if test="brandName != null and brandName != ''">#{brandName},</if>
|
||||
<if test="modelName != null and modelName != ''">#{modelName},</if>
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="rentalDays != null">#{rentalDays},</if>
|
||||
<if test="rentType != null and rentType != ''">#{rentType},</if>
|
||||
<if test="ruleName != null and ruleName != ''">#{ruleName},</if>
|
||||
<if test="pagePath != null and pagePath != ''">#{pagePath},</if>
|
||||
<if test="image != null and image != ''">#{image},</if>
|
||||
<if test="imageList1 != null and imageList1 != ''">#{imageList1},</if>
|
||||
<if test="imageList2 != null and imageList2 != ''">#{imageList2},</if>
|
||||
<if test="imageList3 != null and imageList3 != ''">#{imageList3},</if>
|
||||
<if test="depositFree != null and depositFree != ''">#{depositFree},</if>
|
||||
<if test="depositPrice != null">#{depositPrice},</if>
|
||||
<if test="rentalPrice != null">#{rentalPrice},</if>
|
||||
<if test="batteryRuleId != null">#{batteryRuleId},</if>
|
||||
<if test="carRuleId != null">#{carRuleId},</if>
|
||||
<if test="carModelId != null">#{carModelId},</if>
|
||||
<if test="brandId != null">#{brandId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入 -->
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO zc_rent_rule_item (
|
||||
id, out_item_id, ali_item_id, brand_name, model_name, category_name,
|
||||
dict_label, rule_name, image, battery_rule_id, car_rule_id, car_model_id, brand_id,rental_days,rental_price
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.outItemId},
|
||||
#{item.aliItemId},
|
||||
#{item.brandName},
|
||||
#{item.modelName},
|
||||
#{item.categoryName},
|
||||
#{item.dictLabel},
|
||||
#{item.ruleName},
|
||||
#{item.image},
|
||||
#{item.batteryRuleId},
|
||||
#{item.carRuleId},
|
||||
#{item.carModelId},
|
||||
#{item.brandId},
|
||||
#{item.rentalDays},
|
||||
#{item.rentalPrice},
|
||||
)
|
||||
</foreach>
|
||||
<insert id="insertByFourId" parameterType="com.sczx.pay.alipay.po.RentRuleItem" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zc_rent_rule_item
|
||||
(out_item_id,
|
||||
ali_item_id,
|
||||
out_sku_id,
|
||||
item_desc,
|
||||
brand_name,
|
||||
model_name,
|
||||
category_name,
|
||||
rental_days,
|
||||
rent_type,
|
||||
rule_name,
|
||||
page_path,
|
||||
image,
|
||||
image_list1,
|
||||
image_list2,
|
||||
image_list3,
|
||||
deposit_free,
|
||||
deposit_price,
|
||||
rental_price,
|
||||
battery_rule_id,car_rule_id,car_model_id,brand_id)
|
||||
SELECT
|
||||
#{outItemId} AS out_item_id,
|
||||
'' AS ali_item_id,
|
||||
#{outSkuId} AS out_sku_id,
|
||||
#{itemDesc} as item_desc,
|
||||
zcm.brand_name AS brand_name,
|
||||
zcm.model_name AS model_name,
|
||||
zbc.category_name AS category_name,
|
||||
zrcr.rental_days AS rental_days,
|
||||
sdd.dict_label AS rent_type,
|
||||
zrcr.rule_name AS rule_name,
|
||||
#{pagePath} AS page_path,
|
||||
zcm.image AS image,
|
||||
'' as image_list1,
|
||||
'' as image_list2,
|
||||
'' as image_list3,
|
||||
zrcr.deposit_free AS deposit_free,
|
||||
zrcr.deposit_price AS deposit_price,
|
||||
zrcr.rental_price AS rental_price,
|
||||
zrcrb.battery_rule_id AS battery_rule_id,
|
||||
zcmp.car_rule_id AS car_rule_id,
|
||||
zcmp.car_model_id AS car_model_id,
|
||||
zcb.id AS brand_id
|
||||
FROM
|
||||
zc_car_brand AS zcb,
|
||||
zc_car_model AS zcm,
|
||||
zc_car_model_package AS zcmp,
|
||||
zc_rent_car_rule AS zrcr,
|
||||
zc_rent_battey_rule AS zrbr,
|
||||
zc_rent_car_rule_battery AS zrcrb,
|
||||
sys_dict_data AS sdd,
|
||||
zc_battery_category AS zbc
|
||||
WHERE
|
||||
zcb.id = zcm.brand_id
|
||||
AND zcmp.car_model_id = zcm.id
|
||||
AND zcmp.car_rule_id = zrcr.id
|
||||
AND zrcrb.car_rule_id = zrcr.id
|
||||
AND zrcrb.battery_rule_id = zrbr.id
|
||||
AND sdd.dict_type = 'key_rent_type'
|
||||
AND zrcr.rental_type = sdd.dict_value
|
||||
AND zbc.id = zrbr.category_id
|
||||
AND zcb.id = #{brandId}
|
||||
AND zcmp.car_model_id = #{carModelId}
|
||||
AND zcmp.car_rule_id = #{carRuleId}
|
||||
AND zrcrb.battery_rule_id = #{batteryRuleId}
|
||||
</insert>
|
||||
|
||||
<!-- 更新 -->
|
||||
<update id="update" parameterType="com.sczx.pay.alipay.po.RentRuleItem">
|
||||
UPDATE zc_rent_rule_item
|
||||
<!-- 更新数据 -->
|
||||
<update id="updateById" parameterType="com.sczx.pay.alipay.po.RentRuleItem">
|
||||
update zc_rent_rule_item
|
||||
<set>
|
||||
<if test="outItemId != null and outItemId != ''">out_item_id = #{outItemId},</if>
|
||||
<if test="aliItemId != null and aliItemId != ''">ali_item_id = #{aliItemId},</if>
|
||||
<if test="outSkuId != null and outSkuId != ''">out_sku_id = #{outSkuId},</if>
|
||||
<if test="itemDesc != null and itemDesc != ''">item_desc = #{itemDesc},</if>
|
||||
<if test="brandName != null and brandName != ''">brand_name = #{brandName},</if>
|
||||
<if test="modelName != null and modelName != ''">model_name = #{modelName},</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
|
||||
<if test="rentalDays != null">rental_days = #{rentalDays},</if>
|
||||
<if test="rentType != null and rentType != ''">rent_type = #{rentType},</if>
|
||||
<if test="ruleName != null and ruleName != ''">rule_name = #{ruleName},</if>
|
||||
<if test="image != null">image = #{image},</if>
|
||||
<if test="pagePath != null and pagePath != ''">page_path = #{pagePath},</if>
|
||||
<if test="image != null and image != ''">image = #{image},</if>
|
||||
<if test="imageList1 != null and imageList1 != ''">image_list1 = #{imageList1},</if>
|
||||
<if test="imageList2 != null and imageList2 != ''">image_list2 = #{imageList2},</if>
|
||||
<if test="imageList3 != null and imageList3 != ''">image_list3 = #{imageList3},</if>
|
||||
<if test="depositFree != null and depositFree != ''">deposit_free = #{depositFree},</if>
|
||||
<if test="depositPrice != null">deposit_price = #{depositPrice},</if>
|
||||
<if test="rentalPrice != null">rental_price = #{rentalPrice},</if>
|
||||
<if test="batteryRuleId != null">battery_rule_id = #{batteryRuleId},</if>
|
||||
<if test="carRuleId != null">car_rule_id = #{carRuleId},</if>
|
||||
<if test="carModelId != null">car_model_id = #{carModelId},</if>
|
||||
<if test="brandId != null">brand_id = #{brandId},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateItemIdByOutItemId" parameterType="com.sczx.pay.alipay.po.RentRuleItem">
|
||||
UPDATE zc_rent_rule_item
|
||||
set ali_item_id = #{aliItemId}
|
||||
WHERE out_item_id = #{aliItemId}
|
||||
<update id="updateByOutItemId" parameterType="com.sczx.pay.alipay.po.RentRuleItem">
|
||||
update zc_rent_rule_item
|
||||
<set>
|
||||
<if test="outItemId != null and outItemId != ''">out_item_id = #{outItemId},</if>
|
||||
<if test="aliItemId != null and aliItemId != ''">ali_item_id = #{aliItemId},</if>
|
||||
<if test="outSkuId != null and outSkuId != ''">out_sku_id = #{outSkuId},</if>
|
||||
<if test="itemDesc != null and itemDesc != ''">item_desc = #{itemDesc},</if>
|
||||
<if test="brandName != null and brandName != ''">brand_name = #{brandName},</if>
|
||||
<if test="modelName != null and modelName != ''">model_name = #{modelName},</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="rentalDays != null">rental_days = #{rentalDays},</if>
|
||||
<if test="rentType != null and rentType != ''">rent_type = #{rentType},</if>
|
||||
<if test="ruleName != null and ruleName != ''">rule_name = #{ruleName},</if>
|
||||
<if test="pagePath != null and pagePath != ''">page_path = #{pagePath},</if>
|
||||
<if test="image != null and image != ''">image = #{image},</if>
|
||||
<if test="imageList1 != null and imageList1 != ''">image_list1 = #{imageList1},</if>
|
||||
<if test="imageList2 != null and imageList2 != ''">image_list2 = #{imageList2},</if>
|
||||
<if test="imageList3 != null and imageList3 != ''">image_list3 = #{imageList3},</if>
|
||||
<if test="depositFree != null and depositFree != ''">deposit_free = #{depositFree},</if>
|
||||
<if test="depositPrice != null">deposit_price = #{depositPrice},</if>
|
||||
<if test="rentalPrice != null">rental_price = #{rentalPrice},</if>
|
||||
<if test="batteryRuleId != null">battery_rule_id = #{batteryRuleId},</if>
|
||||
<if test="carRuleId != null">car_rule_id = #{carRuleId},</if>
|
||||
<if test="carModelId != null">car_model_id = #{carModelId},</if>
|
||||
<if test="brandId != null">brand_id = #{brandId},</if>
|
||||
</set>
|
||||
where out_item_id = #{outItemId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectByFourId" parameterType="com.sczx.pay.alipay.po.RentRuleItem" resultMap="BaseResultMap">
|
||||
SELECT zcm.brand_name AS brand_name,
|
||||
zcm.model_name AS model_name,
|
||||
zbc.category_name AS category_name,
|
||||
zrcr.rental_days AS rental_days,
|
||||
sdd.dict_label AS rent_type,
|
||||
zrcr.rule_name AS rule_name,
|
||||
zcm.image AS image,
|
||||
zrcr.deposit_free AS deposit_free,
|
||||
zrcr.deposit_price AS deposit_price,
|
||||
zrcr.rental_price AS rental_price,
|
||||
zrcrb.battery_rule_id AS battery_rule_id,
|
||||
zcmp.car_rule_id AS car_rule_id,
|
||||
zcmp.car_model_id AS car_model_id,
|
||||
zcb.id AS brand_id
|
||||
FROM zc_car_brand AS zcb,
|
||||
zc_car_model AS zcm,
|
||||
zc_car_model_package AS zcmp,
|
||||
zc_rent_car_rule AS zrcr,
|
||||
zc_rent_battey_rule AS zrbr,
|
||||
zc_rent_car_rule_battery AS zrcrb,
|
||||
sys_dict_data AS sdd,
|
||||
zc_battery_category AS zbc
|
||||
WHERE zcb.id = zcm.brand_id
|
||||
AND zcmp.car_model_id = zcm.id
|
||||
AND zcmp.car_rule_id = zrcr.id
|
||||
AND zrcrb.car_rule_id = zrcr.id
|
||||
AND zrcrb.battery_rule_id = zrbr.id
|
||||
AND sdd.dict_type = 'key_rent_type'
|
||||
AND zrcr.rental_type = sdd.dict_value
|
||||
AND zbc.id = zrbr.category_id
|
||||
AND zrcrb.battery_rule_id = #{batteryRuleId}
|
||||
AND zcmp.car_rule_id = #{carRuleId}
|
||||
AND zcmp.car_model_id = #{carModelId}
|
||||
AND zcb.id = #{brandId}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据ID删除 -->
|
||||
<delete id="deleteById" parameterType="Long">
|
||||
DELETE FROM zc_rent_rule_item WHERE id = #{id}
|
||||
delete
|
||||
from zc_rent_rule_item
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user