GoodsWayManageAction.java 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. package com.minpay.common.action;
  2. import com.min.util.DateUtil;
  3. import com.minpay.common.exception.BusinessCodeException;
  4. import com.minpay.common.service.ILogService;
  5. import com.minpay.common.service.IPublicService;
  6. import com.minpay.common.util.RegexUtil;
  7. import com.minpay.db.table.mapper.VmProEquRelMapper;
  8. import com.minpay.db.table.model.VmProEquRel;
  9. import com.minpay.db.table.model.VmProEquRelExample;
  10. import com.minpay.db.table.own.mapper.GoodsWayMapper;
  11. import com.startup.minpay.frame.business.IMINAction;
  12. import com.startup.minpay.frame.business.res.MINActionResult;
  13. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  14. import com.startup.minpay.frame.exception.MINBusinessException;
  15. import com.startup.minpay.frame.jdbc.MINRowBounds;
  16. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  17. import com.startup.minpay.frame.service.base.Service;
  18. import com.startup.minpay.frame.session.MINSession;
  19. import com.startup.minpay.frame.target.MINAction;
  20. import com.startup.minpay.frame.target.MINComponent;
  21. import com.startup.minpay.frame.target.MINParam;
  22. import com.startup.minpay.frame.target.MINValidator;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;
  26. /**
  27. * 货道管理
  28. * @author WANGLM
  29. */
  30. @MINComponent
  31. public class GoodsWayManageAction implements IMINAction {
  32. //新增货道
  33. public final static String ADD_GOODSWAY_INFO = "addGoodsWayInfo";
  34. //查询货道数据
  35. public final static String SELECT_GOODSWAY_INFO = "selectGoodsWayInfo";
  36. //修改货道数据
  37. public final static String MODIFY_GOODSWAY_INFO = "modifyGoodsWayInfo";
  38. /**
  39. * 修改货道信息
  40. * @param proequrelId 货道Id
  41. * @param productId 商品Id
  42. * @param userId 商户Id
  43. * @param sallPrice 售货价
  44. * @param gamePrice 游戏价
  45. * @param costPrice 成本价
  46. * @param isPromotion 是否促销:0是1否
  47. * @param promotionPrice 促销价
  48. * @param gameType 游戏类型(GAME_TYEP:00:不参与,10:游戏购 20:幸运购)
  49. * @param isFragile 是否易碎:0是1否
  50. * @param remarks 备注
  51. * @param state 状态:00正常01货道删除02删除
  52. * @return
  53. * @throws MINBusinessException
  54. */
  55. @MINAction(value = "MODIFY_GOODSWAY_INFO")
  56. public MINActionResult modifyGoodsWayInfo(
  57. @MINParam(key = "proequrelId") String proequrelId,
  58. @MINParam(key = "productId") String productId,
  59. @MINParam(key = "userId") String userId,
  60. @MINParam(key = "sallPrice") String sallPrice,
  61. @MINParam(key = "gamePrice") String gamePrice,
  62. @MINParam(key = "costPrice") String costPrice,
  63. @MINParam(key = "isPromotion") String isPromotion,
  64. @MINParam(key = "promotionPrice") String promotionPrice,
  65. @MINParam(key = "gameType") String gameType,
  66. @MINParam(key = "isFragile") String isFragile,
  67. @MINParam(key = "remarks") String remarks,
  68. @MINParam(key = "state") String state,
  69. MINSession session) throws MINBusinessException {
  70. MINActionResult res = new MINActionResult();
  71. //修改
  72. VmProEquRel vp =new VmProEquRel();
  73. vp.setId(proequrelId);
  74. vp.setExeitState(state);
  75. vp.setModifyUser(userId);
  76. vp.setProductId(productId);
  77. vp.setUserId(userId);
  78. vp.setSallPrice(sallPrice);
  79. vp.setGamePrice(gamePrice);
  80. vp.setCostPrice(costPrice);
  81. vp.setIsPromotion(isPromotion);
  82. vp.setPromotionPrice(promotionPrice);
  83. vp.setGameType(gameType);
  84. vp.setIsFragile(isFragile);
  85. vp.setRemarks(remarks);
  86. vp.setModifyTime(DateUtil.getCurrentDateTimeString());
  87. // 执行新增货到数据
  88. Service.lookup(IMINDataBaseService.class)
  89. .getMybatisMapper(VmProEquRelMapper.class).updateByPrimaryKeySelective(vp);
  90. // 记录操作日志
  91. String logInfo = "商户:" + userId + "修改货道,货道编号:" + proequrelId + "货道状态"+ state;
  92. Service.lookup(ILogService.class).logging(session, logInfo);
  93. return res;
  94. }
  95. /**
  96. * 修改货道信息 校验
  97. * @param proequrelId
  98. * @param productId
  99. * @param session
  100. * @throws MINBusinessException
  101. */
  102. @MINValidator( value = MODIFY_GOODSWAY_INFO)
  103. public void modifyGoodsWayInfoValidator(
  104. @MINParam(key = "proequrelId", regex = RegexUtil.NOT_NULL, error = "货道编号不可为空!") String proequrelId,
  105. @MINParam(key = "productId", regex = RegexUtil.NOT_NULL, error = "商品编号不可为空!") String productId,
  106. MINSession session) throws MINBusinessException {
  107. }
  108. /**
  109. * * 查询货道
  110. * @param vciId 设备
  111. * @param session
  112. * @return
  113. * @throws MINBusinessException
  114. */
  115. @MINAction(value = "SELECT_GOODSWAY_INFO")
  116. public MINActionResult selectGoodsWayInfo(
  117. @MINParam(key = "vciId") String vciId,
  118. @MINParam(key = "page", defaultValue = "1") int page,
  119. @MINParam(key = "limit", defaultValue = "10") int limit,
  120. MINSession session) throws MINBusinessException {
  121. MINActionResult res = new MINActionResult();
  122. MINRowBounds rows = new MINRowBounds(page, limit);
  123. // 创建查询条件
  124. Map<String, String> p = new HashMap<String, String>();
  125. p.put("vciId",vciId);
  126. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class)
  127. .getMybatisMapper(GoodsWayMapper.class).queryGoodsWay(p,rows);
  128. // 设置返回值
  129. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  130. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  131. return res;
  132. }
  133. /**
  134. * 查询货道数据 校验
  135. * @param vciId
  136. * @param session
  137. * @throws MINBusinessException
  138. */
  139. @MINAction(value = "SELECT_GOODSWAY_INFO")
  140. public void selectGoodsWayInfoValidator(
  141. @MINParam(key = "vciId", regex = RegexUtil.NOT_NULL, error = "售货机编号不可为空!") String vciId,
  142. MINSession session) throws MINBusinessException {
  143. }
  144. /**
  145. * 新增货道
  146. * @param vciId 设备Id
  147. * @param productId 商品Id
  148. * @param wayRow 货道行
  149. * @param wayLine 货道列
  150. * @param aisle 货道指令
  151. * @param wayNums 货道容量
  152. * @param proNums 商品余量
  153. * @param userId 商户Id
  154. * @param sallPrice 售货价
  155. * @param gamePrice 游戏价
  156. * @param costPrice 成本价
  157. * @param isPromotion 是否促销:0是1否
  158. * @param promotionPrice 促销价
  159. * @param gameType 游戏类型(GAME_TYEP:00:不参与,10:游戏购 20:幸运购)
  160. * @param isFragile 是否易碎:0是1否
  161. * @param remarks 备注
  162. * @param state 状态:00正常01货道删除02删除
  163. * @param session
  164. * @return
  165. * @throws MINBusinessException
  166. */
  167. @MINAction(value = "ADD_GOODSWAY_INFO")
  168. public MINActionResult addGoodsWayInfo(
  169. @MINParam(key = "vciId") String vciId,
  170. @MINParam(key = "productId") String productId,
  171. @MINParam(key = "wayRow") String wayRow,
  172. @MINParam(key = "wayLine") String wayLine,
  173. @MINParam(key = "aisle") String aisle,
  174. @MINParam(key = "wayNums") String wayNums,
  175. @MINParam(key = "proNums") String proNums,
  176. @MINParam(key = "userId") String userId,
  177. @MINParam(key = "sallPrice") String sallPrice,
  178. @MINParam(key = "gamePrice") String gamePrice,
  179. @MINParam(key = "costPrice") String costPrice,
  180. @MINParam(key = "isPromotion") String isPromotion,
  181. @MINParam(key = "promotionPrice") String promotionPrice,
  182. @MINParam(key = "gameType") String gameType,
  183. @MINParam(key = "isFragile") String isFragile,
  184. @MINParam(key = "remarks") String remarks,
  185. @MINParam(key = "state") String state,
  186. MINSession session) throws MINBusinessException {
  187. MINActionResult res = new MINActionResult();
  188. //查询货道是否已存在
  189. VmProEquRelExample example = new VmProEquRelExample();
  190. example.createCriteria().andEquipmentIdEqualTo(vciId)
  191. .andCargoWayLineEqualTo(wayLine)
  192. .andCargoWayNumsEqualTo(wayNums);
  193. List<VmProEquRel> countList = Service.lookup(IMINDataBaseService.class)
  194. .getMybatisMapper(VmProEquRelMapper.class).selectByExample(example);
  195. if(countList.size() > 0) {
  196. //该货道已存在,请重新添加
  197. throw new BusinessCodeException("JINM4001");
  198. }
  199. //获取货到主键
  200. String proequrel_Id = Service.lookup(IPublicService.class).
  201. getSequence("VM_PROEQUREL_ID");
  202. //新增
  203. VmProEquRel vp =new VmProEquRel();
  204. vp.setEquipmentId(vciId);
  205. vp.setCargoWayRow(wayRow);
  206. vp.setCargoWayNums(wayNums);
  207. vp.setId(proequrel_Id);
  208. vp.setChannel("01");
  209. vp.setProductId(productId);
  210. vp.setAisle(aisle);
  211. vp.setCargoWayLine(wayLine);
  212. vp.setCargoWayRow(wayRow);
  213. vp.setCargoWayNums(wayNums);
  214. vp.setProductNums(proNums);
  215. vp.setUserId(userId);
  216. vp.setSallPrice(sallPrice);
  217. vp.setGamePrice(gamePrice);
  218. vp.setCostPrice(costPrice);
  219. vp.setIsPromotion(isPromotion);
  220. vp.setPromotionPrice(promotionPrice);
  221. vp.setGameType(gameType);
  222. vp.setIsFragile(isFragile);
  223. vp.setRemarks(remarks);
  224. vp.setExeitState(state);
  225. vp.setCreateUser(userId);
  226. vp.setModifyUser(userId);
  227. vp.setCreateTime(DateUtil.getCurrentDateTimeString());
  228. vp.setModifyTime(DateUtil.getCurrentDateTimeString());
  229. // 执行新增货到数据
  230. Service.lookup(IMINDataBaseService.class)
  231. .getMybatisMapper(VmProEquRelMapper.class).insert(vp);
  232. // 记录操作日志
  233. String logInfo = "商户:" + userId + "新增货道,货道编号:" + proequrel_Id;
  234. Service.lookup(ILogService.class).logging(session, logInfo);
  235. return res;
  236. }
  237. /**
  238. * 新增货道 校验
  239. * @param vciId
  240. * @param productId
  241. * @param wayRow
  242. * @param wayLine
  243. * @param session
  244. * @throws MINBusinessException
  245. */
  246. @MINValidator( value = ADD_GOODSWAY_INFO)
  247. public void addGoodsWayInfoValidator(
  248. @MINParam(key = "vciId", regex = RegexUtil.NOT_NULL, error = "售货机编号不可为空!") String vciId,
  249. @MINParam(key = "productId", regex = RegexUtil.NOT_NULL, error = "商品编号不可为空!") String productId,
  250. @MINParam(key = "wayRow", regex = RegexUtil.NOT_NULL, error = "货道行不可为空!") String wayRow,
  251. @MINParam(key = "wayLine", regex = RegexUtil.NOT_NULL, error = "货道列不可为空!") String wayLine,
  252. MINSession session) throws MINBusinessException {
  253. }
  254. }