Browse Source

商品新增或编辑bug修复

eganwu 1 year ago
parent
commit
d5d9e6ddff
1 changed files with 17 additions and 2 deletions
  1. 17 2
      src/custom/restcontroller/webmanage/saletool/fad/FadGoods.java

+ 17 - 2
src/custom/restcontroller/webmanage/saletool/fad/FadGoods.java

@@ -76,6 +76,8 @@ public class FadGoods extends Controller {
             }
             //允许经销商调整,数据是总部的,修改方为经销商
             else if (temp_canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid > 0) {
+                Rows attachmentRows = Attachment.get(this, "sa_fadid", sa_fadid);
+
                 parentid = sa_fadid;
                 sa_fadid = createTableID(sa_fad);
                 InsertSQL sqlFactory = FadHelper.getFadInsertSQL(this, sa_fadid, parentid);
@@ -88,6 +90,19 @@ public class FadGoods extends Controller {
                 listSQL.add(DataAuthHelper.getDataAuthInsertSQL(this, sys_dataauthid).getSQL());
                 listSQL.add(DataAuthHelper.getDataAuthsInsertSQL(this, "sys_enterpriseid", sys_enterpriseid).getSQL());
 
+                for (Row attachmentRow : attachmentRows) {
+                    InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_attachment_links");
+                    insertSQL.setSiteid(siteid);
+                    insertSQL.setUniqueid(createTableID("sys_attachment_links"));
+                    insertSQL.setValue("usetype", attachmentRow.getString("usetype"));
+                    insertSQL.setValue("attachmentid", attachmentRow.getLong("attachmentid"));
+                    insertSQL.setValue("sequence", 1);
+                    insertSQL.setValue("ownertable", sa_fad);
+                    insertSQL.setValue("ownerid", sa_fadid);
+                    insertSQL.setWhere("not exists(select 1 from  sys_attachment_links where attachmentid=" + attachmentRow.getLong("attachmentid") + " and ownertable='sa_fad' and siteid='" + siteid + "' and ownerid=" + sa_fadid + " )");
+                    listSQL.add(insertSQL.getSQL());
+                }
+
             } else {
                 UpdateSQL sqlFactory = FadHelper.getFadUpdateSQL(this, sa_fadid);
                 listSQL.add(sqlFactory.getSQL());
@@ -138,7 +153,7 @@ public class FadGoods extends Controller {
         Rows attRows = getAttachmentUrl(sa_fad, sa_fadid);
         attRows.sortby("sequence", "linksid");
         detailRow.put("attinfos", attRows);
-        detailRow.put("appleturl",userInfo.getWechatAppPage("marketingtool","FadGoodsUrl") + sa_fadid);
+        detailRow.put("appleturl", userInfo.getWechatAppPage("marketingtool", "FadGoodsUrl") + sa_fadid);
 
 
         QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
@@ -294,7 +309,7 @@ public class FadGoods extends Controller {
             Rows attRows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
             attRows.sortby("sequence", "linksid");
             row.put("attinfos", attRows);
-            row.put("appleturl", userInfo.getWechatAppPage("marketingtool","FadGoodsUrl") + row.getString("sa_fadid"));
+            row.put("appleturl", userInfo.getWechatAppPage("marketingtool", "FadGoodsUrl") + row.getString("sa_fadid"));
             row.putIfAbsent("onsaledate", "");
 
             ArrayList<String> tags = DataTag.queryTag(this, "sa_fad", row.getLong("sa_fadid"), true);