Переглянути джерело

Merge branches 'developer' and 'developerB' of git.caimei365.com:chao/caimei-modules-soa into developer

jun.li@caimei365.com 4 роки тому
батько
коміт
507f4e9808

+ 5 - 0
base-module/src/main/java/com/caimei/module/base/entity/bo/Payment.java

@@ -67,4 +67,9 @@ public class Payment implements Serializable {
      * 微信公众号state参数
      */
     private String state;
+
+    /**
+     * 二手发布商品id
+     */
+    private Integer productId;
 }

+ 5 - 0
base-module/src/main/java/com/caimei/module/base/entity/po/CmOrder.java

@@ -276,4 +276,9 @@ public class CmOrder implements Serializable {
     private String thirdPartyOrderNo;
 
     private static final long serialVersionUID = 1L;
+
+    /**
+     * 二手商品订单标识  0非二手商品订单、 1二手商品订单
+     */
+    private String secondHandOrderFlag;
 }

+ 11 - 1
base-module/src/main/java/com/caimei/module/base/entity/po/Product.java

@@ -599,5 +599,15 @@ public class Product implements Serializable {
      */
     private Integer combinationSort;
 
+    /**
+     * 商品的类别:1正常商品(默认),2二手商品
+     */
+    private String productCategory;
+
+    /**
+     * 审核原因
+     */
+    private String auditReason;
+
     private static final long serialVersionUID = 1L;
-}
+}

+ 218 - 0
base-module/src/main/java/com/caimei/module/base/entity/po/SeconHandProduct.java

@@ -0,0 +1,218 @@
+package com.caimei.module.base.entity.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 二手商品详细信息
+ *
+ * @author : Charles
+ * @date : 2020/7/15
+ */
+
+@Data
+public class SeconHandProduct extends Product implements Serializable {
+    private static final long serialVersionUID = -2976754435288893250L;
+
+
+    private Integer id;
+    /**
+     * 是否已售 0和空未出售,1已出售
+     */
+    private String sold;
+        /**
+     * 二手商品分类,1二手仪1器,2临期产品,3其他
+     */
+    private String secondHandType;
+        /**
+         * 二手仪器分类的类型,1轻光电、2重光电、3耗材配件(仅适用于二手仪器分类多个用英文逗号分分隔)
+         */
+    private String instrumentType;
+        /**
+         * 出厂日期格式:2020年6月
+         */
+    private String fixedYears;
+        /**
+         * 产品到期日格式:2020年6月(仅适用于临期产品)
+         */
+    private String maturityYears;
+        /**
+         * 公司名称
+         */
+    private String companyName;
+        /**
+         * 是否启用详聊,1不开启,2开启(开启详聊不展示交易价)
+         */
+    private String detailTalkFlag;
+        /**
+         * 采购价/原价(该二手原始购买价格)
+         */
+    private Double originalPrice;
+
+        /**
+     * 采购价/原价(该二手原始购买价格)千分位串
+     */
+    private String originalPriceStr;
+    /**
+     * 交易价字符串千分位
+     */
+    private String price1Str;
+    /**
+     * 市场价价字符串千分位
+     */
+    private String normalPriceStr;
+        /**
+         * 联系人名字
+         */
+    private String contactName;
+        /**
+         * 联系方式
+         */
+    private String contactMobile;
+        /**
+         * 设备类型:1医美、2非医美
+         */
+    private String secondProductType;
+        /**
+         * 省市区(地址前部分)
+         */
+    private String provinceCityDistrict;
+        /**
+         * 详细联系地址
+         */
+    private String address;
+        /**
+         * 是否已售 0和空未出售,1已出售
+         */
+    private String productQuality;
+        /**
+         * 付款状态1:待支付、2已付款
+         */
+    private String payStatus;
+        /**
+         * 支付金额
+         */
+    private Double payAmount;
+        /**
+         * 线上支付回调返回数据存档
+         */
+    private String payFormData;
+        /**
+         * 付款方式 0后台付款、1:支付宝、2微信 、12PC-B2B网银、13PC-微信支付、14PC-支付宝、15小程序-微信支付
+         */
+    private String payType;
+        /**
+         * 线上付款时间
+         */
+    private Date payDate;
+        /**
+         * 提交时间
+         */
+    private Date submitDate;
+        /**
+         * 审核时间'
+         */
+    private Date reviewedDate;
+        /**
+         * 上架时间(审核时上架变化、自动下架后再上架变化、手动下架后上架如果不在有效期内才变化)
+         */
+    private Date onLineDate;
+    /**
+     * 上架时间字符串(年月日)
+      */
+    private String onLineDateStr;
+    /**
+     * 商品图片信息
+     */
+    private String image1;
+	private String image2;
+	private String image3;
+	private String image4;
+	private String image5;
+    /**
+     * 商品详情信息(补充信息)
+     */
+	private String productDetails;
+
+    /**
+     * 区Id
+     */
+	private Integer townId;
+
+    /**
+     * 浏览量
+     */
+    private Integer viewingNum;
+
+     /**
+     * //是否新上架 0非新上架,1新上架
+     */
+    private String newAdded;
+
+    /**
+     * 二手商品列表图片数据集合
+     */
+    private List<String> imageList;
+
+    /**
+     * 品牌名称
+     */
+    private String brandName;
+
+    /**
+     * 商品类型(二手仪器-重光电)
+     */
+    private String typeStr;
+
+    /**
+     * 品牌信息(品牌描述)
+     */
+    private String brandInfo;
+
+    @Override
+    public String toString() {
+        return "SeconHandProduct{" +
+                "sold='" + sold + '\'' +
+                ", secondHandType='" + secondHandType + '\'' +
+                ", instrumentType='" + instrumentType + '\'' +
+                ", fixedYears='" + fixedYears + '\'' +
+                ", maturityYears='" + maturityYears + '\'' +
+                ", companyName='" + companyName + '\'' +
+                ", detailTalkFlag='" + detailTalkFlag + '\'' +
+                ", originalPrice=" + originalPrice +
+                ", originalPriceStr='" + originalPriceStr + '\'' +
+                ", price1Str='" + price1Str + '\'' +
+                ", normalPriceStr='" + normalPriceStr + '\'' +
+                ", contactName='" + contactName + '\'' +
+                ", contactMobile='" + contactMobile + '\'' +
+                ", secondProductType='" + secondProductType + '\'' +
+                ", provinceCityDistrict='" + provinceCityDistrict + '\'' +
+                ", address='" + address + '\'' +
+                ", productQuality='" + productQuality + '\'' +
+                ", payStatus='" + payStatus + '\'' +
+                ", payAmount=" + payAmount +
+                ", payFormData='" + payFormData + '\'' +
+                ", payType='" + payType + '\'' +
+                ", payDate=" + payDate +
+                ", submitDate=" + submitDate +
+                ", reviewedDate=" + reviewedDate +
+                ", onLineDate=" + onLineDate +
+                ", onLineDateStr='" + onLineDateStr + '\'' +
+                ", image1='" + image1 + '\'' +
+                ", image2='" + image2 + '\'' +
+                ", image3='" + image3 + '\'' +
+                ", image4='" + image4 + '\'' +
+                ", image5='" + image5 + '\'' +
+                ", productDetails='" + productDetails + '\'' +
+                ", townId=" + townId +
+                ", viewingNum=" + viewingNum +
+                ", newAdded='" + newAdded + '\'' +
+                ", imageList=" + imageList +
+                ", brandName='" + brandName + '\'' +
+                ", typeStr='" + typeStr + '\'' +
+                '}';
+    }
+}

+ 5 - 0
base-module/src/main/java/com/caimei/module/base/entity/vo/OrderProductVo.java

@@ -32,4 +32,9 @@ public class OrderProductVo extends CmOrderProduct {
      * 内部商品名称
      */
     private String aliasName;
+
+    /**
+     * 商品的类别:1正常商品(默认),2二手商品
+     */
+    private String productCategory;
 }

+ 3 - 0
pay/src/main/java/com/caimei/module/pay/dao/PayDao.java

@@ -1,5 +1,6 @@
 package com.caimei.module.pay.dao;
 
+import com.caimei.module.base.entity.po.SeconHandProduct;
 import com.caimei.module.base.entity.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -36,4 +37,6 @@ public interface PayDao {
     UserVo findUser(Long userID);
 
     List<OrderProductVo> fandAllOrderProduct(Integer orderId);
+
+    void updateSeconHand(SeconHandProduct seconHandProduct);
 }

+ 17 - 0
pay/src/main/java/com/caimei/module/pay/service/PayService.java

@@ -63,4 +63,21 @@ public interface PayService {
      * @return
      */
     JsonModel findOrderStatus(String mbOrderId);
+
+    /**
+     * 二手交易发布信息,银联,支付宝,微信
+     *
+     * @param payment 支付信息
+     * @param request
+     * @return
+     */
+    JsonModel secondHandPay(Payment payment, HttpServletRequest request);
+
+    /**
+     * 二手支付异步通知回调
+     *
+     * @param data 回调参数
+     * @return
+     */
+    String secondHandPayCallBack(String data) throws Exception;
 }

+ 114 - 14
pay/src/main/java/com/caimei/module/pay/service/impl/PayServiceImpl.java

@@ -3,6 +3,7 @@ package com.caimei.module.pay.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.module.base.entity.bo.JsonModel;
 import com.caimei.module.base.entity.bo.Payment;
+import com.caimei.module.base.entity.po.SeconHandProduct;
 import com.caimei.module.base.entity.vo.*;
 import com.caimei.module.pay.dao.PayDao;
 import com.caimei.module.pay.service.PayService;
@@ -253,25 +254,13 @@ public class PayServiceImpl implements PayService {
         String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
         DiscernReceiptVo discernReceipt = new DiscernReceiptVo();
         discernReceipt.setPayWay("1");
-        if ("ALIPAY_H5".equals(payType)) {
-            //支付宝H5
-            discernReceipt.setPayType("14");
-        } else if ("JSAPI_WEIXIN".equals(payType)) {
-            //微信公众号支付
-            discernReceipt.setPayType("13");
-        } else if ("MINIAPP_WEIXIN".equals(payType)) {
-            //微信小程序支付
-            discernReceipt.setPayType("15");
-        } else {
-            //银联
-            discernReceipt.setPayType("12");
-        }
+        discernReceipt.setPayType(getPayType(payType));
         discernReceipt.setReceiptType("1");
         discernReceipt.setReceiptStatus("3");
         discernReceipt.setReceiptAmount(amount);
         discernReceipt.setConfirmType("4");
         discernReceipt.setRePayFlag("1");
-        discernReceipt.setFormData(data);
+        discernReceipt.setFormData(json.toJSONString());
         discernReceipt.setReceiptDate(curDateStr);
         discernReceipt.setConfirmDate(curDateStr);
         discernReceipt.setReviewDate(curDateStr);
@@ -291,6 +280,25 @@ public class PayServiceImpl implements PayService {
         return "SUCCESS";
     }
 
+    /**
+     * 支付状态转换
+     */
+    private String getPayType(String payType) {
+        if ("ALIPAY_H5".equals(payType)) {
+            //支付宝H5
+            return "14";
+        } else if ("JSAPI_WEIXIN".equals(payType)) {
+            //微信公众号支付
+            return "13";
+        } else if ("MINIAPP_WEIXIN".equals(payType)) {
+            //微信小程序支付
+            return "15";
+        } else {
+            //银联
+            return "12";
+        }
+    }
+
     @Override
     public JsonModel payLink(OrderPayLinkVo orderPayLink) {
         if (null == orderPayLink) {
@@ -401,4 +409,96 @@ public class PayServiceImpl implements PayService {
         return model.success(result);
     }
 
+    @Override
+    public JsonModel secondHandPay(Payment payment, HttpServletRequest request) {
+        JSONObject result = null;
+        try {
+            // 时间戳
+            long time = System.currentTimeMillis() / 1000;
+            // 商户订单号
+            String orderId = payment.getProductId() + "#" + time;
+            //商品名称
+            String product = "采美订单" + orderId;
+            String userType = "ENTERPRISE";
+            //用户IP地址
+            String userIp = IPUtil.getIpAddr(request);
+            JSONObject json = new JSONObject();
+            json.put("merAccount", merAccount);
+            json.put("merNo", merNo);
+            json.put("orderId", orderId);
+            json.put("time", time);
+            //支付金额
+            json.put("amount", payment.getPayAmount());
+            json.put("product", product);
+            json.put("payWay", payment.getPayWay());
+            json.put("payType", payment.getPayType());
+            json.put("userIp", userIp);
+            json.put("returnUrl", payment.getReturnUrl());
+            json.put("notifyUrl", payment.getNotifyUrl());
+            String attach = payment.getProductId() + "," + payment.getPayType();
+            json.put("attach", attach);
+            if (null != payment.getBankCode()) {
+                json.put("bankCode", payment.getBankCode());
+            }
+            json.put("userType", userType);
+            if (null != payment.getOrderId()) {
+                json.put("openId", payment.getOpenid());
+            }
+            String sign = PayUtils.buildSign(json, merKey);
+            json.put("sign", sign);
+            String data = "";
+            try {
+                data = PayUtils.buildDataPrivate(json, merKey);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            result = PayUtils.httpGet("https://platform.mhxxkj.com/paygateway/mbpay/order/v1", merAccount, data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return model.error("支付失败");
+        }
+        String code = result.getString("code");
+        if (!"000000".equals(code)) {
+            String msg = result.getString("msg");
+            log.info("第三方支付失败>>>>>>>msg:" + msg);
+            return model.error(msg);
+        }
+        return model.success(result);
+    }
+
+    @Override
+    public String secondHandPayCallBack(String data) throws Exception {
+        //公钥解密
+        JSONObject json = PayUtils.decryptDataPublic(data, publicKey);
+        log.info("公钥解密>>>>>>" + json);
+        //公钥验签
+        String signaa = json.getString("sign");
+        json.remove("sign");
+        String signbb = PayUtils.buildSign(json, publicKey);
+        if (!signaa.equals(signbb)) {
+            return "验签失败";
+        }
+        //订单状态
+        String orderStatus = json.getString("orderStatus");
+        //附加数据,下单时若有传输则原样返回,下单时为空,则不返回该数据
+        String attach = json.getString("attach");
+        //订单金额,以元为单位
+        BigDecimal amount = json.getBigDecimal("amount");
+        log.info("订单状态>>>>>>" + orderStatus);
+        if ("FAILED".equals(orderStatus)) {
+            return "支付失败";
+        }
+        String[] split = attach.split(",");
+        //订单id
+        Integer productId = Integer.valueOf(split[0]);
+        //支付类型
+        String payType = split[1];
+        SeconHandProduct seconHandProduct = new SeconHandProduct();
+        seconHandProduct.setPayAmount(amount.doubleValue());
+        seconHandProduct.setPayFormData(json.toJSONString());
+        seconHandProduct.setPayType(getPayType(payType));
+        seconHandProduct.setProductID(productId);
+        payDao.updateSeconHand(seconHandProduct);
+        return "SUCCESS";
+    }
 }

+ 13 - 0
pay/src/main/resources/com-caimei-module-pay/PayMapper.xml

@@ -363,4 +363,17 @@
         WHERE
           userID = #{userID}
     </select>
+
+    <update id="updateSeconHand">
+        UPDATE
+          cm_second_hand_detail
+        SET
+          payStatus = '2',
+          payAmount = #{payAmount},
+          payFormData = #{payFormData},
+          payType = #{payType},
+          payDate = NOW()
+        WHERE
+          productID = #{productID}
+    </update>
 </mapper>

+ 22 - 0
product/src/main/java/com/caimei/module/product/dao/ProductModuleDao.java

@@ -1,5 +1,7 @@
 package com.caimei.module.product.dao;
 
+import com.caimei.module.base.entity.po.CmBrand;
+import com.caimei.module.base.entity.po.SeconHandProduct;
 import com.caimei.module.base.entity.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -32,6 +34,8 @@ public interface ProductModuleDao {
 
     List<ProductImageVo> findProductImage(Integer productID);
 
+    List<String> findImageByProductId(Integer productID);
+
     List<String> findProductImageString(Integer productID);
 
     ShopVo findProductShopById(Integer shopID);
@@ -57,4 +61,22 @@ public interface ProductModuleDao {
     List<ProductVo> getDeFaultRecommend(Integer tinyTypeID);
 
     void deleteAllSearchHistory(Integer userId);
+
+    AddressVo getAddressInfo(Integer townId);
+
+    void saveSencondHandProduct(SeconHandProduct seconHandProduct);
+
+    List<SeconHandProduct> getSeconHandProductList(SeconHandProduct seconHandProduct);
+
+    List<SeconHandProduct> getSeconHandProductByLimit(String secondHandType);
+
+    SeconHandProduct getSencondHandProductDetail(Integer productId);
+
+    List<CmBrand> getBrandList();
+
+    void updateViewingNum(SeconHandProduct sencondHandProductDetail);
+
+    List<SeconHandProduct> getSecondHandProductRecommend(Integer productId);
+
+    List<SeconHandProduct>  getOrderSecondHandProductList(@Param("searchKeyword")String searchKeyword, @Param("secondHandType")String secondHandType, @Param("instrumentType")String instrumentType);
 }

+ 12 - 4
product/src/main/java/com/caimei/module/product/service/ProductModuleService.java

@@ -1,10 +1,8 @@
 package com.caimei.module.product.service;
 
 import com.caimei.module.base.entity.bo.PageVo;
-import com.caimei.module.base.entity.vo.BigtypeVo;
-import com.caimei.module.base.entity.vo.LadderPriceVo;
-import com.caimei.module.base.entity.vo.ProductVo;
-import com.caimei.module.base.entity.vo.SearchHistoryVo;
+import com.caimei.module.base.entity.po.SeconHandProduct;
+import com.caimei.module.base.entity.vo.*;
 
 import java.util.List;
 
@@ -71,4 +69,14 @@ public interface ProductModuleService {
      * 相关推荐-根据id
      */
     List<ProductVo> getRecommended(Integer productID);
+
+    /**
+     * 二手商品通过地址ID获取详细省市区
+     */
+     AddressVo getAddressInfo(Integer townId);
+
+    /**
+     * 二手商品数据保存操作
+     */
+    void saveSencondHandProduct(SeconHandProduct seconHandProduct);
 }

+ 11 - 0
product/src/main/java/com/caimei/module/product/service/impl/ProductModuleServiceImpl.java

@@ -1,6 +1,7 @@
 package com.caimei.module.product.service.impl;
 
 import com.caimei.module.base.entity.bo.PageVo;
+import com.caimei.module.base.entity.po.SeconHandProduct;
 import com.caimei.module.base.entity.vo.*;
 import com.caimei.module.product.dao.ProductModuleDao;
 import com.caimei.module.product.service.ProductModuleService;
@@ -144,6 +145,16 @@ public class ProductModuleServiceImpl implements ProductModuleService {
         return productList;
     }
 
+    @Override
+    public AddressVo getAddressInfo(Integer townId){
+        return productModuleDao.getAddressInfo(townId);
+    }
+
+    @Override
+    public void saveSencondHandProduct(SeconHandProduct seconHandProduct) {
+        productModuleDao.saveSencondHandProduct(seconHandProduct);
+    }
+
     /**
      * 商品搜索历史记录
      */

+ 161 - 1
product/src/main/resources/com-caimei-module-product/ProductModuleMapper.xml

@@ -11,7 +11,7 @@
         tinyTypeID, smallTypeID, `name`, tinyTypeCode, icon, validFlag, seo, sortIndex
     </sql>
     <sql id="Product_Column_List">
-        productID, brandID, tinyTypeID, preferredFlag, selfTypeID, shopID, `name`, aliasName, searchKey, productRemarks,
+        productID, brandID, tinyTypeID,productCategory, preferredFlag, selfTypeID, shopID, `name`, aliasName, searchKey, productRemarks,
         normalPrice, price, highestUserLevelPrice, lowestUserLevelPrice, lowestUserLevelID,
         price0, price0Grade, price0Text, price0TextFlag, price1, price1Grade, price1Text,
         price1TextFlag, price8, price8Grade, price8Text, price8TextFlag, ladderPriceFlag,
@@ -143,6 +143,14 @@
         where productID = #{productID,jdbcType=INTEGER}
         ORDER BY mainFlag DESC
     </select>
+    <select id="findImageByProductId" resultType="String">
+        select
+        image
+        from productimage
+        where productID = #{productID,jdbcType=INTEGER}
+        ORDER BY mainFlag DESC
+    </select>
+
     <select id="findProductImageString" resultType="string">
         select
         image
@@ -196,6 +204,11 @@
         </set>
         where id = #{id,jdbcType=BIGINT}
     </update>
+    <update id="updateViewingNum">
+        UPDATE cm_second_hand_detail SET
+        viewingNum = #{viewingNum}
+        WHERE id = #{id}
+    </update>
     <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
         insert into user_search_history
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -227,6 +240,67 @@
           </if>
         </trim>
     </insert>
+
+    <insert id="saveSencondHandProduct"  parameterType="com.caimei.module.base.entity.po.SeconHandProduct"  keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_second_hand_detail(
+			productID,
+			sold,
+			secondHandType,
+			instrumentType,
+			fixedYears,
+			maturityYears,
+			companyName,
+			detailTalkFlag,
+			originalPrice,
+			contactName,
+			contactMobile,
+			secondProductType,
+			townId,
+			brandName,
+			provinceCityDistrict,
+			address,
+			productQuality,
+			productDetails,
+			viewingNum,
+			payStatus,
+			payAmount,
+			payFormData,
+			payType,
+			payDate,
+			submitDate,
+			reviewedDate,
+			onLineDate
+		) VALUES (
+			#{productID},
+			#{sold},
+			#{secondHandType},
+			#{instrumentType},
+			#{fixedYears},
+			#{maturityYears},
+			#{companyName},
+			#{detailTalkFlag},
+			#{originalPrice},
+			#{contactName},
+			#{contactMobile},
+			#{secondProductType},
+			#{townId},
+			#{brandName},
+			#{provinceCityDistrict},
+			#{address},
+			#{productQuality},
+			#{productDetails},
+			#{viewingNum},
+			#{payStatus},
+			#{payAmount},
+			#{payFormData},
+			#{payType},
+			#{payDate},
+			#{submitDate},
+			#{reviewedDate},
+			#{onLineDate}
+		)
+    </insert>
+
     <!--删除大于10条的历史记录-->
     <delete id="deleteSearchHistoryByUserId">
         DELETE FROM user_search_history
@@ -237,6 +311,17 @@
             ) AS temp
         )
     </delete>
+
+    <select id="getAddressInfo" resultType="com.caimei.module.base.entity.vo.AddressVo">
+		SELECT a.name as "province"
+		,b.name as "city"
+		,c.name as "town"
+		,c.townId as "townID"
+		FROM province a
+			RIGHT JOIN city b ON a.provinceId = b.provinceId
+			RIGHT JOIN town c ON b.cityId = c.cityId WHERE c.townId = #{townId}
+	</select>
+
     <delete id="deleteAllSearchHistory">
         DELETE FROM
             user_search_history
@@ -279,4 +364,79 @@
         order by sellNumber desc,onlineTime desc
         limit 7
     </select>
+
+
+    <select id="getSeconHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
+        SELECT
+	        IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,cb.*,cshd.*
+        FROM
+            product p
+        LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
+        left join cm_brand cb on cb.id = p.brandID
+        WHERE
+            p.productCategory = 2
+        AND p.validFlag = 2
+        <if test="secondHandType != null and secondHandType != ''">
+            and cshd.secondHandType = #{secondHandType}
+        </if>
+        <if test="instrumentType != null and instrumentType != '' and instrumentType != '0'  and instrumentType != 0">
+            and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
+        </if>
+        ORDER BY cshd.onLineDate DESC
+    </select>
+    <select id="getSencondHandProductDetail" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
+        SELECT
+            IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",p.*,cb.*,cshd.*,cb.description as "brandInfo"
+        FROM
+            product p
+            LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
+        left join cm_brand cb on cb.id = p.brandID
+        WHERE
+            p.productCategory = 2
+        AND p.productID = #{productId}
+    </select>
+    <select id="getBrandList" resultType="com.caimei.module.base.entity.po.CmBrand">
+        select b.id AS id, b.name AS name from cm_brand b
+		where b.status = '1' and b.delFlag = '0' and b.description is not null and b.description != '' and b.id not in (161)
+		order by b.sort
+    </select>
+
+    <select id="getSecondHandProductRecommend" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
+        select * from cm_second_hand_recommend cshr LEFT JOIN product p on cshr.secondHandProductID = p.productID where cshr.delFlag = 0 and p.validFlag = 2 and  cshr.secondHandProductID = #{productId};
+    </select>
+
+    <select id="getOrderSecondHandProductList" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
+        SELECT
+            *
+        FROM
+            product p
+        LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = p.productID
+        WHERE
+            p.productCategory = 2 and p.validFlag = 2
+            <if test="secondHandType != null and secondHandType != ''">
+            and cshd.secondHandType = #{secondHandType}
+            </if>
+            <if test="instrumentType != null and instrumentType != ''">
+            and cshd.instrumentType  like CONCAT('%',#{instrumentType},'%')
+            </if>
+            <if test="searchKeyword != null and searchKeyword != ''">
+            and p.name like CONCAT('%',#{searchKeyword},'%')
+            </if>
+            ORDER BY cshd.onLineDate DESC
+    </select>
+    <select id="getSeconHandProductByLimit" resultType="com.caimei.module.base.entity.po.SeconHandProduct">
+        SELECT
+	        *
+        FROM
+            product p
+        LEFT JOIN cm_second_hand_detail cshd ON p.productID = cshd.productID
+        WHERE
+            p.productCategory = 2
+        AND p.validFlag = 2
+        <if test="secondHandType != null and secondHandType != ''">
+            and cshd.secondHandType = #{secondHandType}
+        </if>
+        ORDER BY cshd.onLineDate DESC
+        limit 10
+    </select>
 </mapper>