CeErpDesignerBill.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. using Castle.ActiveRecord;
  2. using NHibernate.Criterion;
  3. using System;
  4. using System.Text;
  5. namespace BizCom
  6. {
  7. [ActiveRecord("CE_ErpDesignerBill")]
  8. public class CeErpDesignerBill : ComBase<CeErpDesignerBill>
  9. {
  10. /// <summary>
  11. ///
  12. /// </summary>
  13. [PrimaryKey(PrimaryKeyType.Native)]
  14. public int ID { get; set; }
  15. private string _tid = "";
  16. /// <summary>
  17. ///订单编号
  18. /// </summary>
  19. [Property]
  20. public string tid
  21. {
  22. get { return _tid; }
  23. set { _tid = value; }
  24. }
  25. private string _oid = "";
  26. /// <summary>
  27. ///原订单号
  28. /// </summary>
  29. [Property]
  30. public string oid
  31. {
  32. get { return _oid; }
  33. set { _oid = value; }
  34. }
  35. private int _uid = 0;
  36. /// <summary>
  37. ///设计师用户Id
  38. /// </summary>
  39. [Property]
  40. public int uid
  41. {
  42. get { return _uid; }
  43. set { _uid = value; }
  44. }
  45. private string _userName = "";
  46. /// <summary>
  47. ///设计师名称
  48. /// </summary>
  49. [Property]
  50. public string userName
  51. {
  52. get { return _userName; }
  53. set { _userName = value; }
  54. }
  55. private int _designerType = 0;
  56. /// <summary>
  57. ///设计师类型:1内部设计师 2外协设计师
  58. /// </summary>
  59. [Property]
  60. public int designerType
  61. {
  62. get { return _designerType; }
  63. set { _designerType = value; }
  64. }
  65. private string _designerTypeText = "";
  66. /// <summary>
  67. ///设计师类型
  68. /// </summary>
  69. [Property]
  70. public string designerTypeText
  71. {
  72. get { return _designerTypeText; }
  73. set { _designerTypeText = value; }
  74. }
  75. private int _designNum = 0;
  76. /// <summary>
  77. ///设计款数
  78. /// </summary>
  79. [Property]
  80. public int designNum
  81. {
  82. get { return _designNum; }
  83. set { _designNum = value; }
  84. }
  85. private string _designSize = "";
  86. /// <summary>
  87. ///设计尺寸
  88. /// </summary>
  89. [Property]
  90. public string designSize
  91. {
  92. get { return _designSize; }
  93. set { _designSize = value; }
  94. }
  95. private int _modifyNum = 0;
  96. /// <summary>
  97. ///改稿款数
  98. /// </summary>
  99. [Property]
  100. public int modifyNum
  101. {
  102. get { return _modifyNum; }
  103. set { _modifyNum = value; }
  104. }
  105. private string _modifySize = "";
  106. /// <summary>
  107. ///改稿尺寸
  108. /// </summary>
  109. [Property]
  110. public string modifySize
  111. {
  112. get { return _modifySize; }
  113. set { _modifySize = value; }
  114. }
  115. private double _price = 0;
  116. /// <summary>
  117. ///设计师填写价格
  118. /// </summary>
  119. [Property]
  120. public double price
  121. {
  122. get { return _price; }
  123. set { _price = value; }
  124. }
  125. private double _realPrice = 0;
  126. /// <summary>
  127. ///实际价格
  128. /// </summary>
  129. [Property]
  130. public double realPrice
  131. {
  132. get { return _realPrice; }
  133. set { _realPrice = value; }
  134. }
  135. /// <summary>
  136. ///创建时间
  137. /// </summary>
  138. [Property]
  139. public DateTime? create_time { get; set; }
  140. private int _create_u_id = 0;
  141. /// <summary>
  142. ///创建人uid
  143. /// </summary>
  144. [Property]
  145. public int create_u_id
  146. {
  147. get { return _create_u_id; }
  148. set { _create_u_id = value; }
  149. }
  150. private string _create_u_name = "";
  151. /// <summary>
  152. ///创建人名称
  153. /// </summary>
  154. [Property]
  155. public string create_u_name
  156. {
  157. get { return _create_u_name; }
  158. set { _create_u_name = value; }
  159. }
  160. /// <summary>
  161. ///修改时间
  162. /// </summary>
  163. [Property]
  164. public DateTime? update_time { get; set; }
  165. private int _update_u_id = 0;
  166. /// <summary>
  167. ///更新人uid
  168. /// </summary>
  169. [Property]
  170. public int update_u_id
  171. {
  172. get { return _update_u_id; }
  173. set { _update_u_id = value; }
  174. }
  175. private string _update_u_name = "";
  176. /// <summary>
  177. ///更新人名称
  178. /// </summary>
  179. [Property]
  180. public string update_u_name
  181. {
  182. get { return _update_u_name; }
  183. set { _update_u_name = value; }
  184. }
  185. private int _isAudit = 0;
  186. /// <summary>
  187. ///已审核
  188. /// </summary>
  189. [Property]
  190. public int isAudit
  191. {
  192. get { return _isAudit; }
  193. set { _isAudit = value; }
  194. }
  195. private int _isDel = 0;
  196. /// <summary>
  197. ///删除标识
  198. /// </summary>
  199. [Property]
  200. public int isDel
  201. {
  202. get { return _isDel; }
  203. set { _isDel = value; }
  204. }
  205. public static void Del(string tid)
  206. {
  207. StringBuilder sql = new StringBuilder();
  208. sql.AppendFormat("update CE_ErpDesignerBill set isDel=1 where tid='" + tid + "'");
  209. ExecuteNonQuery(sql.ToString());
  210. }
  211. public static CeErpDesignerBill GetByTid(string eid)
  212. {
  213. return FindFirst(Expression.Sql(string.Format("tid='{0}'", eid)));
  214. }
  215. public static void updateDesignerBill(string tid, int pid)//系统自动核算卡片设计费
  216. {
  217. if (tid.Length <= 0) return;
  218. double realPrice = 0, designLength = 0, designWidth = 0;
  219. double designWs = 0, designPrice = 0, modifyPrice = 1;
  220. CeErpDesignerBill ceErpDesignerBill = GetByTid(tid);
  221. if (ceErpDesignerBill == null) return;
  222. if (ceErpDesignerBill.realPrice != 0) return;
  223. if (ceErpDesignerBill.designSize.IndexOf("x") >= 0)
  224. {
  225. designLength = Convert.ToDouble(ceErpDesignerBill.designSize.Split('x')[0]);
  226. designWidth = Convert.ToDouble(ceErpDesignerBill.designSize.Split('x')[1]);
  227. double l1 = Math.Ceiling(designLength / 90);
  228. double w1 = Math.Ceiling(designWidth / 54);
  229. double l2 = Math.Ceiling(designLength / 54);
  230. double w2 = Math.Ceiling(designWidth / 90);
  231. designWs = Math.Min(l1 * w1, l2 * w2);
  232. }
  233. CeErpProductPrice entitys = CeErpProductPrice.GetByPType(pid, designWs);
  234. if (entitys == null) return;
  235. designPrice = entitys.designPrice;
  236. realPrice = designPrice * ceErpDesignerBill.designNum + modifyPrice * ceErpDesignerBill.modifyNum;
  237. StringBuilder sql = new StringBuilder();
  238. sql.AppendFormat("update CE_ErpDesignerBill set realPrice = " + realPrice + " where tid = '" + tid + "'");
  239. ExecuteNonQuery(sql.ToString());
  240. }
  241. public static void updateBill(string tid, int pid, string bz)//手提袋自动核算
  242. {
  243. if (tid.Length <= 0) return;
  244. string[] cz = bz.Split('-');
  245. string memo = "";
  246. for (int i = 0; i < cz.Length; i++)
  247. {
  248. if (cz[i].IndexOf("mm") > 0)
  249. {
  250. if (cz[i + 2].IndexOf("白卡纸") >= 0)
  251. {
  252. memo = "白卡纸";
  253. }
  254. else
  255. {
  256. memo = "牛皮纸";
  257. }
  258. }
  259. }
  260. double realPrice = 0;
  261. double designPrice = 0, modifyPrice = 0;
  262. CeErpDesignerBill ceErpDesignerBill = GetByTid(tid);
  263. if (ceErpDesignerBill == null) return;
  264. CeErpProductPrice entitys = CeErpProductPrice.GetByPType(pid, memo);
  265. if (entitys == null) return;
  266. realPrice = designPrice * ceErpDesignerBill.designNum + modifyPrice * ceErpDesignerBill.modifyNum;
  267. StringBuilder sql = new StringBuilder();
  268. sql.AppendFormat("update CE_ErpDesginerBill set realPrice = " + realPrice + " where tid = '" + tid + "'");
  269. ExecuteNonQuery(sql.ToString());
  270. }
  271. }
  272. }