ソースを参照

商品评论回复功能

sunyinggang 6 年 前
コミット
4bbe33d799

+ 4 - 9
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminOrderService.java

@@ -229,7 +229,7 @@ public class AdminOrderService {
             return ResponseUtil.badArgument();
         }
         // 目前只支持回复一次
-        if (commentService.findById(commentId) != null) {
+        if (commentService.findById(commentId).getAdminContent().length() != 0) {
             return ResponseUtil.fail(ORDER_REPLY_EXIST, "订单商品已回复!");
         }
         String content = JacksonUtil.parseString(body, "content");
@@ -238,14 +238,9 @@ public class AdminOrderService {
         }
         // 创建评价回复
         LitemallComment comment = new LitemallComment();
-        comment.setType((byte) 2);
-        comment.setValueId(commentId);
-        comment.setContent(content);
-        comment.setUserId(0);                 // 评价回复没有用
-        comment.setStar((short) 0);           // 评价回复没有用
-        comment.setHasPicture(false);        // 评价回复没有用
-        comment.setPicUrls(new String[]{});  // 评价回复没有用
-        commentService.save(comment);
+        comment.setId(commentId);
+        comment.setAdminContent(content);
+        commentService.updateById(comment);
 
         return ResponseUtil.ok();
     }

+ 37 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/domain/LitemallComment.java

@@ -60,6 +60,15 @@ public class LitemallComment {
     /**
      *
      * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column litemall_comment.admin_content
+     *
+     * @mbg.generated
+     */
+    private String adminContent;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
      * This field corresponds to the database column litemall_comment.user_id
      *
      * @mbg.generated
@@ -218,6 +227,30 @@ public class LitemallComment {
 
     /**
      * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column litemall_comment.admin_content
+     *
+     * @return the value of litemall_comment.admin_content
+     *
+     * @mbg.generated
+     */
+    public String getAdminContent() {
+        return adminContent;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column litemall_comment.admin_content
+     *
+     * @param adminContent the value for litemall_comment.admin_content
+     *
+     * @mbg.generated
+     */
+    public void setAdminContent(String adminContent) {
+        this.adminContent = adminContent;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
      * This method returns the value of the database column litemall_comment.user_id
      *
      * @return the value of litemall_comment.user_id
@@ -412,6 +445,7 @@ public class LitemallComment {
         sb.append(", valueId=").append(valueId);
         sb.append(", type=").append(type);
         sb.append(", content=").append(content);
+        sb.append(", adminContent=").append(adminContent);
         sb.append(", userId=").append(userId);
         sb.append(", hasPicture=").append(hasPicture);
         sb.append(", picUrls=").append(picUrls);
@@ -445,6 +479,7 @@ public class LitemallComment {
             && (this.getValueId() == null ? other.getValueId() == null : this.getValueId().equals(other.getValueId()))
             && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
             && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
+            && (this.getAdminContent() == null ? other.getAdminContent() == null : this.getAdminContent().equals(other.getAdminContent()))
             && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
             && (this.getHasPicture() == null ? other.getHasPicture() == null : this.getHasPicture().equals(other.getHasPicture()))
             && (Arrays.equals(this.getPicUrls(), other.getPicUrls()))
@@ -468,6 +503,7 @@ public class LitemallComment {
         result = prime * result + ((getValueId() == null) ? 0 : getValueId().hashCode());
         result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
         result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
+        result = prime * result + ((getAdminContent() == null) ? 0 : getAdminContent().hashCode());
         result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
         result = prime * result + ((getHasPicture() == null) ? 0 : getHasPicture().hashCode());
         result = prime * result + (Arrays.hashCode(getPicUrls()));
@@ -557,6 +593,7 @@ public class LitemallComment {
         valueId("value_id", "valueId", "INTEGER", false),
         type("type", "type", "TINYINT", true),
         content("content", "content", "VARCHAR", false),
+        adminContent("admin_content", "adminContent", "VARCHAR", false),
         userId("user_id", "userId", "INTEGER", false),
         hasPicture("has_picture", "hasPicture", "BIT", false),
         picUrls("pic_urls", "picUrls", "VARCHAR", false),

+ 4 - 0
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java

@@ -97,4 +97,8 @@ public class LitemallCommentService {
     public LitemallComment findById(Integer id) {
         return commentMapper.selectByPrimaryKey(id);
     }
+
+    public int updateById(LitemallComment comment) {
+        return commentMapper.updateByPrimaryKeySelective(comment);
+    }
 }

+ 15 - 3
litemall-db/src/main/resources/org/linlinjava/litemall/db/dao/LitemallCommentMapper.xml

@@ -10,6 +10,7 @@
     <result column="value_id" jdbcType="INTEGER" property="valueId" />
     <result column="type" jdbcType="TINYINT" property="type" />
     <result column="content" jdbcType="VARCHAR" property="content" />
+    <result column="admin_content" jdbcType="VARCHAR" property="adminContent" />
     <result column="user_id" jdbcType="INTEGER" property="userId" />
     <result column="has_picture" jdbcType="BIT" property="hasPicture" />
     <result column="pic_urls" jdbcType="VARCHAR" property="picUrls" typeHandler="org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler" />
@@ -127,7 +128,7 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    id, value_id, `type`, content, user_id, has_picture, pic_urls, star, add_time, update_time, 
+    id, value_id, `type`, content, admin_content, user_id, has_picture, pic_urls, star, add_time, update_time,
     deleted
   </sql>
   <select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallCommentExample" resultMap="BaseResultMap">
@@ -249,11 +250,11 @@
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
       SELECT LAST_INSERT_ID()
     </selectKey>
-    insert into litemall_comment (value_id, `type`, content, 
+    insert into litemall_comment (value_id, `type`, content, admin_content,
       user_id, has_picture, pic_urls, 
       star, add_time, update_time, 
       deleted)
-    values (#{valueId,jdbcType=INTEGER}, #{type,jdbcType=TINYINT}, #{content,jdbcType=VARCHAR}, 
+    values (#{valueId,jdbcType=INTEGER}, #{type,jdbcType=TINYINT}, #{content,jdbcType=VARCHAR}, #{adminContent,jdbcType=VARCHAR},
       #{userId,jdbcType=INTEGER}, #{hasPicture,jdbcType=BIT}, #{picUrls,jdbcType=VARCHAR,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}, 
       #{star,jdbcType=SMALLINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
       #{deleted,jdbcType=BIT})
@@ -277,6 +278,9 @@
       <if test="content != null">
         content,
       </if>
+      <if test="adminContent != null">
+        admin_content,
+      </if>
       <if test="userId != null">
         user_id,
       </if>
@@ -361,6 +365,9 @@
       <if test="record.content != null">
         content = #{record.content,jdbcType=VARCHAR},
       </if>
+      <if test="record.adminContent != null">
+        admin_content = #{record.adminContent,jdbcType=VARCHAR},
+      </if>
       <if test="record.userId != null">
         user_id = #{record.userId,jdbcType=INTEGER},
       </if>
@@ -397,6 +404,7 @@
       value_id = #{record.valueId,jdbcType=INTEGER},
       `type` = #{record.type,jdbcType=TINYINT},
       content = #{record.content,jdbcType=VARCHAR},
+      admin_content = #{record.adminContent,jdbcType=VARCHAR},
       user_id = #{record.userId,jdbcType=INTEGER},
       has_picture = #{record.hasPicture,jdbcType=BIT},
       pic_urls = #{record.picUrls,jdbcType=VARCHAR,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler},
@@ -424,6 +432,9 @@
       <if test="content != null">
         content = #{content,jdbcType=VARCHAR},
       </if>
+      <if test="adminContent != null">
+        admin_content = #{adminContent,jdbcType=VARCHAR},
+      </if>
       <if test="userId != null">
         user_id = #{userId,jdbcType=INTEGER},
       </if>
@@ -457,6 +468,7 @@
     set value_id = #{valueId,jdbcType=INTEGER},
       `type` = #{type,jdbcType=TINYINT},
       content = #{content,jdbcType=VARCHAR},
+      admin_content = #{adminContent,jdbcType=VARCHAR},
       user_id = #{userId,jdbcType=INTEGER},
       has_picture = #{hasPicture,jdbcType=BIT},
       pic_urls = #{picUrls,jdbcType=VARCHAR,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler},

+ 1 - 0
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java

@@ -141,6 +141,7 @@ public class WxCommentController {
             Map<String, Object> commentVo = new HashMap<>();
             commentVo.put("addTime", comment.getAddTime());
             commentVo.put("content", comment.getContent());
+            commentVo.put("adminContent", comment.getAdminContent());
             commentVo.put("picList", comment.getPicUrls());
 
             UserInfo userInfo = userInfoService.getInfo(comment.getUserId());

+ 1 - 0
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGoodsController.java

@@ -128,6 +128,7 @@ public class WxGoodsController {
 				c.put("id", comment.getId());
 				c.put("addTime", comment.getAddTime());
 				c.put("content", comment.getContent());
+				c.put("adminContent", comment.getAdminContent());
 				LitemallUser user = userService.findById(comment.getUserId());
 				c.put("nickname", user == null ? "" : user.getNickname());
 				c.put("avatar", user == null ? "" : user.getAvatar());

+ 3 - 3
litemall-wx/pages/comment/comment.wxml

@@ -20,9 +20,9 @@
       <view class="imgs" wx:if="{{item.picList.length > 0}}">
         <image class="img" wx:for="{{item.picList}}" wx:key="*this" wx:for-item="pitem" src="{{pitem}}"></image>
       </view>
-      <view class="customer-service" wx:if="{{item.reply}}">
-        <text class="u">小商场回复:</text>
-        <text class="c">{{item.reply}}</text>
+      <view class="customer-service" wx:if="{{item.adminContent}}">
+        <text class="u">商家回复:</text>
+        <text class="c">{{item.adminContent}}</text>
       </view>
     </view>
 

+ 4 - 0
litemall-wx/pages/goods/goods.wxml

@@ -75,6 +75,10 @@
         <view class="imgs" wx:if="{{item.picList.length > 0}}">
           <image class="img" wx:for="{{item.picList}}" wx:key="*this" wx:for-item="iitem" src="{{iitem}} "></image>
         </view>
+        <view class="customer-service" wx:if="{{item.adminContent}}">
+          <text class="u">商家回复:</text>
+          <text class="c">{{item.adminContent}}</text>
+        </view>
       </view>
     </view>
   </view>

+ 21 - 0
litemall-wx/pages/goods/goods.wxss

@@ -321,6 +321,27 @@
   margin-bottom: 30rpx;
 }
 
+.comments .customer-service {
+  width: 690rpx;
+  height: auto;
+  overflow: hidden;
+  margin-top: 23rpx;
+  background: rgba(0, 0, 0, 0.03);
+  padding: 21rpx;
+}
+
+.comments .customer-service .u {
+  font-size: 24rpx;
+  color: #333;
+  line-height: 37.5rpx;
+}
+
+.comments .customer-service .c {
+  font-size: 24rpx;
+  color: #999;
+  line-height: 37.5rpx;
+}
+
 .goods-attr {
   width: 750rpx;
   height: auto;

+ 2 - 2
litemall-wx/project.config.json

@@ -10,8 +10,8 @@
 	},
 	"compileType": "miniprogram",
 	"libVersion": "2.4.0",
-	"appid": "wxa5b486c6b918ecfb",
-	"projectname": "litemall-wx",
+	"appid": "wx1cd22d00f1fac673",
+	"projectname": "litemall-wx-l",
 	"simulatorType": "wechat",
 	"simulatorPluginLibVersion": {},
 	"condition": {