invCardManageAction.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. package com.minpay.shouhuo;
  2. import com.minpay.common.bean.User;
  3. import com.minpay.common.format.IFormatService;
  4. import com.minpay.common.service.ILogService;
  5. import com.minpay.common.util.CommonUtil;
  6. import com.minpay.common.util.DateUtil;
  7. import com.minpay.db.table.mapper.VmOrderInfMapper;
  8. import com.minpay.db.table.model.VmOrderInf;
  9. import com.minpay.db.table.own.mapper.OrderManageMapper;
  10. import com.startup.minpay.frame.business.IMINAction;
  11. import com.startup.minpay.frame.business.res.MINActionResult;
  12. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  13. import com.startup.minpay.frame.data.format.MINCopyFormat;
  14. import com.startup.minpay.frame.jdbc.MINRowBounds;
  15. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  16. import com.startup.minpay.frame.service.base.Service;
  17. import com.startup.minpay.frame.session.MINSession;
  18. import com.startup.minpay.frame.target.MINAction;
  19. import com.startup.minpay.frame.target.MINComponent;
  20. import com.startup.minpay.frame.target.MINParam;
  21. import org.apache.commons.lang.StringUtils;
  22. import java.math.BigDecimal;
  23. import java.text.SimpleDateFormat;
  24. import java.util.*;
  25. /**
  26. * 财务管理
  27. *
  28. * @author wlm
  29. */
  30. @MINComponent
  31. public class invCardManageAction implements IMINAction {
  32. /**查询订单详情**/
  33. public final static String SELECT_ORDER_DETAIL = "selectOrderDetail";
  34. /**取货、作废**/
  35. public final static String UPDATE_ORDER_STT = "updateOrderStt";
  36. /**查询取货记录**/
  37. public final static String SELECT_PICKUP_RECORD = "selectPickupRecord";
  38. /** 收入统计 **/
  39. public final static String SELECT_INCOME_STATISTICS = "selectIncomeStatistics";
  40. /** 收入统计 **/
  41. public final static String SELECT_ALL_INCOME = "selectAllIncome";
  42. /** 销售数据 **/
  43. public final static String SELECT_SALES_DATA = "selectSalesData";
  44. /** 销售数据2 **/
  45. public final static String SELECT_ALL_SALE = "selectAllSale";
  46. /** 时间轴查询销售金额、预估利润 **/
  47. public final static String SELECT_INCOME_BYDATE = "selectIncomeBydate";
  48. /**
  49. * 时间轴查询销售金额、预估利润
  50. * @param session
  51. * @return
  52. * @throws Exception
  53. */
  54. @MINAction(value = SELECT_INCOME_BYDATE)
  55. public MINActionResult selectIncomeBydate (
  56. @MINParam(key = "dateFlag") String dateFlag,
  57. MINSession session) throws Exception {
  58. MINActionResult res = new MINActionResult();
  59. User user = session.getUser();
  60. //获取当前时间
  61. Date currentTime = new Date();
  62. String nowDate = DateUtil.format(currentTime,"yyyyMMdd");
  63. Map<String, String> m = new HashMap<String, String>();
  64. //昨天
  65. String yesDate = DateUtil.getDifferentDate(-1).substring(0,8);
  66. //本周第一天
  67. Calendar cal=Calendar.getInstance();
  68. cal.add(Calendar.WEEK_OF_MONTH, 0);
  69. cal.set(Calendar.DAY_OF_WEEK, 2);
  70. Date weekFristDate = cal.getTime();
  71. String weekDate = DateUtil.format(weekFristDate,"yyyyMMdd");
  72. //按时间查询
  73. String time = null;
  74. if("0".equals(dateFlag)) {
  75. m.put("nowDate", nowDate);
  76. Date parse = new SimpleDateFormat("yyyyMMdd").parse(nowDate);
  77. String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
  78. time = dateString;
  79. }else if("1".equals(dateFlag)) {
  80. m.put("yesDate", yesDate);
  81. Date parse = new SimpleDateFormat("yyyyMMdd").parse(yesDate);
  82. String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
  83. time = dateString;
  84. }else if("2".equals(dateFlag)) {
  85. m.put("weekDate", weekDate);
  86. Date parse = new SimpleDateFormat("yyyyMMdd").parse(weekDate);
  87. String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
  88. Date parseb = new SimpleDateFormat("yyyyMMdd").parse(nowDate);
  89. String dateStringb = new SimpleDateFormat("yyyy-MM-dd").format(parseb);
  90. time = dateString.concat(" 至 ").concat(dateStringb);
  91. }
  92. //查询累计收入
  93. String countIncome = Service.lookup(IMINDataBaseService.class)
  94. .getMybatisMapper(OrderManageMapper.class).selectCountIncome(m);
  95. //查询预估利润
  96. String predictIncome = Service.lookup(IMINDataBaseService.class)
  97. .getMybatisMapper(OrderManageMapper.class).selectPredictIncome(m);
  98. //查询累计收入
  99. List<Map<String, String>> mapList = Service.lookup(IMINDataBaseService.class)
  100. .getMybatisMapper(OrderManageMapper.class).selectCountIncomeb(m);
  101. String wxzfbAmout = "0";
  102. String czAmout = "0";
  103. for (int i = 0; i < mapList.size(); i++) {
  104. Map<String, String> map = mapList.get(i);
  105. String transType = map.get("transType");
  106. if(transType.equals("00")){ //充值金额
  107. czAmout = String.valueOf(map.get("amout"));
  108. }
  109. if(transType.equals("10")){ //支付金额
  110. wxzfbAmout = String.valueOf(map.get("amout"));
  111. }
  112. }
  113. predictIncome = CommonUtil.subtract(countIncome,predictIncome);
  114. String zsrAmout = CommonUtil.add(czAmout,wxzfbAmout);
  115. //返回数据
  116. res.set("countIncome", countIncome);
  117. res.set("predictIncome", predictIncome);
  118. res.set("czAmout", czAmout);
  119. res.set("zsrAmout", zsrAmout);
  120. res.set("time", time);
  121. return res;
  122. }
  123. /**
  124. * 总销售数量
  125. * @param session
  126. * @return
  127. * @throws Exception
  128. */
  129. @MINAction(value = SELECT_ALL_SALE)
  130. public MINActionResult selectAllSale (
  131. MINSession session) throws Exception {
  132. MINActionResult res = new MINActionResult();
  133. User user = session.getUser();
  134. //总实际金额
  135. String allSale = Service.lookup(IMINDataBaseService.class)
  136. .getMybatisMapper(OrderManageMapper.class).selectAllSale();
  137. //总商品成本
  138. String allCost = Service.lookup(IMINDataBaseService.class)
  139. .getMybatisMapper(OrderManageMapper.class).selectAllCost();
  140. BigDecimal num1 = new BigDecimal(allSale);
  141. BigDecimal num2 = new BigDecimal(allCost);
  142. BigDecimal allProfit = num1.subtract(num2);
  143. //返回数据
  144. res.set("allSale", allSale);
  145. res.set("allCost", allCost);
  146. res.set("allProfit", allProfit);
  147. return res;
  148. }
  149. /**
  150. * 销售数据
  151. * @param page
  152. * @param limit
  153. * @param session
  154. * @return
  155. * @throws Exception
  156. */
  157. @MINAction(value = SELECT_SALES_DATA)
  158. public MINActionResult selectSalesData (
  159. @MINParam(key = "page", defaultValue = "1") int page,
  160. @MINParam(key = "limit", defaultValue = "7") int limit,
  161. @MINParam(key = "proName") String proName,
  162. MINSession session) throws Exception {
  163. MINActionResult res = new MINActionResult();
  164. User user = session.getUser();
  165. Map<String, String> m = new HashMap<String, String>();
  166. m.put("proName", proName);
  167. MINRowBounds rows = new MINRowBounds(page, limit);
  168. List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
  169. .getMybatisMapper(OrderManageMapper.class).selectProductInfo(rows, m);
  170. detailList = Service.lookup(IFormatService.class).formatCurrency(detailList, "amount", "proNums");
  171. //返回数据
  172. res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
  173. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  174. return res;
  175. }
  176. /**
  177. * 总收入统计
  178. * @param session
  179. * @return
  180. * @throws Exception
  181. */
  182. // @MINAction(value = SELECT_ALL_INCOME)
  183. // public MINActionResult selectAllIncome (
  184. // MINSession session) throws Exception {
  185. // MINActionResult res = new MINActionResult();
  186. // User user = session.getUser();
  187. // //查询订单数
  188. // String orderNum = Service.lookup(IMINDataBaseService.class)
  189. // .getMybatisMapper(OrderManageMapper.class).selectCountOrderNum();
  190. // //查询累计收入
  191. // String countIncome = Service.lookup(IMINDataBaseService.class)
  192. // .getMybatisMapper(OrderManageMapper.class).selectCountIncome();
  193. // //查询总机台数
  194. // String countDevice = Service.lookup(IMINDataBaseService.class)
  195. // .getMybatisMapper(OrderManageMapper.class).selectCountDevice();
  196. // //返回数据
  197. // res.set("orderNum", orderNum);
  198. // res.set("countIncome", countIncome);
  199. // res.set("countDevice", countDevice);
  200. // return res;
  201. // }
  202. /**
  203. * 收入统计
  204. * @param page
  205. * @param limit
  206. * @param session
  207. * @return
  208. * @throws Exception
  209. */
  210. @MINAction(value = SELECT_INCOME_STATISTICS)
  211. public MINActionResult selectIncomeStatistics (
  212. @MINParam(key = "page", defaultValue = "1") int page,
  213. @MINParam(key = "limit", defaultValue = "10") int limit,
  214. @MINParam(key = "equNum") String equNum,
  215. @MINParam(key = "datesTime") String datesTime,
  216. MINSession session) throws Exception {
  217. MINActionResult res = new MINActionResult();
  218. User user = session.getUser();
  219. String branchId = user.getBranchId();
  220. MINRowBounds rows = new MINRowBounds(page, limit);
  221. //获取当前时间
  222. Date currentTime = new Date();
  223. String nowDate = DateUtil.format(currentTime,"yyyyMMdd");
  224. Map<String, String> m = new HashMap<String, String>();
  225. m.put("equNum", equNum);
  226. m.put("datesTime", datesTime);
  227. m.put("nowDate", nowDate);
  228. if(!"88888888".equals(branchId)) {
  229. m.put("branchId", branchId);
  230. }
  231. List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
  232. .getMybatisMapper(OrderManageMapper.class).selectIncomeDetail(rows, m);
  233. detailList = Service.lookup(IFormatService.class).formatDate(detailList, "sellTime");
  234. detailList = Service.lookup(IFormatService.class).formatCurrency(detailList, "sellWxSum", "sellZfSum", "" +
  235. "sellMfSum", "allSell");
  236. //返回数据
  237. res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
  238. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  239. return res;
  240. }
  241. /**
  242. * 取货记录
  243. * @param machineNo
  244. * @param orderNo
  245. * @param pickUpDates
  246. * @param page
  247. * @param limit
  248. * @param session
  249. * @return
  250. * @throws Exception
  251. */
  252. @MINAction(value = SELECT_PICKUP_RECORD)
  253. public MINActionResult selectPickupRecord (
  254. @MINParam(key = "machineNo") String machineNo,
  255. @MINParam(key = "orderNo") String orderNo,
  256. @MINParam(key = "pickUpDates") String pickUpDates,
  257. @MINParam(key = "equrelId") String equrelId,
  258. @MINParam(key = "vciId") String vciId,
  259. @MINParam(key = "pickupNo") String pickupNo,
  260. @MINParam(key = "page", defaultValue = "1") int page,
  261. @MINParam(key = "limit", defaultValue = "3") int limit,
  262. MINSession session) throws Exception {
  263. MINActionResult res = new MINActionResult();
  264. User user = session.getUser();
  265. String branchId = user.getBranchId();
  266. Map<String, String> m = new HashMap<String, String>();
  267. m.put("machineNo", machineNo);
  268. m.put("orderNo", orderNo);
  269. m.put("pickUpDates", pickUpDates);
  270. m.put("equrelId", equrelId);
  271. m.put("vciId", vciId);
  272. m.put("pickupNo", pickupNo);
  273. m.put("branchId", branchId);
  274. MINRowBounds rows = new MINRowBounds(page, limit);
  275. List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
  276. .getMybatisMapper(OrderManageMapper.class).selectPickupRecord(m,rows);
  277. detailList = new MINCopyFormat("{stt:'sttDesc'}").format(detailList);
  278. detailList = Service.lookup(IFormatService.class).formatEnum(detailList,"{sttDesc:'PICKUP_STT'}");
  279. //返回数据
  280. res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
  281. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  282. return res;
  283. }
  284. /**
  285. * 查询订单详情
  286. * @param machineNo
  287. * @param pickUpCode
  288. * @param creatdDtes
  289. * @param pickUpDates
  290. * @param pickUpState
  291. * @param page
  292. * @param limit
  293. * @param session
  294. * @return
  295. * @throws Exception
  296. */
  297. @MINAction(value = SELECT_ORDER_DETAIL)
  298. public MINActionResult selectOrderDetail (
  299. @MINParam(key = "machineNo") String machineNo,
  300. @MINParam(key = "pickUpCode") String pickUpCode,
  301. @MINParam(key = "equrelId") String equrelId,
  302. @MINParam(key = "creatdDtes") String creatdDtes,
  303. @MINParam(key = "pickUpDates") String pickUpDates,
  304. @MINParam(key = "pickUpState") String pickUpState,
  305. @MINParam(key = "page", defaultValue = "1") int page,
  306. @MINParam(key = "limit", defaultValue = "3") int limit,
  307. MINSession session) throws Exception {
  308. MINActionResult res = new MINActionResult();
  309. User user = session.getUser();
  310. String branchId = user.getBranchId();
  311. Map<String, String> m = new HashMap<String, String>();
  312. m.put("machineNo", machineNo);
  313. m.put("pickUpCode", pickUpCode);
  314. m.put("equrelId", equrelId);
  315. m.put("creatdDtes", creatdDtes);
  316. m.put("pickUpDates", pickUpDates);
  317. m.put("pickUpState", pickUpState);
  318. if(!"88888888".equals(branchId)) {
  319. m.put("branchId", branchId);
  320. }
  321. MINRowBounds rows = new MINRowBounds(page, limit);
  322. List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
  323. .getMybatisMapper(OrderManageMapper.class).selectOrderDetail(m,rows);
  324. // 格式化数据
  325. detailList = Service.lookup(IFormatService.class).formatDateTime(detailList, "pickUpTime");
  326. detailList = Service.lookup(IFormatService.class).formatDateTime(detailList, "createTime");
  327. detailList = new MINCopyFormat("{stt:'sttDesc'}").format(detailList);
  328. detailList = Service.lookup(IFormatService.class).formatEnum(detailList,"{sttDesc:'ORDER_PICKUP_STT'}");
  329. //返回数据
  330. res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
  331. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
  332. return res;
  333. }
  334. /**
  335. *卡卷管理、取货、作废
  336. * @param orderNo
  337. * @param temp 操作0:作废,1:取货
  338. * @param session
  339. * @return
  340. * @throws Exception
  341. */
  342. @MINAction(value = UPDATE_ORDER_STT)
  343. public MINActionResult updateOrderStt(
  344. @MINParam ( key = "orderNo")String orderNo,
  345. @MINParam ( key = "temp")String temp,
  346. MINSession session) throws Exception{
  347. MINActionResult res = new MINActionResult();
  348. User user = session.getUser();
  349. String info = "";
  350. //更新订单状态
  351. VmOrderInf vd = new VmOrderInf();
  352. vd.setId(orderNo);
  353. if ("0".equals(temp)) {
  354. vd.setPickupStt("02");
  355. info = "废止";
  356. }else if("1".equals(temp)) {
  357. vd.setPickupStt("01");
  358. info = "发货";
  359. }
  360. Service.lookup(IMINDataBaseService.class)
  361. .updateByPrimaryKeySelective(VmOrderInfMapper.class, vd);
  362. //日志
  363. String logInfo = user.getName()+"-更新订单状态:" +info+ ",订单号"+orderNo;
  364. Service.lookup(ILogService.class).logging(session, logInfo);
  365. return res;
  366. }
  367. }