123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- package restcontroller.webmanage.saletool.sharematerial;
- import beans.attachment.Attachment;
- import beans.datacontrllog.DataContrlLog;
- import beans.itemclass.ItemClass;
- import beans.parameter.Parameter;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.API;
- import common.data.*;
- import org.apache.commons.lang.StringUtils;
- import restcontroller.R;
- import restcontroller.webmanage.saletool.fad.FadHelper;
- import java.util.ArrayList;
- /**
- * 效果图管理
- */
- public class Renderings extends Controller {
- /**
- * 构造函数
- *
- * @param content
- */
- public Renderings(JSONObject content) throws YosException {
- super(content);
- }
- String sat_sharematerial = "sat_sharematerial";
- @API(title = "效果图新增或编辑", apiversion = R.ID20240415164202.v1.class)
- public String insertOrUpdate() throws YosException {
- Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
- if (sat_sharematerialid <= 0) {
- sat_sharematerialid = createTableID(sat_sharematerial);
- InsertSQL sqlFactory = SQLFactory.createInsertSQL(this, sat_sharematerial);
- sqlFactory.setSiteid(siteid);
- sqlFactory.setUniqueid(sat_sharematerialid);
- sqlFactory.setValue("classid", 4);
- sqlFactory.setValue("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.setValue("title", content.getStringValue("title"));
- sqlFactory.setValue("subtitle", content.getStringValue("subtitle"));
- sqlFactory.setValue("notes", content.getStringValue("notes"));
- sqlFactory.setValue("panoramaurl", content.getStringValue("panoramaurl", true));
- sqlFactory.setValue("renderingstype", content.getStringValue("renderingstype"));
- sqlFactory.setValue("renderingsclass", content.getJSONObject("renderingsclass"));
- sqlFactory.setValue("isapplet", content.getBooleanValue("isapplet"));
- sqlFactory.setValue("isbussinesspic", content.getBooleanValue("isbussinesspic"));
- sqlFactory.setValue("sequence", content.getLongValue("sequence"));
- sqlFactory.setValue("readcount_start", content.getLongValue("readcount_start"));
- sqlFactory.insert();
- content.put("sat_sharematerialid", sat_sharematerialid);
- DataContrlLog.createLog(this, "sat_sharematerial", sat_sharematerialid, "新建", "新建效果图 " + content.getStringValue("title")).insert();
- } else {
- UpdateSQL sqlFactory = SQLFactory.createUpdateSQL(this, sat_sharematerial);
- sqlFactory.setUniqueid(sat_sharematerialid);
- sqlFactory.setSiteid(siteid);
- sqlFactory.setValue("title", content.getStringValue("title"));
- sqlFactory.setValue("subtitle", content.getStringValue("subtitle"));
- sqlFactory.setValue("notes", content.getStringValue("notes"));
- sqlFactory.setValue("panoramaurl", content.getStringValue("panoramaurl", true));
- sqlFactory.setValue("renderingstype", content.getStringValue("renderingstype"));
- sqlFactory.setValue("renderingsclass", content.getJSONObject("renderingsclass"));
- sqlFactory.setValue("isapplet", content.getBooleanValue("isapplet"));
- sqlFactory.setValue("isbussinesspic", content.getBooleanValue("isbussinesspic"));
- sqlFactory.setValue("sequence", content.getLongValue("sequence"));
- sqlFactory.setValue("readcount_start", content.getLongValue("readcount_start"));
- sqlFactory.update();
- DataContrlLog.createLog(this, "sat_sharematerial", sat_sharematerialid, "编辑", "编辑效果图 " + content.getStringValue("title")).insert();
- }
- Row row = new Row();
- row.put("sat_sharematerialid", sat_sharematerialid);
- return getSucReturnObject().setData(row).toString();
- }
- @API(title = "效果图详情", apiversion = R.ID20240415164302.v1.class, accesstoken = false)
- public String detail() throws YosException {
- Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
- String ownertable = "sat_sharematerial";
- Rows sharematerialrows = dbConnect.runSqlQuery("select * from sat_sharematerial where sat_sharematerialid=" + sat_sharematerialid);
- if (sharematerialrows.isNotEmpty()) {
- siteid = sharematerialrows.get(0).getString("siteid");
- }
- dbConnect.runSqlUpdate("UPDATE sat_sharematerial SET readcount=readcount+1 WHERE sat_sharematerialid=" + sat_sharematerialid);
- QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial")
- .setTableAlias("t1");
- querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t2", "t2.siteid=t1.siteid and t2.ownertable='sat_sharematerial' and t2.type=1 and t2.ownerid=t1.sat_sharematerialid and t2.userid='" + userid + "'");
- querySQ.addQueryFields("iscollect", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
- querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
- Rows rows = querySQ.query();
- Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
- Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
- attRows.sortby("sequence", "linksid");
- detailRow.put("attinfos", attRows);
- detailRow.putIfAbsent("checkdate", "");
- detailRow.put("appleturl", userInfo.getWechatAppPage("marketingtool", "CaseImgsUrl") + sat_sharematerialid);
- if (StringUtils.isBlank(detailRow.getString("panoramaurl"))) {
- detailRow.put("ispanorama", 0);
- } else {
- detailRow.put("ispanorama", 1);
- }
- if (detailRow.getString("title").equals("")) {
- detailRow.put("title", detailRow.getString("title_c"));
- }
- QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
- attachmentQuery.setSiteid(detailRow.getString("siteid"));
- attachmentQuery.setWhere("ownertable", ownertable);
- attachmentQuery.setWhere("ownerid", sat_sharematerialid);
- attachmentQuery.setWhere("usetype", ownertable);
- attachmentQuery.setOrderBy("t1.sequence,t1.linksid");
- Rows attachmentRows = attachmentQuery.query();
- ArrayList<Long> ids = attachmentRows.toArrayList("attachmentid", new ArrayList<>());
- RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
- for (Row row : attachmentRows) {
- Rows attPicRows = new Rows();
- Rows tempAttRows = attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows());
- for (Row tempAttRow : tempAttRows) {
- // if (tempAttRow.getString("usetype").equals(ownertable)) {
- attPicRows.add(tempAttRow);
- // }
- }
- row.put("attinfos", attPicRows);
- }
- detailRow.put("attinfos_pic", attachmentRows);
- return getSucReturnObject().setData(detailRow).toString();
- }
- @API(title = "效果图列表", apiversion = R.ID20240415164402.v1.class)
- public String list() throws YosException {
- /*
- 过滤条件设置
- */
- StringBuffer where = new StringBuffer(" 1=1 ");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where.append(" and (");
- where.append("t1.title like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
- where.append(" and (");
- where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
- where.append(")");
- }
- if (whereObject.containsKey("begindate_create") && !"".equals(whereObject.getString("begindate_create"))) {
- where.append(" and (");
- where.append("t1.createdate >='").append(whereObject.getString("begindate_create")).append("' ");
- where.append(")");
- }
- if (whereObject.containsKey("enddate_create") && !"".equals(whereObject.getString("enddate_create"))) {
- where.append(" and (");
- where.append("t1.createdate <='").append(whereObject.getString("enddate_create")).append(" 23:59:59' ");
- where.append(")");
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where.append(" and (");
- where.append("t1.checkdate >='").append(whereObject.getString("begindate")).append("' ");
- where.append(")");
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where.append(" and (");
- where.append("t1.checkdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
- where.append(")");
- }
- if (whereObject.containsKey("ispanorama") && !"".equals(whereObject.getString("ispanorama"))) {
- if (whereObject.getString("ispanorama").equals("1")) {
- where.append(" and (");
- where.append("LENGTH(t1.panoramaurl)>0 ");
- where.append(")");
- } else {
- where.append(" and (");
- where.append("LENGTH(t1.panoramaurl)=0 or t1.panoramaurl is null ");
- where.append(")");
- }
- }
- if (whereObject.containsKey("renderingstype") && !"".equals(whereObject.getString("renderingstype"))) {
- where.append(" and (");
- where.append("t1.renderingstype ='").append(whereObject.getString("renderingstype")).append("' ");
- where.append(")");
- }
- if (whereObject.containsKey("style") && !"".equals(whereObject.getString("style"))) {
- where.append(" and (");
- where.append("JSON_CONTAINS(t1.renderingsclass->'$.style', '\"" + whereObject.getString("style") + "\"')");
- where.append(")");
- }
- if (whereObject.containsKey("space") && !"".equals(whereObject.getString("space"))) {
- where.append(" and (");
- where.append("JSON_CONTAINS(t1.renderingsclass->'$.space', '\"" + whereObject.getString("space") + "\"')");
- where.append(")");
- }
- if (whereObject.containsKey("spec") && !"".equals(whereObject.getString("spec"))) {
- where.append(" and (");
- where.append("JSON_CONTAINS(t1.renderingsclass->'$.spec', '\"" + whereObject.getString("spec") + "\"')");
- where.append(")");
- }
- if (whereObject.containsKey("iscollect") && !"".equals(whereObject.getString("iscollect"))) {
- if (whereObject.getString("iscollect").equals("1")) {
- where.append(" and (");
- where.append(" t1.sat_sharematerialid in (SELECT ownerid from sys_datacollect WHERE ownertable='sat_sharematerial' and type=1 and siteid='" + siteid + "' and userid=" + userid + ")");
- where.append(")");
- }
- }
- }
- QuerySQL sqlFactory = SQLFactory.createQuerySQL(this, sat_sharematerial,
- "sat_sharematerialid", "title", "status", "renderingstype", "readcount", "readcount_start", "sequence", "createdate", "checkdate", "renderingsclass", "panoramaurl")
- .setTableAlias("t1");
- sqlFactory.setSiteid(siteid);
- sqlFactory.setWhere("classid", 4);
- sqlFactory.setWhere(where.toString());
- sqlFactory.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
- Rows rows = sqlFactory.query();
- ArrayList<Long> ids = rows.toArrayList("sat_sharematerialid", new ArrayList<>());
- // 附件
- RowsMap RowsMap = getAttachmentUrl(sat_sharematerial, ids);
- for (Row row : rows) {
- Rows Rows = RowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
- row.put("attinfos", Rows);
- row.putIfAbsent("checkdate", "");
- if (StringUtils.isBlank(row.getString("panoramaurl"))) {
- row.put("ispanorama", 0);
- } else {
- row.put("ispanorama", 1);
- }
- row.put("appleturl", userInfo.getWechatAppPage("marketingtool", "CaseImgsUrl") + row.getString("sat_sharematerialid"));
- }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "选择单品列表", apiversion = R.ID20240419135702.v1.class)
- public String chooseFadList() throws YosException {
- StringBuffer where = new StringBuffer(" 1=1 ");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where.append(" and(");
- where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.model like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.spec like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_fad"
- , "sa_fadid", "name", "model", "spec", "price", "onsaledate");
- querySQL.setTableAlias("t1");
- querySQL.setWhere("t1.siteid", siteid);
- querySQL.setWhere(where.toString());
- querySQL.setWhere("not exists(select 1 from sat_sharematerial_link where sat_sharematerialid=" + sat_sharematerialid + " and sa_fadid=t1.sa_fadid and siteid='" + siteid + "' )");
- querySQL.setOrderBy(pageSorting);
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- ArrayList<Long> ids = rows.toArrayList("sa_fadid", new ArrayList<>());
- // 附件
- RowsMap RowsMap = getAttachmentUrl("sa_fad", ids);
- for (Row row : rows) {
- Rows Rows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
- row.put("attinfos", Rows);
- row.putIfAbsent("onsaledate", "");
- }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "关联单品列表", apiversion = R.ID20240419135802.v1.class)
- public String relateFadList() throws YosException {
- StringBuffer where = new StringBuffer(" 1=1 ");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where.append(" and(");
- where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.model like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.spec like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_fad"
- , "sa_fadid", "name", "model", "spec", "price", "onsaledate");
- querySQL.addJoinTable(JOINTYPE.inner, "sat_sharematerial_link", "t2", "t2.sa_fadid=t1.sa_fadid", "sat_sharematerial_linkid");
- querySQL.setTableAlias("t1");
- querySQL.setWhere("t2.sat_sharematerialid", sat_sharematerialid);
- querySQL.setWhere("t1.siteid", siteid);
- querySQL.setWhere(where.toString());
- querySQL.setOrderBy(pageSorting);
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- ArrayList<Long> ids = rows.toArrayList("sa_fadid", new ArrayList<>());
- // 附件
- RowsMap RowsMap = getAttachmentUrl("sa_fad", ids);
- for (Row row : rows) {
- Rows Rows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
- row.put("attinfos", Rows);
- row.putIfAbsent("onsaledate", "");
- }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "关联单品", apiversion = R.ID20240419135902.v1.class)
- public String relateFad() throws YosException {
- Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
- JSONArray sa_fadids = content.getJSONArray("sa_fadids");
- ArrayList<String> sqlList = new ArrayList<>();
- for (Object obj : sa_fadids) {
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_sharematerial_link");
- insertSQL.setSiteid(siteid);
- insertSQL.setUniqueid(createTableID("sat_sharematerial_link"));
- insertSQL.setValue("sa_fadid", obj);
- insertSQL.setValue("sat_sharematerialid", sat_sharematerialid);
- sqlList.add(insertSQL.getSQL());
- }
- dbConnect.runSqlUpdate(sqlList);
- return getSucReturnObject().toString();
- }
- @API(title = "删除单品", apiversion = R.ID20240419136002.v1.class)
- public String deleteFad() throws YosException {
- JSONArray sat_sharematerial_linkids = content.getJSONArray("sat_sharematerial_linkids");
- DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_sharematerial_link");
- deleteSQL.setSiteid(siteid);
- deleteSQL.setWhere("sat_sharematerial_linkid", sat_sharematerial_linkids);
- deleteSQL.delete();
- return getSucReturnObject().toString();
- }
- @API(title = "选择产品(单品,效果图,设计实景图)", apiversion = R.ID20240420095702.v1.class)
- public String getFadUrl() throws YosException {
- int type = content.getIntValue("type");
- StringBuffer where = new StringBuffer(" 1=1 ");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where.append(" and(");
- if (type == 3) {
- where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
- } else {
- where.append("t1.title like'%").append(whereObject.getString("condition")).append("%' ");
- }
- where.append(")");
- }
- }
- QuerySQL querySQL = null;
- //单品
- if (type == 1) {
- querySQL = SQLFactory.createQuerySQL(this, "sat_sharematerial"
- , "sat_sharematerialid", "title").setTableAlias("t1");
- querySQL.setWhere("classid", 4);
- querySQL.setWhere("status='发布'");
- } else if (type == 2) {
- querySQL = SQLFactory.createQuerySQL(this, "sat_sharematerial"
- , "sat_sharematerialid", "title").setTableAlias("t1");
- querySQL.setWhere("classid", 5);
- querySQL.setWhere("status='发布'");
- } else {
- querySQL = SQLFactory.createQuerySQL(this, "sa_fad"
- , "sa_fadid").setTableAlias("t1");
- querySQL.addQueryFields("title", "name");
- querySQL.setWhere("isonsale=1");
- }
- querySQL.setWhere(where.toString());
- querySQL.setSiteid(siteid);
- querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
- Rows rows = querySQL.query();
- RowsMap rowsMap;
- if (type == 3) {
- rowsMap = getAttachmentUrl("sa_fad", rows.toArrayList("sa_fadid", new ArrayList<>()), "sa_fad");
- } else {
- rowsMap = getAttachmentUrl("sat_sharematerial", rows.toArrayList("sat_sharematerialid", new ArrayList<>()), "sat_sharematerial");
- }
- for (Row row : rows) {
- if (type == 1) {
- row.put("appleturl", userInfo.getWechatAppPage("marketingtool", "CaseImgsUrl") + row.getString("sat_sharematerialid"));
- Rows Rows = rowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
- row.put("attinfos", Rows);
- }
- if (type == 2) {
- row.put("appleturl", userInfo.getWechatAppPage("marketingtool", "DesignImgsUrl") + row.getString("sat_sharematerialid"));
- Rows Rows = rowsMap.getOrDefault(row.getString("sat_sharematerialid"), new Rows());
- row.put("attinfos", Rows);
- }
- if (type == 3) {
- row.put("appleturl", userInfo.getWechatAppPage("marketingtool", "FadUrl") + row.getString("sa_fadid"));
- Rows Rows = rowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
- row.put("attinfos", Rows);
- }
- }
- return getSucReturnObject().setData(rows).toString();
- }
- }
|