浏览代码

调整:产品生成商品默认类型最新定价。

lym 4 年之前
父节点
当前提交
0d8fe3416c

+ 2 - 0
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/controller/ProductTypeController.java

@@ -46,12 +46,14 @@ public class ProductTypeController extends CarbonBaseController {
     }
 
     @ApiOperation("修改产品类型")
+    @PostMapping("/update")
     public ResponseBase update(@RequestBody ProductTypeForm productTypeForm) {
         int success = this.productTypeService.modify(productTypeForm);
         return thisReturn(success);
     }
 
     @ApiOperation("分页获取产品类型")
+    @PostMapping("/searchByPage")
     public ResponseBase searchByPage(@RequestBody ProductTypeForm productTypeForm) {
         PageInfo pageInfo = this.productTypeService.queryListByPage(productTypeForm);
        return responseSuccess(pageInfo);

+ 10 - 0
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/dao/ProductTypePriceMapper.java

@@ -1,8 +1,10 @@
 package com.hcloud.microserver.system.bank.dao;
 
 import com.hcloud.microserver.commoncore.base.BaseMapper;
+import com.hcloud.microserver.system.facade.carbon.entity.ProductTypePrice;
 import com.hcloud.microserver.system.facade.carbon.entity.ProductTypePriceWithBLOBs;
 import com.hcloud.microserver.system.facade.carbon.forms.ProductTypePriceForm;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -23,4 +25,12 @@ public interface ProductTypePriceMapper extends BaseMapper<ProductTypePriceWithB
      * @return
      */
     int updateGoodsInfoPrice(ProductTypePriceWithBLOBs productTypePriceWithBLOBs);
+
+    /**
+     * 查询最新的产品类别定价
+     * lym
+     * @param ProductTypeGuid
+     * @return
+     */
+    ProductTypePriceWithBLOBs selectNewProductTypePrice(@Param(("ProductTypeGuid")) String ProductTypeGuid);
 }

+ 14 - 0
carbon-back/carbon-back-service/src/main/java/com/hcloud/microserver/system/bank/service/impl/ProductInfoServiceImpl.java

@@ -54,6 +54,8 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 
     @Resource
     private FarmerInfoMapper farmerInfoMapper;
+    @Resource
+    private ProductTypePriceMapper productTypePriceMapper;
 
     private static final GeneratorIdUtils ID_UTILS_INSTANCE = new GeneratorIdUtils();
 
@@ -408,7 +410,18 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                 goodsInfo.setIsSale(1);
                 goodsInfo.setCreateTime(new Date());
                 goodsInfo.setModifiedTime(new Date());
+                goodsInfo.setCreateUser(CurrUserUtil.getUserId());
+                goodsInfo.setModifiedUser(CurrUserUtil.getUserId());
+
+                //查询产品类别最新定价为商品售价 lym
+                String fkProductType = productInfo.getFkProductType();
+                ProductTypePriceWithBLOBs typePriceWithBLOBs = productTypePriceMapper.selectNewProductTypePrice(fkProductType);
+                if (typePriceWithBLOBs != null && typePriceWithBLOBs.getFkProductType().contains(fkProductType)){
+                    goodsInfo.setPrice(typePriceWithBLOBs.getPrice());
+                }
+
                 result = this.goodsInfoMapper.insert(goodsInfo);
+
                 if (result < 1) throw new RuntimeException("产品发布 -- 添加商品记录失败");
 
                 GoodsDetail goodsDetail = new GoodsDetail();
@@ -437,6 +450,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                 goodsSaleInfo.setSaleType(goodsInfoForm.getSaleType());
                 goodsSaleInfo.setSaleTargets(goodsInfoForm.getSaleTargets());
                 goodsSaleInfo.setModifiedTime(new Date());
+                goodsSaleInfo.setSalePrice(goodsInfo.getPrice());
                 result = this.goodsSaleInfoMapper.insertSelective(goodsSaleInfo);
                 if (result < 1) throw new RuntimeException("产品发布 -- 添加商品销售信息失败");
 

+ 1 - 1
carbon-back/carbon-back-service/src/main/resources/carbon/GoodsCredentialInfoMapper.xml

@@ -1,6 +1,6 @@
 <?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="GoodsCredentialInfoMapper">
+<mapper namespace="com.hcloud.microserver.system.bank.dao.GoodsCredentialInfoMapper">
   <resultMap id="BaseResultMap" type="GoodsCredentialInfo">
     <id column="guid" jdbcType="CHAR" property="guid" />
     <result column="fk_customer_id" jdbcType="CHAR" property="fkCustomerId" />

+ 1 - 1
carbon-back/carbon-back-service/src/main/resources/carbon/GoodsDetailMapper.xml

@@ -1,6 +1,6 @@
 <?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="GoodsDetailMapper">
+<mapper namespace="com.hcloud.microserver.system.bank.dao.GoodsDetailMapper">
     <resultMap id="BaseResultMap" type="GoodsDetail">
         <id column="guid" jdbcType="CHAR" property="guid"/>
         <result column="fk_goods_guid" jdbcType="CHAR" property="fkGoodsGuid"/>

+ 1 - 1
carbon-back/carbon-back-service/src/main/resources/carbon/GoodsInfoMapper.xml

@@ -1,6 +1,6 @@
 <?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="GoodsInfoMapper">
+<mapper namespace="com.hcloud.microserver.system.bank.dao.GoodsInfoMapper">
     <resultMap id="BaseResultMap" type="GoodsInfo">
         <id column="guid" jdbcType="CHAR" property="guid"/>
         <result column="goods_type" jdbcType="VARCHAR" property="goodsType"/>

+ 1 - 1
carbon-back/carbon-back-service/src/main/resources/carbon/GoodsSaleInfoMapper.xml

@@ -1,6 +1,6 @@
 <?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="GoodsSaleInfoMapper">
+<mapper namespace="com.hcloud.microserver.system.bank.dao.GoodsSaleInfoMapper">
   <resultMap id="BaseResultMap" type="GoodsSaleInfo">
     <id column="guid" jdbcType="CHAR" property="guid" />
     <result column="fk_goods_guid" jdbcType="CHAR" property="fkGoodsGuid" />

+ 16 - 3
carbon-back/carbon-back-service/src/main/resources/carbon/ProductTypePriceMapper.xml

@@ -211,14 +211,17 @@
   <select id="selectList" parameterType="com.hcloud.microserver.system.facade.carbon.forms.ProductTypePriceForm" resultMap="ResultMapWithBLOBs">
     SELECT <include refid="Base_Column_List"/>,<include refid="Blob_Column_List"/> FROM t_product_type_price
       WHERE state = 1
-    <if test="typeName != null">
+    <if test="typeName != null and typeName !=''">
       AND type_name LIKE CONCAT("%",#{typeName,jdbcType=LONGVARCHAR},"%)"
     </if>
+    <if test="fkProductType != null and fkProductType !=''">
+      AND FIND_IN_SET(#{fkProductType},fk_product_type)
+    </if>
     <if test="checkState != null">
       AND check_state = #{checkState,jdbcType=INTEGER}
     </if>
-    <if test="checkTime != null">
-      AND check_time = #{checkTime,jdbcType=TIMESTAMP}
+    <if test="checkTime != null and checkTime !=''">
+      AND DATE_FORMAT(check_time,"%Y-%m-%d") = #{checkTime}
     </if>
       ORDER BY create_time DESC
   </select>
@@ -236,4 +239,14 @@
         ) tmp
        )
   </update>
+
+  <!-- 查询最新的产品类别定价 lym -->
+  <select id="selectNewProductTypePrice" parameterType="String" resultMap="ResultMapWithBLOBs">
+      SELECT <include refid="Base_Column_List"/>,<include refid="Blob_Column_List"/>
+      FROM t_product_type_price WHERE state = 1
+        AND check_state = 1
+        AND FIND_IN_SET(#{ProductTypeGuid},fk_product_type)
+      ORDER BY check_time DESC
+      LIMIT 1
+  </select>
 </mapper>