|
@@ -3,10 +3,13 @@ package restcontroller.webmanage.sale.promotion;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
import beans.accountbalance.Accountbalance;
|
|
|
import beans.accountbalance.CashbillEntity;
|
|
|
+import beans.itemclass.ItemClass;
|
|
|
+import common.BaseClass;
|
|
|
import common.data.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
@@ -144,6 +147,122 @@ public class promotion extends Controller {
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "促销方案商品上下架", apiversion = R.ID2024052710133903.v1.class)
|
|
|
+ public String releases() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ JSONArray itemids = content.getJSONArray("itemids");
|
|
|
+ boolean isonsale = content.getBooleanValue("isonsale");
|
|
|
+ List<Long> list = itemids.toJavaList(Long.class);
|
|
|
+ list.add(0l);
|
|
|
+ Long[] stringArray = list.toArray(new Long[0]);
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "商品组上架");
|
|
|
+ if(isonsale){
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案商品上架_通过商品");
|
|
|
+ }else{
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案商品下架_通过商品");
|
|
|
+ }
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter_in("itemids", stringArray);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+// //发送消息
|
|
|
+// for (String id : stringArray) {
|
|
|
+// sendMsg(Long.parseLong(id));
|
|
|
+// }
|
|
|
+ String sql = "select t1.itemid,t1.orderminqty,t1.orderaddqty,t1.itemname,t2.sa_promotionid from plm_item t1 inner join sa_promotion_items t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t2.itemid in " + itemids;
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ Rows itemrows = dbConnect.runSqlQuery(sql);
|
|
|
+ for (Row row :itemrows){
|
|
|
+ if(isonsale){
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", row.getLong("sa_promotionid"), "促销方案商品【"+row.getString("itemname")+"】由"+username+"上架", "促销方案商品上下架").getSQL());
|
|
|
+ }else{
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", row.getLong("sa_promotionid"), "促销方案商品【"+row.getString("itemname")+"】由"+username+"下架" , "促销方案商品上下架").getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询所有促销方案商品列表", apiversion = R.ID2024052710185203.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryItemList() 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.itemno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.itemname 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("or t1.standards like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.color like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isonsale") && !"".equals(whereObject.getString("isonsale"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.isonsale ='").append(whereObject.getString("isonsale")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isservice") && !"".equals(whereObject.getString("isservice"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.isservice ='").append(whereObject.getString("isservice")).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("isonsalebutnotingroup") && !"".equals(whereObject.getString("isonsalebutnotingroup"))) {
|
|
|
+ if (whereObject.getBooleanValue("isonsalebutnotingroup")) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.isonsale =1 and t1.itemid not in (select t1.itemid from sa_itemgroupmx t1 inner join sa_itemgroup t2 on t1.sa_itemgroupid=t2.sa_itemgroupid and t1.siteid=t2.siteid where t2.isonsale=1 )");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("hasprice") && !"".equals(whereObject.getString("hasprice"))) {
|
|
|
+ if (whereObject.getBooleanValue("hasprice")) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append(" exists(select * from sa_itemprice where sa_itemprice.siteid=t1.siteid and sa_itemprice.itemid=t1.itemid and price>0)");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("itemclassid") && !"".equals(whereObject.getString("itemclassid"))) {
|
|
|
+ ArrayList<Long> list = ItemClass.getSubItemClassIds(this, whereObject.getLong("itemclassid"));
|
|
|
+ list.add(whereObject.getLong("itemclassid"));
|
|
|
+ String sql = " and t1.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + list + " and siteid='" + siteid + "')";
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where.append(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("tradefield") && !whereObject.getString("tradefield").isEmpty()) {
|
|
|
+ where.append(" and exists(");
|
|
|
+ where.append(" select 1 from plm_item_tradefield t3 where t3.siteid=t1.siteid and t3.itemid=t1.itemid and t3.tradefield='").append(whereObject.getString("tradefield")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("itemclass") && !whereObject.getString("itemclass").isEmpty()) {
|
|
|
+ String itemclass = whereObject.getString("itemclass");
|
|
|
+
|
|
|
+ where.append(" and t1.itemid in (");
|
|
|
+ where.append(" SELECT t1.itemid FROM sa_itemsaleclass t1 INNER JOIN plm_itemclass t2 ON t2.itemclassid=t1.itemclassid AND t2.siteid=t1.siteid WHERE t2.itemclassname LIKE '%" + itemclass + "%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "plm_item");
|
|
|
+ querySQL.addJoinTable(BaseClass.JOINTYPE.inner, "(select DISTINCT t1.itemid,t1.siteid from sa_promotion_items t1 inner join sa_promotion t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid)", "t2", "t1.itemid=t2.itemid and t1.siteid=t2.siteid ");
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@API(title = "一键复制促销方案", apiversion = R.ID20230713101303.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {promotion.class, promotionSalearea.class, promotionAuth.class, promotionItems.class, promotionItemPrice.class})
|