|
@@ -59,6 +59,8 @@ public class promotion extends Controller {
|
|
|
Long associationaccountclassid = content.getLongValue("associationaccountclassid");
|
|
|
BigDecimal rebateratio = content.getBigDecimalValue("rebateratio");
|
|
|
String packagetype = content.getStringValue("packagetype");
|
|
|
+ boolean eachneedadd=content.getBooleanValue("eachneedadd");
|
|
|
+ Long eachlimitqty = content.getLongValue("eachlimitqty");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "促销方案新增");
|
|
|
|
|
|
if (sa_promotionid <= 0 || dbConnect
|
|
@@ -117,6 +119,8 @@ public class promotion extends Controller {
|
|
|
sqlFactory.addParameter("associationamount", associationamount);
|
|
|
sqlFactory.addParameter("associationaccountclassid", associationaccountclassid);
|
|
|
sqlFactory.addParameter("rebateratio", rebateratio);
|
|
|
+ sqlFactory.addParameter("eachneedadd", eachneedadd);
|
|
|
+ sqlFactory.addParameter("eachlimitqty", eachlimitqty);
|
|
|
|
|
|
// 备注说明
|
|
|
sqlFactory.addParameter("remarks", remarks);
|
|
@@ -527,7 +531,7 @@ public class promotion extends Controller {
|
|
|
Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
|
|
|
Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid,status,promnum,promname,type,associationaccountclassid,associationamount,packagetype from sa_promotion where sa_promotionid ='"
|
|
|
+ .runSqlQuery("select sa_promotionid,status,promnum,promname,type,associationaccountclassid,associationamount,packagetype,eachlimitqty from sa_promotion where sa_promotionid ='"
|
|
|
+ sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
Rows rowsdetails = dbConnect
|
|
|
.runSqlQuery("select t2.itemno,t2.itemname,ifnull(t1.orderminqty,0) orderminqty, ifnull(t1.orderaddqty,0) orderaddqty from sa_promotion_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_promotionid ='"
|
|
@@ -569,6 +573,9 @@ public class promotion extends Controller {
|
|
|
if(row.getLong("count")>100){
|
|
|
return getErrReturnObject().setErrMsg("套餐名:"+row.getString("packagetypemx")+" 商品添加数量已超上限(同一套餐最多只能添加100个商品)").toString();
|
|
|
}
|
|
|
+ if(row.getLong("count")<rows.get(0).getLong("eachlimitqty")){
|
|
|
+ return getErrReturnObject().setErrMsg("限购商品数大于"+row.getString("packagetypemx")+"套餐商品数,请调整后重试!").toString();
|
|
|
+ }
|
|
|
}
|
|
|
Rows promotioncountRows = dbConnect.runSqlQuery("select distinct groupqty/(ifnull(t1.orderminqty,1)) count from sa_promotion_items t1 where t1.siteid='"+siteid+"' and t1.sa_promotionid="+sa_promotionid);
|
|
|
if(promotioncountRows.size()>1){
|
|
@@ -856,4 +863,37 @@ public class promotion extends Controller {
|
|
|
return getSucReturnObject().setData(valueArray).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "判断套餐促销方案是否满足条件", apiversion = R.ID2024091213511703.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String jundgePackagetype() throws YosException {
|
|
|
+ long sa_promotionid =content.getLong("sa_promotionid");
|
|
|
+ JSONArray items =content.getJSONArray("items");
|
|
|
+ ArrayList<Long> sa_promotion_itemsids = new ArrayList<Long>();
|
|
|
+ sa_promotion_itemsids.add((long) 0);
|
|
|
+ for (Object obj : items) {
|
|
|
+ JSONObject item=(JSONObject)obj;
|
|
|
+ sa_promotion_itemsids.add(item.getLong("sa_promotion_itemsid"));
|
|
|
+ }
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_promotion where siteid='"+siteid+"' and type='套餐活动' and sa_promotionid="+sa_promotionid);
|
|
|
+ if(rows.isNotEmpty()){
|
|
|
+ int eachlimitqty=rows.get(0).getInteger("eachlimitqty");
|
|
|
+ if(rows.get(0).getBoolean("eachneedadd") && eachlimitqty>0){
|
|
|
+ String sql ="select ifnull(packagetypemx,'') packagetypemx,count(1) count from sa_promotion_items where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid +" and sa_promotion_itemsid in "+sa_promotion_itemsids +" group by ifnull(packagetypemx,'')";
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ Rows promotionItemsRows = dbConnect.runSqlQuery(sql);
|
|
|
+ for(Row row :promotionItemsRows){
|
|
|
+ if(StringUtils.isBlank(row.getString("packagetypemx"))){
|
|
|
+ return getErrReturnObject().setErrMsg("促销方案维护出错").toString();
|
|
|
+ }
|
|
|
+ if(eachlimitqty!=row.getInteger("count")){
|
|
|
+ return getErrReturnObject().setErrMsg(row.getString("packagetypemx")+"套餐未满足限购品数"+eachlimitqty+"的要求,禁止创建订单,请修改后重试!").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|