|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.webmanage.sale.warrantycard;
|
|
package restcontroller.webmanage.sale.warrantycard;
|
|
|
|
|
|
|
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import common.Controller;
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
import common.YosException;
|
|
@@ -7,11 +8,13 @@ import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
import common.data.*;
|
|
import common.data.*;
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import restcontroller.R;
|
|
import restcontroller.R;
|
|
|
import restcontroller.webmanage.sale.salearea.salearea;
|
|
import restcontroller.webmanage.sale.salearea.salearea;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
|
|
|
@API(title = "保修卡")
|
|
@API(title = "保修卡")
|
|
@@ -119,12 +122,16 @@ public class warrantycard extends Controller {
|
|
|
public String updatedate() throws YosException {
|
|
public String updatedate() throws YosException {
|
|
|
long sa_warrantycardid = content.getLong("sa_warrantycardid");
|
|
long sa_warrantycardid = content.getLong("sa_warrantycardid");
|
|
|
String begindate = content.getString("begindate");
|
|
String begindate = content.getString("begindate");
|
|
|
- Rows rows = dbConnect.runSqlQuery("select itemid from sa_warrantycard where siteid='" + siteid
|
|
|
|
|
|
|
+ String enddate = content.getStringValue("enddate");
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select itemid,begdate,enddate from sa_warrantycard where siteid='" + siteid
|
|
|
+ "' and sa_warrantycardid='" + sa_warrantycardid + "'");
|
|
+ "' and sa_warrantycardid='" + sa_warrantycardid + "'");
|
|
|
|
|
|
|
|
if (rows.isEmpty()) {
|
|
if (rows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("保修卡不存在").toString();
|
|
return getErrReturnObject().setErrMsg("保修卡不存在").toString();
|
|
|
}
|
|
}
|
|
|
|
|
+ if (getDate_Str(content.getDate("begindate")).compareTo(getDate_Str(rows.get(0).getDate("begdate")))>0) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("开始日期不能晚于原日期").toString();
|
|
|
|
|
+ }
|
|
|
Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='" + siteid + "' and itemid=" + rows.get(0).getLong("itemid"));
|
|
Rows itemRows = dbConnect.runSqlQuery("select * from plm_item where siteid='" + siteid + "' and itemid=" + rows.get(0).getLong("itemid"));
|
|
|
if (itemRows.isEmpty()) {
|
|
if (itemRows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该保修卡对应商品不存在").toString();
|
|
return getErrReturnObject().setErrMsg("该保修卡对应商品不存在").toString();
|
|
@@ -142,7 +149,7 @@ public class warrantycard extends Controller {
|
|
|
updateSQL.setUniqueid(sa_warrantycardid);
|
|
updateSQL.setUniqueid(sa_warrantycardid);
|
|
|
updateSQL.setSiteid(siteid);
|
|
updateSQL.setSiteid(siteid);
|
|
|
updateSQL.setValue("begdate", begindate);
|
|
updateSQL.setValue("begdate", begindate);
|
|
|
- updateSQL.setValue("enddate", newDate.toString());
|
|
|
|
|
|
|
+ updateSQL.setValue("enddate", StringUtils.isBlank(enddate)?newDate.toString():enddate);
|
|
|
updateSQL.setValue("changeuserid", userid);
|
|
updateSQL.setValue("changeuserid", userid);
|
|
|
updateSQL.setValue("changeby", username);
|
|
updateSQL.setValue("changeby", username);
|
|
|
updateSQL.setDateValue("changedate");
|
|
updateSQL.setDateValue("changedate");
|
|
@@ -151,5 +158,35 @@ public class warrantycard extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "作废保修卡", apiversion = R.ID2025103114461303.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {warrantycard.class})
|
|
|
|
|
+ public String voidWarrantycard() throws YosException {
|
|
|
|
|
+ long sa_warrantycardid = content.getLong("sa_warrantycardid");
|
|
|
|
|
+ String voidreason =content.getStringValue("voidreason");
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select isvoid from sa_warrantycard where siteid='" + siteid
|
|
|
|
|
+ + "' and sa_warrantycardid='" + sa_warrantycardid + "'");
|
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("保修卡不存在").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rows.get(0).getBoolean("isvoid")) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("保修卡已作废,无法再次作废").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_warrantycard");
|
|
|
|
|
+ updateSQL.setUniqueid(sa_warrantycardid);
|
|
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
|
|
+ updateSQL.setValue("isvoid", true);
|
|
|
|
|
+ updateSQL.setValue("voidreason", voidreason);
|
|
|
|
|
+ updateSQL.setValue("changeuserid", userid);
|
|
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
|
|
+ updateSQL.setDateValue("voiddate");
|
|
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_warrantycard", sa_warrantycardid, "作废", "保修卡作废成功")
|
|
|
|
|
+ .getSQL());
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+ return getSucReturnObject().toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|