浏览代码

团购后台接口

Longlin 5 年之前
父节点
当前提交
d8b4576342

+ 1 - 0
whepi-ui/templates/yeweihui/tgPublish.ftl

@@ -183,6 +183,7 @@
             tgGoods: goods,
             tgPrice: price,
             tgMinNum: minnum,
+            tgMaxNum: maxnum,
             endTime: end_time,
             deliverTime: deliver_time,
             tgPhoneNumber: phone_number,

+ 2 - 0
whepi-web/src/main/java/com/bofeng/dao/JmTuangouDao.java

@@ -20,6 +20,8 @@ public interface JmTuangouDao extends BaseMapper<JmTuangou> {
 
   List<JmTuangou> queryTuangouListByUserIdAndTitle(@Param("userId") Long userId, @Param("title") String title);
 
+  List<JmTuangou> whepiTuangoulist(@Param("userId") Long userId, @Param("uptownId") Long uptownId, @Param("queryProperties") String queryProperties, @Param("status") Long status);
+
   JmTuangou selectJmTuangouByJmId(@Param("JmId") Long JmId);
 
   Integer updateRemarkByJmId(@Param("JmId") Long JmId, @Param("remark") String remark);

+ 41 - 0
whepi-web/src/main/java/com/bofeng/service/JmTuangouService.java

@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -61,6 +62,38 @@ public class JmTuangouService {
     }
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public Integer whepiTuangouPublish(String uptownIds, JmTuangou jmTuangou) {
+
+        Integer success = 0;
+        List<String> uptownIdArray = Arrays.asList(uptownIds.split(","));
+        for (String uptownId : uptownIdArray) {
+
+            jmTuangou.setJmId(IdWorker.getId());
+
+            jmTuangou.setUptownId(Long.parseLong(uptownId));
+
+            jmTuangou.setTgStatus(1);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+            Date tgEndTime = new Date();
+            Date tgDeliverTime = new Date();
+            try {
+                tgEndTime = sdf.parse(jmTuangou.getEndTime());
+                tgDeliverTime = sdf.parse(jmTuangou.getDeliverTime());
+            }
+            catch (ParseException e) {
+                e.printStackTrace();
+            }
+
+            jmTuangou.setTgEndTime(tgEndTime);
+            jmTuangou.setTgDeliverTime(tgDeliverTime);
+            success = jmTuangouDao.insert(jmTuangou);
+        }
+        return success;
+    }
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public List<JmTuangou> queryTuangouListByTitle(Long userId, String title) {
 
         buyService.updateStatus();
@@ -94,6 +127,14 @@ public class JmTuangouService {
     }
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public List<JmTuangou> whepiTuangoulist(Long userId, Long uptownId, String queryProperties, Long status) {
+
+        buyService.updateStatus();
+
+        return jmTuangouDao.whepiTuangoulist(userId, uptownId, queryProperties, status);
+    }
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public Integer updateRemarkByJmId(Long jmId, Long status, String remark) {
         if (status == 0) {
             return jmTuangouDao.updateRemarkByJmId(jmId, remark);

+ 4 - 4
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -64,10 +64,10 @@ public class UserOpenController {
                              @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType) throws JsonProcessingException {
         List<UserRole> list = new ArrayList<>();
         if (userId == 0) {
-            UserOpen userOpen = homeService.getUserOpen();
-            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
-//            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
-//            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
+//            UserOpen userOpen = homeService.getUserOpen();
+//            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
+            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
+            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
             userId = userOpen.getUserId();
             model.put("user", userOpen);
             model.put("user_id", "\"" + userOpen.getUserId() + "\"");

+ 21 - 4
whepi-web/src/main/java/com/bofeng/wx/controller/YeWeiHuiController.java

@@ -20,10 +20,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletResponse;
@@ -368,6 +365,26 @@ public class YeWeiHuiController {
         }
     }
 
+    @PostMapping("/whepi/yeweihui/tglist")
+    public Model whepiTuangoulist(@Pd(name = "userId") Long userId, @Pd(name = "uptownId", required = false) Long uptownId, @Pd(name = "queryProperties", required = false) String queryProperties, @Pd(name = "status", required = false) Long status) {
+
+        List<JmTuangou> myList = jmTuangouService.whepiTuangoulist(userId, uptownId, queryProperties, status);
+
+        return Model.newSuccess(myList);
+    }
+
+    @PostMapping("/whepi/yeweihui/tgPublish")
+    public Model whepiTuangouPublish(@Pd(name = "uptownIds") String uptownIds, JmTuangou jmTuangou) {
+
+        Integer success = jmTuangouService.whepiTuangouPublish(uptownIds, jmTuangou);
+        if (success == 1) {
+            return Model.newSuccess("操作成功");
+        }
+        else {
+            return Model.newFail("操作失败");
+        }
+    }
+
     @PostMapping("/yeweihui/tuangou/list/query.json")
     public Model queryTuangouListByTitle(@Pd(name = "userId") Long userId, @Pd(name = "title", required = false) String title) {
 

+ 1 - 1
whepi-web/src/main/resources/application.yml

@@ -43,7 +43,7 @@ endpoints:
 #  whitelabel.enabled: false
 
 spring:
-  profiles.active: guojing
+  profiles.active: lll
 
   application:
     name: bofeng-web

+ 18 - 0
whepi-web/src/main/resources/mapper/JmTuangouMapper.xml

@@ -30,6 +30,24 @@
         order by a.tg_end_time desc
     </select>
 
+    <select id="whepiTuangoulist" resultType="com.bofeng.entity.JmTuangou">
+        select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
+        from jm_tuangou a
+        <where>
+            a.user_id=#{userId}
+            <if test="uptownId!=null and uptownId!=''">
+                and a.uptown_id=#{uptownId}
+            </if>
+            <if test="queryProperties!=null and queryProperties!=''">
+                and a.tg_title like concat('%',#{queryProperties},'%')
+            </if>
+            <if test="status!=null and status!=''">
+                and a.tg_status=#{status}
+            </if>
+        </where>
+        order by a.tg_end_time desc
+    </select>
+
     <select id="selectJmTuangouByJmId" resultType="com.bofeng.entity.JmTuangou">
         select a.*, IFNULL((select SUM(b.buy_count) FROM jm_buy b where b.jm_id=a.jm_id and buy_status=1),0) as currentNum
         from jm_tuangou a