|
|
@@ -0,0 +1,237 @@
|
|
|
+package com.tianhu.system.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.keao.tianhu.starter.mybatis.plus.controller.BaseController;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.web.domain.AjaxResult;
|
|
|
+import com.tianhu.common.security.annotation.PreAuthorize;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteZxBankService;
|
|
|
+import com.tianhu.system.api.domain.SysUser;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import com.tianhu.system.domain.PayAccInf;
|
|
|
+import com.tianhu.system.domain.PubVerifyCode;
|
|
|
+import com.tianhu.system.domain.SysUserCompanyRel;
|
|
|
+import com.tianhu.system.domain.ZcChargeInf;
|
|
|
+import com.tianhu.system.service.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: UserWthdrawalController提现<br>
|
|
|
+ * Description: Controller <br>
|
|
|
+ * Company: keao
|
|
|
+ *
|
|
|
+ * @author peixh
|
|
|
+ * @version v1.0.0 2021-10-19 peixh 由Generator自动创建
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/userWthdrawal")
|
|
|
+public class UserWthdrawalController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPayAccInfService payAccInfService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserCompanyRelService iSysUserCompanyRelService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService iSysUserService;
|
|
|
+ @Autowired
|
|
|
+ private IPubVerifyCodeService iPubVerifyCodeService;
|
|
|
+ @Autowired
|
|
|
+ private OwnUserWthdrawalService ownUserWthdrawalService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteZxBankService remoteZxBankService;
|
|
|
+ @Autowired
|
|
|
+ private IPayAccInfService iPayAccInfService;
|
|
|
+ @Autowired
|
|
|
+ private IZcChargeInfService iZcChargeInfService;
|
|
|
+
|
|
|
+ @PreAuthorize(hasPermi = "user:wthdrawal:add")
|
|
|
+ @PostMapping("wthdrawal")
|
|
|
+ public R wthdrawal(@RequestBody Map map) {
|
|
|
+ //验证码
|
|
|
+ String shortMessageCode = CommonUtil.objToString(map.get("shortMessageCode"));
|
|
|
+ //实体账户
|
|
|
+ String stAccNo = CommonUtil.objToString(map.get("stAccNo"));
|
|
|
+ //电子账户
|
|
|
+ String dzAccNo = CommonUtil.objToString(map.get("dzAccNo"));
|
|
|
+ //提现金额
|
|
|
+ String tranAmt = CommonUtil.objToString(map.get("tranAmt"));
|
|
|
+ //获取当前操作人员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+ //查询经办人手机号
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ //企业id
|
|
|
+ wrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
+ //是否经办人 0:不是, 1:是
|
|
|
+ wrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> userCompanyList = iSysUserCompanyRelService.findSysUserCompanyRels(wrapper);
|
|
|
+ //手机号
|
|
|
+ Long userId = userCompanyList.get(0).getSucrUserId();
|
|
|
+ SysUser sysUser = iSysUserService.selectUserById(userId);
|
|
|
+ String phone = sysUser.getUserName();
|
|
|
+ // 验证短信验证码
|
|
|
+ if(CommonUtil.isNotEmpty(shortMessageCode)){
|
|
|
+ LambdaQueryWrapper<PubVerifyCode> pubVerifyCode = new LambdaQueryWrapper<>();
|
|
|
+ pubVerifyCode.eq(PubVerifyCode::getPvcPhone,phone);
|
|
|
+ pubVerifyCode.eq(PubVerifyCode::getPvcCode,shortMessageCode);
|
|
|
+ pubVerifyCode.orderByDesc(PubVerifyCode::getPvcLastTime);
|
|
|
+ List<PubVerifyCode> staffInf = iPubVerifyCodeService.findPubVerifyCodes(pubVerifyCode);
|
|
|
+ if(staffInf.size()>0){
|
|
|
+ if("01".equals(staffInf.get(0).getPvcState())){
|
|
|
+ return R.fail("验证码已失效,请重新获取!");
|
|
|
+ }
|
|
|
+ //取得指定时间间隔后的系统时间
|
|
|
+ GregorianCalendar calendar = (GregorianCalendar) Calendar.getInstance();
|
|
|
+ calendar.add( Calendar.MINUTE, -5);
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ if(formatter.format(calendar.getTime()).compareTo(formatter.format(staffInf.get(0).getPvcLastTime()))>0){
|
|
|
+ return R.fail("验证码已失效,请重新获取!");
|
|
|
+ }
|
|
|
+
|
|
|
+ staffInf.get(0).setPvcState("01");
|
|
|
+ iPubVerifyCodeService.updatePubVerifyCode(staffInf.get(0));
|
|
|
+ remoteZxBankService.withdrawalInterface(stAccNo,tranAmt);
|
|
|
+ }else{
|
|
|
+ return R.fail("验证码错误,请重新输入!");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return R.fail("请填写验证码");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询费用状态
|
|
|
+ * @param accNo 电子账户
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listChargeStatus/{accNo}")
|
|
|
+ public AjaxResult listChargeStatus(@PathVariable("accNo") String accNo){
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //企业id
|
|
|
+ map.put("companyId",companyId);
|
|
|
+ //电子账户
|
|
|
+ map.put("accNo",accNo);
|
|
|
+ List<Map> list = ownUserWthdrawalService.selectChargeInfList(map);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转账(缴纳手续费)
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("payMoney")
|
|
|
+ public R payMoney(@RequestBody Map<String, Object> map) {
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ String userId = user.getUserId()+"";
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+ String accNo = map.get("accNo")+"";
|
|
|
+ Map maps = new HashMap();
|
|
|
+ //企业id
|
|
|
+ maps.put("companyId",companyId);
|
|
|
+ //电子账户
|
|
|
+ maps.put("accNo",accNo);
|
|
|
+ List<Map> list = ownUserWthdrawalService.selectChargeInfList(map);
|
|
|
+ //--------------------查询本公司电子账户
|
|
|
+ LambdaQueryWrapper<PayAccInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //企业id
|
|
|
+ queryWrapper.eq(PayAccInf::getPaiCstno,companyId);
|
|
|
+ //账户类型(00基本账户01贷款账户02信用账户03手续费账户04待结算账户05提现账户06虚拟账户)
|
|
|
+ queryWrapper.eq(PayAccInf::getPaiAcctype,"06");
|
|
|
+ //开户行号(1000:中信银行)
|
|
|
+ queryWrapper.eq(PayAccInf::getPaiQlbankno,"302");
|
|
|
+ //账户状态(0:未开通,1:冻结,2已开通3:待激活)
|
|
|
+ queryWrapper.eq(PayAccInf::getPaiStatus,"2");
|
|
|
+ List<PayAccInf> accInfList = iPayAccInfService.findPayAccInfs(queryWrapper);
|
|
|
+ //账号
|
|
|
+ String paiAccNo = "";
|
|
|
+ //账户名称
|
|
|
+ String paiAccnoName = "";
|
|
|
+ if (accInfList.size() > 0){
|
|
|
+ paiAccNo = accInfList.get(0).getPaiAccno();
|
|
|
+ paiAccnoName = accInfList.get(0).getPaiAccnoName();
|
|
|
+ }
|
|
|
+ //--------------------查询平台公共计息账户
|
|
|
+ LambdaQueryWrapper<PayAccInf> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ //企业id
|
|
|
+ wrapper.eq(PayAccInf::getPaiCstno,"000000");
|
|
|
+ //账户类型(00基本账户01贷款账户02信用账户03手续费账户04待结算账户05提现账户06虚拟账户)
|
|
|
+ wrapper.eq(PayAccInf::getPaiAcctype,"07");
|
|
|
+ //开户行号(1000:中信银行)
|
|
|
+ wrapper.eq(PayAccInf::getPaiQlbankno,"302");
|
|
|
+ //账户状态(0:未开通,1:冻结,2已开通3:待激活)
|
|
|
+ wrapper.eq(PayAccInf::getPaiStatus,"2");
|
|
|
+ List<PayAccInf> accList = iPayAccInfService.findPayAccInfs(wrapper);
|
|
|
+ //账号
|
|
|
+ String accountNo = "";
|
|
|
+ //开户行名
|
|
|
+ String accnoName = "";
|
|
|
+ if (accList.size() > 0){
|
|
|
+ accountNo = accList.get(0).getPaiAccno();
|
|
|
+ accnoName = accList.get(0).getPaiAccnoName();
|
|
|
+ }
|
|
|
+ List<Map> result = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ //费用主键
|
|
|
+ String zciId = list.get(i).get("zciId")+"";
|
|
|
+ //手续费
|
|
|
+ String zciAmount = list.get(i).get("zciAmount")+"";
|
|
|
+ //融资编号
|
|
|
+ String zfrNumber = list.get(i).get("zfrNumber")+"";
|
|
|
+ R r = remoteZxBankService.transfer(paiAccNo,accountNo,accnoName,zciAmount,companyId,zciId,"10");
|
|
|
+ //数据信息
|
|
|
+ Map mapData = (Map) r.getData();
|
|
|
+ //状态是否存在
|
|
|
+ ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
+ zcChargeInf.setZciId(zciId);
|
|
|
+ if(mapData.containsKey("status")) {
|
|
|
+ //状态 0 交易中 1 成功 2 失败
|
|
|
+ String status = mapData.get("status").toString();
|
|
|
+ if (!"1".equals(status)){
|
|
|
+ Map end = new HashMap();
|
|
|
+ end.put("status",status);
|
|
|
+ end.put("zfrNumber",zfrNumber);
|
|
|
+ end.put("zciAmount",zciAmount);
|
|
|
+ result.add(end);
|
|
|
+ }else if ("0".equals(status)){
|
|
|
+ zcChargeInf.setZciStatus("01");
|
|
|
+ }else if ("1".equals(status)){
|
|
|
+ zcChargeInf.setZciStatus("02");
|
|
|
+ }else if ("2".equals(status)){
|
|
|
+ zcChargeInf.setZciStatus("05");
|
|
|
+ }
|
|
|
+ zcChargeInf.setUpdateBy(userId);
|
|
|
+ zcChargeInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ iZcChargeInfService.updateZcChargeInf(zcChargeInf);
|
|
|
+ }else {
|
|
|
+ zcChargeInf.setZciStatus("05");
|
|
|
+ zcChargeInf.setUpdateBy(userId);
|
|
|
+ zcChargeInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ iZcChargeInfService.updateZcChargeInf(zcChargeInf);
|
|
|
+ return R.fail("缴费失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
+}
|