BusinessNumManageAction.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. package com.minpay.payManage.action;
  2. import com.minpay.common.bean.User;
  3. import com.minpay.common.constant.Constant;
  4. import com.minpay.common.format.IFormatService;
  5. import com.minpay.common.service.ILogService;
  6. import com.minpay.common.service.IPublicService;
  7. import com.minpay.common.util.DateUtil;
  8. import com.minpay.db.table.mapper.VmAccountMapper;
  9. import com.minpay.db.table.mapper.VmHlAccountMapper;
  10. import com.minpay.db.table.model.VmAccount;
  11. import com.minpay.db.table.model.VmAccountExample;
  12. import com.minpay.db.table.model.VmHlAccount;
  13. import com.minpay.db.table.model.VmHlAccountExample;
  14. import com.mysql.jdbc.StringUtils;
  15. import com.startup.minpay.frame.business.IMINAction;
  16. import com.startup.minpay.frame.business.res.MINActionResult;
  17. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  18. import com.startup.minpay.frame.constant.IMINTransactionEnum;
  19. import com.startup.minpay.frame.data.format.MINCopyFormat;
  20. import com.startup.minpay.frame.exception.MINBusinessException;
  21. import com.startup.minpay.frame.jdbc.MINRowBounds;
  22. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  23. import com.startup.minpay.frame.service.base.Service;
  24. import com.startup.minpay.frame.session.MINSession;
  25. import com.startup.minpay.frame.target.MINAction;
  26. import com.startup.minpay.frame.target.MINComponent;
  27. import com.startup.minpay.frame.target.MINParam;
  28. import java.util.List;
  29. /**
  30. * 收款商户号管理
  31. *
  32. * @author weijg
  33. * 2020-08-25 23:15
  34. */
  35. @MINComponent
  36. public class BusinessNumManageAction implements IMINAction {
  37. /** 收款商户号信息查询 */
  38. public final static String TENCENTMANAGE_QUERY = "businessNumManageQuery";
  39. /** 添加收款商户号 */
  40. public final static String ADD_TENCENT = "addbusinessNum";
  41. /** 删除收款商户号 */
  42. public final static String DELETE_TENCENT = "deleteBusinessNum";
  43. /** 修改收款商户号 */
  44. public final static String MODIFY_TENCENT = "modifybusinessNum";
  45. /** 查询所有收款商户号 */
  46. public final static String QUERY_TENCENT = "queryTencent";
  47. /**
  48. * 收款商户号信息查询
  49. * @param session
  50. * @param accountName 商户名称
  51. * @param accountId 商户号
  52. * @param type 商户类型
  53. * @param page
  54. * @param limit
  55. * @return
  56. * @throws MINBusinessException
  57. */
  58. @MINAction(value = TENCENTMANAGE_QUERY)
  59. public MINActionResult businessNumManageQuery(MINSession session,
  60. // @MINParam(key = "userId") String userId,
  61. @MINParam(key = "accountName") String accountName,
  62. @MINParam(key = "accountId") String accountId,
  63. @MINParam(key = "type") String type,
  64. @MINParam(key = "page", defaultValue = "1") int page,
  65. @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
  66. MINActionResult res = new MINActionResult();
  67. // 查询当前角色编号
  68. User u = session.getUser();
  69. String imUserId = u.getId();
  70. MINRowBounds rows = new MINRowBounds(page, limit);
  71. VmHlAccountExample vmHlAccountExample = new VmHlAccountExample();
  72. VmHlAccountExample.Criteria createCriteria = vmHlAccountExample.createCriteria();
  73. if(!StringUtils.isNullOrEmpty(accountName)){
  74. createCriteria.andNameLike("%"+accountName+"%");
  75. }
  76. if(!StringUtils.isNullOrEmpty(type)){
  77. createCriteria.andTypeEqualTo(type);
  78. }
  79. if(Constant.ADMINISTRATION_SYSTEM_NUMBER.equals(u.getBranchId())){
  80. if(!StringUtils.isNullOrEmpty(accountId)){
  81. createCriteria.andUsridEqualTo(accountId);
  82. }
  83. }else{
  84. createCriteria.andUsridEqualTo(u.getBranchId());
  85. }
  86. createCriteria.andStateEqualTo("00");
  87. List<VmHlAccount> businessNumList = Service.lookup(IMINDataBaseService.class)
  88. .getMybatisMapper(VmHlAccountMapper.class).selectByExample(vmHlAccountExample,rows);
  89. businessNumList = new MINCopyFormat("{type:'typeDesc'}").format(businessNumList);
  90. businessNumList = Service.lookup(IFormatService.class).formatEnum(businessNumList, "{typeDesc:'BUSINESSNUM_TYPE'}");
  91. businessNumList = Service.lookup(IFormatService.class).formatDateTime(businessNumList, "createTime");
  92. res.set(IMINBusinessConstant.F_PAGING_LAY, businessNumList);
  93. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
  94. return res;
  95. }
  96. /**
  97. * 添加收款商户号
  98. * @param name 账户名称
  99. * @param type 账户类型
  100. * @param session
  101. * @return
  102. * @throws MINBusinessException
  103. */
  104. @MINAction(value = ADD_TENCENT,transaction = IMINTransactionEnum.CMT)
  105. public MINActionResult addbusinessNum(
  106. @MINParam(key = "accountId") String accountId,
  107. @MINParam(key = "name") String name,
  108. @MINParam(key = "type") String type,
  109. @MINParam(key = "number") String number,
  110. MINSession session) throws MINBusinessException {
  111. MINActionResult res = new MINActionResult();
  112. //获取当前时间
  113. String nowTime = DateUtil.getCurrentDateTimeString();
  114. // 获取操作员信息
  115. User user = session.getUser();
  116. //查询收款商户号是否重复
  117. VmAccountExample accountExample = new VmAccountExample();
  118. accountExample.createCriteria().andIdEqualTo(accountId);
  119. List<VmAccount> list = Service.lookup(IMINDataBaseService.class)
  120. .getMybatisMapper(VmAccountMapper.class)
  121. .selectByExample(accountExample);
  122. if(list.size() > 0 ){
  123. throw new MINBusinessException("收款商户号重复");
  124. }
  125. // 获取商品主键
  126. String id = Service.lookup(IPublicService.class).getSequence("VM_ACT_ID");
  127. VmHlAccount vti = new VmHlAccount();
  128. vti.setId(id); // 账户ID
  129. vti.setName(name); // 账户名称
  130. vti.setUsrid(accountId); // 存储机构编号
  131. vti.setType(type); // 账户类型
  132. vti.setNumber(number); // 账号
  133. vti.setChannel(user.getChannel()); // 渠道(V01:自助售货机)
  134. vti.setCreateUser(user.getId()); // 创建人
  135. vti.setCreateTime(nowTime); // 创建时间
  136. vti.setModifyUser(user.getId()); // 修改人
  137. vti.setModifyTime(nowTime); // 修改时间
  138. // 新增收款商户号信息,执行插入数据
  139. Service.lookup(IMINDataBaseService.class)
  140. .getMybatisMapper(VmHlAccountMapper.class)
  141. .insertSelective(vti);
  142. // 记录操作日志
  143. String logInfo = "操作员:" + user.getName() + "添加收款商户号,收款商户号编号:" + accountId;
  144. Service.lookup(ILogService.class).logging(session, logInfo);
  145. return res;
  146. }
  147. /**
  148. *修改收款商户号
  149. * @param id 账户ID
  150. * @param accountName 账户名称
  151. * @param accountType 账户类型
  152. * @param number 三方账号
  153. * @param session
  154. * @return
  155. * @throws MINBusinessException
  156. */
  157. @MINAction(value = MODIFY_TENCENT, transaction = IMINTransactionEnum.CMT )
  158. public MINActionResult modifybusinessNum(
  159. @MINParam(key = "id") String id,
  160. @MINParam(key = "accountName") String accountName,
  161. @MINParam(key = "accountType") String accountType,
  162. @MINParam(key = "number") String number,
  163. MINSession session) throws MINBusinessException{
  164. MINActionResult res = new MINActionResult();
  165. //获取操作员信息
  166. User user = session.getUser();
  167. //获取当前时间
  168. String dateTime = com.min.util.DateUtil.getCurrentDateTimeString();
  169. VmHlAccount vti = new VmHlAccount();
  170. vti.setId(id); // 账户ID
  171. vti.setName(accountName); // 账户名称
  172. vti.setType(accountType); // 账户类型
  173. vti.setNumber(number); // 账号
  174. vti.setChannel(user.getChannel()); // 渠道(V01:自助售货机)
  175. vti.setModifyUser(user.getId()); // 修改人
  176. vti.setModifyTime(dateTime); // 修改时间
  177. //执行修改
  178. Service.lookup(IMINDataBaseService.class)
  179. .getMybatisMapper(VmHlAccountMapper.class)
  180. .updateByPrimaryKeySelective(vti);
  181. //记录日志信息
  182. String logInfo = "操作员:"+user.getName() +"修改收款商户号,名称:"+ accountName +",编号: "+ id;
  183. Service.lookup(ILogService.class).logging(session, logInfo);
  184. return res;
  185. }
  186. /**
  187. * 收款商户号删除
  188. * @param id
  189. * @param session
  190. * @return
  191. * @throws MINBusinessException
  192. */
  193. @MINAction(value = DELETE_TENCENT, session = true)
  194. public MINActionResult deleteBusinessNum(
  195. @MINParam(key = "id") String id,
  196. MINSession session
  197. ) throws MINBusinessException {
  198. MINActionResult res = new MINActionResult();
  199. VmHlAccount ta = new VmHlAccount();
  200. ta.setState("01"); //删除
  201. ta.setId(id);
  202. //更新数据
  203. Service.lookup(IMINDataBaseService.class).updateByPrimaryKeySelective(VmHlAccountMapper.class, ta);
  204. Service.lookup(ILogService.class).logging(session, "删除收款商户号id:" + id);
  205. return res;
  206. }
  207. /**
  208. * 查询所有商户号
  209. *
  210. * @param session
  211. * @return
  212. * @throws MINBusinessException
  213. */
  214. @MINAction(value = QUERY_TENCENT)
  215. public MINActionResult queryTencent(MINSession session) throws MINBusinessException {
  216. MINActionResult res = new MINActionResult();
  217. VmHlAccountExample example = new VmHlAccountExample();
  218. VmHlAccountExample.Criteria criteria = example.createCriteria();
  219. User user = session.getUser();
  220. criteria.andStateNotEqualTo("00");
  221. if(!user.getBranchId().equals(Constant.DEFAULT_INSTITUTIONS)){
  222. criteria.andIdEqualTo(user.getBranchId());
  223. }
  224. List<VmHlAccount> ls = Service.lookup(IMINDataBaseService.class).selectByExample(VmHlAccountMapper.class, example);
  225. res.set(IMINBusinessConstant.F_QUERY_RESULT, ls);
  226. return res;
  227. }
  228. }