Browse Source

增加拆单逻辑

master
xh-pan1 3 years ago
parent
commit
99595a0292
  1. 5
      cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/Sku.java
  2. 28
      cereshop-admin/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml
  3. 6
      cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml
  4. 92
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java
  5. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/buyer/CereBuyerShopCouponDAO.java
  6. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/logistics/CereOrderLogisticsDAO.java
  7. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/order/CereShopOrderDAO.java
  8. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/product/CereProductSkuDAO.java
  9. 15
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopCrossDetailDAO.java
  10. 15
      cereshop-app/src/main/java/com/shop/cereshop/app/dao/storehouse/CereShopStorehouseDAO.java
  11. 21
      cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/CrossStockResponeBo.java
  12. 21
      cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/IbOrderItemRequestBo.java
  13. 34
      cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/KjtStockNumberResponeBo.java
  14. 73
      cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/NewIbOrderRequestBo.java
  15. 16
      cereshop-app/src/main/java/com/shop/cereshop/app/page/cart/CartSku.java
  16. 22
      cereshop-app/src/main/java/com/shop/cereshop/app/page/product/ProductDetail.java
  17. 6
      cereshop-app/src/main/java/com/shop/cereshop/app/page/product/ProductSkus.java
  18. 23
      cereshop-app/src/main/java/com/shop/cereshop/app/page/settlement/SettlementShop.java
  19. 17
      cereshop-app/src/main/java/com/shop/cereshop/app/param/order/OrderProductParam.java
  20. 312
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java
  21. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/CereBuyerShopCouponService.java
  22. 4
      cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/impl/CereBuyerShopCouponServiceImpl.java
  23. 4
      cereshop-app/src/main/java/com/shop/cereshop/app/service/extend/impl/HuaxunServiceImpl.java
  24. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/logistics/CereOrderLogisticsService.java
  25. 5
      cereshop-app/src/main/java/com/shop/cereshop/app/service/logistics/impl/CereOrderLogisticsServiceImpl.java
  26. 798
      cereshop-app/src/main/java/com/shop/cereshop/app/service/order/impl/CereShopOrderServiceImpl.java
  27. 6
      cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/JoinPlaceOrder.java
  28. 8
      cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/LaunchPlaceOrder.java
  29. 19
      cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/NormalPlaceOrder.java
  30. 48
      cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/PlaceOrderTemplate.java
  31. 2
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereProductSkuService.java
  32. 4
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereProductSkuServiceImpl.java
  33. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java
  34. 19
      cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/CrossStockService.java
  35. 114
      cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/impl/CrossStockServiceImpl.java
  36. 26
      cereshop-app/src/main/java/com/shop/cereshop/app/service/storehouse/CereShopStorehouseService.java
  37. 36
      cereshop-app/src/main/java/com/shop/cereshop/app/service/storehouse/impl/CereShopStorehouseServiceImpl.java
  38. 10
      cereshop-app/src/main/resources/application.yml
  39. 4
      cereshop-app/src/main/resources/mybatis/mapper/buyer/CereBuyerShopCouponDAO.xml
  40. 8
      cereshop-app/src/main/resources/mybatis/mapper/logistics/CereOrderLogisticsDAO.xml
  41. 8
      cereshop-app/src/main/resources/mybatis/mapper/order/CereShopOrderDAO.xml
  42. 36
      cereshop-app/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml
  43. 5
      cereshop-app/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml
  44. 23
      cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml
  45. 12
      cereshop-business/src/main/java/com/shop/cereshop/business/page/logistics/Logistics.java
  46. 12
      cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java
  47. 12
      cereshop-business/src/main/java/com/shop/cereshop/business/page/tool/ToolProduct.java
  48. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/param/logistics/LogistSaveParam.java
  49. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/param/logistics/LogistUpdateParam.java
  50. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuParam.java
  51. 29
      cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailGetAllParam.java
  52. 28
      cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailGetByIdParam.java
  53. 132
      cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailSaveParam.java
  54. 132
      cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailUpdateParam.java
  55. 3
      cereshop-business/src/main/java/com/shop/cereshop/business/service/logistics/impl/CereOrderLogisticsServiceImpl.java
  56. 1
      cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java
  57. 27
      cereshop-business/src/main/resources/mybatis/mapper/logistics/CereOrderLogisticsDAO.xml
  58. 28
      cereshop-business/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml
  59. 2
      cereshop-business/src/main/resources/mybatis/mapper/tool/CereShopDiscountDAO.xml
  60. 41
      cereshop-commons/src/main/java/com/shop/cereshop/commons/config/CrossStockConfig.java
  61. 33
      cereshop-commons/src/main/java/com/shop/cereshop/commons/config/HuaxunConfig.java
  62. 3
      cereshop-commons/src/main/java/com/shop/cereshop/commons/constant/CoReturnFormat.java
  63. 5
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/logistics/CereOrderLogistics.java
  64. 2
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/order/CereOrderProduct.java
  65. 6
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/order/CereShopOrder.java
  66. 6
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereProductSku.java

5
cereshop-admin/src/main/java/com/shop/cereshop/admin/page/product/Sku.java

@ -31,4 +31,9 @@ public class Sku extends CereProductSku {
* 规格属性信息
*/
private List<CereSkuName> cereSkuNames;
/**
* 仓库名称
*/
private String storehouseName;
}

28
cereshop-admin/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml

@ -7,6 +7,8 @@
<result column="SKU" jdbcType="VARCHAR" property="SKU" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="original_price" jdbcType="DECIMAL" property="originalPrice" />
<result column="rate" jdbcType="DECIMAL" property="rate" />
<result column="storehouse_id" jdbcType="BIGINT" property="storehouseId" />
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
<result column="total" jdbcType="INTEGER" property="total" />
<result column="weight" jdbcType="DECIMAL" property="weight" />
@ -16,7 +18,7 @@
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
sku_id, product_id,SKU, price, original_price, stock_number,total, weight,
sku_id, product_id,SKU, price, original_price, rate, storehouse_id, stock_number,total, weight,
sku_image, `style`, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@ -44,6 +46,12 @@
<if test="originalPrice != null">
original_price,
</if>
<if test="rate != null">
rate,
</if>
<if test="storehouseId != null">
storehouse_id,
</if>
<if test="stockNumber != null">
stock_number,
</if>
@ -117,6 +125,12 @@
<if test="originalPrice != null">
original_price = #{originalPrice,jdbcType=DECIMAL},
</if>
<if test="rate != null">
rate = #{rate,jdbcType=DECIMAL},
</if>
<if test="storehouseId != null">
storehouse_id = #{storehouseId,jdbcType=BIGINT},
</if>
<if test="stockNumber != null">
stock_number = #{stockNumber,jdbcType=INTEGER},
</if>
@ -147,6 +161,8 @@
SKU = #{SKU,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
original_price = #{originalPrice,jdbcType=DECIMAL},
rate = #{rate,jdbcType=DECIMAL},
storehouse_id = #{storehouseId,jdbcType=BIGINT},
stock_number = #{stockNumber,jdbcType=INTEGER},
total = #{total,jdbcType=INTEGER},
weight = #{weight,jdbcType=DECIMAL},
@ -163,10 +179,12 @@
</select>
<select id="findByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.admin.page.product.Sku">
SELECT product_id, sku_id,
price, original_price, stock_number, total
weight, sku_image, `style`, SKU
FROM cere_product_sku where product_id=#{productId}
SELECT cps.product_id, cps.sku_id,
cps.price, cps.original_price, cps.rate, cps.storehouse_id, css.storehouse_name, cps.stock_number, cps.total,
cps.weight, cps.sku_image, cps.`style`, cps.SKU
FROM cere_product_sku cps
LEFT JOIN cere_shop_storehouse css ON css.storehouse_id = cps.storehouse_id
where cps.product_id=#{productId}
</select>
<select id="findNameByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.admin.page.product.SkuNameParam">

6
cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml

@ -240,8 +240,8 @@
<select id="getProducts" parameterType="com.shop.cereshop.admin.param.product.CanvasAdminProductParam" resultType="com.shop.cereshop.admin.page.product.CanvasProduct">
SELECT a.shop_id,d.shop_name,a.product_id,a.product_name,x.users,d.shop_logo,
IF(h.image IS NULL OR h.image='',c.product_image,h.image) image,
b.price,b.sku_id,b.original_price,IF(f.number IS NULL,0,f.number) number,b.stock_number from cere_shop_product a
LEFT JOIN (SELECT a.product_id,a.price,a.sku_id,a.original_price,a.stock_number from cere_product_sku a,cere_shop_product b
b.price,b.sku_id,b.original_price,b.rate, IF(f.number IS NULL,0,f.number) number,b.stock_number from cere_shop_product a
LEFT JOIN (SELECT a.product_id,a.price,a.sku_id,a.original_price,a.rate,a.stock_number from cere_product_sku a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) b ON a.product_id=b.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id
@ -279,7 +279,7 @@
<select id="getGroupWorkProducts" parameterType="com.shop.cereshop.admin.param.product.CanvasAdminProductParam" resultType="com.shop.cereshop.admin.page.product.CanvasProduct">
SELECT b.shop_id,d.shop_name,a.product_id,b.product_name,x.users,h.start_time,h.end_time,h.state,
IF(m.image IS NULL OR m.image='',c.product_image,m.image) image,h.if_enable,h.enable_time,
a.price,a.sku_id,n.price original_price,IF(f.number IS NULL,0,f.number) number,n.stock_number FROM cere_shop_group_work_detail a
a.price,a.sku_id,n.price original_price,n.rate rate,IF(f.number IS NULL,0,f.number) number,n.stock_number FROM cere_shop_group_work_detail a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id

92
cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java

@ -0,0 +1,92 @@
package com.shop.cereshop.app.controller.extend;
import com.alibaba.fastjson.JSONObject;
import com.shop.cereshop.app.pay.xs.domain.XsCallBackRequestVo;
import com.shop.cereshop.app.pay.xs.service.XsPayService;
import com.shop.cereshop.app.service.extend.HuaxunService;
import com.shop.cereshop.app.service.order.CereShopOrderService;
import com.shop.cereshop.commons.config.XspayConfig;
import com.shop.cereshop.commons.constant.XsPayEnum;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.StringUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Base64;
/**
* 新生支付模块
*/
@RestController
@RequestMapping("extend/xsPay")
@Slf4j(topic = "xsPayController")
@Api(value = "新生支付模块", tags = "新生支付模块")
public class XsPayController {
@Autowired
private XsPayService xsPayService;
@Autowired
private HuaxunService huaxunService;
@Autowired
private CereShopOrderService cereShopOrderService;
/**
* 支付通知回调
* @throws Exception
*/
@PostMapping("pay/notify")
public void payNotify(@RequestParam(name = "msg") String msg) throws Exception {
try {
XsCallBackRequestVo xsCallBackRequestVo = xsPayService.parseCallBackRequestVo(msg);
String status = xsCallBackRequestVo.getContent().getString("status");
//0进行中 1成功 2失败
if(StringUtils.equals(status, "1")){
log.info("新生支付回调成功");
//截取订单编号
JSONObject content = xsCallBackRequestVo.getContent();
String merOrderId = content.getString("merOrderId");
String[] split = merOrderId.split("-");
if(!EmptyUtils.isEmpty(split)){
String orderFormId=split[0];
if(!EmptyUtils.isEmpty(orderFormId)){
//支付有礼
cereShopOrderService.payGift(orderFormId);
String dealId = content.getString("dealId");
//处理支付成功后的其他逻辑
cereShopOrderService.handleWxLog(orderFormId, dealId, merOrderId);
}
}
//TODO 如果不是跨境支付应该不调用改接口------pxh
if(StringUtils.equals(XspayConfig.DEFUALT_TRADE_TYPE, XsPayEnum.TRADE_TYPE_CROSS_BOARD_PAYMENT.getCode())){
String payRequestBodyJson = xsPayService.getPayRequestBodyJson(merOrderId, new BigDecimal(Integer.parseInt(content.getString("orderAmount")) * 1.0f / 100),
XsPayEnum.TRADE_TYPE_CROSS_BOARD_PAYMENT.getCode(), content.getString("payType"));
huaxunService.pushBaoguanRequest(payRequestBodyJson);
String msgStr = new String(Base64.getDecoder().decode(msg));
huaxunService.pushBaoguanRespone(msgStr);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 退款通知回调
* @throws Exception
*/
@PostMapping("refund/notify")
public void refundNotify(@RequestParam(name = "msg") String msg) throws Exception {
log.info("----refundNotify:" + msg);
}
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/buyer/CereBuyerShopCouponDAO.java

@ -44,7 +44,7 @@ public interface CereBuyerShopCouponDAO extends BaseMapper<CereBuyerShopCoupon>
List<Long> findProductIds(@Param("shopCouponId") Long shopCouponId);
List<CereBuyerShopCoupon> findByIds(@Param("list") List<OrderProductParam> list);
List<CereBuyerShopCoupon> findByIds(@Param("list") List<Long> list);
List<ProductCoupon> findCouponMatchCondition(@Param("buyerUserId") Long buyerUserId,
@Param("fullMoneyUpperLimit") BigDecimal fullMoneyUpperLimit,

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/logistics/CereOrderLogisticsDAO.java

@ -27,5 +27,7 @@ public interface CereOrderLogisticsDAO extends BaseMapper<CereOrderLogistics> {
List<CereOrderLogistics> findLogistics(@Param("shopId") Long shopId);
List<CereOrderLogistics> findLogisticsList(@Param("shopIdList") List<Long> shopIdList);
List<CereLogisticsCharge> findCharges(@Param("logisticsId") Long logisticsId);
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/order/CereShopOrderDAO.java

@ -37,6 +37,8 @@ public interface CereShopOrderDAO extends BaseMapper<CereShopOrder> {
SettlementShop findSettlementShop(@Param("shopId") Long shopId);
List<SettlementShop> findSettlementShopList(@Param("shopIdList") List<Long> shopIdList);
String findSkuValues(@Param("skuId") Long skuId);
CereShopOrder findById(@Param("orderId") Long orderId);

2
cereshop-app/src/main/java/com/shop/cereshop/app/dao/product/CereProductSkuDAO.java

@ -48,7 +48,7 @@ public interface CereProductSkuDAO extends BaseMapper<CereProductSku> {
Integer findStockNumberBySkuId(@Param("skuId") Long skuId);
List<CartSku> findStockNumberBySkus(@Param("skus") List<ProductSku> skus);
List<CartSku> findStockNumberBySkus(@Param("skuIdList") List<Long> skuIdList);
void updateBatch(@Param("list") List<CartSku> list);

15
cereshop-app/src/main/java/com/shop/cereshop/app/dao/shop/CereShopCrossDetailDAO.java

@ -0,0 +1,15 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.dao.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.shop.CereShopCrossDetail;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CereShopCrossDetailDAO extends BaseMapper<CereShopCrossDetail> {
}

15
cereshop-app/src/main/java/com/shop/cereshop/app/dao/storehouse/CereShopStorehouseDAO.java

@ -0,0 +1,15 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.dao.storehouse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CereShopStorehouseDAO extends BaseMapper<CereShopStorehouse> {
}

21
cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/CrossStockResponeBo.java

@ -0,0 +1,21 @@
package com.shop.cereshop.app.domain.stock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "CrossStockResponeBo", description = "仓储接口返回值")
public class CrossStockResponeBo<T> implements Serializable {
@ApiModelProperty(value = "记录数")
private String count;
@ApiModelProperty(value = "库存对象")
private T data;
@ApiModelProperty(value = "返回描述")
private String desc;
@ApiModelProperty(value = "返回码(00-成功,其他异常)")
private String result;
}

21
cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/IbOrderItemRequestBo.java

@ -0,0 +1,21 @@
package com.shop.cereshop.app.domain.stock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "IbOrderItemRequestBo", description = "仓储报关子订单入参")
public class IbOrderItemRequestBo implements Serializable {
// @ApiModelProperty(value = "商品条码[不填时请到商品管理中维护条码排序]")
// private String defaultcode;
@ApiModelProperty(value = "单价")
private BigDecimal price;
@ApiModelProperty(value = "数量")
private BigDecimal qty;
@ApiModelProperty(value = "商品货号")
private String sku;
}

34
cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/KjtStockNumberResponeBo.java

@ -0,0 +1,34 @@
package com.shop.cereshop.app.domain.stock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "KjtStockNumberResponeBo", description = "仓储报关返回值")
public class KjtStockNumberResponeBo implements Serializable {
@ApiModelProperty(value = "商品条码")
private String defaultcode;
@ApiModelProperty(value = "商品名称")
private String goodsname;
@ApiModelProperty(value = "残品")
private BigDecimal inferiorboxnumber;
@ApiModelProperty(value = "正品")
private BigDecimal inferiornitumber;
@ApiModelProperty(value = "已出库")
private String isextraproduct;
@ApiModelProperty(value = "待出库")
private BigDecimal reserved;
@ApiModelProperty(value = "sku")
private String sku;
@ApiModelProperty(value = "仓库唯一标识")
private String storeid;
@ApiModelProperty(value = "可售数量")
private BigDecimal unsellable;
@ApiModelProperty(value = "预扣库存")
private BigDecimal withholdnumber;
}

73
cereshop-app/src/main/java/com/shop/cereshop/app/domain/stock/NewIbOrderRequestBo.java

@ -0,0 +1,73 @@
package com.shop.cereshop.app.domain.stock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel(value = "NewIbOrderRequestBo", description = "仓储报关入参")
public class NewIbOrderRequestBo implements Serializable {
@ApiModelProperty(value = "实际支付金额(单位:元)(小数点保留两位)(实际付金额=商品的总金额+税金+运费-优惠卷)")
private BigDecimal acturalpaid;
@ApiModelProperty(value = "订单批次号")
private String batchnumbers;
@ApiModelProperty(value = "订购人身份证号码")
private String buyeridnumber;
@ApiModelProperty(value = "订购人姓名")
private String buyername;
@ApiModelProperty(value = "订购人注册号")
private String buyerregno;
@ApiModelProperty(value = "子账号唯一标识")
private String childid;
@ApiModelProperty(value = "收货人姓名")
private String consignee;
@ApiModelProperty(value = "收货地址")
private String consigneeaddress;
@ApiModelProperty(value = "收货人城市")
private String consigneecity;
@ApiModelProperty(value = "收货人公司")
private String consigneecompany;
@ApiModelProperty(value = "收件人邮箱")
private String consigneeemail;
@ApiModelProperty(value = "收件人身份证")
private String consigneeidcard;
@ApiModelProperty(value = "收货人省")
private String consigneeprovince;
@ApiModelProperty(value = "街道")
private String consigneestreet;
@ApiModelProperty(value = "收货人电话")
private String consigneetelephone;
@ApiModelProperty(value = "优惠券金额(小数点保留两位)")
private BigDecimal discount;
@ApiModelProperty(value = "电商平台代码")
private String ebpcode;
@ApiModelProperty(value = "电商平台名称")
private String ebpname;
@ApiModelProperty(value = "快递类型")
private String expressid;
@ApiModelProperty(value = "运杂费(小数点保留两位)")
private BigDecimal freight;
@ApiModelProperty(value = "保税商品")
private List<IbOrderItemRequestBo> items;
@ApiModelProperty(value = "企业备注")
private String note;
@ApiModelProperty(value = "订单编号")
private String orderno;
@ApiModelProperty(value = "支付企业代码")
private String paycode;
@ApiModelProperty(value = "支付企业名称")
private String payname;
@ApiModelProperty(value = "支付交易编号")
private String paytransactionid;
@ApiModelProperty(value = "订购人电话")
private String purchasertelephone;
@ApiModelProperty(value = "仓库ID")
private String storeid;
@ApiModelProperty(value = "代收税款(小数点保留两位)")
private BigDecimal taxtotal;
}

16
cereshop-app/src/main/java/com/shop/cereshop/app/page/cart/CartSku.java

@ -23,11 +23,21 @@ import java.util.Map;
public class CartSku {
/**
* 订单唯一性Id--后台临时使用
*/
private Long uniqueId;
/**
* 店铺id
*/
private Long shopId;
/**
* 仓库id
*/
private Long storehouseId;
/**
* 评论id
*/
@ApiModelProperty(value = "评论id")
@ -64,6 +74,12 @@ public class CartSku {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* 售价
*/
@ApiModelProperty(value = "售价")

22
cereshop-app/src/main/java/com/shop/cereshop/app/page/product/ProductDetail.java

@ -140,6 +140,18 @@ public class ProductDetail {
private BigDecimal originalPrice;
/**
* 仓库Id
*/
@ApiModelProperty(value = "仓库Id")
private Long storehouseId;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* 售价
*/
@ApiModelProperty(value = "售价")
@ -163,11 +175,11 @@ public class ProductDetail {
@ApiModelProperty(value = "收货地址")
private CereBuyerReceive receive;
/**
* 快递费用
*/
@ApiModelProperty(value = "快递费用")
private BigDecimal logisticsPrice;
// /**
// * 快递费用
// */
// @ApiModelProperty(value = "快递费用")
// private BigDecimal logisticsPrice;
/**
* 付款人数

6
cereshop-app/src/main/java/com/shop/cereshop/app/page/product/ProductSkus.java

@ -53,6 +53,12 @@ public class ProductSkus {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* 售价
*/
@ApiModelProperty(value = "售价")

23
cereshop-app/src/main/java/com/shop/cereshop/app/page/settlement/SettlementShop.java

@ -23,6 +23,11 @@ import java.util.Map;
public class SettlementShop {
/**
* 临时订单主键
*/
@ApiModelProperty(value = "临时订单主键")
private Long uniqueId;
/**
* 店铺id
*/
@ApiModelProperty(value = "店铺id")
@ -35,6 +40,18 @@ public class SettlementShop {
private String shopName;
/**
* 仓库id
*/
@ApiModelProperty(value = "仓库id")
private Long storehouseId;
/**
* 仓库名称
*/
@ApiModelProperty(value = "仓库名称")
private String storehouseName;
/**
* 店铺地址
*/
@ApiModelProperty(value = "店铺地址")
@ -93,4 +110,10 @@ public class SettlementShop {
*/
@ApiModelProperty("收货地址与商家配送区域不匹配")
private boolean receiveNotMatch;
/**
* 是否是跨境商品
*/
@ApiModelProperty(value = "是否是跨境商品")
private Integer isCross;
}

17
cereshop-app/src/main/java/com/shop/cereshop/app/param/order/OrderProductParam.java

@ -23,12 +23,24 @@ import java.util.List;
public class OrderProductParam implements Serializable {
/**
* 唯一Id逻辑计算临时使用
*/
@ApiModelProperty(value = "唯一Id", hidden = true)
private Long uniqueId;
/**
* 店铺id
*/
@ApiModelProperty(value = "店铺id")
private Long shopId;
/**
* 仓库id
*/
@ApiModelProperty(value = "仓库id")
private Long storehouseId;
/**
* 客户领取店铺优惠券主键id
*/
@ApiModelProperty(value = "客户领取店铺优惠券主键id")
@ -47,6 +59,11 @@ public class OrderProductParam implements Serializable {
private Distribution distribution;
/**
* 是否是跨境订单
*/
private Integer isCross;
/**
* 订单备注
*/
@ApiModelProperty(value = "订单备注")

312
cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java

@ -6,27 +6,49 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.shop.cereshop.app.dao.order.CereOrderProductDAO;
import com.shop.cereshop.app.dao.order.CereShopOrderDAO;
import com.shop.cereshop.app.pay.xs.domain.XsCallBackRequestVo;
import com.shop.cereshop.app.pay.xs.domain.XsRequestBo;
import com.shop.cereshop.app.pay.xs.service.XsPayService;
import com.shop.cereshop.app.pay.xs.utils.CommonUtils;
import com.shop.cereshop.app.pay.xs.utils.HttpUtils;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.commons.config.XspayConfig;
import com.shop.cereshop.commons.constant.XsPayEnum;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.order.CereOrderParent;
import com.shop.cereshop.commons.domain.order.CereOrderProduct;
import com.shop.cereshop.commons.domain.order.CereShopOrder;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.utils.URIBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service(value = "xsPayService")
@Slf4j
public class XsPayServiceImpl implements XsPayService {
@Autowired
private CereShopOrderDAO cereShopOrderDAO;
@Autowired
private CereBuyerUserService cereBuyerUserService;
@Autowired
private CereOrderProductDAO cereOrderProductDAO;
//支付申请服务代码 serCode
private static final String PAY_SER_CODE = "101005";
//退款申请服务代码 serCode
@ -47,8 +69,7 @@ public class XsPayServiceImpl implements XsPayService {
//构建请求参数
Map<String, String> headMap = CommonUtils.buildHeadMap(REFUND_SER_CODE);
Map<String, Object> contentMap = buildOrderRefundContentMap(outTradeNo, transactionId, total,
XspayConfig.APP_NOTICE_URL);
Map<String, Object> contentMap = buildOrderRefundContentMap(outTradeNo, transactionId, total, XspayConfig.APP_NOTICE_URL);
//head+content做md5并根据加签方式加密
String msg = CommonUtils.getRequestMsg(headMap, contentMap);
log.info("【" + PAY_SER_CODE + "】接口-请求报文:msg="+msg);
@ -91,42 +112,42 @@ public class XsPayServiceImpl implements XsPayService {
//获取保证金二维码
@Override
public String getCollectionCode(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException, Exception {
//构建请求参数
Map<String, String> headMap = CommonUtils.buildHeadMap(PAY_SER_CODE);
Map<String, Object> contentMap = buildPayContentMap(orderFormid, money, tradeType, XsPayEnum.PAY_TYPE_QRCODE.getCode(), XspayConfig.BUSINESS_RETURN_URL,
XspayConfig.BUSINESS_NOTICE_URL);
//head+content做md5并根据加签方式加密
String msg = CommonUtils.getRequestMsg(headMap, contentMap);
log.info("【" + PAY_SER_CODE + "】接口-请求报文:msg="+msg);
String respMsg = HttpUtils.httpPost(XspayConfig.URL,msg);
//若响应respMsg为空时联系新生工作人员此处因时收银台模式前端页面提交方式当时错误时错误信息会重定向到其他页面展示
log.info("【" + PAY_SER_CODE + "】接口-响应报文:" + respMsg);
if(StrUtil.isNotBlank(respMsg)){
try {
//解析响应报文并验签
CommonUtils.verifySignRespMsg(PAY_SER_CODE,respMsg);
LinkedHashMap<String,String> responseMap = JSONObject.parseObject(respMsg,new TypeReference<LinkedHashMap<String,String>>(){}, Feature.OrderedField );
String resMsg = responseMap.get("msg");
String responeMsg = new String(Base64.getDecoder().decode(resMsg));
JSONObject jsonObject = JSONObject.parseObject(responeMsg);
String qrCodeUrl = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("qrCodeUrl");
qrCodeUrl = new URIBuilder(qrCodeUrl).getQueryParams().get(0).getValue();
return qrCodeUrl;
} catch (CoBusinessException e) {
throw e;
} catch (Exception e) {
//支付方式为B2CB2BH5成功响应时respMsg为html页面代码
if(respMsg.contains("toNativePayIndexForm")){
log.info("【" + PAY_SER_CODE + "】接口-响应报文-HTML代码无需验签");
}else{
e.printStackTrace();
}
throw new CoBusinessException("10000","获取支付二维码出错");
}
}
// //构建请求参数
// Map<String, String> headMap = CommonUtils.buildHeadMap(PAY_SER_CODE);
//
// Map<String, Object> contentMap = buildPayContentMap(orderFormid, money, tradeType, XsPayEnum.PAY_TYPE_QRCODE.getCode(), XspayConfig.BUSINESS_RETURN_URL,
// XspayConfig.BUSINESS_NOTICE_URL);
// //head+content做md5并根据加签方式加密
// String msg = CommonUtils.getRequestMsg(headMap, contentMap);
// log.info("【" + PAY_SER_CODE + "】接口-请求报文:msg="+msg);
//
// String respMsg = HttpUtils.httpPost(XspayConfig.URL,msg);
// //若响应respMsg为空时联系新生工作人员此处因时收银台模式前端页面提交方式当时错误时错误信息会重定向到其他页面展示
// log.info("【" + PAY_SER_CODE + "】接口-响应报文:" + respMsg);
//
// if(StrUtil.isNotBlank(respMsg)){
// try {
// //解析响应报文并验签
// CommonUtils.verifySignRespMsg(PAY_SER_CODE,respMsg);
// LinkedHashMap<String,String> responseMap = JSONObject.parseObject(respMsg,new TypeReference<LinkedHashMap<String,String>>(){}, Feature.OrderedField );
// String resMsg = responseMap.get("msg");
// String responeMsg = new String(Base64.getDecoder().decode(resMsg));
// JSONObject jsonObject = JSONObject.parseObject(responeMsg);
// String qrCodeUrl = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("qrCodeUrl");
// qrCodeUrl = new URIBuilder(qrCodeUrl).getQueryParams().get(0).getValue();
// return qrCodeUrl;
// } catch (CoBusinessException e) {
// throw e;
// } catch (Exception e) {
// //支付方式为B2CB2BH5成功响应时respMsg为html页面代码
// if(respMsg.contains("toNativePayIndexForm")){
// log.info("【" + PAY_SER_CODE + "】接口-响应报文-HTML代码无需验签");
// }else{
// e.printStackTrace();
// }
// throw new CoBusinessException("10000","获取支付二维码出错");
// }
// }
return null;
}
@ -176,11 +197,38 @@ public class XsPayServiceImpl implements XsPayService {
return jsonString;
}
public XsRequestBo getPayRequestBody(String outTradeNo, BigDecimal money, String tradeType, String payType) throws CoBusinessException, Exception {
public XsRequestBo getPayRequestBody(String orderFormId, BigDecimal money, String tradeType, String payType) throws CoBusinessException, Exception {
List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormId;
String[] split = orderFormId.split("-");
if(!EmptyUtils.isEmpty(split)) {
cereOrderFormId = split[0];
}
//查询是否为父订单编号
CereOrderParent parent = cereShopOrderDAO.findByParentFormid(cereOrderFormId);
if (parent != null) {
//查询所有子订单数据
orderList = cereShopOrderDAO.findByParentId(parent.getParentId());
} else {
//子订单支付回调
orderList = cereShopOrderDAO.findByFormid(cereOrderFormId);
}
if(orderList.isEmpty()){
throw new CoBusinessException("10000","订单查找出错");
}
CereBuyerUser user = cereBuyerUserService.selectByBuyerUserId(orderList.get(0).getBuyerUserId());
List<CereOrderProduct> cereOrderProductList = cereOrderProductDAO.findByOrderIds(orderList.stream().map(CereShopOrder::getId).collect(Collectors.toList()));
//构建请求参数
Map<String, String> headMap = CommonUtils.buildHeadMap(PAY_SER_CODE);
Map<String, Object> contentMap = buildPayContentMap(outTradeNo, money, tradeType, payType, XspayConfig.APP_RETURN_URL,
Map<String, Object> contentMap = buildPayContentMap(orderFormId, user, orderList, cereOrderProductList,
money, tradeType, payType, XspayConfig.APP_RETURN_URL,
XspayConfig.APP_NOTICE_URL);
XsRequestBo xsRequestBo = new XsRequestBo();
@ -210,12 +258,14 @@ public class XsPayServiceImpl implements XsPayService {
* 构建content请求参数
* @return
*/
private static Map<String,Object> buildPayContentMap(String orderFormid, BigDecimal money, String tradeType,
private static Map<String,Object> buildPayContentMap(String orderFormid, CereBuyerUser user, List<CereShopOrder> orderList,
List<CereOrderProduct> cereOrderProductList, BigDecimal money, String tradeType,
String payType, String returnUrl, String noticeUrl){
// 设置请求正文 contentMap有序顺序按照文档从上到下为空字段可不传该字段
Map<String, Object> contentMap = new LinkedHashMap<>();
//商户订单号
contentMap.put("merOrderId", orderFormid);
//商户名称 请根据实际情况替换
contentMap.put("displayName", "成美国际");
@ -228,7 +278,7 @@ public class XsPayServiceImpl implements XsPayService {
contentMap.put("goodsType", "01");
//订单金额单位分
contentMap.put("orderAmount", 1);//money.multiply(new BigDecimal(100)).intValue());
contentMap.put("orderAmount", money.multiply(new BigDecimal(100)).intValue());
//订单币种 CNY:人民币
contentMap.put("orderCurrencyCode", "CNY");
//贸易类型 0004-货物贸易
@ -246,7 +296,7 @@ public class XsPayServiceImpl implements XsPayService {
//分账标识 0:不分账 1:实时分账 2:延时分账
contentMap.put("shareFlag", "0");
//分账订单信息 shangFlag=1时必填
JSONArray jsonArray = buildSubMerchantOrderDetails();
JSONArray jsonArray = buildSubMerchantOrderDetails(orderList, cereOrderProductList);
contentMap.put("subMerchantOrderDetails", JSONArray.toJSONString(jsonArray));
//回调地址--支付成功后的前端回调地址先写死首页
@ -258,15 +308,16 @@ public class XsPayServiceImpl implements XsPayService {
contentMap.put("platformId","");
//商户用户号 请根据实际情况选择填写 TODO 这个先写死但是应该要根据订单的支付人来传值
contentMap.put("customerId", "U00001");
contentMap.put("customerId", user.getBuyerUserId() + "");
//商户用户类型 请根据实际情况选择填写
contentMap.put("customerType", "1");
//商户用户姓名 请根据实际情况选择填写
contentMap.put("customerName", "潘孝河");
contentMap.put("customerName", user.getRealName());
//商户用户证件号 请根据实际情况选择填写
contentMap.put("customerIdNo", "460004198911216054");
contentMap.put("customerIdNo", user.getIdCard());
//商户用户手机号 请根据实际情况选择填写
contentMap.put("customerTel", "13700418358");
contentMap.put("customerTel", user.getPhone());
//以下信息在支付类型为快捷支付的时候必填
//商户用户银行卡号
contentMap.put("bankCardNo", "");
@ -291,52 +342,27 @@ public class XsPayServiceImpl implements XsPayService {
* 构建分账明细
* @return
*/
private static JSONArray buildSubMerchantOrderDetails(){
private static JSONArray buildSubMerchantOrderDetails(List<CereShopOrder> orderList,
List<CereOrderProduct> cereOrderProductList){
JSONArray jsonArray = new JSONArray();
// //子订单1
// JSONObject subOrder1 = new JSONObject();
// subOrder1.put("subOrderId","sub20201001");
// subOrder1.put("subOrderAmount",50);
// //子订单1 明细1
// JSONArray detailArray1 = new JSONArray();
// JSONObject detail1 = new JSONObject();
// detail1.put("shareDetailId","sub20201001sd00001");
// detail1.put("shareParId","1000000037901581");
// detail1.put("shareAmount",20);
// detail1.put("settleCurCode","CNY");
// detailArray1.add(detail1);
// //子订单1 明细2
// JSONObject detail2 = new JSONObject();
// detail2.put("shareDetailId","sub20201001sd00002");
// detail2.put("shareParId","1000000037901520");
// detail2.put("shareAmount",30);
// detail2.put("settleCurCode","CNY");
// detailArray1.add(detail2);
// subOrder1.put("shareDetail",detailArray1);
// jsonArray.add(subOrder1);
//
// //子订单2
// JSONObject subOrder2 = new JSONObject();
// subOrder2.put("subOrderId","sub20201002");
// subOrder2.put("subOrderAmount",50);
// //子订单2 明细1
// JSONArray detailArray2 = new JSONArray();
// JSONObject detail3 = new JSONObject();
// detail3.put("shareDetailId","sub20201002sd00001");
// detail3.put("shareParId","1000000037901485");
// detail3.put("shareAmount",20);
// detail3.put("settleCurCode","CNY");
// detailArray2.add(detail3);
// //子订单2 明细2
// JSONObject detail4 = new JSONObject();
// detail4.put("shareDetailId","sub20201002sd00002");
// detail4.put("shareParId","1000000037901484");
// detail4.put("shareAmount",30);
// detail4.put("settleCurCode","CNY");
// detailArray2.add(detail4);
// subOrder2.put("shareDetail",detailArray2);
//
// jsonArray.add(subOrder2);
for (CereShopOrder cereShopOrder : orderList) {
JSONObject subOrder1 = new JSONObject();
subOrder1.put("subOrderId",cereShopOrder.getOrderId());
subOrder1.put("subOrderAmount", cereShopOrder.getPrice());
List<CereOrderProduct> orderProductList = cereOrderProductList.stream().filter(item -> item.getOrderId().equals(cereShopOrder.getOrderId())).collect(Collectors.toList());
for (CereOrderProduct cereOrderProduct : orderProductList) {
//子订单1 明细1
JSONArray detailArray1 = new JSONArray();
JSONObject detail1 = new JSONObject();
detail1.put("shareDetailId","" + cereOrderProduct.getOrderId() + cereOrderProduct.getOrderProductId());
detail1.put("shareParId",cereShopOrder.getShopId() + "");
detail1.put("shareAmount",cereOrderProduct.getActualPrice());
detail1.put("settleCurCode","CNY");
detailArray1.add(detail1);
}
}
return jsonArray;
}
@ -376,4 +402,106 @@ public class XsPayServiceImpl implements XsPayService {
return xsCallBackRequestVo;
}
//推单接口
public String aaa(String orderFormid, BigDecimal money, String ip, String tradeType) throws CoBusinessException, Exception {
XsRequestBo xsRequestBo = getPayRequestBody(orderFormid, money, tradeType, XsPayEnum.PAY_TYPE_QRCODE.getCode());
//head+content做md5并根据加签方式加密
String msg = CommonUtils.getRequestMsg(xsRequestBo.getHead(),xsRequestBo.getContent());
log.info("【" + PAY_SER_CODE + "】接口-请求报文:msg="+msg);
String respMsg = HttpUtils.httpPost(XspayConfig.URL,msg);
//若响应respMsg为空时联系新生工作人员此处因时收银台模式前端页面提交方式当时错误时错误信息会重定向到其他页面展示
log.info("【" + PAY_SER_CODE + "】接口-响应报文:" + respMsg);
if(StrUtil.isNotBlank(respMsg)){
try {
//解析响应报文并验签
CommonUtils.verifySignRespMsg(PAY_SER_CODE,respMsg);
LinkedHashMap<String,String> responseMap = JSONObject.parseObject(respMsg,new TypeReference<LinkedHashMap<String,String>>(){}, Feature.OrderedField );
String resMsg = responseMap.get("msg");
String responeMsg = new String(Base64.getDecoder().decode(resMsg));
JSONObject jsonObject = JSONObject.parseObject(responeMsg);
String qrCodeUrl = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("qrCodeUrl");
qrCodeUrl = new URIBuilder(qrCodeUrl).getQueryParams().get(0).getValue();
return qrCodeUrl;
} catch (CoBusinessException e) {
throw e;
} catch (Exception e) {
//支付方式为B2CB2BH5成功响应时respMsg为html页面代码
if(respMsg.contains("toNativePayIndexForm")){
log.info("【" + PAY_SER_CODE + "】接口-响应报文-HTML代码无需验签");
}else{
e.printStackTrace();
}
throw new CoBusinessException("10000","获取支付二维码出错");
}
}
return null;
}
/**
* 构建content请求参数
* @return
*/
private static Map<String,Object> build17ContentMap(){
// 设置请求正文 contentMap有序顺序按照文档从上到下为空字段可不传该字段
Map<String, Object> contentMap = new LinkedHashMap<>();
contentMap.put("eportCode", "00");
//商户订单号(对应101004101005接口中merOrderId主订单推送时该订单号推送至海关)
contentMap.put("merOrderId", System.currentTimeMillis()+"");
//订单币种
contentMap.put("currencyCode", "CNY");
//电商平台备案号 备案号需登录新生商户后台配置
contentMap.put("eCompanyCode", "2102960L0U");
//电商平台备案名称 备案名称需登录新生商户后台配置
contentMap.put("eCompanyName", "大连小洋伞国际贸易有限公司");
//海关关区代码
contentMap.put("customsCode", "5165");
//进口类型
contentMap.put("intype", "1");
//支付交易号 对应101004101005接口响应dealId字段
contentMap.put("payTransactionNo", "1022204040009067712");
//操作类型 1-新增
contentMap.put("actionType", "1");
//支付人姓名 支付人信息需与101004101005接口中付款人信息一致
contentMap.put("payerName", "廖文聪");
//支付人证件类型 01-身份证
contentMap.put("payerType", "01");
//支付人证件号码 支付人信息需与101004101005接口中付款人信息一致
contentMap.put("payerId", "441324198806092351");
//支付人手机号
contentMap.put("payerPhoneNumber", "13413034683");
//订单明细 拆单报关时使用该字段
JSONArray jsonArray = buildOrderDetails();
contentMap.put("orderDetails", JSONArray.toJSONString(jsonArray));
//通知地址
contentMap.put("noticeUrl", "http://lcoalhost:8080/gatewayTest/notify");
return contentMap;
}
/**
* 构建子订单明细
* @return
*/
private static JSONArray buildOrderDetails(){
JSONArray jsonArray = new JSONArray();
//子订单1
JSONObject detail1 = new JSONObject();
detail1.put("subOrderNo",System.currentTimeMillis()+"");//商户子订单号(拆单报关时该订单号推送至海关)
detail1.put("payAmount",100);//单位为分与订单币种一致币种
detail1.put("goodsName","商品名称");//商品名称
detail1.put("goodsCount","1");//商品数量
jsonArray.add(detail1);
//子订单2
JSONObject detail2 = new JSONObject();
detail2.put("subOrderNo",System.currentTimeMillis()+"1");//商户子订单号(拆单报关时该订单号推送至海关)
detail2.put("payAmount",200);//单位为分与订单币种一致币种
detail2.put("goodsName","商品名称");//商品名称
detail2.put("goodsCount","1");//商品数量
jsonArray.add(detail2);
return jsonArray;
}
}

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/CereBuyerShopCouponService.java

@ -31,7 +31,7 @@ public interface CereBuyerShopCouponService {
List<Long> findProductIds(Long shopCouponId);
List<CereBuyerShopCoupon> findByIds(List<OrderProductParam> shops);
List<CereBuyerShopCoupon> findByIds(List<Long> shopIdList);
List<ProductCoupon> findCouponMatchCondition(Long buyerUserId, BigDecimal fullMoneyUpperLimit, List<Long> productIdList);

4
cereshop-app/src/main/java/com/shop/cereshop/app/service/buyer/impl/CereBuyerShopCouponServiceImpl.java

@ -66,8 +66,8 @@ public class CereBuyerShopCouponServiceImpl implements CereBuyerShopCouponServic
}
@Override
public List<CereBuyerShopCoupon> findByIds(List<OrderProductParam> shops) {
return cereBuyerShopCouponDAO.findByIds(shops);
public List<CereBuyerShopCoupon> findByIds(List<Long> shopIdList) {
return cereBuyerShopCouponDAO.findByIds(shopIdList);
}
@Override

4
cereshop-app/src/main/java/com/shop/cereshop/app/service/extend/impl/HuaxunServiceImpl.java

@ -52,7 +52,7 @@ public class HuaxunServiceImpl implements HuaxunService {
HuaxunPayBaoGuanRequestBo bo = new HuaxunPayBaoGuanRequestBo();
bo.setChannel("xinsheng");
bo.setRequest(request);
HttpResult httpResult = HttpUtils.doPost(HuaxunConfig.PAY_URL, bo);
HttpResult httpResult = HttpUtils.doPost(HuaxunConfig.getPayUrl(), bo);
if (httpResult.getStatus() == 200 && StringUtils.equals("success", httpResult.getBody())){
//报关成功
log.info("报关发送支付请求成功");
@ -69,7 +69,7 @@ public class HuaxunServiceImpl implements HuaxunService {
HuaxunPayBaoGuanResponseBo bo = new HuaxunPayBaoGuanResponseBo();
bo.setChannel("xinsheng");
bo.setResponse(response);
HttpResult httpResult = HttpUtils.doPost(HuaxunConfig.PAYBACK_URL, bo);
HttpResult httpResult = HttpUtils.doPost(HuaxunConfig.getPayBackUrl(), bo);
if (httpResult.getStatus() == 200 && StringUtils.equals("success", httpResult.getBody())){
//报关成功
log.info("报关发送支付回调成功");

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/logistics/CereOrderLogisticsService.java

@ -13,5 +13,7 @@ import java.util.List;
public interface CereOrderLogisticsService {
List<CereOrderLogistics> findLogistics(Long shopId);
List<CereOrderLogistics> findLogisticsList(List<Long> shopIdList);
List<CereLogisticsCharge> findCharges(Long logisticsId);
}

5
cereshop-app/src/main/java/com/shop/cereshop/app/service/logistics/impl/CereOrderLogisticsServiceImpl.java

@ -26,6 +26,11 @@ public class CereOrderLogisticsServiceImpl implements CereOrderLogisticsService
}
@Override
public List<CereOrderLogistics> findLogisticsList(List<Long> shopIdList) {
return cereOrderLogisticsDAO.findLogisticsList(shopIdList);
}
@Override
public List<CereLogisticsCharge> findCharges(Long logisticsId) {
return cereOrderLogisticsDAO.findCharges(logisticsId);
}

798
cereshop-app/src/main/java/com/shop/cereshop/app/service/order/impl/CereShopOrderServiceImpl.java

@ -97,6 +97,7 @@ import com.shop.cereshop.app.service.sensitive.CerePlatformSensitiveService;
import com.shop.cereshop.app.service.shop.CereShopCommentService;
import com.shop.cereshop.app.service.shop.CereShopConversionService;
import com.shop.cereshop.app.service.stock.CereStockService;
import com.shop.cereshop.app.service.storehouse.CereShopStorehouseService;
import com.shop.cereshop.app.utils.DistributionUtil;
import com.shop.cereshop.commons.config.AlipayConfig;
import com.shop.cereshop.commons.config.PayConfig;
@ -133,6 +134,7 @@ import com.shop.cereshop.commons.domain.scene.CereShopSceneMember;
import com.shop.cereshop.commons.domain.sensitive.CerePlatformSensitive;
import com.shop.cereshop.commons.domain.shop.CereShopComment;
import com.shop.cereshop.commons.domain.shop.CereShopConversion;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import com.shop.cereshop.commons.domain.tool.*;
import com.shop.cereshop.commons.domain.word.CerePlatformWord;
import com.shop.cereshop.commons.exception.CoBusinessException;
@ -142,9 +144,9 @@ import com.shop.cereshop.commons.utils.third.WxCardUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.poi.util.IOUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -352,6 +354,9 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
@Autowired
private CereSkuRealInfoDAO cereSkuRealInfoDAO;
@Autowired
private CereShopStorehouseService cereShopStorehouseService;
/**
* app支付版本号
*/
@ -1635,12 +1640,7 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
List<SettlementShop> shopSettlementList = new ArrayList<>();
//查找所有的活动相关信息
//cerePlatformSeckillService.
List<Long> shopIdList = new ArrayList<>();
for (ShopProductParam shop : param.getShops()) {
shopIdList.add(shop.getShopId());
}
List<Long> shopIdList = param.getShops().stream().map(ShopProductParam::getShopId).distinct().collect(Collectors.toList());
// 平台秒杀
List<ShopPlatformSeckill> platformSeckillList = cerePlatformSeckillService.selectPlatformSeckillsByShopIdList(shopIdList);
Map<Long, List<ShopPlatformSeckill>> productIdPlatformSeckillMap = platformSeckillList.stream().collect(Collectors.groupingBy(ShopPlatformSeckill::getProductId));
@ -1657,9 +1657,6 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
List<ShopBusinessDiscount> discountList = cereShopDiscountService.selectByShopIdList(shopIdList);
Map<Long, List<ShopBusinessDiscount>> skuIdDiscountMap = discountList.stream().collect(Collectors.groupingBy(ShopBusinessDiscount::getSkuId));
// 定价捆绑
// Map<Long, Map<Long, List<CerePriceRule>>> priceMap = cereShopPriceService.selectPriceMap(shopIdList);
// 组合捆绑
List<CereShopComposeDTO> composeDTOList = Collections.emptyList();
if (ParamEnum.BUY_NOW.getCode().equals(param.getType())) {
@ -1689,10 +1686,8 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
CerePlatformDict dict3 = cerePlatformDictService.getByName(DictConstants.CREDIT_DEDUCT_LIMIT);
//1积分抵扣多少额度
CerePlatformDict dict4 = cerePlatformDictService.getByName(DictConstants.CREDIT_EXCHANGE_RATE);
log.info("dict: {} dict2: {} dict3:{} dict4: {}", JSON.toJSONString(dict), JSON.toJSONString(dict2),
JSON.toJSONString(dict3), JSON.toJSONString(dict4));
if (dict != null && StringUtils.isNotBlank(dict.getDictDescribe())
&& IntegerEnum.YES.getCode().equals(Integer.parseInt(dict.getDictDescribe()))) {
if (dict != null && StringUtils.isNotBlank(dict.getDictDescribe()) && IntegerEnum.YES.getCode().equals(Integer.parseInt(dict.getDictDescribe()))) {
creditSwitch = true;
CereBuyerUser buyerUser = cereBuyerUserService.selectByBuyerUserId(user.getBuyerUserId());
totalRemainCredit = buyerUser.getCredit();
@ -1724,253 +1719,440 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
//商家id 对应的定价捆绑的 商品id列表
Map<Long, List<Long>> shopPriceProductIdListMap = new HashMap<>();
List<ProductSku> allSkus = new ArrayList();
for (ShopProductParam shop : param.getShops()) {
allSkus.addAll(shop.getSkus());
}
//查询所有购买商品的库存数据
List<Long> skuIdList = allSkus.stream().map(ProductSku::getSkuId).distinct().collect(Collectors.toList());
List<CartSku> allProductSkus = cereProductSkuService.findStockNumberBySkus(skuIdList);
List<Long> storehouseIdList = allProductSkus.stream().map(CartSku::getStorehouseId).distinct().collect(Collectors.toList());
List<CereShopStorehouse> allStorehouseList = cereShopStorehouseService.getAll(storehouseIdList);
//计算某个定价id优惠了多少钱
Map<Long, DiscountDescDTO> priceDiscountMap = new HashMap<>();
//计算某个组合捆绑id优惠了多少钱
Map<Long, DiscountDescDTO> composeDiscountMap = new HashMap<>();
List<SettlementShop> settlementShopList = cereShopOrderDAO.findSettlementShopList(shopIdList);
//满足使用优惠券条件的商品列表
List<Long> shopCanUseCouponProductIdList = new ArrayList<>();
List<CereOrderLogistics> logisticsList = cereOrderLogisticsService.findLogisticsList(shopIdList);
//查询店铺信息
SettlementShop settlementShop = cereShopOrderDAO.findSettlementShop(shop.getShopId());
settlementShop.setShopId(shop.getShopId());
List<CartSku> invalidSkus = new ArrayList<>();
int invalidNumber = 0;
BigDecimal total = BigDecimal.ZERO;
//sku后面接的 优惠信息
Map<Long, List<String>> skuDiscountInfoMap = new HashMap<>();
settlementShop.setSkuDiscountInfoMap(skuDiscountInfoMap);
//拆单后的结果主键仓库Id值为对应的订单商品详情
Map<Long, List<ShopProductParam>> crossShopProductParamListMap = new HashMap<>();
//商品还可以抵扣多少积分
Map<Long, Integer> productRemainCreditMap = new HashMap<>();
//根据商家仓库限制等进行拆单
//仓库限制到这里只需要根据订单总额来进行拆单因为单商品限额的单商品数量已经在加入购物车的时候做了限制总商品数量限制暂时不做支持后续如果需要支持也放在这里
Map<Long, CartSku> map = new HashMap<>();
for (ShopProductParam shop : param.getShops()) {
//这里进行拆单
if (!EmptyUtils.isEmpty(shop.getSkus())) {
//查询当前店铺所有购买商品的库存数据
List<CartSku> productSkus = cereProductSkuService.findStockNumberBySkus(shop.getSkus());
if (!EmptyUtils.isEmpty(productSkus)) {
for (CartSku sku : productSkus) {
map.put(sku.getSkuId(), sku);
if (creditSwitch && IntegerEnum.YES.getCode().equals(sku.getIfCredit())) {
productRemainCreditMap.put(sku.getProductId(), sku.getCreditLimit());
} else {
productRemainCreditMap.put(sku.getProductId(), 0);
//同一个商家内的所有商品
for (ProductSku skus : shop.getSkus()) {
CartSku findCartSku = allProductSkus.stream().filter(item -> item.getSkuId().equals(skus.getSkuId())).findFirst().orElse(null);
if (findCartSku != null) {
CereShopStorehouse cereShopStorehouse = allStorehouseList.stream().filter(item -> item.getStorehouseId().equals(findCartSku.getStorehouseId())).findFirst().orElse(null);
if(cereShopStorehouse != null){
if(cereShopStorehouse.getKind() == 1){
//国内仓-分仓库拆单这里本来应该是国内订单并单的但是因为订单的运费问题保持拆单逻辑
if(!crossShopProductParamListMap.containsKey(cereShopStorehouse.getStorehouseId())){
crossShopProductParamListMap.put(cereShopStorehouse.getStorehouseId(),new ArrayList<>());
}
List<ShopProductParam> storehouseShopProductParamList = crossShopProductParamListMap.get(cereShopStorehouse.getStorehouseId());
if(storehouseShopProductParamList.isEmpty()){
ShopProductParam storehouseShopProductParam = new ShopProductParam();
BeanUtils.copyProperties(shop, storehouseShopProductParam);
storehouseShopProductParam.setSkus(new ArrayList<>());
storehouseShopProductParamList.add(storehouseShopProductParam);
}
storehouseShopProductParamList.get(0).getSkus().add(skus);
}else if(cereShopStorehouse.getKind() == 2){
//保税仓
if(!crossShopProductParamListMap.containsKey(cereShopStorehouse.getStorehouseId())){
crossShopProductParamListMap.put(cereShopStorehouse.getStorehouseId(),new ArrayList<>());
}
List<ShopProductParam> storehouseShopProductParamList = crossShopProductParamListMap.get(cereShopStorehouse.getStorehouseId());
if(storehouseShopProductParamList.isEmpty()){
ShopProductParam storehouseShopProductParam = new ShopProductParam();
BeanUtils.copyProperties(shop, storehouseShopProductParam);
storehouseShopProductParam.setSkus(new ArrayList<>());
storehouseShopProductParam.getSkus().add(skus);
storehouseShopProductParamList.add(storehouseShopProductParam);
}else {
ShopProductParam storehouseShopProductParam = storehouseShopProductParamList.get(storehouseShopProductParamList.size() - 1);
//如果总价超过订单限制总价则拆单
BigDecimal totalPrice = BigDecimal.ZERO;
for (ProductSku storehouseProductSkus : storehouseShopProductParam.getSkus()) {
CartSku findStorehouseCartSku = allProductSkus.stream().filter(item -> item.getSkuId().equals(storehouseProductSkus.getSkuId())).findFirst().orElse(null);
if(findStorehouseCartSku != null){
totalPrice = totalPrice.add(findStorehouseCartSku.getPrice().multiply(BigDecimal.valueOf(storehouseProductSkus.getNumber())));
}
}
totalPrice = totalPrice.add(findCartSku.getPrice().multiply(BigDecimal.valueOf(skus.getNumber())));
if(totalPrice.compareTo(cereShopStorehouse.getMoreProductOrderPriceLimit()) > 0){
storehouseShopProductParam = new ShopProductParam();
BeanUtils.copyProperties(shop, storehouseShopProductParam);
storehouseShopProductParam.setSkus(new ArrayList<>());
storehouseShopProductParam.getSkus().add(skus);
storehouseShopProductParamList.add(storehouseShopProductParam);
}else {
storehouseShopProductParam.getSkus().add(skus);
}
}
}else if(cereShopStorehouse.getKind() == 3){
//海外仓
if(!crossShopProductParamListMap.containsKey(cereShopStorehouse.getStorehouseId())){
crossShopProductParamListMap.put(cereShopStorehouse.getStorehouseId(),new ArrayList<>());
}
List<ShopProductParam> storehouseShopProductParamList = crossShopProductParamListMap.get(cereShopStorehouse.getStorehouseId());
if(storehouseShopProductParamList.isEmpty()){
ShopProductParam storehouseShopProductParam = new ShopProductParam();
BeanUtils.copyProperties(shop, storehouseShopProductParam);
storehouseShopProductParam.setSkus(new ArrayList<>());
storehouseShopProductParamList.add(storehouseShopProductParam);
}
storehouseShopProductParamList.get(0).getSkus().add(skus);
}
}
}
}
//将商品数量放到map中
Map<Long, Integer> numberMap = shop.getSkus().stream()
.collect(Collectors.toMap(ProductSku::getSkuId, ProductSku::getNumber));
Map<Long, Integer> productIdBuyNumberMap = new HashMap<>();
Set<Long> usedSkuIdSet = new HashSet<>();
if (!EmptyUtils.isEmpty(numberMap)) {
//查询规格信息数据
List<CartSku> skus = cereProductSkuService.findStockNumberBySkus(shop.getSkus());
if (!EmptyUtils.isEmpty(skus)) {
//设置商品数量
skus.forEach(sku -> {
sku.setNumber(numberMap.get(sku.getSkuId()));
sku.setShopId(shop.getShopId());
Integer buyNum = productIdBuyNumberMap.getOrDefault(sku.getProductId(), 0);
productIdBuyNumberMap.put(sku.getProductId(), buyNum + sku.getNumber());
});
/*for (CartSku sku : skus) {
//秒杀活动和限时折扣活动校验
//checkActivity(param, numberMap.get(sku.getSkuId()), sku, settlement, user, shop);
//设置规格属性值数组
sku.setValues(EmptyUtils.getImages(sku.getValue()));
}*/
for (CartSku sku : skus) {
shopCanUseCouponProductIdList.add(sku.getProductId());
List<ShopPlatformSeckill> shopPlatformSeckillList = productIdPlatformSeckillMap.get(sku.getProductId());
List<ShopPlatformDiscount> shopPlatformDiscountList = productIdPlatformDiscountMap.get(sku.getProductId());
List<ShopBusinessSeckill> shopBusinessSeckillList = skuIdSeckillMap.get(sku.getSkuId());
List<ShopBusinessDiscount> shopBusinessDiscountList = skuIdDiscountMap.get(sku.getSkuId());
BigDecimal num = new BigDecimal(sku.getNumber());
//匹配平台秒杀
if (CollectionUtils.isNotEmpty(shopPlatformSeckillList)) {
ShopPlatformSeckill seckill = shopPlatformSeckillList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setPlatformSeckillId(shopPlatformSeckillList.get(0).getSeckillId());
if (sku.getOriginalPrice().compareTo(seckill.getSeckillMoney()) >= 0) {
sku.setPrice(sku.getOriginalPrice().subtract(seckill.getSeckillMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(seckill.getIfLimit())) {
if (productIdBuyNumberMap.get(sku.getProductId()) > seckill.getLimitNumber()) {
for (Map.Entry<Long, List<ShopProductParam>> storehouseProdustsListEntry : crossShopProductParamListMap.entrySet()) {
Long storehouseId = storehouseProdustsListEntry.getKey();
List<ShopProductParam> storehouseProdustsList = storehouseProdustsListEntry.getValue();
for (ShopProductParam shop : storehouseProdustsList) {
//计算某个定价id优惠了多少钱
Map<Long, DiscountDescDTO> priceDiscountMap = new HashMap<>();
//计算某个组合捆绑id优惠了多少钱
Map<Long, DiscountDescDTO> composeDiscountMap = new HashMap<>();
//满足使用优惠券条件的商品列表
List<Long> shopCanUseCouponProductIdList = new ArrayList<>();
//查询店铺信息findSettlementShopList
SettlementShop tempSettlementShop = settlementShopList.stream().filter(item -> item.getShopId().equals(shop.getShopId())).findFirst().orElse(null);
SettlementShop settlementShop = new SettlementShop();
BeanUtils.copyProperties(tempSettlementShop, settlementShop);
settlementShop.setShopId(shop.getShopId());
settlementShop.setStorehouseId(storehouseId);
CereShopStorehouse shopStorehouse = allStorehouseList.stream().filter(item -> item.getStorehouseId().equals(storehouseId)).findFirst().orElse(null);
settlementShop.setStorehouseName(shopStorehouse.getStorehouseName());
if(shopStorehouse.getKind() == 2){
settlementShop.setIsCross(1);
}else {
settlementShop.setIsCross(0);
}
String uniqueIdKey = shop.getShopId() + "-" + storehouseId + "-" + shop.getSkus().stream().map(item -> item.getSkuId().toString()).reduce((x, y) -> x + y).orElse("");
settlementShop.setUniqueId((long) uniqueIdKey.hashCode());
List<CartSku> invalidSkus = new ArrayList<>();
int invalidNumber = 0;
BigDecimal total = BigDecimal.ZERO;
//sku后面接的 优惠信息
Map<Long, List<String>> skuDiscountInfoMap = new HashMap<>();
settlementShop.setSkuDiscountInfoMap(skuDiscountInfoMap);
//商品还可以抵扣多少积分
Map<Long, Integer> productRemainCreditMap = new HashMap<>();
Map<Long, CartSku> map = new HashMap<>();
if (!EmptyUtils.isEmpty(shop.getSkus())) {
//查询当前订单所购买商品的详细数据
List<CartSku> productSkus = new ArrayList<>();
for (ProductSku skus : shop.getSkus()) {
CartSku findCartSku = allProductSkus.stream().filter(item -> item.getSkuId().equals(skus.getSkuId())).findFirst().orElse(null);
if (findCartSku != null) {
productSkus.add(findCartSku);
}
}
if (!EmptyUtils.isEmpty(productSkus)) {
for (CartSku sku : productSkus) {
map.put(sku.getSkuId(), sku);
if (creditSwitch && IntegerEnum.YES.getCode().equals(sku.getIfCredit())) {
productRemainCreditMap.put(sku.getProductId(), sku.getCreditLimit());
} else {
productRemainCreditMap.put(sku.getProductId(), 0);
}
}
}
//将商品数量放到map中
Map<Long, Integer> numberMap = shop.getSkus().stream().collect(Collectors.toMap(ProductSku::getSkuId, ProductSku::getNumber));
Map<Long, Integer> productIdBuyNumberMap = new HashMap<>();
Set<Long> usedSkuIdSet = new HashSet<>();
if (!EmptyUtils.isEmpty(numberMap)) {
//查询规格信息数据
List<CartSku> skus = productSkus;
if (!EmptyUtils.isEmpty(skus)) {
for (CartSku sku : skus) {
sku.setNumber(numberMap.get(sku.getSkuId()));
sku.setShopId(shop.getShopId());
sku.setUniqueId(settlementShop.getUniqueId());
//设置商品数量
Integer buyNum = productIdBuyNumberMap.getOrDefault(sku.getProductId(), 0);
productIdBuyNumberMap.put(sku.getProductId(), buyNum + sku.getNumber());
shopCanUseCouponProductIdList.add(sku.getProductId());
List<ShopPlatformSeckill> shopPlatformSeckillList = productIdPlatformSeckillMap.get(sku.getProductId());
List<ShopPlatformDiscount> shopPlatformDiscountList = productIdPlatformDiscountMap.get(sku.getProductId());
List<ShopBusinessSeckill> shopBusinessSeckillList = skuIdSeckillMap.get(sku.getSkuId());
List<ShopBusinessDiscount> shopBusinessDiscountList = skuIdDiscountMap.get(sku.getSkuId());
//匹配平台秒杀
if (CollectionUtils.isNotEmpty(shopPlatformSeckillList)) {
ShopPlatformSeckill seckill = shopPlatformSeckillList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setPlatformSeckillId(shopPlatformSeckillList.get(0).getSeckillId());
if (sku.getOriginalPrice().compareTo(seckill.getSeckillMoney()) >= 0) {
sku.setPrice(sku.getOriginalPrice().subtract(seckill.getSeckillMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(seckill.getIfLimit())) {
if (productIdBuyNumberMap.get(sku.getProductId()) > seckill.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
}
}
if (seckill.getNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > seckill.getNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_STOCK_ERROR);
}
//不允许叠加优惠券
if (IntegerEnum.NO.getCode().equals(seckill.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
}
//匹配平台折扣
if (CollectionUtils.isNotEmpty(shopPlatformDiscountList)) {
ShopPlatformDiscount discount = shopPlatformDiscountList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setPlatformDiscountId(shopPlatformDiscountList.get(0).getDiscountId());
sku.setPrice(sku.getOriginalPrice().multiply(discount.getDiscount()).divide(BigDecimal.TEN, 2, BigDecimal.ROUND_HALF_UP));
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(discount.getIfLimit())) {
if (productIdBuyNumberMap.get(sku.getProductId()) > discount.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
}
}
if (seckill.getNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > seckill.getNumber()) {
if (discount.getNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > discount.getNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_STOCK_ERROR);
}
//不允许叠加优惠券
if (IntegerEnum.NO.getCode().equals(seckill.getIfAdd())) {
if (IntegerEnum.NO.getCode().equals(discount.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
}
//匹配平台折扣
if (CollectionUtils.isNotEmpty(shopPlatformDiscountList)) {
ShopPlatformDiscount discount = shopPlatformDiscountList.get(0);
//匹配商家秒杀
if (CollectionUtils.isNotEmpty(shopBusinessSeckillList)) {
ShopBusinessSeckill seckill = shopBusinessSeckillList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setPlatformDiscountId(shopPlatformDiscountList.get(0).getDiscountId());
sku.setPrice(sku.getOriginalPrice().multiply(discount.getDiscount()).divide(BigDecimal.TEN, 2, BigDecimal.ROUND_HALF_UP));
usedSkuIdSet.add(sku.getSkuId());
sku.setShopSeckillId(shopBusinessSeckillList.get(0).getSeckillId());
sku.setPrice(seckill.getSeckillPrice());
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(discount.getIfLimit())) {
if (productIdBuyNumberMap.get(sku.getProductId()) > discount.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(seckill.getIfLimit())) {
if (seckill.getLimitNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > seckill.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
}
}
}
if (discount.getNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > discount.getNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_STOCK_ERROR);
}
//不允许叠加优惠券
if (IntegerEnum.NO.getCode().equals(discount.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
//匹配商家秒杀
if (CollectionUtils.isNotEmpty(shopBusinessSeckillList)) {
ShopBusinessSeckill seckill = shopBusinessSeckillList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setShopSeckillId(shopBusinessSeckillList.get(0).getSeckillId());
sku.setPrice(seckill.getSeckillPrice());
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(seckill.getIfLimit())) {
if (seckill.getLimitNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > seckill.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
if (IntegerEnum.NO.getCode().equals(seckill.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
if (IntegerEnum.NO.getCode().equals(seckill.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
//匹配商家折扣
if (CollectionUtils.isNotEmpty(shopBusinessDiscountList)) {
ShopBusinessDiscount discount = shopBusinessDiscountList.get(0);
//匹配商家折扣
if (CollectionUtils.isNotEmpty(shopBusinessDiscountList)) {
ShopBusinessDiscount discount = shopBusinessDiscountList.get(0);
usedSkuIdSet.add(sku.getSkuId());
sku.setShopDiscountId(discount.getDiscountId());
sku.setPrice(discount.getPrice());
usedSkuIdSet.add(sku.getSkuId());
sku.setShopDiscountId(discount.getDiscountId());
sku.setPrice(discount.getPrice());
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(discount.getIfLimit())) {
if (discount.getLimitNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > discount.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
if (IntegerEnum.PRODUCT_IF_LIMIT_YES.getCode().equals(discount.getIfLimit())) {
if (discount.getLimitNumber() != null && productIdBuyNumberMap.get(sku.getProductId()) > discount.getLimitNumber()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_LIMIT_ERROR);
}
}
if (IntegerEnum.NO.getCode().equals(discount.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
if (IntegerEnum.NO.getCode().equals(discount.getIfAdd())) {
shopCanUseCouponProductIdList.remove(sku.getProductId());
}
}
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal price = sku.getPrice().multiply(new BigDecimal(sku.getNumber()));
Integer needCredit = price.divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal price = sku.getPrice().multiply(new BigDecimal(sku.getNumber()));
Integer needCredit = price.divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
}
}
}
}
}
List<CartSku> skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
List<CartSku> skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
// 匹配定价捆绑
matchPriceCombine(shop.getShopId(), skus, skuList, settlementShop, usedSkuIdSet, priceDiscountMap);
// 匹配定价捆绑
matchPriceCombine(shop.getShopId(), skus, skuList, settlementShop, usedSkuIdSet, priceDiscountMap);
skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
// 匹配组合捆绑
matchComposeCombine(shop.getShopId(), skuList, usedSkuIdSet, shopIdComposeMap, composeDiscountMap, numberMap);
// 匹配组合捆绑
matchComposeCombine(shop.getShopId(), skuList, usedSkuIdSet, shopIdComposeMap, composeDiscountMap, numberMap);
skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
skuList = skus.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
// 匹配场景营销
matchSceneMarket(shop.getShopId(), user, skuList, usedSkuIdSet, shopIdSceneDiscountMap, sceneMarketFreeShipingMap);
// 匹配场景营销
matchSceneMarket(shop.getShopId(), user, skuList, usedSkuIdSet, shopIdSceneDiscountMap, sceneMarketFreeShipingMap);
skuList = skuList.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
skuList = skuList.stream().filter(sku -> !usedSkuIdSet.contains(sku.getSkuId())).collect(Collectors.toList());
//匹配会员价
matchMember(shop.getShopId(), user, skuList, usedSkuIdSet, memberDiscountPriceMap);
//匹配会员价
matchMember(shop.getShopId(), user, skuList, usedSkuIdSet, memberDiscountPriceMap);
//针对定价捆绑如果
//Map<Long, List<Long>> productIdPlatformCouponIdMap = new HashMap<>();
//Map<Long, List<Long>> productIdShopCouponIdMap = new HashMap<>();
for (CartSku sku : skus) {
//秒杀活动和限时折扣活动校验
checkActivity(param, numberMap.get(sku.getSkuId()), sku, settlement, user, shop);
//设置规格属性值数组
sku.setValues(EmptyUtils.getImages(sku.getValue()));
//针对定价捆绑如果
for (CartSku sku : skus) {
//秒杀活动和限时折扣活动校验
checkActivity(param, numberMap.get(sku.getSkuId()), sku, settlement, user, shop);
//设置规格属性值数组
sku.setValues(EmptyUtils.getImages(sku.getValue()));
sku.setTotal(new BigDecimal(sku.getNumber()).multiply(sku.getPrice()));
sku.setSelected(IntegerEnum.YES.getCode());
//定义是否需要查询优惠券标识,默认需要
sku.setTotal(new BigDecimal(sku.getNumber()).multiply(sku.getPrice()));
sku.setSelected(IntegerEnum.YES.getCode());
//定义是否需要查询优惠券标识,默认需要
/*setSettlementCoupons(param, shop, user.getBuyerUserId(), sku, settlementShop, settlement,
settlement.getCoupons(), settlementShop.getShopCoupons(), productIdPlatformCouponIdMap, productIdShopCouponIdMap);*/
//校验库存
int stockNumber = 0;
//校验库存
int stockNumber = 0;
/*if(!EmptyUtils.isEmpty(stringRedisService.get(String.valueOf(sku.getSkuId())))){
stockNumber=(int) stringRedisService.get(String.valueOf(sku.getSkuId()));
}else {
stockNumber= map.get(sku.getSkuId()).getStockNumber();
}*/
stockNumber = map.get(sku.getSkuId()).getStockNumber();
if (sku.getNumber() > stockNumber) {
//叠加商品件数
invalidNumber += sku.getNumber();
flag.set(true);
invalidSkus.add(sku);
stockNumber = map.get(sku.getSkuId()).getStockNumber();
if (sku.getNumber() > stockNumber) {
//叠加商品件数
invalidNumber += sku.getNumber();
flag.set(true);
invalidSkus.add(sku);
}
//total = total.add(sku.getTotal());
}
//total = total.add(sku.getTotal());
}
//settlementShop.setSkus(skus);
settlementShop.setNumber(skus.stream().mapToInt(CartSku::getNumber).sum());
List<CartSku> sortSkuList = new ArrayList<>();
settlementShop.setNumber(skus.stream().mapToInt(CartSku::getNumber).sum());
if (priceDiscountMap.size() > 0) {
for (Long id : priceDiscountMap.keySet()) {
DiscountDescDTO value = priceDiscountMap.get(id);
List<CartSku> sortSkuList = new ArrayList<>();
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getPriceId() != null && sku.getPriceId().equals(id)).collect(Collectors.toList());
sortSkuList.addAll(tmpSkuList);
BigDecimal tmpTotal = BigDecimal.ZERO;
if (priceDiscountMap.size() > 0) {
for (Long id : priceDiscountMap.keySet()) {
DiscountDescDTO value = priceDiscountMap.get(id);
for (CartSku sku : tmpSkuList) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getPriceId() != null && sku.getPriceId().equals(id)).collect(Collectors.toList());
sortSkuList.addAll(tmpSkuList);
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
shopPriceProductIdListMap.put(shop.getShopId(), tmpSkuList.stream().map(CartSku::getProductId).distinct().collect(Collectors.toList()));
total = total.subtract(value.getDiscountTotal());
settlementShop.setPriceAfterDiscount(tmpTotal.subtract(value.getDiscountTotal()));
for (CartSku sku : tmpSkuList) {
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal percent = sku.getPrice().multiply(new BigDecimal(sku.getNumber())).divide(tmpTotal, 4, BigDecimal.ROUND_HALF_UP);
Integer needCredit = tmpTotal.subtract(value.getDiscountTotal()).multiply(percent).divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
}
}
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("定价捆绑 %.2f元任选%d件 x %d", value.getComposePrice(), value.getComposeNum(), value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
}
shopPriceProductIdListMap.put(shop.getShopId(), tmpSkuList.stream().map(CartSku::getProductId).distinct().collect(Collectors.toList()));
if (composeDiscountMap.size() > 0) {
for (Long id : composeDiscountMap.keySet()) {
DiscountDescDTO value = composeDiscountMap.get(id);
total = total.subtract(value.getDiscountTotal());
settlementShop.setPriceAfterDiscount(tmpTotal.subtract(value.getDiscountTotal()));
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getComposeId() != null && sku.getComposeId().equals(id)).collect(Collectors.toList());
sortSkuList.addAll(tmpSkuList);
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
total = total.subtract(value.getDiscountTotal());
for (CartSku sku : tmpSkuList) {
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal percent = sku.getPrice().multiply(new BigDecimal(sku.getNumber())).divide(tmpTotal, 4, BigDecimal.ROUND_HALF_UP);
Integer needCredit = tmpTotal.subtract(value.getDiscountTotal()).multiply(percent).divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
}
}
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("组合捆绑 x %d", value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
}
if (shopIdSceneDiscountMap.get(shop.getShopId()) != null) {
DiscountDescDTO value = shopIdSceneDiscountMap.get(shop.getShopId());
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getSceneId() != null).collect(Collectors.toList());
/*sortSkuList.addAll(tmpSkuList);
for (CartSku sku:tmpSkuList) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
total = total.subtract(value.getDiscountTotal());*/
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
for (CartSku sku : tmpSkuList) {
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
@ -1992,16 +2174,15 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("定价捆绑 %.2f元任选%d件 x %d", value.getComposePrice(), value.getComposeNum(), value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("场景营销 %.1f折 x %d", value.getDiscount(), value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
}
if (composeDiscountMap.size() > 0) {
for (Long id : composeDiscountMap.keySet()) {
DiscountDescDTO value = composeDiscountMap.get(id);
if (memberDiscountPriceMap.get(shop.getShopId()) != null) {
DiscountDescDTO value = memberDiscountPriceMap.get(shop.getShopId());
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getComposeId() != null && sku.getComposeId().equals(id)).collect(Collectors.toList());
List<CartSku> tmpSkuList = skus.stream().filter(CartSku::isUseMember).collect(Collectors.toList());
sortSkuList.addAll(tmpSkuList);
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
@ -2030,68 +2211,18 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("组合捆绑 x %d", value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
}
if (shopIdSceneDiscountMap.get(shop.getShopId()) != null) {
DiscountDescDTO value = shopIdSceneDiscountMap.get(shop.getShopId());
List<CartSku> tmpSkuList = skus.stream().filter(sku -> sku.getSceneId() != null).collect(Collectors.toList());
/*sortSkuList.addAll(tmpSkuList);
for (CartSku sku:tmpSkuList) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
total = total.subtract(value.getDiscountTotal());*/
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("会员价 x %d", value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
for (CartSku sku : tmpSkuList) {
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal percent = sku.getPrice().multiply(new BigDecimal(sku.getNumber())).divide(tmpTotal, 4, BigDecimal.ROUND_HALF_UP);
Integer needCredit = tmpTotal.subtract(value.getDiscountTotal()).multiply(percent).divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
}
}
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("场景营销 %.1f折 x %d", value.getDiscount(), value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
if (memberDiscountPriceMap.get(shop.getShopId()) != null) {
DiscountDescDTO value = memberDiscountPriceMap.get(shop.getShopId());
List<CartSku> tmpSkuList = skus.stream().filter(CartSku::isUseMember).collect(Collectors.toList());
sortSkuList.addAll(tmpSkuList);
BigDecimal tmpTotal = BigDecimal.ZERO;
for (CartSku sku : tmpSkuList) {
//剩下的就是普通的商品
skus.removeAll(sortSkuList);
for (CartSku sku : skus) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
tmpTotal = tmpTotal.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
}
total = total.subtract(value.getDiscountTotal());
for (CartSku sku : tmpSkuList) {
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal percent = sku.getPrice().multiply(new BigDecimal(sku.getNumber())).divide(tmpTotal, 4, BigDecimal.ROUND_HALF_UP);
Integer needCredit = tmpTotal.subtract(value.getDiscountTotal()).multiply(percent).divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
BigDecimal price = sku.getPrice().multiply(new BigDecimal(sku.getNumber()));
Integer needCredit = price.divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
@ -2106,115 +2237,67 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
}
}
}
skuDiscountInfoMap.put(tmpSkuList.get(tmpSkuList.size() - 1).getSkuId(), Arrays.asList(String.format("会员价 x %d", value.getDiscountNum()), "优惠¥" + value.getDiscountTotal()));
}
//剩下的就是普通的商品
skus.removeAll(sortSkuList);
for (CartSku sku : skus) {
total = total.add(sku.getPrice().multiply(new BigDecimal(sku.getNumber())));
Integer remainCredit = productRemainCreditMap.get(sku.getProductId());
if (totalRemainCredit > 0 && remainCredit > 0) {
BigDecimal price = sku.getPrice().multiply(new BigDecimal(sku.getNumber()));
Integer needCredit = price.divide(creditExchangeRate, 0, BigDecimal.ROUND_HALF_DOWN).intValue();
if (needCredit > 0) {
Integer min = Math.min(remainCredit, totalRemainCredit);
if (min >= needCredit) {
productRemainCreditMap.put(sku.getProductId(), remainCredit - needCredit);
skuCreditMap.put(sku.getSkuId(), needCredit);
totalRemainCredit -= needCredit;
} else {
productRemainCreditMap.put(sku.getProductId(), remainCredit - min);
skuCreditMap.put(sku.getSkuId(), min);
totalRemainCredit -= min;
}
sortSkuList.addAll(skus);
settlementShop.setSkus(sortSkuList);
if (flag.get()) {
SettlementShop settlementShop1 = new SettlementShop();
settlementShop1.setShopId(shop.getShopId());
settlementShop1.setNumber(invalidNumber);
settlementShop1.setSkus(invalidSkus);
invalidShops.add(settlementShop1);
} else {
//查询店铺物流方案
//根据仓库来计算运费
List<CereOrderLogistics> logistics = logisticsList.stream().filter(item -> shop.getShopId().equals(item.getShopId()) && storehouseId.equals(item.getStorehouseId())).collect(Collectors.toList());
List<CartSku> logisticsSkuList = sortSkuList;
if (sceneMarketFreeShipingMap.get(shop.getShopId()) != null) {
logisticsSkuList = sortSkuList.stream().filter(sku -> sku.getSceneId() == null).collect(Collectors.toList());
}
}
}
sortSkuList.addAll(skus);
settlementShop.setSkus(sortSkuList);
//定价捆绑查询出的商家优惠券要求同时匹配定价捆绑活动中的所有商品
/*if (productIdShopCouponIdMap.size() > 0) {
Set<Long> couponIdSet = new HashSet<>();
for (List<Long> couponIdList : productIdShopCouponIdMap.values()) {
couponIdSet.addAll(couponIdList);
}
Collection<Long> intersection = new HashSet<>(couponIdSet);
for (List<Long> couponIdList : productIdShopCouponIdMap.values()) {
intersection = CollectionUtils.intersection(intersection, couponIdList);
}
Collection<Long> finalIntersection = intersection;
settlementShop.getShopCoupons().removeIf(obj -> couponIdSet.contains(obj.getCouponId()) && !finalIntersection.contains(obj.getCouponId()));
for (ProductCoupon coupon : settlementShop.getShopCoupons()) {
if (settlementShop.getPriceAfterDiscount() != null
&& coupon.getFullMoney().compareTo(settlementShop.getPriceAfterDiscount()) > 0
&& coupon.getIds() != null) {
//商家券不满足 满X元优惠的条件直接去掉定价捆绑商品对应的商品id列表
coupon.getIds().removeAll(productIdShopCouponIdMap.keySet());
Distribution distribution = null;
try {
distribution = setLogisticPrice(logistics, logisticsSkuList, settlement.getReceive(), numberMap);
} catch (CoBusinessException e) {
throw new RuntimeException(e);
}
}
//进一步判断如果优惠券没有包含其它商品直接移除掉这张优惠券
List<Long> shopProductIdList = settlementShop.getSkus().stream().map(CartSku::getProductId).collect(Collectors.toList());
Iterator<ProductCoupon> ite = settlementShop.getShopCoupons().iterator();
while (ite.hasNext()) {
ProductCoupon coupon = ite.next();
Collection<Long> interProductIdList = CollectionUtils.intersection(coupon.getIds(), shopProductIdList);
if (CollectionUtils.isEmpty(interProductIdList)) {
ite.remove();
if (distribution == null) {
settlementShop.setReceiveNotMatch(true);
distribution = new Distribution();
distribution.setDistributionName("全国包邮");
distribution.setDistributionPrice(BigDecimal.ZERO);
distribution.setLogisticsId(-1L);
settlementShop.setDistribution(distribution);
} else {
settlementShop.setDistribution(distribution);
}
}
}*/
if (flag.get()) {
SettlementShop settlementShop1 = new SettlementShop();
settlementShop1.setShopId(shop.getShopId());
settlementShop1.setNumber(invalidNumber);
settlementShop1.setSkus(invalidSkus);
invalidShops.add(settlementShop1);
} else {
//查询店铺物流方案
List<CereOrderLogistics> logistics = cereOrderLogisticsService.findLogistics(shop.getShopId());
//计算物流费用 如果场景营销中有包邮则把包邮的sku过滤掉
List<CartSku> logisticsSkuList = sortSkuList;
if (sceneMarketFreeShipingMap.get(shop.getShopId()) != null) {
logisticsSkuList = sortSkuList.stream().filter(sku -> sku.getSceneId() == null).collect(Collectors.toList());
}
Distribution distribution = setLogisticPrice(logistics, logisticsSkuList, settlement.getReceive(), numberMap);
if (distribution == null) {
settlementShop.setReceiveNotMatch(true);
distribution = new Distribution();
distribution.setDistributionName("全国包邮");
distribution.setDistributionPrice(BigDecimal.ZERO);
distribution.setLogisticsId(-1L);
settlementShop.setDistribution(distribution);
} else {
settlementShop.setDistribution(distribution);
}
}
}
}
}
settlementShop.setTotal(total.setScale(2, BigDecimal.ROUND_HALF_UP));
canUseCouponProductIdList.addAll(shopCanUseCouponProductIdList);
//设置商家优惠券
if (CollectionUtils.isNotEmpty(shopCanUseCouponProductIdList)) {
List<ProductCoupon> couponList = cereBuyerShopCouponService.findCouponMatchCondition(user.getBuyerUserId(), settlementShop.getTotal(), shopCanUseCouponProductIdList);
couponList.removeIf(pc -> !reMatchCoupon(pc, Collections.singletonList(settlementShop), shopPriceProductIdListMap));
couponList.forEach(this::assembleContent);
settlementShop.setShopCoupons(couponList);
}
//计算订单总价
settlementShop.setTotal(total.setScale(2, BigDecimal.ROUND_HALF_UP));
canUseCouponProductIdList.addAll(shopCanUseCouponProductIdList);
shopSettlementList.add(settlementShop);
//设置商家优惠券
if (CollectionUtils.isNotEmpty(shopCanUseCouponProductIdList)) {
List<ProductCoupon> couponList = cereBuyerShopCouponService.findCouponMatchCondition(user.getBuyerUserId(), settlementShop.getTotal(), shopCanUseCouponProductIdList);
couponList.removeIf(pc -> !reMatchCoupon(pc, Collections.singletonList(settlementShop), shopPriceProductIdListMap));
couponList.forEach(this::assembleContent);
settlementShop.setShopCoupons(couponList);
}
shopSettlementList.add(settlementShop);
}
}
//设置客户优惠券
if (!canUseCouponProductIdList.isEmpty()) {
//整个订单最高价 只需要查询优惠券满额上限在这个一下的就可以了
BigDecimal totalPrice = shopSettlementList.stream().map(SettlementShop::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
//查出满足订单总额的优惠券
List<ProductCoupon> couponList = cereBuyerCouponService.findCouponMatchCondition(user.getBuyerUserId(), totalPrice, canUseCouponProductIdList);
//分别判断每个优惠券,是否完全匹配商家的定价捆绑
if (CollectionUtils.isNotEmpty(couponList)) {
@ -3081,7 +3164,6 @@ public class CereShopOrderServiceImpl implements CereShopOrderService {
CereShopOrder shopOrder = cereShopOrderDAO.findById(param.getOrderId());
if (shopOrder != null) {
payUrl.setOrderId(param.getOrderId());
//TODO 这里需要获取父订单Id------pxh
payUrl.setMoney(shopOrder.getPrice());
//生成收款码
String formid = shopOrder.getOrderFormid() + "-" + RandomStringUtil.getRandomCode(3, 0) + "XCX";

6
cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/JoinPlaceOrder.java

@ -48,6 +48,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author pepis
@ -86,6 +88,9 @@ public class JoinPlaceOrder extends PlaceOrderTemplate {
if (null == cereShopGroupWork || EmptyUtils.isEmpty(param.getShops())) {
throw new CoBusinessException(CoReturnFormat.PARAM_INVALID);
}
if (param.getShops().stream().collect(Collectors.toMap(Function.identity(), s -> 1, Integer::sum)).entrySet().stream().filter(entry -> entry.getValue() > 1).findAny().orElse(null) != null) {
throw new CoBusinessException(CoReturnFormat.COUPON_ALREADY_USE);
}
}
// public void placeOrder(OrderParam param, CereBuyerUser user, String ip, PayUrl payUrl, String time) throws Exception {
@ -160,6 +165,7 @@ public class JoinPlaceOrder extends PlaceOrderTemplate {
//sku.setSelected(numberMap.get(sku.getSkuId()).getSelected());
//设置店铺id
sku.setShopId(shop.getShopId());
sku.setUniqueId(shop.getUniqueId());
map.put(sku.getSkuId(), sku);
});
}

8
cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/LaunchPlaceOrder.java

@ -59,6 +59,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -101,6 +102,9 @@ public class LaunchPlaceOrder extends PlaceOrderTemplate {
if (null == cereShopGroupWork || EmptyUtils.isEmpty(param.getShops())) {
throw new CoBusinessException(CoReturnFormat.PARAM_INVALID);
}
if (param.getShops().stream().collect(Collectors.toMap(Function.identity(), s -> 1, Integer::sum)).entrySet().stream().filter(entry -> entry.getValue() > 1).findAny().orElse(null) != null) {
throw new CoBusinessException(CoReturnFormat.COUPON_ALREADY_USE);
}
}
// @Override
@ -175,6 +179,7 @@ public class LaunchPlaceOrder extends PlaceOrderTemplate {
sku.setNumber(numberMap.get(sku.getSkuId()).getNumber());
//设置选中状态
//sku.setSelected(numberMap.get(sku.getSkuId()).getSelected());
sku.setUniqueId(shop.getUniqueId());
//设置店铺id
sku.setShopId(shop.getShopId());
map.put(sku.getSkuId(), sku);
@ -234,6 +239,7 @@ public class LaunchPlaceOrder extends PlaceOrderTemplate {
order.setCustomerPhone(user.getPhone());
order.setLogisticsPrice(shop.getDistribution().getDistributionPrice());
order.setRemark(shop.getRemark());
order.setIsCross(shop.getIsCross());
order.setLogisticsId(shop.getDistribution().getLogisticsId());
order.setState(IntegerEnum.ORDER_STAY_PAY.getCode());
order.setOrderFormid(RandomStringUtil.getRandomCode(15, 0));
@ -264,7 +270,7 @@ public class LaunchPlaceOrder extends PlaceOrderTemplate {
.add(shopDeductCreditAmountMap.getOrDefault(shop.getShopId(), BigDecimal.ZERO));
order.setDiscountPrice(discountPrice);
if (!EmptyUtils.isEmpty(skus)) {
order.setOrderPrice(shopPriceMap.get(shop.getShopId()).setScale(2, BigDecimal.ROUND_HALF_UP));
order.setOrderPrice(shopPriceMap.get(shop.getUniqueId()).setScale(2, BigDecimal.ROUND_HALF_UP));
//订单支付金额=订单总金额+运费-计算出来的优惠金额
order.setPrice(order.getOrderPrice().subtract(order.getDiscountPrice()).setScale(2, BigDecimal.ROUND_HALF_UP));
order.setPaymentState(IntegerEnum.ORDER_PAY_STAY.getCode());

19
cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/NormalPlaceOrder.java

@ -65,6 +65,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -85,6 +86,9 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
if (EmptyUtils.isEmpty(param.getShops())) {
throw new CoBusinessException(CoReturnFormat.PARAM_INVALID);
}
if (param.getShops().stream().collect(Collectors.toMap(Function.identity(), s -> 1, Integer::sum)).entrySet().stream().filter(entry -> entry.getValue() > 1).findAny().orElse(null) != null) {
throw new CoBusinessException(CoReturnFormat.COUPON_ALREADY_USE);
}
}
// @Override
// public void placeOrder(OrderParam param, CereBuyerUser user, String ip, PayUrl payUrl, String time) throws Exception {
@ -145,7 +149,7 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
Map<Long, CartSku> map = new HashMap<>();
List<Long> shopIdList = param.getShops().stream().map(OrderProductParam::getShopId).collect(Collectors.toList());
List<Long> shopIdList = param.getShops().stream().map(OrderProductParam::getShopId).distinct().collect(Collectors.toList());
// 平台秒杀
List<ShopPlatformSeckill> platformSeckillList = cerePlatformSeckillService.selectPlatformSeckillsByShopIdList(shopIdList);
@ -170,13 +174,14 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
List<CereShopComposeDTO> composeDTOList = cereShopComposeService.selectByShopIdList(shopIdList);
Map<Long, List<CereShopComposeDTO>> composeMap = composeDTOList.stream().collect(Collectors.groupingBy(CereShopComposeDTO::getComposeId));
//根据订单计算优惠这里要去除商家的影响
for (OrderProductParam shop : param.getShops()) {
shopDiscountPriceMap.put(shop.getShopId(), BigDecimal.ZERO);
shopIdList.add(shop.getShopId());
shopDiscountPriceMap.put(shop.getUniqueId(), BigDecimal.ZERO);
if (!EmptyUtils.isEmpty(shop.getSkus())) {
List<Long> skuIdList = shop.getSkus().stream().map(ProductSku::getSkuId).collect(Collectors.toList());
//查询当前店铺所有购买商品的库存数据
List<CartSku> productSkus = cereProductSkuService.findStockNumberBySkus(shop.getSkus());
List<CartSku> productSkus = cereProductSkuService.findStockNumberBySkus(skuIdList);
if (!EmptyUtils.isEmpty(productSkus)) {
productSkus.forEach(sku -> {
ProductSku paramSku = numberMap.get(sku.getSkuId());
@ -184,6 +189,7 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
sku.setNumber(paramSku.getNumber());
//设置选中状态
//sku.setSelected(paramSku.getSelected());
sku.setUniqueId(shop.getUniqueId());
//设置店铺id
sku.setShopId(shop.getShopId());
//设置相关活动id
@ -384,7 +390,7 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
map.get(tmpSkuList.get(i).getSkuId()).setActualPrice(BigDecimal.ZERO);
}
shopDiscountPriceMap.put(shop.getShopId(), shopDiscountPriceMap.get(shop.getShopId()).add(tmpDiscountPrice));
shopDiscountPriceMap.put(shop.getUniqueId(), shopDiscountPriceMap.get(shop.getShopId()).add(tmpDiscountPrice));
break;
}
}
@ -519,6 +525,7 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
order.setCustomerPhone(user.getPhone());
order.setLogisticsPrice(shop.getDistribution().getDistributionPrice());
order.setRemark(shop.getRemark());
order.setIsCross(shop.getIsCross());
order.setLogisticsId(shop.getDistribution().getLogisticsId());
order.setState(IntegerEnum.ORDER_STAY_PAY.getCode());
order.setOrderFormid(RandomStringUtil.getRandomCode(15, 0));
@ -554,7 +561,7 @@ public class NormalPlaceOrder extends PlaceOrderTemplate {
.add(shopDeductCreditAmountMap.getOrDefault(shop.getShopId(), BigDecimal.ZERO));
order.setDiscountPrice(discountPrice);
if (!EmptyUtils.isEmpty(skus)) {
order.setOrderPrice(shopPriceMap.get(shop.getShopId()).setScale(2, BigDecimal.ROUND_HALF_UP));
order.setOrderPrice(shopPriceMap.get(shop.getUniqueId()).setScale(2, BigDecimal.ROUND_HALF_UP));
//订单支付金额=订单总金额+运费-计算出来的优惠金额
order.setPrice(order.getOrderPrice().add(order.getLogisticsPrice()).subtract(order.getDiscountPrice()).setScale(2, BigDecimal.ROUND_HALF_UP));
//设置定价捆绑优惠金额

48
cereshop-app/src/main/java/com/shop/cereshop/app/service/order/placeOrderTemplate/PlaceOrderTemplate.java

@ -127,10 +127,20 @@ public abstract class PlaceOrderTemplate {
* @throws Exception
*/
public final PayUrl placeOrder(OrderParam param, CereBuyerUser user, String ip, String time) throws Exception {
//校验数据
check(param);
//定义map封装商品购买数量
//所有优惠先计算产品活动的再计算平台优惠券再计算商家优惠券
//设置订单唯一键便于后续计算以及定位
Random random = new Random();
for (OrderProductParam shop : param.getShops()) {
if(shop.getUniqueId() == null) {
shop.setUniqueId(random.nextLong());
}
}
//定义map封装商品购买数量--商品集合
Map<Long, ProductSku> paramSkuMap = getBuySkuMap(param);
//校验库存 本次下单中的商品是否有库存不足
@ -140,8 +150,10 @@ public abstract class PlaceOrderTemplate {
AtomicReference<BigDecimal> skuDiscountPrice = new AtomicReference<>(BigDecimal.ZERO);
//促销活动优惠每个商家各优惠多少当前只存储定价捆绑的优惠
Map<Long, BigDecimal> pricingDiscountPriceMap = new HashMap<>();
//获取sku信息封装成 map
Map<Long, CartSku> map = getLongCartSkuMap(param, user, paramSkuMap, flag, skuDiscountPrice, pricingDiscountPriceMap);
//库存不足 请求失败
if (flag.get()) {
throw new CoBusinessException(CoReturnFormat.PRODUCT_STOCK_ERROR);
@ -151,15 +163,16 @@ public abstract class PlaceOrderTemplate {
//计算订单总金额
BigDecimal orderPrice = calOrderPrice(map, paramSkuMap, shopPriceMap);
//结合促销活动优惠金额计算子订单的orderPrice
for (Long shopId:pricingDiscountPriceMap.keySet()) {
BigDecimal shopDiscountPrice = pricingDiscountPriceMap.get(shopId);
for (Long uniqueId:pricingDiscountPriceMap.keySet()) {
BigDecimal shopDiscountPrice = pricingDiscountPriceMap.get(uniqueId);
if (shopDiscountPrice != null) {
shopPriceMap.put(shopId, shopPriceMap.get(shopId).subtract(shopDiscountPrice));
shopPriceMap.put(uniqueId, shopPriceMap.get(uniqueId).subtract(shopDiscountPrice));
}
}
//计算运费
BigDecimal logisticPrice = calLogisticPrice(param);
//订单金额 - 营销活动优惠(例如定价捆绑)
orderPrice = orderPrice.subtract(skuDiscountPrice.get());
@ -219,8 +232,7 @@ public abstract class PlaceOrderTemplate {
PayUrl payUrl =new PayUrl();
payUrl.setMoney(parent.getPrice());
payUrl.setOrderId(parent.getParentId());
//生成支付二维码
generatePayUrl(param, user.getWechatOpenId(), parent.getParentFormid(), ip, payUrl);
//扣减积分
if (!deductCreditAmount.equals(BigDecimal.ZERO)) {
@ -234,6 +246,9 @@ public abstract class PlaceOrderTemplate {
//更新平台优惠券状态
useBuyerCoupon(cereBuyerCoupon, time);
//生成支付二维码
generatePayUrl(param, user.getWechatOpenId(), parent.getParentFormid(), ip, payUrl);
return payUrl;
}
@ -348,7 +363,7 @@ public abstract class PlaceOrderTemplate {
* @throws Exception /
*/
protected abstract void createShopOrders(Long parentId, OrderParam param, CereBuyerUser user, String time, Map<Long, CartSku> map,
Map<Long, BigDecimal> shopPriceMap, Map<Long, CereBuyerShopCoupon> discountMap,
Map<Long, BigDecimal> orderPrice, Map<Long, CereBuyerShopCoupon> discountMap,
Map<Long, BigDecimal> shopDeductCreditAmountMap, Map<Long, BigDecimal> platformCouponDiscountMap,
Map<Long, BigDecimal> pricingDiscountPriceMap, PayUrl payUrl) throws Exception;
@ -420,11 +435,11 @@ public abstract class PlaceOrderTemplate {
BigDecimal total = BigDecimal.ZERO;
for (Long skuId : map.keySet()) {
CartSku sku = map.get(skuId);
Long shopId = sku.getShopId();
Long uniqueId = sku.getUniqueId();
BigDecimal num = new BigDecimal(numberMap.get(skuId).getNumber());
BigDecimal price = sku.getPrice().multiply(num);
total = total.add(price);
shopPriceMap.put(shopId, shopPriceMap.getOrDefault(shopId, BigDecimal.ZERO).add(price));
shopPriceMap.put(uniqueId, shopPriceMap.getOrDefault(uniqueId, BigDecimal.ZERO).add(price));
}
return total;
}
@ -466,13 +481,13 @@ public abstract class PlaceOrderTemplate {
BigDecimal calculatedDiscountPrice = BigDecimal.ZERO;
List<Map.Entry<Long, BigDecimal>> shopPriceList = new ArrayList<>(shopPriceMap.entrySet());
for (int i=0;i<shopPriceList.size();i++) {
Long shopId = shopPriceList.get(i).getKey();
Long uniqueId = shopPriceList.get(i).getKey();
if (i == shopPriceList.size()-1) {
platformCouponDiscountMap.put(shopId, decimal.subtract(calculatedDiscountPrice));
platformCouponDiscountMap.put(uniqueId, decimal.subtract(calculatedDiscountPrice));
} else {
BigDecimal percent = shopPriceList.get(i).getValue().divide(orderPrice, 4, BigDecimal.ROUND_HALF_UP);
BigDecimal shopDiscountPrice = decimal.multiply(percent).setScale(2, BigDecimal.ROUND_HALF_UP);
platformCouponDiscountMap.put(shopId, shopDiscountPrice);
platformCouponDiscountMap.put(uniqueId, shopDiscountPrice);
calculatedDiscountPrice = calculatedDiscountPrice.add(shopDiscountPrice);
}
}
@ -569,9 +584,12 @@ public abstract class PlaceOrderTemplate {
}
}
}
//查询所有店铺优惠券数据
List<CereBuyerShopCoupon> list = cereBuyerShopCouponService.findByIds(param.getShops());
//计算店铺优惠券金额总和
List<Long> shopIdList = param.getShops().stream().map(OrderProductParam::getShopId).distinct().collect(Collectors.toList());
List<CereBuyerShopCoupon> list = cereBuyerShopCouponService.findByIds(shopIdList);
//计算店铺优惠券金额总和--注意订单不是根据店铺作为主键的但是店铺优惠券是根据店铺作为主键的要做好怎么分配--TODO pxh
if (!EmptyUtils.isEmpty(list)) {
for (CereBuyerShopCoupon cereBuyerShopCoupon : list) {
Long shopCouponId = cereBuyerShopCoupon.getShopCouponId();

2
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/CereProductSkuService.java

@ -36,7 +36,7 @@ public interface CereProductSkuService {
Integer findStockNumber(Long skuId);
List<CartSku> findStockNumberBySkus(List<ProductSku> skus);
List<CartSku> findStockNumberBySkus(List<Long> skuIdList);
void updateBatch(List<CartSku> productSkus) throws CoBusinessException;

4
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereProductSkuServiceImpl.java

@ -73,8 +73,8 @@ public class CereProductSkuServiceImpl implements CereProductSkuService {
}
@Override
public List<CartSku> findStockNumberBySkus(List<ProductSku> skus) {
return cereProductSkuDAO.findStockNumberBySkus(skus);
public List<CartSku> findStockNumberBySkus(List<Long> skuIdList) {
return cereProductSkuDAO.findStockNumberBySkus(skuIdList);
}
@Override

36
cereshop-app/src/main/java/com/shop/cereshop/app/service/product/impl/CereShopProductServiceImpl.java

@ -20,7 +20,6 @@ import com.shop.cereshop.app.page.cart.CartSku;
import com.shop.cereshop.app.page.index.Product;
import com.shop.cereshop.app.page.order.ShopDistributor;
import com.shop.cereshop.app.page.product.*;
import com.shop.cereshop.app.page.settlement.Distribution;
import com.shop.cereshop.app.param.canvas.CanvasAppProductParam;
import com.shop.cereshop.app.param.index.SearchParam;
import com.shop.cereshop.app.param.product.PageProductParam;
@ -57,6 +56,7 @@ import com.shop.cereshop.app.service.shop.CereShopCommentService;
import com.shop.cereshop.app.service.shop.CereShopConversionService;
import com.shop.cereshop.app.service.shop.CereShopVisitService;
import com.shop.cereshop.app.service.stock.CereStockService;
import com.shop.cereshop.app.service.storehouse.CereShopStorehouseService;
import com.shop.cereshop.app.utils.AlipayUtil;
import com.shop.cereshop.app.utils.WechatUtil;
import com.shop.cereshop.commons.cache.constants.CacheKeyConstants;
@ -75,6 +75,7 @@ import com.shop.cereshop.commons.domain.logistics.CereOrderLogistics;
import com.shop.cereshop.commons.domain.product.*;
import com.shop.cereshop.commons.domain.shop.CereShopConversion;
import com.shop.cereshop.commons.domain.shop.CereShopVisit;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.upload.strategy.FileStrategy;
import com.shop.cereshop.commons.utils.EmptyUtils;
@ -217,6 +218,9 @@ public class CereShopProductServiceImpl implements CereShopProductService {
@Autowired
private CereCollageOrderService cereCollageOrderService;
@Autowired
private CereShopStorehouseService cereShopStorehouseService;
/**
* 商品详情前缀
*/
@ -308,10 +312,10 @@ public class CereShopProductServiceImpl implements CereShopProductService {
sku.setWeight(detail.getWeight());
skuList.add(sku);
Distribution distribution = cereShopOrderService.setLogisticPrice(logistics, skuList, detail.getReceive(), numberMap);
if (distribution != null) {
detail.setLogisticsPrice(distribution.getDistributionPrice());
}
// Distribution distribution = cereShopOrderService.setLogisticPrice(logistics, skuList, detail.getReceive(), numberMap);
// if (distribution != null) {
// detail.setLogisticsPrice(distribution.getDistributionPrice());
// }
}
//查询该商品收藏id
@ -409,6 +413,28 @@ public class CereShopProductServiceImpl implements CereShopProductService {
//查询同类商品
List<Product> similarProducts = cereShopProductDAO.findSimilarProducts(detail.getClassifyId());
detail.setSimilarProducts(similarProducts);
//查询仓库设置限购数量
if(detail.getStorehouseId() != null && detail.getStorehouseId() > 0) {
CereShopStorehouse cereShopStorehouse = cereShopStorehouseService.getById(detail.getStorehouseId());
if(cereShopStorehouse != null){
Integer limitNum = cereShopStorehouse.getOneProductNumLimit();
if(limitNum == null || limitNum<=0){
limitNum = Integer.MAX_VALUE;
}
BigDecimal oneProductOrderPriceLimit = cereShopStorehouse.getOneProductOrderPriceLimit();
if(oneProductOrderPriceLimit != null && oneProductOrderPriceLimit.compareTo(BigDecimal.ZERO) > 0){
limitNum = Math.min(limitNum, oneProductOrderPriceLimit.divide(detail.getPrice(),0,BigDecimal.ROUND_DOWN).intValue());
}
if(limitNum != null && limitNum < Integer.MAX_VALUE){
if(detail.getLimitNumber() == null){
detail.setLimitNumber(limitNum);
}else {
detail.setLimitNumber(Math.min(detail.getLimitNumber(), limitNum));
}
}
}
}
}
//更新日度统计
CereProductStatsByDay stats = new CereProductStatsByDay();

19
cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/CrossStockService.java

@ -0,0 +1,19 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.stock;
import com.shop.cereshop.app.page.product.ProductStockInfo;
import com.shop.cereshop.commons.exception.CoBusinessException;
public interface CrossStockService {
/**
* 仓储推关
* @param orderFormId
*/
void ibOrder(String orderFormId) throws CoBusinessException;
}

114
cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/impl/CrossStockServiceImpl.java

@ -0,0 +1,114 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.stock.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shop.cereshop.app.dao.order.CereOrderProductDAO;
import com.shop.cereshop.app.dao.order.CereShopOrderDAO;
import com.shop.cereshop.app.dao.shop.CereShopCrossDetailDAO;
import com.shop.cereshop.app.dao.storehouse.CereShopStorehouseDAO;
import com.shop.cereshop.app.domain.stock.NewIbOrderRequestBo;
import com.shop.cereshop.app.page.cart.CartSku;
import com.shop.cereshop.app.service.buyer.CereBuyerUserService;
import com.shop.cereshop.app.service.order.CereOrderProductService;
import com.shop.cereshop.app.service.stock.CrossStockService;
import com.shop.cereshop.commons.config.CrossStockConfig;
import com.shop.cereshop.commons.domain.express.HttpResult;
import com.shop.cereshop.commons.domain.order.CereOrderParent;
import com.shop.cereshop.commons.domain.order.CereShopOrder;
import com.shop.cereshop.commons.domain.shop.CereShopCrossDetail;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.HttpUtils;
import com.shop.cereshop.commons.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
public class CrossStockServiceImpl implements CrossStockService{
@Autowired
private CereShopOrderDAO cereShopOrderDAO;
@Autowired
private CereBuyerUserService cereBuyerUserService;
@Autowired
private CereOrderProductDAO cereOrderProductDAO;
@Autowired
private CereShopCrossDetailDAO cereShopCrossDetailDAO;
@Autowired
private CereOrderProductService cereOrderProductService;
@Autowired
private CereShopStorehouseDAO cereShopStorehouseDAO;
@Override
public void ibOrder(String orderFormId) throws CoBusinessException {
List<CereShopOrder> orderList = null;
String cereOrderFormId = orderFormId;
String[] split = orderFormId.split("-");
if(!EmptyUtils.isEmpty(split)) {
cereOrderFormId = split[0];
}
//查询是否为父订单编号
CereOrderParent parent = cereShopOrderDAO.findByParentFormid(cereOrderFormId);
if (parent != null) {
//查询所有子订单数据
orderList = cereShopOrderDAO.findByParentId(parent.getParentId());
} else {
//子订单支付回调
orderList = cereShopOrderDAO.findByFormid(cereOrderFormId);
}
if(orderList.isEmpty()){
throw new CoBusinessException("10000","订单查找出错");
}
orderList = orderList.stream().filter(item -> item.getIsCross() == 1).collect(Collectors.toList());
if(orderList.isEmpty()){
//这个是纯国内订单不需要处理
return;
}
//查找商家--第一个跨境订单
CereShopOrder firstOrder = orderList.get(0);
//商家详细信息
CereShopCrossDetail cereShopCrossDetail = cereShopCrossDetailDAO.selectOne(Wrappers.<CereShopCrossDetail>lambdaQuery().eq(CereShopCrossDetail::getShopId, firstOrder.getShopId()));
if(cereShopCrossDetail == null){
throw new CoBusinessException("10000","商家未设置跨境信息");
}
//获取SKU详情
List<CartSku> skus = cereOrderProductService.findOrderProductSku(firstOrder.getOrderId());
//查询仓库--因为一个订单内所有商品都是同一个仓库的所以直接获取即可
CereShopStorehouse cereShopStorehouse = cereShopStorehouseDAO.selectOne(Wrappers.<CereShopStorehouse>lambdaQuery().eq(CereShopStorehouse::getStorehouseId, firstOrder.getShopId()));
//组装请求参数
NewIbOrderRequestBo bo = new NewIbOrderRequestBo();
HttpResult httpResult = HttpUtils.doPost(CrossStockConfig.getApiUrl("ibOrder"), bo);
if (httpResult.getStatus() == 200 && StringUtils.equals("success", httpResult.getBody())){
//报关成功
log.info("报关发送支付请求成功");
}else {
log.info("报关发送支付请求失败:" + httpResult.getBody());
// log.info("报关发送支付请求参数:" + request);
}
}
}

26
cereshop-app/src/main/java/com/shop/cereshop/app/service/storehouse/CereShopStorehouseService.java

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.storehouse;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import java.util.List;
public interface CereShopStorehouseService {
/**
* 查询详情
* @return
*/
CereShopStorehouse getById(Long storehouseId);
/**
* 查询列表
* @param storehouseIdList
* @return
*/
List<CereShopStorehouse> getAll(List<Long> storehouseIdList);
}

36
cereshop-app/src/main/java/com/shop/cereshop/app/service/storehouse/impl/CereShopStorehouseServiceImpl.java

@ -0,0 +1,36 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.app.service.storehouse.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shop.cereshop.app.dao.storehouse.CereShopStorehouseDAO;
import com.shop.cereshop.app.service.storehouse.CereShopStorehouseService;
import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CereShopStorehouseServiceImpl implements CereShopStorehouseService {
@Autowired
private CereShopStorehouseDAO cereShopStorehouseDAO;
@Override
public CereShopStorehouse getById(Long storehouseId) {
return cereShopStorehouseDAO.selectById(storehouseId);
}
@Override
public List<CereShopStorehouse> getAll(List<Long> storehouseIdList) {
LambdaQueryWrapper<CereShopStorehouse> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CereShopStorehouse::getStorehouseId, storehouseIdList);
return cereShopStorehouseDAO.selectList(wrapper);
}
}

10
cereshop-app/src/main/resources/application.yml

@ -85,3 +85,13 @@ xspay:
sign_type: 1
rsa_private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANMGXGvYX9yqb5qauZgc2mXk4R+2op9KLhCuqO0mt5aTyAFfGXty2RHAinwQif6AUyfFZK7p0/9xz2yX4VHltA4qFNsgQmi2Qtry8MTbBrPtVgukWdLmcK7NqR9C8reXO7e/Np3SPNLle5MsEkwM25cMK56JEc3WMRe+KIRZ69d1AgMBAAECgYBTSW1suyeKplIKCQs7OBgSozUfGSwyBksMFoNhpihLa+RCdlBOYtO9p+qAcN6l7evkBIpqZqtfZIHjcEZj1m8reIHHBnuv/sKGXWPvMBKqckenwNnqUzlj4X8hvFtkbcqXLGdyYoicW+P5+P8zHmYRom+izd5FO9281zXa4UK6gQJBAOquqD84B1VnNq2xopaaJvxaL4c5IOinkfRWShttANCpt1D0t1cs+7WPq9sdFZ4cyHYomxuC4knqJh1E/WzCVqUCQQDmMZH8+6sgqOrgsECw6w0KdUci/XgzT/DRS/3MFMeRv7ygEtdlyvyxRirEArsjQgDg3IBLo9TxBUdygPhgXnSRAkEAtp95r9By7IOoKhw8cMO+qMuphqnvMP0NeD0Z6CO36ajYTXhRn9YSfiQyUQ1eAC9X05MfuJXucCR0ynwgVd0ZPQJAdYaRdow3TrFvWdAi9zDKs7A05ZRrrib+WJ1nsq5ZRfySnVeBSaNdaFTeuLx8NwAX2rY5emTm7zc2xys5pFoVQQJAUPrxmTbELDTF1by6POX/IT3iSeClzOx+M05Yd4sgXtALPjYt0VMLtnsfmt9qMEjhk0Q95wgdmeHsBHxno5qGfQ==
newpay_public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDmVh2/xldLXhVU/mNT57m95uw0Hr0Pdl4pUyM2xV509LqLYTbLduCqqnuMTJUq7Irv8SsKfVqB7zKggxFyjmIfeeyTbhMDJkWZ20xRhv+rSw3ZBQD/Hbn+cxhi4FZ3gc+jUSI1pIsPrlvRK7E5DyWLa/RvZYiQfW/XYI4c1Mb29QIDAQAB
huaxun:
url: https://bg.qdhuaxun.cn/index.php
appId: 8bd29f557af22ec4062774
key: alexyu01
crossstock:
url: http://47.112.3.12:8288
appToken: ad523693d56243dc87e820bd44e18da1
appKey: 4d6e1cf9dbb24dc78c3c4d24db021333

4
cereshop-app/src/main/resources/mybatis/mapper/buyer/CereBuyerShopCouponDAO.xml

@ -244,8 +244,8 @@
<select id="findByIds" parameterType="java.util.List" resultType="com.shop.cereshop.commons.domain.buyer.CereBuyerShopCoupon">
SELECT * FROM cere_buyer_shop_coupon where id in (
<foreach collection="list" item="item" index="index" separator=",">
#{item.id}
<foreach collection="list" item="shopId" index="index" separator=",">
#{shopId}
</foreach>
)
</select>

8
cereshop-app/src/main/resources/mybatis/mapper/logistics/CereOrderLogisticsDAO.xml

@ -105,6 +105,14 @@
SELECT * FROM cere_order_logistics where shop_id=#{shopId}
</select>
<select id="findLogisticsList" parameterType="java.util.List" resultType="com.shop.cereshop.commons.domain.logistics.CereOrderLogistics">
SELECT * FROM cere_order_logistics where
shop_id in ( <foreach collection="shopIdList" item="shopId" index="index" separator=",">
#{shopId}
</foreach>
)
</select>
<select id="findCharges" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.logistics.CereLogisticsCharge">
SELECT * FROM cere_logistics_charge where logistics_id=#{logisticsId}
</select>

8
cereshop-app/src/main/resources/mybatis/mapper/order/CereShopOrderDAO.xml

@ -475,6 +475,14 @@
SELECT shop_id,shop_name,shop_adress,shop_logo FROM cere_platform_shop where shop_id=#{shopId}
</select>
<select id="findSettlementShopList" parameterType="java.util.List" resultType="com.shop.cereshop.app.page.settlement.SettlementShop">
SELECT shop_id,shop_name,shop_adress,shop_logo FROM cere_platform_shop where
shop_id in ( <foreach collection="shopIdList" item="shopId" index="index" separator=",">
#{shopId}
</foreach>
)
</select>
<select id="findSkuValues" parameterType="java.lang.Object" resultType="java.lang.String">
SELECT GROUP_CONCAT(sku_value) from cere_sku_name
where sku_id=#{skuId}

36
cereshop-app/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml

@ -7,6 +7,7 @@
<result column="SKU" jdbcType="VARCHAR" property="SKU" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="original_price" jdbcType="DECIMAL" property="originalPrice" />
<result column="rate" jdbcType="DECIMAL" property="rate" />
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
<result column="total" jdbcType="INTEGER" property="total" />
<result column="weight" jdbcType="DECIMAL" property="weight" />
@ -16,7 +17,7 @@
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
sku_id, product_id,SKU, price, original_price, stock_number,total, weight,
sku_id, product_id,SKU, price, original_price, rate, stock_number,total, weight,
sku_image, `style`, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@ -44,6 +45,9 @@
<if test="originalPrice != null">
original_price,
</if>
<if test="rate != null">
rate,
</if>
<if test="stockNumber != null">
stock_number,
</if>
@ -117,6 +121,9 @@
<if test="originalPrice != null">
original_price = #{originalPrice,jdbcType=DECIMAL},
</if>
<if test="rate != null">
rate = #{rate,jdbcType=DECIMAL},
</if>
<if test="stockNumber != null">
stock_number = #{stockNumber,jdbcType=INTEGER},
</if>
@ -147,6 +154,7 @@
SKU = #{SKU,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
original_price = #{originalPrice,jdbcType=DECIMAL},
rate = #{rate,jdbcType=DECIMAL},
stock_number = #{stockNumber,jdbcType=INTEGER},
total = #{total,jdbcType=INTEGER},
weight = #{weight,jdbcType=DECIMAL},
@ -183,7 +191,7 @@
</select>
<select id="findSku" parameterType="java.lang.Object" resultType="com.shop.cereshop.app.page.product.ProductSkus">
SELECT b.shop_id,a.product_id,a.sku_id,b.product_name,b.if_huabei,a.original_price,a.weight,
SELECT b.shop_id,a.product_id,a.sku_id,b.product_name,b.if_huabei,a.original_price,a.rate, a.weight,
IF(d.image IS NULL OR d.image='',c.product_image,d.image) image,a.stock_number,a.SKU,b.if_logistics,
IF(m.price IS NULL,IF(n.seckill_price IS NULL,
IF(h.price IS NULL,a.price,h.price),n.seckill_price),m.price) price from cere_product_sku a
@ -204,13 +212,13 @@
</select>
<select id="findFirstSku" parameterType="java.lang.Object" resultType="com.shop.cereshop.app.page.product.ProductSkus">
SELECT a.shop_id,a.product_id,a.product_name,a.if_huabei,c.sku_id,c.original_price,a.if_logistics,
SELECT a.shop_id,a.product_id,a.product_name,a.if_huabei,c.sku_id,c.original_price,c.rate,a.if_logistics,
c.weight,c.SKU,c.stock_number,IF(d.image IS NULL,b.product_image,d.image) image,
IF(m.price IS NULL,IF(n.seckill_price IS NULL,
IF(h.price IS NULL,c.price,h.price),n.seckill_price),m.price) price from cere_shop_product a
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b where a.product_id=b.product_id
GROUP BY a.product_id) b ON b.product_id=a.product_id
LEFT JOIN (SELECT a.product_id,a.sku_id,a.original_price,a.price,a.weight,a.stock_number,a.SKU from cere_product_sku a,cere_shop_product b
LEFT JOIN (SELECT a.product_id,a.sku_id,a.original_price,a.rate,a.price,a.weight,a.stock_number,a.SKU from cere_product_sku a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id
LEFT JOIN (SELECT a.sku_id,a.image from cere_sku_name a,cere_product_sku b where a.sku_id=b.sku_id LIMIT 1) d ON c.sku_id=d.sku_id
LEFT JOIN (SELECT a.shop_group_work_id,a.sku_id,a.price,MIN(start_time) FROM cere_shop_group_work_detail a
@ -231,7 +239,7 @@
a.stock_number,
a.total,
IF(d.image IS NULL,c.product_image,d.image) image,
a.original_price,
a.original_price,a.rate,
a.price,
f.valueCodes
from cere_product_sku a
@ -245,7 +253,7 @@
<select id="findSkuByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.product.Sku">
SELECT a.sku_id,a.stock_number,
a.original_price,
a.original_price,a.rate,
IF(d.image IS NULL,c.product_image,d.image) image,
IF(m.price IS NULL,IF(n.seckill_price IS NULL,
IF(h.price IS NULL,a.price,h.price),n.seckill_price),m.price) price,
@ -287,7 +295,7 @@
</select>
<select id="findGroupWorkSkuByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.product.Sku">
SELECT a.sku_id,a.original_price,IF(e.price IS NULL,a.price,e.price) price,a.price sale_price,a.stock_number,
SELECT a.sku_id,a.original_price,a.rate,IF(e.price IS NULL,a.price,e.price) price,a.price sale_price,a.stock_number,
a.total,IF(d.image IS NULL OR d.image='',c.product_image,d.image) image,f.valueCodes,
IF(e.price IS NULL,0,1) activityType from cere_product_sku a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
@ -300,7 +308,7 @@
</select>
<select id="findSeckillSkuByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.product.Sku">
SELECT a.sku_id,a.original_price,IF(e.seckill_price IS NULL,a.price,e.seckill_price) price,a.stock_number,
SELECT a.sku_id,a.original_price,a.rate,IF(e.seckill_price IS NULL,a.price,e.seckill_price) price,a.stock_number,
a.total,IF(d.image IS NULL OR d.image='',c.product_image,d.image) image,f.valueCodes,
IF(e.seckill_price IS NULL,0,2) activityType from cere_product_sku a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
@ -313,7 +321,7 @@
</select>
<select id="findDiscountSkuByProductId" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.product.Sku">
SELECT a.sku_id,a.original_price,IF(e.price IS NULL,a.price,e.price) price,a.stock_number,
SELECT a.sku_id,a.original_price,a.rate,IF(e.price IS NULL,a.price,e.price) price,a.stock_number,
a.total,IF(d.image IS NULL OR d.image='',c.product_image,d.image) image,f.valueCodes,
IF(e.price IS NULL,0,3) activityType from cere_product_sku a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
@ -341,8 +349,8 @@
</select>
<select id="findStockNumberBySkus" parameterType="java.util.List" resultType="com.shop.cereshop.app.page.cart.CartSku">
SELECT a.product_id,a.sku_id,b.product_name,a.weight,a.stock_number,b.if_oversold,
a.SKU, c.`value`, b.if_logistics, a.original_price, a.price, b.if_credit, b.credit_limit,
SELECT a.storehouse_id, a.product_id,a.sku_id,b.product_name,a.weight,a.stock_number,b.if_oversold,
a.SKU, c.`value`, b.if_logistics, a.original_price, a.rate, a.price, b.if_credit, b.credit_limit,
IF(c.image IS NULL OR c.image='',d.product_image,c.image) image FROM cere_product_sku a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
LEFT JOIN (SELECT sku_id,image,GROUP_CONCAT(sku_value) `value`
@ -350,14 +358,14 @@
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) d ON a.product_id=d.product_id
where a.sku_id in (
<foreach collection="skus" item="item" index="index" separator=",">
#{item.skuId}
<foreach collection="skuIdList" item="skuId" index="index" separator=",">
#{skuId}
</foreach>
)
</select>
<select id="findGroupWorkStockNumberBySkus" parameterType="java.util.List" resultType="com.shop.cereshop.app.page.cart.CartSku">
SELECT a.product_id,a.sku_id,b.product_name,a.original_price,a.weight,a.stock_number,b.if_oversold,
SELECT a.product_id,a.sku_id,b.product_name,a.original_price,a.rate, a.weight,a.stock_number,b.if_oversold,
a.SKU,c.`value`,b.if_logistics,e.price,
IF(c.image IS NULL OR c.image='',d.product_image,c.image) image FROM cere_product_sku a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id

5
cereshop-app/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml

@ -236,6 +236,8 @@
a.shelve_state,
a.if_huabei,
b.original_price,
b.storehouse_id,
b.rate,
c.shop_name,
c.shop_logo,
a.product_brief,
@ -659,7 +661,8 @@
<select id="queryProductDetail" resultType="com.shop.cereshop.app.page.product.ProductDetail">
select a.product_id, a.shop_id, a.product_text as text, a.shelve_state,
a.if_huabei, a.product_brief, a.classify_id, a.if_logistics,
b.sku_id, b.weight, b.price, b.original_price
b.sku_id, b.weight, b.price, b.original_price, b.storehouse_id,
b.rate,
c.shop_name, c.shop_logo
from cere_shop_product a join cere_product_sku b on b.product_id = a.product_id
join cere_platform_shop c on a.shop_id = c.shop_id

23
cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.business.dao.storehouse.CereShopStorehouseDAO">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse">
<id column="storehouse_id" jdbcType="BIGINT" property="storehouseId" />
<result column="shop_id" jdbcType="BIGINT" property="shopId" />
<result column="storehouse_name" jdbcType="VARCHAR" property="storehouseName" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="kind" jdbcType="INTEGER" property="kind" />
<result column="if_cashier" jdbcType="BIT" property="ifCashier" />
<result column="one_product_order_price_limit" jdbcType="DECIMAL" property="oneProductOrderPriceLimit" />
<result column="more_product_order_price_limit" jdbcType="DECIMAL" property="moreProductOrderPriceLimit" />
<result column="one_product_num_limit" jdbcType="INTEGER" property="oneProductNumLimit" />
<result column="more_product_num_limit" jdbcType="INTEGER" property="moreProductNumLimit" />
<result column="order_number_limit" jdbcType="INTEGER" property="orderNumberLimit" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
storehouse_id, shop_id, storehouse_name, type, kind, if_cashier, one_product_order_price_limit, more_product_order_price_limit,one_product_num_limit,more_product_num_limit, order_number_limit,create_time,update_time
</sql>
</mapper>

12
cereshop-business/src/main/java/com/shop/cereshop/business/page/logistics/Logistics.java

@ -31,6 +31,18 @@ public class Logistics {
private String logisticsName;
/**
* 仓库id
*/
@ApiModelProperty(value = "仓库id")
private Long storehouseId;
/**
* 仓库名称
*/
@ApiModelProperty(value = "仓库名称")
private String storehouseName;
/**
* 计费方式 1-按件数 2-按重量 3-全国包邮
*/
@ApiModelProperty(value = "计费方式 1-按件数 2-按重量 3-全国包邮")

12
cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java

@ -148,6 +148,18 @@ public class ShopProduct {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* 仓库Id
*/
@ApiModelProperty(value = "仓库Id")
private Long storehouseId;
/**
* 库存
*/
@ApiModelProperty(value = "库存")

12
cereshop-business/src/main/java/com/shop/cereshop/business/page/tool/ToolProduct.java

@ -49,6 +49,12 @@ public class ToolProduct {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* 活动价格
*/
@ApiModelProperty(value = "活动价格")
@ -61,6 +67,12 @@ public class ToolProduct {
private BigDecimal discount;
/**
* 仓库Id
*/
@ApiModelProperty(value = "仓库Id")
private Integer storehouseId;
/**
* 库存数量
*/
@ApiModelProperty(value = "库存数量")

6
cereshop-business/src/main/java/com/shop/cereshop/business/param/logistics/LogistSaveParam.java

@ -28,6 +28,12 @@ public class LogistSaveParam {
private Long shopId;
/**
* 仓库id
*/
@ApiModelProperty(value = "仓库id")
private Long storehouseId;
/**
* 方案名称
*/
@ApiModelProperty(value = "方案名称")

6
cereshop-business/src/main/java/com/shop/cereshop/business/param/logistics/LogistUpdateParam.java

@ -31,6 +31,12 @@ public class LogistUpdateParam {
private Long shopId;
/**
* 仓库id
*/
@ApiModelProperty(value = "仓库id")
private Long storehouseId;
/**
* 方案名称
*/
@ApiModelProperty(value = "方案名称")

6
cereshop-business/src/main/java/com/shop/cereshop/business/param/product/SkuParam.java

@ -54,6 +54,12 @@ public class SkuParam {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* * 所属仓库
*/
@ApiModelProperty(value = "所属仓库")

29
cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailGetAllParam.java

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.shop;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* cere_shop_cross_detail 店铺跨境拓展信息
* @author
*/
@Data
@ApiModel(value = "ShopCrossDetailGetAllParam", description = "获取店铺跨境信息列表请求")
public class ShopCrossDetailGetAllParam extends PageParam implements Serializable {
/**
* 店铺id
*/
@ApiModelProperty(value = "店铺id")
private Long shopId;
}

28
cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailGetByIdParam.java

@ -0,0 +1,28 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.shop;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* cere_shop_cross_detail 店铺跨境拓展信息
* @author
*/
@Data
@ApiModel(value = "ShopCrossDetailGetByIdParam", description = "获取店铺跨境信息详情请求")
public class ShopCrossDetailGetByIdParam extends PageParam implements Serializable {
/**
* 店铺秒杀活动id
*/
@ApiModelProperty(value = "拓展信息Id")
private Long crossDetailId;
}

132
cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailSaveParam.java

@ -0,0 +1,132 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.shop;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* cere_shop_cross_detail 店铺跨境拓展信息
* @author
*/
@Data
public class ShopCrossDetailSaveParam implements Serializable {
/**
* 关联店铺id
*/
@ApiModelProperty(value = "关联店铺id")
private Long shopId;
/**
* 电商平台名称
*/
@ApiModelProperty(value = "电商平台名称")
private String ebpname;
/**
* 电商平台代码
*/
@ApiModelProperty(value = "电商平台代码")
private String ebpcode;
/**
* 电商企业名称
*/
@ApiModelProperty(value = "电商企业名称")
private String ebpcname;
/**
* 电商企业代码
*/
@ApiModelProperty(value = "电商企业代码")
private String ebpccode;
/**
* 申报企业名称
*/
@ApiModelProperty(value = "申报企业名称")
private String agentName;
/**
* 申报企业代码
*/
@ApiModelProperty(value = "申报企业代码")
private String agentCode;
/**
* 区内企业名称
*/
@ApiModelProperty(value = "区内企业名称")
private String areaName;
/**
* 区内企业代码
*/
@ApiModelProperty(value = "区内企业代码")
private String areaCode;
/**
* 担保企业名称
*/
@ApiModelProperty(value = "担保企业名称")
private String assureName;
/**
* 担保企业代码
*/
@ApiModelProperty(value = "担保企业代码")
private String assureCode;
/**
* 账册编号
*/
@ApiModelProperty(value = "账册编号")
private String zcCode;
/**
* 申报海关代码
*/
@ApiModelProperty(value = "申报海关代码")
private String sbhgCode;
/**
* 口岸海关代码
*/
@ApiModelProperty(value = "口岸海关代码")
private String kahgCode;
/**
* 订单传输企业名称
*/
@ApiModelProperty(value = "订单传输企业名称")
private String copName;
/**
* 订单传输企业代码
*/
@ApiModelProperty(value = "订单传输企业代码")
private String copCode;
/**
* 清单传输企业名称
*/
@ApiModelProperty(value = "清单传输企业名称")
private String copName1;
/**
* 清单传输企业代码
*/
@ApiModelProperty(value = "清单传输企业代码")
private String copCode1;
/**
* 公司对公银行账户
*/
@ApiModelProperty(value = "公司对公银行账户")
private String bankCode;
private static final long serialVersionUID = 1L;
}

132
cereshop-business/src/main/java/com/shop/cereshop/business/param/shop/ShopCrossDetailUpdateParam.java

@ -0,0 +1,132 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.shop;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* cere_shop_cross_detail 店铺跨境拓展信息
* @author
*/
@Data
public class ShopCrossDetailUpdateParam implements Serializable {
@ApiModelProperty(value = "拓展信息Id")
private Long crossDetailId;
/**
* 关联店铺id
*/
@ApiModelProperty(value = "关联店铺id")
private Long shopId;
/**
* 电商平台名称
*/
@ApiModelProperty(value = "电商平台名称")
private String ebpname;
/**
* 电商平台代码
*/
@ApiModelProperty(value = "电商平台代码")
private String ebpcode;
/**
* 电商企业名称
*/
@ApiModelProperty(value = "电商企业名称")
private String ebpcname;
/**
* 电商企业代码
*/
@ApiModelProperty(value = "电商企业代码")
private String ebpccode;
/**
* 申报企业名称
*/
@ApiModelProperty(value = "申报企业名称")
private String agentName;
/**
* 申报企业代码
*/
@ApiModelProperty(value = "申报企业代码")
private String agentCode;
/**
* 区内企业名称
*/
@ApiModelProperty(value = "区内企业名称")
private String areaName;
/**
* 区内企业代码
*/
@ApiModelProperty(value = "区内企业代码")
private String areaCode;
/**
* 担保企业名称
*/
@ApiModelProperty(value = "担保企业名称")
private String assureName;
/**
* 担保企业代码
*/
@ApiModelProperty(value = "担保企业代码")
private String assureCode;
/**
* 账册编号
*/
@ApiModelProperty(value = "账册编号")
private String zcCode;
/**
* 申报海关代码
*/
@ApiModelProperty(value = "申报海关代码")
private String sbhgCode;
/**
* 口岸海关代码
*/
@ApiModelProperty(value = "口岸海关代码")
private String kahgCode;
/**
* 订单传输企业名称
*/
@ApiModelProperty(value = "订单传输企业名称")
private String copName;
/**
* 订单传输企业代码
*/
@ApiModelProperty(value = "订单传输企业代码")
private String copCode;
/**
* 清单传输企业名称
*/
@ApiModelProperty(value = "清单传输企业名称")
private String copName1;
/**
* 清单传输企业代码
*/
@ApiModelProperty(value = "清单传输企业代码")
private String copCode1;
/**
* 公司对公银行账户
*/
@ApiModelProperty(value = "公司对公银行账户")
private String bankCode;
private static final long serialVersionUID = 1L;
}

3
cereshop-business/src/main/java/com/shop/cereshop/business/service/logistics/impl/CereOrderLogisticsServiceImpl.java

@ -54,6 +54,8 @@ public class CereOrderLogisticsServiceImpl implements CereOrderLogisticsService
cereOrderLogistics.setChargeType(param.getChargeType());
cereOrderLogistics.setCreateTime(time);
cereOrderLogistics.setShopId(param.getShopId());
cereOrderLogistics.setStorehouseId(param.getStorehouseId());
//新增物流方案
cereOrderLogisticsDAO.insert(cereOrderLogistics);
//新增计费明细数据
@ -85,6 +87,7 @@ public class CereOrderLogisticsServiceImpl implements CereOrderLogisticsService
cereOrderLogistics.setChargeType(param.getChargeType());
cereOrderLogistics.setUpdateTime(time);
cereOrderLogistics.setShopId(param.getShopId());
cereOrderLogistics.setStorehouseId(param.getStorehouseId());
cereOrderLogisticsDAO.updateByPrimaryKeySelective(cereOrderLogistics);
//清空计费明细
cereLogisticsChargeService.deleteByLogisticsId(param.getLogisticsId());

1
cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java

@ -722,6 +722,7 @@ public class CereShopProductServiceImpl implements CereShopProductService {
}
cereProductSku.setOriginalPrice(sku.getOriginalPrice());
cereProductSku.setPrice(sku.getPrice());
cereProductSku.setRate(sku.getRate());
cereProductSku.setSkuImage(sku.getSkuImage());
cereProductSku.setSKU(sku.getSku());
cereProductSku.setStockNumber(sku.getStockNumber());

27
cereshop-business/src/main/resources/mybatis/mapper/logistics/CereOrderLogisticsDAO.xml

@ -4,14 +4,14 @@
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.logistics.CereOrderLogistics">
<id column="logistics_id" jdbcType="BIGINT" property="logisticsId" />
<result column="shop_id" jdbcType="BIGINT" property="shopId" />
<result column="storehouse_id" jdbcType="BIGINT" property="storehouseId" />
<result column="logistics_name" jdbcType="VARCHAR" property="logisticsName" />
<result column="charge_type" jdbcType="BIT" property="chargeType" />
<result column="region" jdbcType="VARCHAR" property="region" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
logistics_id,shop_id, logistics_name, charge_type, create_time, update_time
logistics_id,shop_id, storehouse_id, logistics_name, charge_type, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
@ -29,6 +29,9 @@
<if test="shopId != null">
shop_id,
</if>
<if test="storehouseId != null">
storehouse_id,
</if>
<if test="logisticsName != null and logisticsName!=''">
logistics_name,
</if>
@ -66,6 +69,9 @@
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="storehouseId != null">
storehouse_id = #{storehouseId,jdbcType=BIGINT},
</if>
<if test="logisticsName != null and logisticsName!=''">
logistics_name = #{logisticsName,jdbcType=VARCHAR},
</if>
@ -84,6 +90,7 @@
<update id="updateByPrimaryKey" parameterType="com.shop.cereshop.commons.domain.logistics.CereOrderLogistics">
update cere_order_logistics
set shop_id = #{shopId,jdbcType=BIGINT},
storehouse_id = #{storehouseId,jdbcType=BIGINT},
logistics_name = #{logisticsName,jdbcType=VARCHAR},
charge_type = #{chargeType,jdbcType=BIT},
create_time = #{createTime,jdbcType=VARCHAR},
@ -92,13 +99,23 @@
</update>
<select id="getById" parameterType="java.lang.Object" resultType="com.shop.cereshop.business.page.logistics.Logistics">
SELECT logistics_id,logistics_name,charge_type FROM cere_order_logistics where logistics_id=#{logisticsId}
SELECT
col.logistics_id,
col.storehouse_id,
css.storehouse_name,
col.logistics_name,
col.charge_type
FROM cere_order_logistics col
LEFT JOIN cere_shop_storehouse css ON css.storehouse_id = col.storehouse_id
where col.logistics_id=#{logisticsId}
</select>
<select id="getAll" parameterType="com.shop.cereshop.business.param.shop.ShopParam" resultType="com.shop.cereshop.business.page.logistics.Logistics">
SELECT a.logistics_id,a.logistics_name,a.charge_type, regions FROM cere_order_logistics a
SELECT a.logistics_id, a.storehouse_id,
css.storehouse_name,a.logistics_name,a.charge_type, regions FROM cere_order_logistics a
LEFT JOIN cere_shop_storehouse css ON css.storehouse_id = a.storehouse_id
LEFT JOIN (SELECT GROUP_CONCAT(region) regions,logistics_id from cere_logistics_charge GROUP BY logistics_id) b ON a.logistics_id=b.logistics_id
where shop_id=#{shopId}
where a.shop_id=#{shopId}
<if test="logisticsName!=null and logisticsName!=''">
and a.logistics_name like concat('%',#{logisticsName},'%')
</if>

28
cereshop-business/src/main/resources/mybatis/mapper/product/CereProductSkuDAO.xml

@ -7,6 +7,8 @@
<result column="SKU" jdbcType="VARCHAR" property="SKU"/>
<result column="price" jdbcType="DECIMAL" property="price"/>
<result column="original_price" jdbcType="DECIMAL" property="originalPrice"/>
<result column="rate" jdbcType="DECIMAL" property="rate"/>
<result column="storehouse_id" jdbcType="BIGINT" property="storehouseId"/>
<result column="stock_number" jdbcType="INTEGER" property="stockNumber"/>
<result column="total" jdbcType="INTEGER" property="total"/>
<result column="weight" jdbcType="DECIMAL" property="weight"/>
@ -17,7 +19,7 @@
</resultMap>
<sql id="Base_Column_List">
sku_id
, product_id,SKU, price, original_price, stock_number,total, weight,
, product_id,SKU, price, original_price, rate, storehouse_id, stock_number,total, weight,
sku_image, `style`, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@ -47,6 +49,12 @@
<if test="originalPrice != null">
original_price,
</if>
<if test="rate != null">
rate,
</if>
<if test="storehouseId != null">
storehouse_id,
</if>
<if test="stockNumber != null">
stock_number,
</if>
@ -82,6 +90,12 @@
<if test="originalPrice != null">
#{originalPrice,jdbcType=DECIMAL},
</if>
<if test="rate != null">
#{rate,jdbcType=DECIMAL},
</if>
<if test="storehouseId != null">
#{storehouseId,jdbcType=BIGINT},
</if>
<if test="stockNumber != null">
#{stockNumber,jdbcType=INTEGER},
</if>
@ -120,6 +134,9 @@
<if test="originalPrice != null">
original_price = #{originalPrice,jdbcType=DECIMAL},
</if>
<if test="rate != null">
rate = #{rate,jdbcType=DECIMAL},
</if>
<if test="isCross != null">
is_cross = #{isCross,jdbcType=BIT},
</if>
@ -156,6 +173,8 @@
SKU = #{SKU,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
original_price = #{originalPrice,jdbcType=DECIMAL},
rate = #{rate,jdbcType=DECIMAL},
storehouse_id = #{storehouseId,jdbcType=BIGINT},
stock_number = #{stockNumber,jdbcType=INTEGER},
total = #{total,jdbcType=INTEGER},
weight = #{weight,jdbcType=DECIMAL},
@ -168,7 +187,7 @@
<insert id="insertBatch" parameterType="java.util.List">
insert into cere_product_sku (product_id, sku_name, sku_value,
price, original_price, stock_number,
price, original_price, rate, storehouse_id, stock_number,
weight, sku_image, `style`,
create_time) values
<foreach collection="list" item="item" index="index" separator=",">
@ -178,6 +197,8 @@
#{item.skuValue},
#{item.price},
#{item.originalPrice},
#{item.rate},
#{item.storehouseId},
#{item.stockNumber},
#{item.weight},
#{item.skuImage},
@ -207,6 +228,7 @@
sku_id,
price,
original_price,
rate,
storehouse_id,
is_cross,
stock_number,
@ -238,6 +260,8 @@
c.product_name,
IF(b.image IS NULL, d.product_image, b.image) image,
a.original_price,
a.rate,
a.storehouse_id,
a.stock_number,
b.`value`
from cere_product_sku a

2
cereshop-business/src/main/resources/mybatis/mapper/tool/CereShopDiscountDAO.xml

@ -413,7 +413,7 @@
<update id="updateDiscountEndState" parameterType="java.lang.Object">
update cere_shop_discount SET state=2,update_time=#{time} where shop_discount_id in (
<foreach collection="list" item="item" index="index" separator=",">
#{item.discountId}
#{item.shopDiscountId}
</foreach>
)
</update>

41
cereshop-commons/src/main/java/com/shop/cereshop/commons/config/CrossStockConfig.java

@ -0,0 +1,41 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.commons.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class CrossStockConfig {
public static String URL = "http://47.112.3.12:8288";
public static String APPTOKEN = "ad523693d56243dc87e820bd44e18da1";
// 加密key
public static String APPKEY = "4d6e1cf9dbb24dc78c3c4d24db021333";
@Value("${crossstock.url:}")
public void setUrl(String url) {
this.URL = url;
}
@Value("${crossstock.appToken:}")
public void setToken(String appToken) {
this.APPTOKEN = appToken;
}
@Value("${crossstock.appKey:}")
public void setAppKey(String appKey) {
this.APPKEY = appKey;
}
public static String getApiUrl(String apiUrlPath){
return URL + "/" + apiUrlPath + "?apptoken=" + APPTOKEN + "&appkey=" + APPKEY;
}
}

33
cereshop-commons/src/main/java/com/shop/cereshop/commons/config/HuaxunConfig.java

@ -5,16 +5,41 @@
*/
package com.shop.cereshop.commons.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class HuaxunConfig {
// 加密key
private static String URL = "https://bg.qdhuaxun.cn/index.php";
// 加密key
private static String APPID = "8bd29f557af22ec4062774";
// 加密key
public static String KEY = "alexyu01";
// PAY_URL
public static String PAY_URL = "https://bg.qdhuaxun.cn/index.php?r=paybaoguan.api.pay&appid=8bd29f557af22ec4062774";
// PAYBACK_URL
public static String PAYBACK_URL = "https://bg.qdhuaxun.cn/index.php?r=paybaoguan.api.payback&appid=8bd29f557af22ec4062774";
@Value("${huaxun.url:}")
public void setUrl(String url) {
this.URL = url;
}
@Value("${huaxun.appId:}")
public void setAppId(String appId) {
this.APPID = appId;
}
@Value("${huaxun.key:}")
public void setKey(String key) {
this.KEY = key;
}
public static String getPayUrl(){
return HuaxunConfig.URL + "?r=paybaoguan.api.pay&appid=" + HuaxunConfig.APPID;
}
public static String getPayBackUrl(){
return HuaxunConfig.URL + "?r=paybaoguan.api.payback&appid=" + HuaxunConfig.APPID;
}
}

3
cereshop-commons/src/main/java/com/shop/cereshop/commons/constant/CoReturnFormat.java

@ -245,6 +245,7 @@ public class CoReturnFormat {
put(CoReturnFormat.SHOP_COUPON_EXPIRED, "商家优惠券已过期");
put(CoReturnFormat.SHOP_COUPON_ABNORMAL, "商家优惠券状态异常");
put(CoReturnFormat.CHANNEL_COUPON_SOLD_OUT_OR_END, "优惠券已领完或活动已结束");
put(CoReturnFormat.COUPON_ALREADY_USE, "优惠券重复使用,请重新选择优惠券");
//================================ 平台 ==================================
@ -675,6 +676,8 @@ public class CoReturnFormat {
/** 优惠券已领完或活动已结束 */
public static final String CHANNEL_COUPON_SOLD_OUT_OR_END = "700010";
public static final String COUPON_ALREADY_USE = "700011";
//================================ 平台 ==================================
/** 该类型画布已存在,请修改*/
public static final String CANVAS_ALREADY= "800001";

5
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/logistics/CereOrderLogistics.java

@ -29,6 +29,11 @@ public class CereOrderLogistics implements Serializable {
private Long shopId;
/**
* 仓库id
*/
private Long storehouseId;
/**
* 方案名称
*/
private String logisticsName;

2
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/order/CereOrderProduct.java

@ -57,7 +57,7 @@ public class CereOrderProduct implements Serializable {
private BigDecimal productPrice;
/**
* 该sku实际总支付加个(不包含运费和积分)
* 该sku实际总支付价格(不包含运费和积分)
*/
private BigDecimal actualPrice;

6
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/order/CereShopOrder.java

@ -8,6 +8,7 @@ package com.shop.cereshop.commons.domain.order;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ -241,6 +242,11 @@ public class CereShopOrder implements Serializable {
*/
private BigDecimal pricingPrice;
/**
* 是否是跨境订单
*/
private Integer isCross;
private static final long serialVersionUID = 1L;
}

6
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereProductSku.java

@ -56,6 +56,12 @@ public class CereProductSku implements Serializable {
private BigDecimal originalPrice;
/**
* 税率
*/
@ApiModelProperty(value = "税率")
private BigDecimal rate;
/**
* * 所属仓库
*/
@ApiModelProperty(value = "所属仓库")

Loading…
Cancel
Save