瀏覽代碼

Merge remote-tracking branch 'origin/master'

zhaoxian 2 年之前
父節點
當前提交
d273065b03

+ 3 - 3
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemCollectSamplesController.java

@@ -163,11 +163,11 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             if (Check.isNull(itemIds)) {
                 throw new Exception("请传入需要申请的商品列表");
             }
-            JSONArray promoterIds = requestJson.getJSONArray("promoterIds");
-            if (Check.isNull(promoterIds)) {
+            JSONArray ids = requestJson.getJSONArray("ids");
+            if (Check.isNull(ids)) {
                 throw new Exception("请传入需要申请的达人列表");
             }
-            JSONObject previewJson = kuaishouItemCollectSamplesService.preview(userId, sysUser.getNickName(), itemIds, promoterIds);
+            JSONObject previewJson = kuaishouItemCollectSamplesService.preview(userId, sysUser.getNickName(), itemIds, ids);
             returnJson.put("code", 0);
             returnJson.put("message", "success");
             returnJson.put("preview", previewJson);

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouItemCollectSamplesMapper.java

@@ -69,7 +69,7 @@ public interface KuaishouItemCollectSamplesMapper {
 
     List<JSONObject> getItemList(@Param("itemIds") JSONArray itemIds);
 
-    List<JSONObject> promoterList(@Param("promoterIds") JSONArray promoterIds);
+    List<JSONObject> promoterList(@Param("ids") JSONArray ids);
 
     Integer check(@Param("itemId") Long itemId, @Param("promoterId") Long promoterId);
 

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouItemCollectSamplesService.java

@@ -66,7 +66,7 @@ public interface IKuaishouItemCollectSamplesService {
     int deleteKuaishouItemCollectSamplesById(Long id);
 
 
-    JSONObject preview(Long userId, String nickName, JSONArray itemIds, JSONArray promoterIds);
+    JSONObject preview(Long userId, String nickName, JSONArray itemIds, JSONArray ids);
 
     void batchAdd(JSONArray temCollectSamples);
 

+ 13 - 7
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -152,8 +152,9 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
         return kuaishouItemCollectSamplesMapper.deleteKuaishouItemCollectSamplesById(id);
     }
 
+
     @Override
-    public JSONObject preview(Long userId, String nickName, JSONArray itemIds, JSONArray promoterIds) {
+    public JSONObject preview(Long userId, String nickName, JSONArray itemIds, JSONArray ids) {
         JSONObject previewJson = new JSONObject();
         List<JSONObject> itemList = kuaishouItemCollectSamplesMapper.getItemList(itemIds);
         Map<Long, JSONObject> itemMap = new HashMap<>();
@@ -162,18 +163,23 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             itemMap.put(itemJson.getLong("itemId"), itemJson);
         }
         Map<Long, JSONObject> promoterMap = new HashMap<>();
-        List<JSONObject> promoterList = kuaishouItemCollectSamplesMapper.promoterList(promoterIds);
+        List<JSONObject> promoterList = kuaishouItemCollectSamplesMapper.promoterList(ids);
         for (int i = 0; i < promoterList.size(); i++) {
             JSONObject promoterJson = promoterList.get(i);
-            promoterMap.put(promoterJson.getLong("promoterId"), promoterJson);
+            promoterMap.put(promoterJson.getLong("id"), promoterJson);
         }
         Integer sampleReceivedCount = 0;
         List<JSONObject> samples = new ArrayList<>();
         for (int i = 0; i < itemIds.size(); i++) {
             Long itemId = itemIds.getLong(i);
             JSONObject itemJson = itemMap.get(itemId);
-            for (int j = 0; j < promoterIds.size(); j++) {
-                Long promoterId = promoterIds.getLong(j);
+            for (int j = 0; j < ids.size(); j++) {
+                Long id = ids.getLong(j);
+                JSONObject promoterJson = promoterMap.get(id);
+                if(Check.isNull(promoterJson)){
+                    continue;
+                }
+                Long promoterId = promoterJson.getLong("promoterId");
                 Integer count = kuaishouItemCollectSamplesMapper.check(itemId, promoterId);
                 if (count > 0) {
                     sampleReceivedCount++;
@@ -190,8 +196,8 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
                 sampleJson.put("itemCreateName", itemJson.getString("userName"));
                 sampleJson.put("collectSampleId", userId);
                 sampleJson.put("collectSampleName", nickName);
-                JSONObject promoterJson = promoterMap.get(promoterId);
-                sampleJson.put("promoterId", promoterJson.getLong("promoterId"));
+              
+                sampleJson.put("promoterId", promoterId);
                 sampleJson.put("promoterNickName", promoterJson.getString("promoterNickName"));
                 sampleJson.put("promoterPhone", promoterJson.getString("promoterPhone"));
                 sampleJson.put("promoterAddress", promoterJson.getString("promoterAddress"));

+ 6 - 6
ruixuan-live/src/main/resources/mapper/isc/KuaishouItemCollectSamplesMapper.xml

@@ -174,22 +174,22 @@
     <select id="promoterList" resultType="com.alibaba.fastjson.JSONObject"
             parameterType="com.alibaba.fastjson.JSONArray">
         select
+        id as 'id',
         promoter_id as 'promoterId',
         promoter_nick_name as 'promoterNickName',
         promoter_url as 'promoterUrl',
-        consignee,
+        consignee as 'consignee',
         promoter_address as 'promoterAddress',
         phone as 'promoterPhone'
         from kuaishou_promoter
         where 1 =1
-        <if test='promoterIds != null and promoterIds.size() > 0'>
-            AND promoter_id in
-            <foreach collection="promoterIds" item="promoterId" separator=","
+        <if test='ids != null and ids.size() > 0'>
+            AND id in
+            <foreach collection="ids" item="id" separator=","
                      open="(" close=")">
-                #{promoterId}
+                #{id}
             </foreach>
         </if>
-        group by promoter_id
     </select>
     <select id="check" resultType="java.lang.Integer">
         select count(1)