|
@@ -0,0 +1,929 @@
|
|
|
+package com.jpsoft.bus.modules.mobile.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
|
|
|
+import com.jpsoft.bus.modules.base.entity.OrderInfo;
|
|
|
+import com.jpsoft.bus.modules.base.entity.ProblemFeedback;
|
|
|
+import com.jpsoft.bus.modules.base.service.MergeOrderInfoService;
|
|
|
+import com.jpsoft.bus.modules.base.service.OrderInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.VehicleDTO;
|
|
|
+import com.jpsoft.bus.modules.bus.entity.*;
|
|
|
+import com.jpsoft.bus.modules.bus.service.*;
|
|
|
+import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.bus.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.bus.modules.common.utils.DES3;
|
|
|
+import com.jpsoft.bus.modules.common.utils.JwtUtil;
|
|
|
+import com.jpsoft.bus.modules.common.utils.SMSUtil;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.ProfitListDTO;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.SellListDTO;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.WithdrawalRecordDetailDTO;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.WithdrawalRecordListDTO;
|
|
|
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
|
|
|
+import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
|
|
|
+import com.jpsoft.bus.modules.merchant.entity.WithdrawalRecord;
|
|
|
+import com.jpsoft.bus.modules.merchant.service.AccountInfoService;
|
|
|
+import com.jpsoft.bus.modules.merchant.service.CapitalInfoService;
|
|
|
+import com.jpsoft.bus.modules.merchant.service.WithdrawalRecordService;
|
|
|
+import com.jpsoft.bus.modules.sys.entity.DataDictionary;
|
|
|
+import com.jpsoft.bus.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.BigInteger;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 墨鱼_mo
|
|
|
+ * @date 2021-5-7 11:05
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/merchantApi")
|
|
|
+@Api(value = "merchantApi")
|
|
|
+@Slf4j
|
|
|
+public class MerchantApiController {
|
|
|
+
|
|
|
+ @Value("${jwt.secret}")
|
|
|
+ private String jwtSecret;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DriverInfoService driverInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RouteInfoService routeInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PassengerInfoService passengerInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CapitalInfoService capitalInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WithdrawalRecordService withdrawalRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MergeOrderInfoService mergeOrderInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderInfoService orderInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VehicleInfoService vehicleInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StationInfoService stationInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ShiftInfoService shiftInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AccountInfoService accountInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("getVerifyCode")
|
|
|
+ @ApiOperation(value = "商户获取短信验证码(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phone", value = "电话", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<String> getVerifyCode(String phone) {
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.findByPhone(phone);
|
|
|
+ if (accountInfo == null) {
|
|
|
+ throw new Exception("该号码还未注册营收管理员帐号");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String key = "SMS_" + phone;
|
|
|
+
|
|
|
+ String verifyCode = (String) redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(verifyCode)) {
|
|
|
+ verifyCode = SMSUtil.generateNumberString(6);
|
|
|
+ JSONObject verifyCodeJSON = new JSONObject();
|
|
|
+ verifyCodeJSON.put("code", verifyCode);
|
|
|
+
|
|
|
+ messageResult = SMSUtil.send(phone, "车信达", "SMS_49390047", verifyCodeJSON.toString());
|
|
|
+
|
|
|
+ //设置当前用户的验证码,5分钟内有效
|
|
|
+ redisTemplate.opsForValue().set(key, verifyCode, 5, TimeUnit.MINUTES);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("validateCode")
|
|
|
+ @ApiOperation(value = "验证短信验证码(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "verifyCode", value = "验证码", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "openId", value = "微信openId", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> validateCode(String phone, String verifyCode, String openId) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.findByPhone(phone);
|
|
|
+ if (accountInfo == null) {
|
|
|
+ throw new Exception("该号码还未注册营收管理员帐号");
|
|
|
+ }
|
|
|
+ String smsKey = "SMS_" + phone;
|
|
|
+
|
|
|
+ String beforeVerifyCode = (String) redisTemplate.opsForValue().get(smsKey);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
+ throw new Exception("用户标识为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(beforeVerifyCode)) {
|
|
|
+ throw new Exception("验证码已过期!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!beforeVerifyCode.equals(verifyCode)) {
|
|
|
+ throw new Exception("验证码错误!");
|
|
|
+ }
|
|
|
+
|
|
|
+ accountInfo.setOpenId(openId);
|
|
|
+ accountInfoService.update(accountInfo);
|
|
|
+
|
|
|
+
|
|
|
+ String token = JwtUtil.createToken(jwtSecret, String.valueOf(accountInfo.getId()), DateTime.now().plusDays(30).toDate());
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("token", token);
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("findByOpenId")
|
|
|
+ @ApiOperation(value = "通过openId查询人员(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "openId", value = "微信openId", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> findByOpenId(String openId) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (StringUtils.isBlank(openId)) {
|
|
|
+ throw new Exception("获取微信信息有误");
|
|
|
+ }
|
|
|
+ AccountInfo accountInfo = accountInfoService.findByOpenId(openId);
|
|
|
+
|
|
|
+ String token = JwtUtil.createToken(jwtSecret, String.valueOf(accountInfo.getId()), DateTime.now().plusDays(30).toDate());
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("token", token);
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("revenueStatisticsUp")
|
|
|
+ @ApiOperation(value = "营收统计(上)")
|
|
|
+ public MessageResult<Map> revenueStatisticsUp(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ //今日收益
|
|
|
+ BigDecimal todayRevenue = BigDecimal.ZERO;
|
|
|
+ //昨日收益
|
|
|
+ BigDecimal yesterdayRevenue = BigDecimal.ZERO;
|
|
|
+ //累计收益
|
|
|
+ BigDecimal totalRevenue = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
|
|
|
+ if (capitalInfo != null){
|
|
|
+ totalRevenue = capitalInfo.getTotalRevenue();
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (vehicleInfoList.size()>0){
|
|
|
+ //今日收益
|
|
|
+ BigDecimal todaySum = orderInfoService.paySum(null,companyInfo.getId(),null, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (todaySum != null){
|
|
|
+ todayRevenue = todaySum;
|
|
|
+ }
|
|
|
+ //昨日收益
|
|
|
+ BigDecimal yesterdaySum = orderInfoService.paySum(null,companyInfo.getId(),null,DateUtil.beginOfDay(DateUtil.offsetDay(new Date(),-1)),DateUtil.endOfDay(DateUtil.offsetDay(new Date(),-1)),null);
|
|
|
+ if (yesterdaySum != null){
|
|
|
+ yesterdayRevenue = yesterdaySum;
|
|
|
+ }
|
|
|
+
|
|
|
+ //总收益
|
|
|
+ BigDecimal totalSum = orderInfoService.paySum(null,companyInfo.getId(),null,null,new cn.hutool.core.date.DateTime(),null);
|
|
|
+
|
|
|
+ if (totalSum != null){
|
|
|
+ totalRevenue = totalSum;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("todayRevenue",todayRevenue);
|
|
|
+ map.put("yesterdayRevenue",yesterdayRevenue);
|
|
|
+ map.put("totalRevenue",totalRevenue);
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("revenueStatisticsDown")
|
|
|
+ @ApiOperation(value = "营收统计(下)")
|
|
|
+ public MessageResult<Map> revenueStatisticsDown(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ //线上购票款
|
|
|
+ BigDecimal onlineRevenue = BigDecimal.ZERO;
|
|
|
+ //微信收款
|
|
|
+ BigDecimal wechatRevenue = BigDecimal.ZERO;
|
|
|
+ //支付宝收款
|
|
|
+ BigDecimal alipayRevenue = BigDecimal.ZERO;
|
|
|
+ //现金收款
|
|
|
+ BigDecimal cashRevenue = BigDecimal.ZERO;
|
|
|
+ //车票收款
|
|
|
+ BigDecimal ticketRevenue = BigDecimal.ZERO;
|
|
|
+ //售票数
|
|
|
+ Integer num = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // if (vehicleInfoList.size()>0){
|
|
|
+ //微信
|
|
|
+ BigDecimal wechatSum = orderInfoService.paySum(null,companyInfo.getId(),"wechat", DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (wechatSum != null){
|
|
|
+ wechatRevenue = wechatSum;
|
|
|
+ }
|
|
|
+ //支付宝
|
|
|
+ BigDecimal alipaySum = orderInfoService.paySum(null,companyInfo.getId(),"alipay",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (alipaySum != null){
|
|
|
+ alipayRevenue = alipaySum;
|
|
|
+ }
|
|
|
+
|
|
|
+ //现金
|
|
|
+ BigDecimal cashSum = orderInfoService.paySum(null,companyInfo.getId(),"cash",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (cashSum != null){
|
|
|
+ cashRevenue = cashSum;
|
|
|
+ }
|
|
|
+
|
|
|
+ //车票
|
|
|
+ BigDecimal ticketSum = orderInfoService.paySum(null,companyInfo.getId(),"ticket",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (ticketSum != null){
|
|
|
+ ticketRevenue = ticketSum;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer ticketNum = orderInfoService.payNum(null,companyInfo.getId(),null,DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
|
|
|
+ if (ticketNum != null){
|
|
|
+ num = ticketNum;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("onlineRevenue",wechatRevenue.add(alipayRevenue));
|
|
|
+ map.put("wechatRevenue",wechatRevenue);
|
|
|
+ map.put("alipayRevenue",alipayRevenue);
|
|
|
+ map.put("cashRevenue",cashRevenue);
|
|
|
+ map.put("ticketRevenue",ticketRevenue);
|
|
|
+ map.put("num",num);
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("merchantVehicleList")
|
|
|
+ @ApiOperation(value = "商户的车辆列表")
|
|
|
+ public MessageResult<List<VehicleDTO>> merchantVehicleList(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<List<VehicleDTO>> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ List<VehicleDTO> list = new ArrayList<>();
|
|
|
+ if (vehicleInfoList.size()>0){
|
|
|
+ for (VehicleInfo vehicleInfo : vehicleInfoList){
|
|
|
+ VehicleDTO vehicleDTO = new VehicleDTO();
|
|
|
+ BeanUtils.copyProperties(vehicleInfo,vehicleDTO);
|
|
|
+ list.add(vehicleDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData(list);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("profitList")
|
|
|
+ @ApiOperation(value = "收益明细")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "vehicleId", value = "车辆id", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "dateStr", value = "时间(格式:yyyy-MM)", required = false, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<ProfitListDTO> profitList(String vehicleId,String payName,String dateStr,String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<ProfitListDTO> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ ProfitListDTO profitListDTO = new ProfitListDTO();
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(vehicleId)){
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ if (vehicleInfo != null){
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int n = 0;
|
|
|
+ //开始计算的日期
|
|
|
+ Date startDate = DateUtil.endOfDay(new Date());
|
|
|
+ Date newDate = DateUtil.beginOfMonth(new Date());
|
|
|
+ String dateDesc = DateUtil.format(newDate,"yyyy年MM月");
|
|
|
+ if (StringUtils.isNotBlank(dateStr)){
|
|
|
+ Date date = DateUtil.parse(dateStr,"yyyy-MM");
|
|
|
+
|
|
|
+ dateDesc = DateUtil.format(date,"yyyy年MM月");
|
|
|
+ if (newDate.compareTo(DateUtil.beginOfMonth(date))>0){
|
|
|
+ Date endOfMonth = DateUtil.endOfMonth(date);
|
|
|
+ n = DateUtil.dayOfMonth(endOfMonth);
|
|
|
+ startDate = DateUtil.endOfMonth(date);
|
|
|
+ }else if(newDate.compareTo(DateUtil.beginOfMonth(date))==0){
|
|
|
+ n = DateUtil.thisDayOfMonth();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ n = DateUtil.thisDayOfMonth();
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal revenue = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ profitListDTO.setDateDesc(dateDesc);
|
|
|
+
|
|
|
+
|
|
|
+ List<ProfitListDTO> list = new ArrayList<>();
|
|
|
+ if (n>0){
|
|
|
+ for (int m = 0 ; m <n; m++){
|
|
|
+ ProfitListDTO profitListDTO1 = new ProfitListDTO();
|
|
|
+ Date baseDate = DateUtil.offsetDay(startDate,-m);
|
|
|
+ Date baseStartDate = DateUtil.beginOfDay(baseDate);
|
|
|
+ // BigDecimal baseSum = BigDecimal.ZERO;
|
|
|
+ // if (vehicleInfoList.size()>0){
|
|
|
+ BigDecimal baseSum = orderInfoService.paySum(null,companyInfo.getId(),payName,baseStartDate,baseDate,null);
|
|
|
+ // }
|
|
|
+
|
|
|
+ profitListDTO1.setDateDesc(DateUtil.format(baseDate,"yyyy-MM-dd"));
|
|
|
+ profitListDTO1.setRevenue(baseSum == null?BigDecimal.ZERO:baseSum);
|
|
|
+ list.add(profitListDTO1);
|
|
|
+ revenue = revenue.add(baseSum == null?BigDecimal.ZERO:baseSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ profitListDTO.setRevenue(revenue);
|
|
|
+ profitListDTO.setList(list);
|
|
|
+ messageResult.setData(profitListDTO);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("sellList")
|
|
|
+ @ApiOperation(value = "售票明细")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "vehicleId", value = "车辆id", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "dateStr", value = "时间(格式:yyyy-MM)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "dateType", value = "全天:0,上半天:1,下半天:2", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> sellList(String vehicleId, String payName, String dateStr,String dateType, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(vehicleId)){
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ if (vehicleInfo != null){
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("payStatus",20);
|
|
|
+ if (StringUtils.isNotBlank(payName)){
|
|
|
+ searchParams.put("payName",payName);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = DateUtil.parse(dateStr,"yyyy-MM-dd");
|
|
|
+ Date startTime = DateUtil.beginOfDay(date);
|
|
|
+ Date endTime = DateUtil.endOfDay(date);
|
|
|
+ Date middleTime = DateUtil.parse(dateStr + " 12:00:00","yyyy-MM-dd HH:mm:ss");
|
|
|
+ if ("1".equals(dateType)){
|
|
|
+ endTime = middleTime;
|
|
|
+ }
|
|
|
+ if ("2".equals(dateType)){
|
|
|
+ startTime = middleTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("payBeginTime",startTime);
|
|
|
+ searchParams.put("payEndTime",endTime);
|
|
|
+ if (StringUtils.isNotBlank(vehicleId)){
|
|
|
+ searchParams.put("vehicleId",vehicleId);
|
|
|
+ }
|
|
|
+ searchParams.put("orderCompanyId",companyInfo.getId());
|
|
|
+ // searchParams.put("vehicleInfoList",vehicleInfoList);
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.pay_time","desc"));
|
|
|
+
|
|
|
+ Page<OrderInfo> page = orderInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ List<OrderInfo> orderInfoList = page.getResult();
|
|
|
+ List<SellListDTO> list = new ArrayList<>();
|
|
|
+ if (orderInfoList.size()>0){
|
|
|
+ for (OrderInfo orderInfo : orderInfoList){
|
|
|
+ SellListDTO sellListDTO = new SellListDTO();
|
|
|
+ BeanUtils.copyProperties(orderInfo,sellListDTO);
|
|
|
+
|
|
|
+ MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
|
|
|
+ ShiftInfo shiftInfo = shiftInfoService.get(mergeOrderInfo.getVehicleShiftId());
|
|
|
+ StationInfo start = stationInfoService.get(shiftInfo.getStartStationId());
|
|
|
+ StationInfo end = stationInfoService.get(shiftInfo.getEndStationId());
|
|
|
+ sellListDTO.setRouteName(start.getName() + "-" + end.getName());
|
|
|
+ sellListDTO.setPayNameStr(orderInfo.getPayNameStr(orderInfo.getPayName()));
|
|
|
+ list.add(sellListDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String,Object> pageMap = new HashMap<>();
|
|
|
+ pageMap.put("recordsTotal",page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered",page.getTotal());
|
|
|
+ pageMap.put("totalPage",page.getPages());
|
|
|
+ pageMap.put("pageNumber",page.getPageNum());
|
|
|
+ pageMap.put("pageSize",page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("sellDetail")
|
|
|
+ @ApiOperation(value = "售票详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> sellDetail(String id,String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ OrderInfo orderInfo = orderInfoService.get(id);
|
|
|
+
|
|
|
+ if (orderInfo == null){
|
|
|
+ throw new Exception("订单不存在");
|
|
|
+ }
|
|
|
+ //乘客记录
|
|
|
+ PassengerInfo passengerInfo = passengerInfoService.get(orderInfo.getPassengerId());
|
|
|
+
|
|
|
+ MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
|
|
|
+ //购票上车点
|
|
|
+ StationInfo ticketUpStation = stationInfoService.get(orderInfo.getTicketUpStationId());
|
|
|
+ //购票下车点
|
|
|
+ StationInfo ticketDownStation = stationInfoService.get(orderInfo.getTicketDownStationId());
|
|
|
+
|
|
|
+
|
|
|
+ //班次
|
|
|
+ ShiftInfo shiftInfo = shiftInfoService.get(mergeOrderInfo.getVehicleShiftId());
|
|
|
+ //线路
|
|
|
+ RouteInfo routeInfo = routeInfoService.get(shiftInfo.getRouteId());
|
|
|
+ //班次开始点
|
|
|
+ StationInfo start = stationInfoService.get(shiftInfo.getStartStationId());
|
|
|
+ //班次终点
|
|
|
+ StationInfo end = stationInfoService.get(shiftInfo.getEndStationId());
|
|
|
+ //司机
|
|
|
+ DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
|
|
|
+ //车辆
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ map.put("outOrderNo",orderInfo.getOutOrderNo());
|
|
|
+ map.put("payName",orderInfo.getPayName());
|
|
|
+ map.put("payNameStr",orderInfo.getPayNameStr(orderInfo.getPayName()));
|
|
|
+ map.put("ticketType",orderInfo.getTicketType());
|
|
|
+ map.put("ticketTypeStr",orderInfo.getTicketTypeStr(orderInfo.getTicketType()));
|
|
|
+ map.put("goodTicketFee",orderInfo.getGoodsTicket());
|
|
|
+ map.put("ticketFee",orderInfo.getTotalFee().subtract(orderInfo.getGoodsTicket()));
|
|
|
+ map.put("totalFee",orderInfo.getTotalFee());
|
|
|
+ map.put("ticketTrip",ticketUpStation.getName() + "-" +ticketDownStation.getName());
|
|
|
+ if ("2".equals(passengerInfo.getStatus())){
|
|
|
+ map.put("ticketStatus","已过期");
|
|
|
+ }
|
|
|
+ if ("1".equals(passengerInfo.getStatus())){
|
|
|
+ map.put("ticketStatus","乘车中");
|
|
|
+ }
|
|
|
+ map.put("createTime",DateUtil.format(orderInfo.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ map.put("payTime",DateUtil.format(orderInfo.getPayTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ Date closeTime = null;
|
|
|
+ if (passengerInfo.getDownTime() != null){
|
|
|
+ closeTime = passengerInfo.getDownTime();
|
|
|
+
|
|
|
+ }
|
|
|
+ map.put("closeTime",DateUtil.format(closeTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
+
|
|
|
+ map.put("routeName",routeInfo.getName());
|
|
|
+ map.put("routeTrip",start.getName() + "-" + end.getName());
|
|
|
+ map.put("routeTime",routeInfo.getStartTime() + "-" + routeInfo.getEndTime());
|
|
|
+ map.put("licensePlateNumber",vehicleInfo.getLicensePlateNumber());
|
|
|
+ map.put("driverName",driverInfo.getName());
|
|
|
+ map.put("phone",driverInfo.getPhone());
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("myAccount")
|
|
|
+ @ApiOperation(value = "我的账户")
|
|
|
+ public MessageResult<Map> myAccount(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ BigDecimal withdrawalAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal todayRevenue = BigDecimal.ZERO;
|
|
|
+ BigDecimal onlineTotalRevenue = BigDecimal.ZERO;
|
|
|
+ BigDecimal alreadyWithdrawalAmount = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
|
|
|
+ if (capitalInfo != null){
|
|
|
+ withdrawalAmount = capitalInfo.getWithdrawalAmount();
|
|
|
+ onlineTotalRevenue = capitalInfo.getOnlineTotalRevenue();
|
|
|
+ alreadyWithdrawalAmount = capitalInfo.getAlreadyWithdrawalAmount();
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ // if (vehicleInfoList.size()>0){
|
|
|
+ BigDecimal wechatTodaySum = orderInfoService.paySum(null,companyInfo.getId(),"wechat",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),false);
|
|
|
+ BigDecimal alipayTodaySum = orderInfoService.paySum(null,companyInfo.getId(),"alipay",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),false);
|
|
|
+ todayRevenue = (wechatTodaySum == null?BigDecimal.ZERO:wechatTodaySum).add(alipayTodaySum==null?BigDecimal.ZERO:alipayTodaySum);
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ DataDictionary dataDictionary = dataDictionaryService.findByName("提现日期");
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("withdrawalAmount",withdrawalAmount);
|
|
|
+ map.put("todayRevenue",todayRevenue);
|
|
|
+ map.put("onlineTotalRevenue",onlineTotalRevenue.add(todayRevenue));
|
|
|
+ map.put("alreadyWithdrawalAmount",alreadyWithdrawalAmount);
|
|
|
+ map.put("account",accountInfo);
|
|
|
+ map.put("date",dataDictionary.getValue());
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("logOut")
|
|
|
+ @ApiOperation(value = "登出")
|
|
|
+ public MessageResult<Map> logOut(String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ accountInfo.setOpenId("");
|
|
|
+ accountInfoService.update(accountInfo);
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("withdrawalRecordList")
|
|
|
+ @ApiOperation(value = "提现记录")
|
|
|
+ public MessageResult<Map> withdrawalRecordList(String token, @RequestAttribute String subject,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("merchantId",accountInfo.getId());
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
+ Page<WithdrawalRecord> page = withdrawalRecordService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ List<WithdrawalRecord> withdrawalRecordList = page.getResult();
|
|
|
+ List<WithdrawalRecordListDTO> list = new ArrayList<>();
|
|
|
+ if (withdrawalRecordList.size()>0){
|
|
|
+ for (WithdrawalRecord withdrawalRecord : withdrawalRecordList){
|
|
|
+ WithdrawalRecordListDTO withdrawalRecordListDTO = new WithdrawalRecordListDTO();
|
|
|
+ withdrawalRecordListDTO.setId(withdrawalRecord.getId());
|
|
|
+ withdrawalRecordListDTO.setName("账户提现");
|
|
|
+ withdrawalRecordListDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ withdrawalRecordListDTO.setStatus(withdrawalRecord.getStatus());
|
|
|
+ withdrawalRecordListDTO.setStatusStr(withdrawalRecord.getStatusStr(withdrawalRecord.getStatus()));
|
|
|
+ withdrawalRecordListDTO.setAmount("-" + withdrawalRecord.getApplyWithdrawalAmount());
|
|
|
+ list.add(withdrawalRecordListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String,Object> pageMap = new HashMap<>();
|
|
|
+ pageMap.put("recordsTotal",page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered",page.getTotal());
|
|
|
+ pageMap.put("totalPage",page.getPages());
|
|
|
+ pageMap.put("pageNumber",page.getPageNum());
|
|
|
+ pageMap.put("pageSize",page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("withdrawalRecordDetail")
|
|
|
+ @ApiOperation(value = "提现记录详情")
|
|
|
+ public MessageResult<WithdrawalRecordDetailDTO> withdrawalRecordDetail(String id, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<WithdrawalRecordDetailDTO> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ WithdrawalRecord withdrawalRecord = withdrawalRecordService.get(id);
|
|
|
+ if (withdrawalRecord == null){
|
|
|
+ throw new Exception("记录不存在");
|
|
|
+ }
|
|
|
+ WithdrawalRecordDetailDTO withdrawalRecordDetailDTO = new WithdrawalRecordDetailDTO();
|
|
|
+ withdrawalRecordDetailDTO.setName("账户提现");
|
|
|
+ withdrawalRecordDetailDTO.setAmount("-"+withdrawalRecord.getApplyWithdrawalAmount());
|
|
|
+ withdrawalRecordDetailDTO.setStatus(withdrawalRecord.getStatus());
|
|
|
+ withdrawalRecordDetailDTO.setStatusStr(withdrawalRecord.getStatusStr(withdrawalRecord.getStatus()));
|
|
|
+ withdrawalRecordDetailDTO.setWithdrawalNo(withdrawalRecord.getWithdrawalNo());
|
|
|
+ if ("0".equals(withdrawalRecord.getStatus())){
|
|
|
+ withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getExamineTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+
|
|
|
+ withdrawalRecordDetailDTO.setRemark(withdrawalRecord.getRemark());
|
|
|
+
|
|
|
+ messageResult.setData(withdrawalRecordDetailDTO);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("withdrawalSubmit")
|
|
|
+ @ApiOperation(value = "提现")
|
|
|
+ public MessageResult<Map> withdrawal(String amount, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
|
|
|
+ if (capitalInfo == null){
|
|
|
+ throw new Exception("没有相关账户信息");
|
|
|
+ }
|
|
|
+ List<WithdrawalRecord> withdrawalRecordList = withdrawalRecordService.findByMerchantIdAndStatus(accountInfo.getId(),"0");
|
|
|
+
|
|
|
+ if (withdrawalRecordList.size()>0){
|
|
|
+ throw new Exception("有一笔正在审核的提现记录,不可再次申请");
|
|
|
+ }
|
|
|
+ BigDecimal bigAmount = new BigDecimal(amount);
|
|
|
+ if (bigAmount.compareTo(capitalInfo.getWithdrawalAmount()) >0){
|
|
|
+ throw new Exception("提现金额不可超过可提现金额");
|
|
|
+ }
|
|
|
+
|
|
|
+ WithdrawalRecord withdrawalRecord = new WithdrawalRecord();
|
|
|
+ withdrawalRecord.setId(UUID.randomUUID().toString());
|
|
|
+ withdrawalRecord.setMerchantId(accountInfo.getId());
|
|
|
+ withdrawalRecord.setApplyWithdrawalAmount(bigAmount);
|
|
|
+ withdrawalRecord.setApplyTime(new Date());
|
|
|
+ withdrawalRecord.setStatus("0");
|
|
|
+ withdrawalRecord.setWithdrawalNo(com.jpsoft.bus.modules.common.utils.StringUtils.getOutTradeNo());
|
|
|
+ withdrawalRecord.setCreateBy(accountInfo.getId());
|
|
|
+ withdrawalRecord.setCreateTime(new Date());
|
|
|
+ withdrawalRecordService.insert(withdrawalRecord);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|