|
|
@@ -9,9 +9,11 @@ import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.data.Rows;
|
|
|
+import common.data.RowsMap;
|
|
|
import common.data.SQLFactory;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
public class promotionAuth extends Controller {
|
|
|
@@ -31,10 +33,10 @@ public class promotionAuth extends Controller {
|
|
|
long[] sa_promotion_authid = createTableID("sa_promotion_auth", enterpriseinfos.size());
|
|
|
for (Object obj : enterpriseinfos) {
|
|
|
JSONObject enterpriseinfo = (JSONObject) obj;
|
|
|
- if (enterpriseinfo.getLong("sa_promotion_authid") <= 0 || dbConnect.runSqlQuery(
|
|
|
- "select sa_promotion_authid from sa_promotion_auth where sa_promotion_authid="
|
|
|
- + enterpriseinfo.getLong("sa_promotion_authid"))
|
|
|
- .isEmpty()) {
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
+ "select sa_promotion_authid,settlestatus,saledamount from sa_promotion_auth where sa_promotion_authid="
|
|
|
+ + enterpriseinfo.getLong("sa_promotion_authid"));
|
|
|
+ if (enterpriseinfo.getLong("sa_promotion_authid") <= 0 || rows.isEmpty()) {
|
|
|
SQLFactory saleFactory = new SQLFactory(this, "促销方案参与授权范围新增");
|
|
|
saleFactory.addParameter("siteid", siteid);
|
|
|
saleFactory.addParameter("sa_promotion_authid", sa_promotion_authid[i]);
|
|
|
@@ -49,6 +51,12 @@ public class promotionAuth extends Controller {
|
|
|
|
|
|
i++;
|
|
|
} else {
|
|
|
+ if(rows.get(0).getBoolean("settlestatus")){
|
|
|
+ return getErrReturnObject().setErrMsg("已结算,无法修改").toString();
|
|
|
+ }
|
|
|
+ if(rows.get(0).getBigDecimal("saledamount").compareTo(enterpriseinfo.getBigDecimalValue("limitamount"))>0){
|
|
|
+ return getErrReturnObject().setErrMsg("限购金额必须大于等于已购金额").toString();
|
|
|
+ }
|
|
|
SQLFactory saleFactory = new SQLFactory(this, "促销方案参与授权范围更新");
|
|
|
saleFactory.addParameter("sa_promotion_authid", enterpriseinfo.getLong("sa_promotion_authid"));
|
|
|
// saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
|
|
|
@@ -129,11 +137,23 @@ public class promotionAuth extends Controller {
|
|
|
|
|
|
JSONArray sa_promotion_authids = content.getJSONArray("sa_promotion_authids");
|
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotion_authids.size());
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
+ "select sa_promotion_authid,settlestatus,saledamount from sa_promotion_auth where sa_promotion_authid in"
|
|
|
+ + sa_promotion_authids.toJSONString().replace("[", "(").replace("]", ")"));
|
|
|
+ RowsMap rowsMap =rows.toRowsMap("sa_promotion_authid");
|
|
|
for (Object o : sa_promotion_authids) {
|
|
|
- long sa_promotion_authid = Long.parseLong(o.toString());
|
|
|
+ String sa_promotion_authid = o.toString();
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
+ if(rowsMap.containsKey(sa_promotion_authid)){
|
|
|
+ if(rowsMap.get(sa_promotion_authid).isNotEmpty()){
|
|
|
+ if(rowsMap.get(sa_promotion_authid).get(0).getBigDecimal("saledamount").compareTo(BigDecimal.ZERO)!=0){
|
|
|
+ batchDeleteErr.addErr(Long.parseLong(sa_promotion_authid),"存在已购金额的授权经销商禁止删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
SQLFactory deletesql = new SQLFactory("sql:delete from sa_promotion_auth where siteid='" + siteid
|
|
|
- + "' and sa_promotion_authid=" + sa_promotion_authid);
|
|
|
+ + "' and sa_promotion_authid='" + sa_promotion_authid+"'");
|
|
|
list.add(deletesql.getSQL());
|
|
|
|
|
|
dbConnect.runSqlUpdate(list);
|