| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- using BizCom;
- using BizCom.Enum;
- using SQLData;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SiteCore.Handler
- {
- public partial class app
- {
- #region address
- public void xiu_getuseraddress()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- string sql = "select id,address,linkman,linkphone,lng,lat,isdef from s_xiuuseraddress where userid=" + uid + " order by isdef desc,id desc";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void xiu_useraddressdef()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- if (UrlPostParmsCheck("aid"))
- {
- int uaId = GetPostInt("aid");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update s_xiuuseraddress set isdef=0 where userid={0} ;", uid);
- sql.AppendFormat("update s_xiuuseraddress set isdef=1 where id={0} and userid={1} ;", uaId, uid);
- //sql.AppendFormat("update s_user set addressid={1} where id={0} ;", uid, uaId);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- conSuccess("保存成功!");
- return;
- }
- conError("错误的参数");
- }
- public void xiu_ins_useraddress()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- if (UrlPostParmsCheck("address,man,phone"))
- {
- int aid = GetPostInt("aid");
- string address = GetPostString("address");
- string man = GetPostString("man");
- string phone = GetPostString("phone");
- string lng = GetPostString("lng");
- string lat = GetPostString("lat");
- int def = GetPostInt("def");
- //,lng,lat
- SXiuUserAddress aEntity = null;
- if (aid > 0) aEntity = SXiuUserAddress.Get(aid, uo.userid);
- if (aEntity == null) aEntity = new SXiuUserAddress();
- aEntity.Address = address;
- aEntity.UserID = uo.userid;
- aEntity.LinkMan = man;
- aEntity.LinkPhone = phone;
- aEntity.lng = lng;
- aEntity.lat = lat;
- if (def < 1) aEntity.isDef = true;
- if (aid > 0) aEntity.Update();
- else aEntity.Create();
- conSuccess("己保存!");
- return;
- }
- conError("无法保存");
- }
- public void xiu_del_useraddress()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- if (UrlPostParmsCheck("aid"))
- {
- int aid = GetPostInt("aid");
- SXiuUserAddress aEntity = SXiuUserAddress.Get(aid, uo.userid);
- if (aEntity != null)
- {
- aEntity.Delete();
- conSuccess("已删除!");
- return;
- }
- }
- conError("无法删除");
- }
- #endregion
- #region xiumaster
- public void get_xiunav()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string key = GetPostString("key");
- if (key.Length > 0) lw.Add(string.Format("title like '%{0}%'", key));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Order = "sort asc";
- DataTable dt = WebCache.GetData("s_xiunav", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_grabre_mastercord()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- lw.Add("opuserid=0");//可以接的单子
- //lw.Add("opuserid=" + uid);//接单人是自己
- //view_XiuRecord
- //string key = GetPostString("key");
- //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- //dStruct.Order = "sort asc";
- dStruct.Fileds = "id,HeadImg as img,name,lng,lat,areaname";
- DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_masterrecord()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- lw.Add("opuserid=0");//可以接的单子
- lw.Add("state=0");//可接单
- //lw.Add("opuserid=" + uid);//接单人是自己
- //view_XiuRecord
- //string key = GetPostString("key");
- //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- //dStruct.Order = "sort asc";
- dStruct.Fileds = "id,summary as con,addressinfo as ainfo,imgs,addtime,xiutypeid,state,code";
- DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_mymasterrecord()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- lw.Add("opuserid=" + uid);//已经接的单子
- //lw.Add("opuserid=" + uid);//接单人是自己
- //view_XiuRecord
- //string key = GetPostString("key");
- //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- //dStruct.Order = "sort asc";
- dStruct.Fileds = "id,summary as con,addressinfo as ainfo,imgs,addtime,xiutypeid,state,code";
- DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void reject_masterrecord()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- if (UrlPostParmsCheck("rid,code"))
- {
- int rid = GetPostInt("rid");
- string code = GetPostString("code");
- SXiuRecord entity = SXiuRecord.GetByMaster(rid, code, uid);
- if (entity == null)
- {
- conError("找不到该记录");
- return;
- }
- entity.State = (int)XiuState.None;
- entity.Update();
- conSuccess("谈不拢取消订单");
- return;
- }
- }
- public void finish_masterrecord()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- if (UrlPostParmsCheck("rid,code"))
- {
- int rid = GetPostInt("rid");
- string code = GetPostString("code");
- SXiuRecord entity = SXiuRecord.GetByMaster(rid, code, uid);
- if (entity == null)
- {
- conError("找不到该记录");
- return;
- }
- entity.State = (int)XiuState.Finish;
- entity.Update();
- conSuccess("已完成订单");
- return;
- }
- }
- public object grabObj = new object();
- public void grab_masterrecord() //抢单
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- if (UrlPostParmsCheck("rid,code"))
- {
- int rid = GetPostInt("rid");
- string code = GetPostString("code");
- SXiuRecord entity = SXiuRecord.GetByCode(rid, code);
- if (entity == null)
- {
- conError("找不到该记录");
- return;
- }
- lock (grabObj)
- {
- if (entity.OpUserID > 0)
- {
- conError("该单已被其它工程师接走");
- return;
- }
- else
- {
- entity.OpUserID = uid;
- entity.ReceiveTime = DateTime.Now;
- entity.Update();
- }
- }
- conSuccess("已抢单");
- return;
- }
- conError("错误的参数");
- return;
- }
- public void get_xiumaster()
- {
- //UserObj uo = GetXiuEntity();
- //if (uo == null) return;
- //int uid = uo.userid;
- string sql = "select top 5 id,userpic,sex,name,phone,duties,tags,star from view_xiumaster order by id asc";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void get_typemaster()
- {
- UserObj uo = GetXiuEntity();
- if (uo == null) return;
- int uid = uo.userid;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int type = GetPostInt("tid");
- if (type > 0)
- {
- lw.Add(" CHARINDEX('" + type + ",',tids+',')>0 ");
- }
- dStruct.Fileds = "id,userpic,sex,name,phone,duties,tags,star";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_xiumaster", dStruct);
- conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- #endregion
- }
- }
|