周箭河 4 лет назад
Родитель
Сommit
a8af0173a0

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentRouteOrderDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.common.dal.BaseDAO;
@@ -52,4 +53,10 @@ public interface StudentPaymentRouteOrderDao extends BaseDAO<Long, StudentPaymen
      * @return
      */
     Boolean deleteByOrderNo(@Param("orderNo") String orderNo);
+
+    /**
+     * 插入外部订单
+     * @return
+     */
+    int insertOrder(StudentPaymentOrder order);
 }

+ 5 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -92,7 +92,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
         studentPaymentRouteOrderDto.setCreateTime(studentPaymentRouteOrderDto.getPayTime());
         studentPaymentRouteOrderDto.setUpdateTime(nowDate);
 
-        studentPaymentOrderDao.insert(studentPaymentRouteOrderDto);
+        studentPaymentRouteOrderDao.insertOrder(studentPaymentRouteOrderDto);
         StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
         studentPaymentRouteOrder.setOrderNo(orderNo);
         studentPaymentRouteOrder.setMerNo(studentPaymentRouteOrderDto.getMerNo());
@@ -116,7 +116,10 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
             for (Map.Entry<Integer, Integer> goodsMap : studentPaymentRouteOrderDto.getGoodies().entrySet()) {
                 Goods goods = goodsDao.get(goodsMap.getKey());
 
-                BigDecimal actualAmount = studentPaymentRouteOrderDto.getGoodsAmount().multiply(goods.getGroupPurchasePrice().multiply(new BigDecimal(goodsMap.getValue()))).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
+                BigDecimal actualAmount = BigDecimal.ZERO;
+                if (goodsTotalPrice.compareTo(BigDecimal.ZERO) != 0) {
+                    actualAmount = studentPaymentRouteOrderDto.getGoodsAmount().multiply(goods.getGroupPurchasePrice().multiply(new BigDecimal(goodsMap.getValue()))).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
+                }
                 if (i == studentPaymentRouteOrderDto.getGoodies().size()) {
                     actualAmount = studentPaymentRouteOrderDto.getGoodsAmount().subtract(hasRouteAmount);
                 }

+ 20 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -221,4 +221,24 @@
         where order_no_ = #{orderNo}
     </delete>
 
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insertOrder" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
+            keyColumn="id" keyProperty="id">
+        INSERT INTO student_payment_order
+        (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
+        per_amount_,
+        balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
+        status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
+        payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_)
+        VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{userId}, #{organId}, #{routingOrganId},
+        #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
+        #{remitFee}, #{courseRemitFee}, #{transNo},
+        #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, #{createTime}, now(),
+        #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
+        #{musicGroupId},
+        #{classGroupId}, #{payTime})
+    </insert>
+
 </mapper>