|
|
@@ -972,14 +972,23 @@ public class workorder extends Controller {
|
|
|
}
|
|
|
|
|
|
if(rows.get(0).getString("type").equals("安装")){
|
|
|
- Rows itemrows =dbConnect.runSqlQuery("select t3.sa_customersid,t3.name,t3.phonenumber,t3.province,t3.city,t3.county,t3.address,t1.sku,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid 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 where t1.sa_serviceorderid="+rows.get(0).getLong("sa_serviceorderid")+" and t1.siteid='"+siteid+"' ");
|
|
|
+ Rows itemrows =dbConnect.runSqlQuery("select t3.sa_customersid,t5.sa_agentsid customeragentsid,t3.name,t3.phonenumber,t3.province,t3.city,t3.county,t3.address,t1.sku,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid,t6.sa_agentsid sa_agentsid_to,t6.agentnum toagentnum 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 " +
|
|
|
+ "where t1.sa_serviceorderid="+rows.get(0).getLong("sa_serviceorderid")+" and t1.siteid='"+siteid+"' ");
|
|
|
|
|
|
if(itemrows.isNotEmpty()){
|
|
|
|
|
|
//判断客户id
|
|
|
long sa_customersid=0;
|
|
|
+ //判断客户id对应的经销商id
|
|
|
+ long customeragentsid=0;
|
|
|
if(itemrows.get(0).getLong("sa_customersid")!=0){
|
|
|
sa_customersid=itemrows.get(0).getLong("sa_customersid");
|
|
|
+ customeragentsid=itemrows.get(0).getLong("customeragentsid");
|
|
|
}else if(false){
|
|
|
//查询序列号是否有客户id(通过crm门店出库单中间表查询)待更新
|
|
|
}else{
|
|
|
@@ -987,7 +996,14 @@ public class workorder extends Controller {
|
|
|
sa_customersid=createTableID("sa_customers");
|
|
|
insertSQL.setUniqueid(sa_customersid);
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
|
|
|
+ if(itemrows.get(0).getLong("sa_agentsid")==0){
|
|
|
+ insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid_to"));
|
|
|
+ customeragentsid=itemrows.get(0).getLong("sa_agentsid_to");
|
|
|
+ }else{
|
|
|
+ insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
|
|
|
+ customeragentsid=itemrows.get(0).getLong("sa_agentsid");
|
|
|
+ }
|
|
|
+ insertSQL.setValue("sa_agentsid_to", itemrows.get(0).getLong("sa_agentsid_to"));
|
|
|
insertSQL.setValue("name",itemrows.get(0).getString("name"));
|
|
|
insertSQL.setValue("phonenumber",itemrows.get(0).getString("phonenumber"));
|
|
|
insertSQL.setValue("province",itemrows.get(0).getString("province"));
|
|
|
@@ -1012,8 +1028,10 @@ public class workorder extends Controller {
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_warrantycard");
|
|
|
insertSQL.setUniqueid(createTableID("sa_warrantycard"));
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
|
|
|
- insertSQL.setValue("cardno", "");
|
|
|
+ insertSQL.setValue("sa_agentsid",customeragentsid);
|
|
|
+ insertSQL.setValue("toagentnum",itemrows.get(0).getLong("toagentnum"));
|
|
|
+
|
|
|
+ insertSQL.setValue("cardno", createBillCode("warrantycard"));
|
|
|
insertSQL.setValue("sa_customersid",sa_customersid);
|
|
|
insertSQL.setValue("enddate", formattedDate);
|
|
|
insertSQL.setValue("begdate", getDateTime_Str());
|