Prechádzať zdrojové kódy

Merge branch 'dev_v1.3.4_20220909' of http://git.dayaedu.com/yonge/cooleshow into dev_v1.3.4_20220909

Eric 2 rokov pred
rodič
commit
8beb7f9888

+ 9 - 0
cooleshow-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/model/OmsOrderItem.java

@@ -69,8 +69,17 @@ public class OmsOrderItem implements Serializable {
     @ApiModelProperty("退货状态:-1 ->未退款;0->待处理;1->退货中;2->已完成;3->已拒绝")
     private Integer returnStatus;
 
+    private BigDecimal precisionAmount;
+
     private static final long serialVersionUID = 1L;
 
+    public BigDecimal getPrecisionAmount() {
+        return precisionAmount;
+    }
+
+    public void setPrecisionAmount(BigDecimal precisionAmount) {
+        this.precisionAmount = precisionAmount;
+    }
 
     public Long getPromoterId() {
         return promoterId;

+ 9 - 0
cooleshow-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/model/OmsOrderReturnApply.java

@@ -92,8 +92,17 @@ public class OmsOrderReturnApply implements Serializable {
     @ApiModelProperty("退货单号")
     private String deliverySn;
 
+    private BigDecimal precisionAmount;
+
     private static final long serialVersionUID = 1L;
 
+    public BigDecimal getPrecisionAmount() {
+        return precisionAmount;
+    }
+
+    public void setPrecisionAmount(BigDecimal precisionAmount) {
+        this.precisionAmount = precisionAmount;
+    }
 
     public Long getOrderItemId() {
         return orderItemId;

+ 18 - 3
cooleshow-mall/mall-mbg/src/main/resources/config/mybatis/OmsOrderItemMapper.xml

@@ -26,6 +26,7 @@
     <result column="returnStatus" jdbcType="INTEGER" property="returnStatus" />
     <result column="promoter_id" jdbcType="INTEGER" property="promoterId" />
     <result column="share_proportion_" jdbcType="INTEGER" property="shareProportion" />
+    <result column="precision_amount" jdbcType="INTEGER" property="precisionAmount" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -89,7 +90,7 @@
     id, order_id, order_sn, product_id, product_pic, product_name, product_brand, product_sn, 
     product_price, product_quantity, product_sku_id, product_sku_code, product_category_id, 
     promotion_name, promotion_amount, coupon_amount, integration_amount, real_amount, 
-    gift_integration, gift_growth, product_attr,promoter_id,share_proportion_
+    gift_integration, gift_growth, product_attr,promoter_id,share_proportion_,precision_amount
   </sql>
   <select id="selectByExample" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderItemExample" resultMap="BaseResultMap">
     select a.*,if(oora.status is null,-1,oora.status) as returnStatus from  (
@@ -133,14 +134,14 @@
       product_sku_id, product_sku_code, product_category_id, 
       promotion_name, promotion_amount, coupon_amount, 
       integration_amount, real_amount, gift_integration, 
-      gift_growth, product_attr,promoter_id,share_proportion_)
+      gift_growth, product_attr,promoter_id,share_proportion_,precision_amount)
     values (#{orderId,jdbcType=BIGINT}, #{orderSn,jdbcType=VARCHAR}, #{productId,jdbcType=BIGINT}, 
       #{productPic,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, #{productBrand,jdbcType=VARCHAR}, 
       #{productSn,jdbcType=VARCHAR}, #{productPrice,jdbcType=DECIMAL}, #{productQuantity,jdbcType=INTEGER}, 
       #{productSkuId,jdbcType=BIGINT}, #{productSkuCode,jdbcType=VARCHAR}, #{productCategoryId,jdbcType=BIGINT}, 
       #{promotionName,jdbcType=VARCHAR}, #{promotionAmount,jdbcType=DECIMAL}, #{couponAmount,jdbcType=DECIMAL}, 
       #{integrationAmount,jdbcType=DECIMAL}, #{realAmount,jdbcType=DECIMAL}, #{giftIntegration,jdbcType=INTEGER}, 
-      #{giftGrowth,jdbcType=INTEGER}, #{productAttr,jdbcType=VARCHAR},#{promoterId},#{shareProportion})
+      #{giftGrowth,jdbcType=INTEGER}, #{productAttr,jdbcType=VARCHAR},#{promoterId},#{shareProportion},#{precisionAmount})
   </insert>
   <insert id="insertSelective" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderItem">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -214,6 +215,9 @@
       <if test="shareProportion != null">
         share_proportion_,
       </if>
+      <if test="precisionAmount != null">
+        precision_amount,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="orderId != null">
@@ -282,6 +286,9 @@
       <if test="shareProportion != null">
         #{shareProportion,jdbcType=VARCHAR},
       </if>
+      <if test="precisionAmount != null">
+        #{precisionAmount},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderItemExample" resultType="java.lang.Long">
@@ -362,6 +369,9 @@
       <if test="record.shareProportion != null">
         share_proportion_ = #{record.shareProportion,jdbcType=VARCHAR},
       </if>
+      <if test="record.precisionAmount != null">
+        precision_amount = #{record.precisionAmount,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -391,6 +401,7 @@
       gift_growth = #{record.giftGrowth,jdbcType=INTEGER},
       promoter_id = #{record.promoterId,jdbcType=INTEGER},
       share_proportion_ = #{record.shareProportion},
+      precision_amount = #{record.precisionAmount},
       product_attr = #{record.productAttr,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -465,6 +476,9 @@
       <if test="shareProportion != null">
         share_proportion_ = #{shareProportion,jdbcType=VARCHAR},
       </if>
+      <if test="precisionAmount != null">
+        precision_amount = #{precisionAmount,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -491,6 +505,7 @@
       gift_growth = #{giftGrowth,jdbcType=INTEGER},
       promoter_id = #{promoterId,jdbcType=INTEGER},
     share_proportion_ = #{shareProportion},
+    precision_amount = #{precisionAmount},
       product_attr = #{productAttr,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>

+ 18 - 3
cooleshow-mall/mall-mbg/src/main/resources/config/mybatis/OmsOrderReturnApplyMapper.xml

@@ -11,6 +11,7 @@
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="member_username" jdbcType="VARCHAR" property="memberUsername" />
     <result column="return_amount" jdbcType="DECIMAL" property="returnAmount" />
+    <result column="precision_amount" jdbcType="DECIMAL" property="precisionAmount" />
     <result column="return_name" jdbcType="VARCHAR" property="returnName" />
     <result column="return_phone" jdbcType="VARCHAR" property="returnPhone" />
     <result column="status" jdbcType="INTEGER" property="status" />
@@ -94,7 +95,7 @@
     id, order_id, company_address_id, product_id, order_sn, create_time, member_username, 
     return_amount, return_name, return_phone, status, handle_time, product_pic, product_name, 
     product_brand, product_attr, product_count, product_price, product_real_price, reason, 
-    description, proof_pics, handle_note, handle_man, receive_man, receive_time, receive_note,delivery_sn,order_item_id
+    description, proof_pics, handle_note, handle_man, receive_man, receive_time, receive_note,delivery_sn,order_item_id,precision_amount
   </sql>
   <select id="selectByExample" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderReturnApplyExample" resultMap="BaseResultMap">
     select
@@ -138,7 +139,7 @@
       product_count, product_price, product_real_price, 
       reason, description, proof_pics, 
       handle_note, handle_man, receive_man, 
-      receive_time, receive_note,delivery_sn,order_item_id)
+      receive_time, receive_note,delivery_sn,order_item_id,precision_amount)
     values (#{orderId,jdbcType=BIGINT}, #{companyAddressId,jdbcType=BIGINT}, #{productId,jdbcType=BIGINT}, 
       #{orderSn,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{memberUsername,jdbcType=VARCHAR}, 
       #{returnAmount,jdbcType=DECIMAL}, #{returnName,jdbcType=VARCHAR}, #{returnPhone,jdbcType=VARCHAR}, 
@@ -147,7 +148,7 @@
       #{productCount,jdbcType=INTEGER}, #{productPrice,jdbcType=DECIMAL}, #{productRealPrice,jdbcType=DECIMAL}, 
       #{reason,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{proofPics,jdbcType=VARCHAR}, 
       #{handleNote,jdbcType=VARCHAR}, #{handleMan,jdbcType=VARCHAR}, #{receiveMan,jdbcType=VARCHAR}, 
-      #{receiveTime,jdbcType=TIMESTAMP}, #{receiveNote,jdbcType=VARCHAR},#{deliverySn},#{orderItemId})
+      #{receiveTime,jdbcType=TIMESTAMP}, #{receiveNote,jdbcType=VARCHAR},#{deliverySn},#{orderItemId},#{precisionAmount})
   </insert>
   <insert id="insertSelective" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderReturnApply">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -239,6 +240,9 @@
       <if test="orderItemId != null">
         order_item_id,
       </if>
+      <if test="precisionAmount != null">
+        precision_amount,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="orderId != null">
@@ -325,6 +329,9 @@
       <if test="orderItemId != null">
         #{orderItemId},
       </if>
+      <if test="precisionAmount != null">
+        #{precisionAmount},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.yonge.cooleshow.mbg.model.OmsOrderReturnApplyExample" resultType="java.lang.Long">
@@ -423,6 +430,9 @@
       <if test="record.orderItemId != null">
         order_item_id = #{record.orderItemId},
       </if>
+      <if test="record.precisionAmount != null">
+        precision_amount = #{record.precisionAmount},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -458,6 +468,7 @@
       receive_time = #{record.receiveTime,jdbcType=TIMESTAMP},
       receive_note = #{record.receiveNote,jdbcType=VARCHAR},
       order_item_id = #{record.orderItemId},
+      precision_amount = #{record.precisionAmount},
       delivery_sn = #{record.deliverySn,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -550,6 +561,9 @@
       <if test="orderItemId != null">
         order_item_id = #{orderItemId},
       </if>
+      <if test="precisionAmount != null">
+        precision_amount = #{precisionAmount},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -582,6 +596,7 @@
       receive_time = #{receiveTime,jdbcType=TIMESTAMP},
       receive_note = #{receiveNote,jdbcType=VARCHAR},
       order_item_id = #{orderItemId},
+      precision_amount = #{precisionAmount},
       delivery_sn = #{deliverySn,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>

+ 1 - 1
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderReturnApplyServiceImpl.java

@@ -90,7 +90,7 @@ public class OmsPortalOrderReturnApplyServiceImpl implements OmsPortalOrderRetur
         }
         realApply.setProductPrice(omsOrderItem.getProductPrice());
         realApply.setProductRealPrice(omsOrderItem.getRealAmount());
-
+        realApply.setPrecisionAmount(omsOrderItem.getPrecisionAmount());
         realApply.setCreateTime(new Date());
         realApply.setStatus(0);
         return returnApplyMapper.insert(realApply);

+ 10 - 2
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -380,7 +380,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
             }
             MallOrderItemDto teacherShareDto = new MallOrderItemDto();
             BeanUtils.copyProperties(omsOrderItem,teacherShareDto);
-            teacherShareDto.setRealAmount(omsOrderItem.getRealAmount().multiply(BigDecimal.valueOf(omsOrderItem.getProductQuantity())));
+            teacherShareDto.setRealAmount(omsOrderItem.getRealAmount().multiply(BigDecimal.valueOf(omsOrderItem.getProductQuantity()))
+                                                      .subtract(omsOrderItem.getPrecisionAmount()));
             teacherShareDto.setStatus(status);
             teacherShareDto.setUserId(detail.getMemberId());
             list.add(teacherShareDto);
@@ -1312,10 +1313,17 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
         for (OmsOrderItem orderItem : orderItemList) {
             //(商品价格/可用商品总价)*优惠券面额
             BigDecimal couponAmount = orderItem.getProductPrice()
-                                               .divide(totalAmount, 3, BigDecimal.ROUND_DOWN)
+                                               .divide(totalAmount, 2, BigDecimal.ROUND_DOWN)
                                                .multiply(coupon);
             orderItem.setCouponAmount(couponAmount);
+            orderItem.setPrecisionAmount(BigDecimal.ZERO);
         }
+        BigDecimal reduce = orderItemList.stream()
+                                         .map(omsOrderItem -> omsOrderItem.getCouponAmount().multiply(BigDecimal.valueOf(omsOrderItem.getProductQuantity())))
+                                         .reduce(BigDecimal.ZERO, BigDecimal::add);
+        OmsOrderItem omsOrderItem = orderItemList.get(0);
+        omsOrderItem.setPrecisionAmount(coupon.subtract(reduce));
+
     }
 
     /**

+ 2 - 2
cooleshow-mall/mall-portal/src/main/resources/config/mybatis/PortalOrderItemDao.xml

@@ -7,7 +7,7 @@
         product_sn, product_price, product_quantity,
         product_sku_id, product_category_id, product_sku_code,promotion_name,
         promotion_amount, coupon_amount, integration_amount,
-        real_amount,product_attr,promoter_id,share_proportion_) values
+        real_amount,product_attr,promoter_id,share_proportion_,precision_amount) values
         <foreach collection="list" item="item" separator="," index="index">
             (#{item.orderId,jdbcType=BIGINT}, #{item.orderSn,jdbcType=VARCHAR}, #{item.productId,jdbcType=BIGINT},
             #{item.productPic,jdbcType=VARCHAR}, #{item.productName,jdbcType=VARCHAR}, #{item.productBrand,jdbcType=VARCHAR},
@@ -16,7 +16,7 @@
             #{item.promotionName,jdbcType=VARCHAR},
             #{item.promotionAmount,jdbcType=DECIMAL}, #{item.couponAmount,jdbcType=DECIMAL},
             #{item.integrationAmount,jdbcType=DECIMAL},
-            #{item.realAmount,jdbcType=DECIMAL},#{item.productAttr,jdbcType=VARCHAR},#{item.promoterId},#{item.shareProportion})
+            #{item.realAmount,jdbcType=DECIMAL},#{item.productAttr,jdbcType=VARCHAR},#{item.promoterId},#{item.shareProportion},#{item.precisionAmount})
         </foreach>
     </insert>
 </mapper>