|
|
@@ -1063,13 +1063,13 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
if (rows.get(0).getString("type").equals("安装")) {
|
|
|
- Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.sa_customersid,t5.sa_agentsid customeragentsid,t5.name,t5.phonenumber,t3.province,t3.city,t3.county,t5.address,t1.sku,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 " +
|
|
|
- " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
|
|
|
- " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid " +
|
|
|
- " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid " +
|
|
|
- " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid " +
|
|
|
- " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid " +
|
|
|
- " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " +
|
|
|
+ Rows itemrows = dbConnect.runSqlQuery("select t1.sku,t3.scenecontact,t3.scenecontactphonenumber,t3.sa_customersid,t5.sa_agentsid customeragentsid,case when t3.sa_customersid!=0 then t5.name else t3.name end name,case when t3.sa_customersid!=0 then t5.phonenumber else t3.phonenumber end phonenumber,t3.province,t3.city,t3.county, case when t3.sa_customersid!=0 then t5.address else t3.address end address,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum,t7.itemid from sa_serviceorderitems t1 \n" +
|
|
|
+ " inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid \n" +
|
|
|
+ " left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid \n" +
|
|
|
+ " left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid \n" +
|
|
|
+ " left join sa_customers t5 on t5.sa_customersid=t3.sa_customersid and t5.siteid=t3.siteid \n" +
|
|
|
+ " left join sa_agents t6 on t3.sys_enterpriseid_service=t6.sys_enterpriseid and t3.siteid=t6.siteid \n" +
|
|
|
+ " left join sa_itemsku t7 on t7.sku=t1.sku and t7.siteid=t1.siteid " +
|
|
|
"where t1.sa_serviceorderid=" + rows.get(0).getLong("sa_serviceorderid") + " and t1.siteid='" + siteid + "' ");
|
|
|
|
|
|
if (itemrows.isNotEmpty()) {
|
|
|
@@ -1082,7 +1082,7 @@ public class workorder extends Controller {
|
|
|
sa_customersid = itemrows.get(0).getLong("sa_customersid");
|
|
|
customeragentsid = itemrows.get(0).getLong("customeragentsid");
|
|
|
}else {
|
|
|
- return getErrReturnObject().setErrMsg("客户不存在").toString();
|
|
|
+// return getErrReturnObject().setErrMsg("客户不存在").toString();
|
|
|
// InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_customers");
|
|
|
// sa_customersid = createTableID("sa_customers");
|
|
|
// insertSQL.setUniqueid(sa_customersid);
|
|
|
@@ -1120,13 +1120,19 @@ public class workorder extends Controller {
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_warrantycard");
|
|
|
insertSQL.setUniqueid(createTableID("sa_warrantycard"));
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sa_agentsid", customeragentsid);
|
|
|
- insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
+ if(sa_customersid!=0){
|
|
|
+ insertSQL.setValue("sa_agentsid", customeragentsid);
|
|
|
+ insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
+ }else{
|
|
|
+ insertSQL.setValue("sa_agentsid", itemrows.get(0).getString("sa_agentsid_to"));
|
|
|
+ insertSQL.setValue("toagentnum", itemrows.get(0).getString("toagentnum"));
|
|
|
+ }
|
|
|
+
|
|
|
insertSQL.setValue("sku", itemrows.get(0).getString("sku"));
|
|
|
insertSQL.setValue("cardno", createBillCode("warrantycard"));
|
|
|
insertSQL.setValue("sa_customersid", sa_customersid);
|
|
|
- insertSQL.setValue("name", itemrows.get(0).getString("name"));
|
|
|
- insertSQL.setValue("phonenumber", itemrows.get(0).getString("phonenumber"));
|
|
|
+ insertSQL.setValue("name", itemrows.get(0).getString("scenecontact"));
|
|
|
+ insertSQL.setValue("phonenumber", itemrows.get(0).getString("scenecontactphonenumber"));
|
|
|
insertSQL.setValue("address", itemrows.get(0).getString("address"));
|
|
|
insertSQL.setValue("enddate", formattedDate);
|
|
|
insertSQL.setValue("begdate", getDateTime_Str());
|