RechargeManageAction.java 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. package com.minpay.rechargeManage;
  2. import com.min.sha1.SHA1;
  3. import com.minpay.common.bean.User;
  4. import com.minpay.common.constant.Constant;
  5. import com.minpay.common.constant.ServConstant;
  6. import com.minpay.common.exception.BusinessCodeException;
  7. import com.minpay.common.format.IFormatService;
  8. import com.minpay.common.service.ILogService;
  9. import com.minpay.common.service.IPublicService;
  10. import com.minpay.common.util.RegexUtil;
  11. import com.minpay.db.table.mapper.ImLogonCtrlMapper;
  12. import com.minpay.db.table.mapper.ImUserMapper;
  13. import com.minpay.db.table.mapper.ImUserRoleRelMapper;
  14. import com.minpay.db.table.mapper.VmRechargeRuleMapper;
  15. import com.minpay.db.table.model.*;
  16. import com.minpay.db.table.own.mapper.UserMapper;
  17. import com.mysql.jdbc.StringUtils;
  18. import com.startup.minpay.frame.business.IMINAction;
  19. import com.startup.minpay.frame.business.MINHttpServletRequestContext;
  20. import com.startup.minpay.frame.business.res.MINActionResult;
  21. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  22. import com.startup.minpay.frame.constant.IMINTransactionEnum;
  23. import com.startup.minpay.frame.exception.MINBusinessException;
  24. import com.startup.minpay.frame.jdbc.MINRowBounds;
  25. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  26. import com.startup.minpay.frame.service.base.Service;
  27. import com.startup.minpay.frame.session.MINSession;
  28. import com.startup.minpay.frame.target.MINAction;
  29. import com.startup.minpay.frame.target.MINComponent;
  30. import com.startup.minpay.frame.target.MINParam;
  31. import com.startup.minpay.frame.target.MINValidator;
  32. import com.startup.minpay.util.DateTime;
  33. import java.util.HashMap;
  34. import java.util.List;
  35. import java.util.Map;
  36. /**
  37. * 操作员管理
  38. * @author xbh
  39. *
  40. */
  41. @MINComponent
  42. public class RechargeManageAction implements IMINAction {
  43. public final static String QUERY_RECHARGE_RULE = "queryRechargeRule";
  44. public final static String ADD_RECHARGE_RULE = "addRechargeRule";
  45. public final static String MODIFY_RECHARGE_RULE = "modifyRechargeRule";
  46. public final static String DELETE_RECHARGE_RULE = "deleteRechargeRule";
  47. /**
  48. * 查询充值规则
  49. * @param session
  50. * @param page
  51. * @param limit
  52. * @param dates
  53. * @param rechargeAmt
  54. * @param fapRequest
  55. * @return
  56. * @throws MINBusinessException
  57. */
  58. @MINAction(value = QUERY_RECHARGE_RULE)
  59. public MINActionResult queryRechargeRule(
  60. MINSession session,
  61. @MINParam(key = "page", defaultValue = "1") int page,
  62. @MINParam(key = "limit", defaultValue = "3") int limit,
  63. @MINParam(key = "dates") String dates,
  64. @MINParam(key = "rechargeAmt") String rechargeAmt,
  65. @MINParam(key = "desc") String desc,
  66. MINHttpServletRequestContext fapRequest
  67. ) throws MINBusinessException {
  68. MINActionResult res = new MINActionResult();
  69. VmRechargeRuleExample vmRechargeRuleExample = new VmRechargeRuleExample();
  70. VmRechargeRuleExample.Criteria createCriteria = vmRechargeRuleExample.createCriteria();
  71. if(!StringUtils.isNullOrEmpty(rechargeAmt)){
  72. createCriteria.andRechargeAmtEqualTo(rechargeAmt);
  73. }
  74. if(!StringUtils.isNullOrEmpty(dates)){
  75. dates = dates.replaceAll("-", "").replaceAll(" ", "");
  76. createCriteria.andCreateTimeBetween(dates.substring(0, 8),dates.substring(8, 16));
  77. }
  78. createCriteria.andStateEqualTo("0");
  79. MINRowBounds rows = new MINRowBounds(page, limit);
  80. // 查询
  81. List<VmRechargeRule> ls = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmRechargeRuleMapper.class).selectByExample(vmRechargeRuleExample, rows);
  82. // 格式化
  83. ls = Service.lookup(IFormatService.class).formatDateTime(ls, "createTime");
  84. // 设置返回值
  85. res.set(IMINBusinessConstant.F_PAGING_LAY, ls);
  86. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  87. return res;
  88. }
  89. /**
  90. * 添加充值规则
  91. * @param rechargeAmt
  92. * @param giveAmt
  93. * @param desc
  94. * @param session
  95. * @return
  96. * @throws MINBusinessException
  97. */
  98. @MINAction(value = ADD_RECHARGE_RULE, transaction = IMINTransactionEnum.CMT)
  99. public MINActionResult addRechargeRule(
  100. @MINParam(key = "rechargeAmt") String rechargeAmt,
  101. @MINParam(key = "giveAmt") String giveAmt,
  102. @MINParam(key = "desc") String desc,
  103. MINSession session) throws MINBusinessException {
  104. MINActionResult res = new MINActionResult();
  105. User user = session.getUser();
  106. if(!Constant.ADMINISTRATION_SYSTEM_NUMBER.equals(user.getBranchId())){
  107. throw new MINBusinessException("此用户没有权限,此操作");
  108. }
  109. String id = Service.lookup(IPublicService.class).getSequence("RECHARGE_RULE_NO");
  110. String time = new DateTime().toDateTimeString();
  111. id = time.concat(id);
  112. VmRechargeRule vmRechargeRule = new VmRechargeRule();
  113. vmRechargeRule.setId(id);
  114. vmRechargeRule.setRechargeAmt(rechargeAmt);
  115. vmRechargeRule.setGiveAmt(giveAmt);
  116. vmRechargeRule.setDesc(desc);
  117. vmRechargeRule.setCreateTime(time);
  118. vmRechargeRule.setCreateUser(user.getId());
  119. Service.lookup(IMINDataBaseService.class).insertSelective(VmRechargeRuleMapper.class, vmRechargeRule);
  120. String logInfo = "添加充值规则:" + id;
  121. Service.lookup(ILogService.class).logging(session, logInfo);
  122. return res;
  123. }
  124. @MINValidator(value = ADD_RECHARGE_RULE)
  125. public MINActionResult addRechargeRuleValidator(
  126. @MINParam(key = "rechargeAmt",regex = RegexUtil.AMOUNT_NOTNULL, error = "请正确的金额") String rechargeAmt,
  127. @MINParam(key = "giveAmt",regex = RegexUtil.AMOUNT_NOTNULL, error = "请正确的金额") String giveAmt,
  128. MINSession session) throws MINBusinessException {
  129. MINActionResult res = new MINActionResult();
  130. return res;
  131. }
  132. /**
  133. * 编辑充值规则
  134. * @param id
  135. * @param rechargeAmt
  136. * @param giveAmt
  137. * @param desc
  138. * @param session
  139. * @return
  140. * @throws MINBusinessException
  141. */
  142. @MINAction(value = MODIFY_RECHARGE_RULE, transaction = IMINTransactionEnum.CMT)
  143. public MINActionResult modifyRechargeRule(
  144. @MINParam(key = "id") String id,
  145. @MINParam(key = "rechargeAmt") String rechargeAmt,
  146. @MINParam(key = "giveAmt") String giveAmt,
  147. @MINParam(key = "desc") String desc,
  148. MINSession session
  149. ) throws MINBusinessException {
  150. MINActionResult res = new MINActionResult();
  151. VmRechargeRule vmRechargeRule = new VmRechargeRule();
  152. vmRechargeRule.setId(id);
  153. vmRechargeRule.setRechargeAmt(rechargeAmt);
  154. vmRechargeRule.setGiveAmt(giveAmt);
  155. vmRechargeRule.setDesc(desc);
  156. Service.lookup(IMINDataBaseService.class).updateByPrimaryKeySelective(VmRechargeRuleMapper.class, vmRechargeRule);
  157. String logInfo = "编辑充值规则:" + id;
  158. Service.lookup(ILogService.class).logging(session, logInfo);
  159. return res;
  160. }
  161. @MINValidator(value = MODIFY_RECHARGE_RULE)
  162. public MINActionResult modifyRechargeRuleValidator(
  163. @MINParam(key = "id",regex = RegexUtil.NOT_NULL, error = "数据异常") String id,
  164. @MINParam(key = "rechargeAmt",regex = RegexUtil.AMOUNT_NOTNULL, error = "请正确的金额") String rechargeAmt,
  165. @MINParam(key = "giveAmt",regex = RegexUtil.AMOUNT_NOTNULL, error = "请正确的金额") String giveAmt,
  166. MINSession session) throws MINBusinessException {
  167. MINActionResult res = new MINActionResult();
  168. return res;
  169. }
  170. /**
  171. * 删除规则
  172. * @param id
  173. * @param session
  174. * @return
  175. * @throws MINBusinessException
  176. */
  177. @MINAction(value = DELETE_RECHARGE_RULE, transaction = IMINTransactionEnum.CMT)
  178. public MINActionResult deleteRechargeRule(
  179. @MINParam(key = "id") String id,
  180. MINSession session
  181. ) throws MINBusinessException {
  182. MINActionResult res = new MINActionResult();
  183. VmRechargeRule vmRechargeRule = new VmRechargeRule();
  184. vmRechargeRule.setId(id);
  185. vmRechargeRule.setState("1");
  186. Service.lookup(IMINDataBaseService.class).updateByPrimaryKeySelective(VmRechargeRuleMapper.class, vmRechargeRule);
  187. String logInfo = "删除充值规则:" + id;
  188. Service.lookup(ILogService.class).logging(session, logInfo);
  189. return res;
  190. }
  191. @MINValidator(value = DELETE_RECHARGE_RULE)
  192. public MINActionResult deleteRechargeRuleValidator(
  193. @MINParam(key = "id",regex = RegexUtil.NOT_NULL, error = "数据异常") String id,
  194. MINSession session) throws MINBusinessException {
  195. MINActionResult res = new MINActionResult();
  196. return res;
  197. }
  198. }