|
|
@@ -233,6 +233,7 @@ public class sendrepair extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "确认", apiversion = R.ID2025102409585903.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {sendrepair.class})
|
|
|
public String confirm() throws YosException {
|
|
|
Long sa_sendrepairid = content.getLong("sa_sendrepairid");
|
|
|
boolean isconfirm = content.getBooleanValue("isconfirm");
|
|
|
@@ -284,6 +285,7 @@ public class sendrepair extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "进仓", apiversion = R.ID2025102413280503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {sendrepair.class})
|
|
|
public String instock() throws YosException {
|
|
|
Long sa_sendrepairid = content.getLong("sa_sendrepairid");
|
|
|
boolean isinstock = content.getBooleanValue("isinstock");
|
|
|
@@ -572,6 +574,7 @@ public class sendrepair extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "审核", apiversion = R.ID2025102509532403.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {sendrepair.class})
|
|
|
public String check() throws YosException {
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
Long sa_sendrepairid = content.getLong("sa_sendrepairid");
|
|
|
@@ -671,6 +674,132 @@ public class sendrepair extends Controller {
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "审核(送修单退钱处理)", apiversion = R.ID2025112514103403.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {sendrepair.class})
|
|
|
+ public String check_refundprocessing() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ Long sa_sendrepairid = content.getLong("sa_sendrepairid");
|
|
|
+ boolean ischeck = content.getBooleanValue("ischeck");
|
|
|
+ BigDecimal amount = content.getBigDecimal("amount");
|
|
|
+ long sa_accountclassid=0;
|
|
|
+ Rows accountclassrows = dbConnect.runSqlQuery("select * from sa_accountclass where accountno='01'");
|
|
|
+ if(accountclassrows.isNotEmpty()){
|
|
|
+ sa_accountclassid=accountclassrows.get(0).getLong("sa_accountclassid");
|
|
|
+ }
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.sys_enterpriseid,t1.remarks,t1.billno,t1.status,t2.qty,t2.sa_sendrepair_detailid,t2.amount,t2.agentcost,t2.disposition,t2.sku from sa_sendrepair t1 " +
|
|
|
+ "inner join sa_sendrepair_detail t2 on t1.sa_sendrepairid=t2.sa_sendrepairid" +
|
|
|
+ " where t1.sa_sendrepairid ='"
|
|
|
+ + sa_sendrepairid + "' and t1.siteid='" + siteid + "'");
|
|
|
+ if(rows.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("送修单不存在")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ Row row =rows.get(0);
|
|
|
+
|
|
|
+ Rows dispositionRows =dbConnect.runSqlQuery("select * from sa_aftersalesmag_disposition where disposition='"+row.getString("disposition")+"'");
|
|
|
+ if(dispositionRows.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("返修处理意见不存在")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ischeck) {
|
|
|
+ if (!row.getString("status").equals("退款确认")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的送修单为非退款确认状态,无法审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!row.getString("status").equals("审核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的送修单为非审核状态,无法反审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ if (!dispositionRows.get(0).getBoolean("isrefund")) {
|
|
|
+ return getErrReturnObject().setErrMsg("该单不能反审核")
|
|
|
+ .toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 是否退款
|
|
|
+ if (dispositionRows.get(0).getBoolean("isrefund")) {
|
|
|
+ for (Row rowdetail :rows){
|
|
|
+ //取消序列号的返修状态
|
|
|
+ sqlList.add("update sa_itemsku set isreturn=0,sys_enterpriseid=0,sa_agentsid=0 where sku='" + rowdetail.getString("sku")+"'");
|
|
|
+ /**
|
|
|
+ * 将保修卡作废
|
|
|
+ */
|
|
|
+ sqlList.add("update sa_warrantycard set isvoid=1,voiddate=CURRENT_TIME,voidreason='退货作废保修卡 "+ rowdetail.getString("billno")+"' where sku='" + rowdetail.getString("sku")+"'");
|
|
|
+
|
|
|
+ }
|
|
|
+ /******** 账户余额扣减 ********/
|
|
|
+ BigDecimal totalamount = amount;// 退款总额
|
|
|
+ sqlList.add("update sa_sendrepair set amount="+amount+" where sa_sendrepairid='" +sa_sendrepairid+"'");
|
|
|
+ // 如果退款金额大于0
|
|
|
+ if (totalamount.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ totalamount = ischeck ? totalamount.negate():totalamount;
|
|
|
+ CashbillEntity cashbillEntity = new CashbillEntity();
|
|
|
+ cashbillEntity.setAmount(totalamount);
|
|
|
+ cashbillEntity.setDiscountamountamount(BigDecimal.ZERO);
|
|
|
+ cashbillEntity.setOwnerid(sa_sendrepairid);
|
|
|
+ cashbillEntity.setOwnertable("sa_sendrepair");
|
|
|
+ cashbillEntity.setRemarks("该单由送修单" + row.getString("billno") +(ischeck ? "审核" : "反审核")+"时自动生成");
|
|
|
+ cashbillEntity.setSource("送修单"+(ischeck ? "审核" : "反审核"));
|
|
|
+ cashbillEntity.setTypemx("整机退款");
|
|
|
+ JSONObject cashbillPay = Accountbalance.createCashbillPay(this, row.getLong("sys_enterpriseid"), sa_accountclassid, cashbillEntity, true);
|
|
|
+ sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
+ }
|
|
|
+ /*********** 售后开始 ************/
|
|
|
+ Rows zprkrows = dbConnect.runSqlQuery("select t2.* from st_stockbill t1 inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid " +
|
|
|
+ " where t1.siteid='"+siteid+"' and t1.typemx='正品入库' and t1.type='其他入库' and t1.sourceobject='sa_sendrepair' and t1.sourceid="+sa_sendrepairid);
|
|
|
+ Rows bfrkrows = dbConnect.runSqlQuery("select t2.* from st_stockbill t1 inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid " +
|
|
|
+ " where t1.siteid='"+siteid+"' and t1.typemx='报废入库' and t1.type='其他入库' and t1.sourceobject='sa_sendrepair' and t1.sourceid="+sa_sendrepairid);
|
|
|
+
|
|
|
+ if (zprkrows.toRowsMap("st_stockbillid").size()== 1) {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "st_stockbill_items");
|
|
|
+ updateSQL.setUniqueid(zprkrows.get(0).getLong("st_stockbill_itemsid"));
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("amount",ischeck ? totalamount.negate() : 0);
|
|
|
+ updateSQL.setValue("price",(ischeck ? totalamount.negate() : BigDecimal.ZERO).divide(zprkrows.get(0).getBigDecimal("qty")));
|
|
|
+ updateSQL.setValue("defaultprice",(ischeck ? totalamount.negate() : BigDecimal.ZERO).divide(zprkrows.get(0).getBigDecimal("qty")));
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ sqlList.add("update st_stockbill set billdate=CURRENT_TIME where st_stockbillid="+zprkrows.get(0).getLong("st_stockbillid"));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bfrkrows.toRowsMap("st_stockbillid").size()== 1) {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "st_stockbill_items");
|
|
|
+ updateSQL.setUniqueid(bfrkrows.get(0).getLong("st_stockbill_itemsid"));
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("amount",ischeck ? totalamount.negate() : 0);
|
|
|
+ updateSQL.setValue("price",(ischeck ? totalamount.negate() : BigDecimal.ZERO).divide(bfrkrows.get(0).getBigDecimal("qty")));
|
|
|
+ updateSQL.setValue("defaultprice",(ischeck ? totalamount.negate() : BigDecimal.ZERO).divide(bfrkrows.get(0).getBigDecimal("qty")));
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ sqlList.add("update st_stockbill set billdate=CURRENT_TIME where st_stockbillid="+bfrkrows.get(0).getLong("st_stockbillid"));
|
|
|
+
|
|
|
+ }
|
|
|
+ /*********** 售后结束 ************/
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_sendrepair");
|
|
|
+ updateSQL.setUniqueid(sa_sendrepairid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ if (ischeck) {
|
|
|
+ updateSQL.setValue("status","审核");
|
|
|
+ updateSQL.setValue("checkby",username);
|
|
|
+ updateSQL.setDateValue("checkdate");
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_sendrepair", sa_sendrepairid, "审核", "送修单退钱处理审核成功").getSQL());
|
|
|
+ } else {
|
|
|
+ updateSQL.setValue("status","退款确认");
|
|
|
+ updateSQL.setValue("checkby","");
|
|
|
+ updateSQL.setValue("checkdate","null");
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_sendrepair", sa_sendrepairid, "反审核", "送修单退钱处理反审核成功").getSQL());
|
|
|
+ }
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 翻新序列号不变 品号改变
|