app.master.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using BizCom;
  2. using BizCom.Enum;
  3. using SQLData;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace SiteCore.Handler
  11. {
  12. public partial class app
  13. {
  14. #region address
  15. public void xiu_getuseraddress()
  16. {
  17. UserObj uo = GetXiuEntity();
  18. if (uo == null) return;
  19. int uid = uo.userid;
  20. string sql = "select id,address,linkman,linkphone,lng,lat,isdef from s_xiuuseraddress where userid=" + uid + " order by isdef desc,id desc";
  21. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  22. conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  23. }
  24. public void xiu_useraddressdef()
  25. {
  26. UserObj uo = GetXiuEntity();
  27. if (uo == null) return;
  28. int uid = uo.userid;
  29. if (UrlPostParmsCheck("aid"))
  30. {
  31. int uaId = GetPostInt("aid");
  32. StringBuilder sql = new StringBuilder();
  33. sql.AppendFormat("update s_xiuuseraddress set isdef=0 where userid={0} ;", uid);
  34. sql.AppendFormat("update s_xiuuseraddress set isdef=1 where id={0} and userid={1} ;", uaId, uid);
  35. //sql.AppendFormat("update s_user set addressid={1} where id={0} ;", uid, uaId);
  36. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  37. conSuccess("保存成功!");
  38. return;
  39. }
  40. conError("错误的参数");
  41. }
  42. public void xiu_ins_useraddress()
  43. {
  44. UserObj uo = GetXiuEntity();
  45. if (uo == null) return;
  46. if (UrlPostParmsCheck("address,man,phone"))
  47. {
  48. int aid = GetPostInt("aid");
  49. string address = GetPostString("address");
  50. string man = GetPostString("man");
  51. string phone = GetPostString("phone");
  52. string lng = GetPostString("lng");
  53. string lat = GetPostString("lat");
  54. int def = GetPostInt("def");
  55. //,lng,lat
  56. SXiuUserAddress aEntity = null;
  57. if (aid > 0) aEntity = SXiuUserAddress.Get(aid, uo.userid);
  58. if (aEntity == null) aEntity = new SXiuUserAddress();
  59. aEntity.Address = address;
  60. aEntity.UserID = uo.userid;
  61. aEntity.LinkMan = man;
  62. aEntity.LinkPhone = phone;
  63. aEntity.lng = lng;
  64. aEntity.lat = lat;
  65. if (def < 1) aEntity.isDef = true;
  66. if (aid > 0) aEntity.Update();
  67. else aEntity.Create();
  68. conSuccess("己保存!");
  69. return;
  70. }
  71. conError("无法保存");
  72. }
  73. public void xiu_del_useraddress()
  74. {
  75. UserObj uo = GetXiuEntity();
  76. if (uo == null) return;
  77. if (UrlPostParmsCheck("aid"))
  78. {
  79. int aid = GetPostInt("aid");
  80. SXiuUserAddress aEntity = SXiuUserAddress.Get(aid, uo.userid);
  81. if (aEntity != null)
  82. {
  83. aEntity.Delete();
  84. conSuccess("已删除!");
  85. return;
  86. }
  87. }
  88. conError("无法删除");
  89. }
  90. #endregion
  91. #region xiumaster
  92. public void get_xiunav()
  93. {
  94. DataStruct dStruct = GetPostStruct();
  95. List<string> lw = new List<string>();
  96. string key = GetPostString("key");
  97. if (key.Length > 0) lw.Add(string.Format("title like '%{0}%'", key));
  98. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  99. dStruct.Order = "sort asc";
  100. DataTable dt = WebCache.GetData("s_xiunav", dStruct);
  101. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  102. }
  103. public void get_grabre_mastercord()
  104. {
  105. UserObj uo = GetXiuEntity();
  106. if (uo == null) return;
  107. int uid = uo.userid;
  108. DataStruct dStruct = GetPostStruct();
  109. List<string> lw = new List<string>();
  110. lw.Add("opuserid=0");//可以接的单子
  111. //lw.Add("opuserid=" + uid);//接单人是自己
  112. //view_XiuRecord
  113. //string key = GetPostString("key");
  114. //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
  115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  116. //dStruct.Order = "sort asc";
  117. dStruct.Fileds = "id,HeadImg as img,name,lng,lat,areaname";
  118. DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
  119. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  120. }
  121. public void get_masterrecord()
  122. {
  123. UserObj uo = GetXiuEntity();
  124. if (uo == null) return;
  125. int uid = uo.userid;
  126. DataStruct dStruct = GetPostStruct();
  127. List<string> lw = new List<string>();
  128. lw.Add("opuserid=0");//可以接的单子
  129. lw.Add("state=0");//可接单
  130. //lw.Add("opuserid=" + uid);//接单人是自己
  131. //view_XiuRecord
  132. //string key = GetPostString("key");
  133. //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
  134. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  135. //dStruct.Order = "sort asc";
  136. dStruct.Fileds = "id,summary as con,addressinfo as ainfo,imgs,addtime,xiutypeid,state,code";
  137. DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
  138. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  139. }
  140. public void get_mymasterrecord()
  141. {
  142. UserObj uo = GetXiuEntity();
  143. if (uo == null) return;
  144. int uid = uo.userid;
  145. DataStruct dStruct = GetPostStruct();
  146. List<string> lw = new List<string>();
  147. lw.Add("opuserid=" + uid);//已经接的单子
  148. //lw.Add("opuserid=" + uid);//接单人是自己
  149. //view_XiuRecord
  150. //string key = GetPostString("key");
  151. //if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
  152. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  153. //dStruct.Order = "sort asc";
  154. dStruct.Fileds = "id,summary as con,addressinfo as ainfo,imgs,addtime,xiutypeid,state,code";
  155. DataTable dt = WebCache.GetData("view_XiuRecord", dStruct);
  156. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  157. }
  158. public void reject_masterrecord()
  159. {
  160. UserObj uo = GetXiuEntity();
  161. if (uo == null) return;
  162. int uid = uo.userid;
  163. if (UrlPostParmsCheck("rid,code"))
  164. {
  165. int rid = GetPostInt("rid");
  166. string code = GetPostString("code");
  167. SXiuRecord entity = SXiuRecord.GetByMaster(rid, code, uid);
  168. if (entity == null)
  169. {
  170. conError("找不到该记录");
  171. return;
  172. }
  173. entity.State = (int)XiuState.None;
  174. entity.Update();
  175. conSuccess("谈不拢取消订单");
  176. return;
  177. }
  178. }
  179. public void finish_masterrecord()
  180. {
  181. UserObj uo = GetXiuEntity();
  182. if (uo == null) return;
  183. int uid = uo.userid;
  184. if (UrlPostParmsCheck("rid,code"))
  185. {
  186. int rid = GetPostInt("rid");
  187. string code = GetPostString("code");
  188. SXiuRecord entity = SXiuRecord.GetByMaster(rid, code, uid);
  189. if (entity == null)
  190. {
  191. conError("找不到该记录");
  192. return;
  193. }
  194. entity.State = (int)XiuState.Finish;
  195. entity.Update();
  196. conSuccess("已完成订单");
  197. return;
  198. }
  199. }
  200. public object grabObj = new object();
  201. public void grab_masterrecord() //抢单
  202. {
  203. UserObj uo = GetXiuEntity();
  204. if (uo == null) return;
  205. int uid = uo.userid;
  206. if (UrlPostParmsCheck("rid,code"))
  207. {
  208. int rid = GetPostInt("rid");
  209. string code = GetPostString("code");
  210. SXiuRecord entity = SXiuRecord.GetByCode(rid, code);
  211. if (entity == null)
  212. {
  213. conError("找不到该记录");
  214. return;
  215. }
  216. lock (grabObj)
  217. {
  218. if (entity.OpUserID > 0)
  219. {
  220. conError("该单已被其它工程师接走");
  221. return;
  222. }
  223. else
  224. {
  225. entity.OpUserID = uid;
  226. entity.ReceiveTime = DateTime.Now;
  227. entity.Update();
  228. }
  229. }
  230. conSuccess("已抢单");
  231. return;
  232. }
  233. conError("错误的参数");
  234. return;
  235. }
  236. public void get_xiumaster()
  237. {
  238. //UserObj uo = GetXiuEntity();
  239. //if (uo == null) return;
  240. //int uid = uo.userid;
  241. string sql = "select top 5 id,userpic,sex,name,phone,duties,tags,star from view_xiumaster order by id asc";
  242. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  243. conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  244. }
  245. public void get_typemaster()
  246. {
  247. UserObj uo = GetXiuEntity();
  248. if (uo == null) return;
  249. int uid = uo.userid;
  250. DataStruct dStruct = GetPostStruct();
  251. List<string> lw = new List<string>();
  252. int type = GetPostInt("tid");
  253. if (type > 0)
  254. {
  255. lw.Add(" CHARINDEX('" + type + ",',tids+',')>0 ");
  256. }
  257. dStruct.Fileds = "id,userpic,sex,name,phone,duties,tags,star";
  258. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  259. DataTable dt = WebCache.GetData("view_xiumaster", dStruct);
  260. conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  261. }
  262. #endregion
  263. }
  264. }