|
|
@@ -10,7 +10,13 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.core.utils.OrderCodeUtils;
|
|
|
+import com.fs.company.domain.CompanyRecharge;
|
|
|
+import com.fs.company.param.CompanyRechargeParam;
|
|
|
+import com.fs.company.service.ICompanyRechargeService;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCourseRedPacketLog;
|
|
|
import com.fs.course.domain.FsUserCoursePeriod;
|
|
|
@@ -28,8 +34,11 @@ import com.fs.system.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.fs.his.utils.PhoneUtil.encryptPhone;
|
|
|
@@ -57,6 +66,10 @@ public class FsCourseRedPacketLogController extends BaseController
|
|
|
|
|
|
@Autowired
|
|
|
private IFsUserCoursePeriodService fsUserCoursePeriodService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyRechargeService rechargeService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
@Value("${cloud_host.company_name}")
|
|
|
private String signProjectName;
|
|
|
/**
|
|
|
@@ -305,9 +318,9 @@ public class FsCourseRedPacketLogController extends BaseController
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 红包消耗统计
|
|
|
+ * 红包消耗统计(含当前企业红包余额 redPackageMoney)
|
|
|
* @param fsCourseRedPacketLog
|
|
|
- * @return
|
|
|
+ * @return TableDataInfo,其中 ext.redPackageMoney 为当前企业红包余额
|
|
|
*/
|
|
|
@GetMapping("/getReadPackageTotal")
|
|
|
public TableDataInfo getReadPackageTotal(FsCourseRedPacketLog fsCourseRedPacketLog) {
|
|
|
@@ -316,6 +329,45 @@ public class FsCourseRedPacketLogController extends BaseController
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
fsCourseRedPacketLog.setCompanyId(companyId);
|
|
|
List<FsCourseRedPacketLogListPVO> list = fsCourseRedPacketLogService.getReadPackageTotal(fsCourseRedPacketLog);
|
|
|
- return getDataTable(list);
|
|
|
+ BigDecimal redPackageMoney = companyService.getRedPackageMoney(companyId);
|
|
|
+ return getDataTable(list).put("redPackageMoney", redPackageMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业转账充值(红包余额,提交即生效,无需审核)
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('his:company:recharge')")
|
|
|
+ @Log(title = "企业转账", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping(value = "/recharge")
|
|
|
+ @Transactional
|
|
|
+ @RepeatSubmit
|
|
|
+ public R recharge(@RequestBody CompanyRechargeParam param)
|
|
|
+ {
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
+ String orderSn = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isEmpty(orderSn)) {
|
|
|
+ return R.error("订单生成失败,请重试");
|
|
|
+ }
|
|
|
+ CompanyRecharge recharge = new CompanyRecharge();
|
|
|
+ recharge.setRechargeNo(orderSn);
|
|
|
+ recharge.setCompanyId(companyId);
|
|
|
+ recharge.setMoney(param.getMoney());
|
|
|
+ recharge.setCreateUserId(loginUser.getUser().getUserId());
|
|
|
+ recharge.setRemark(param.getRemark());
|
|
|
+ recharge.setPayType(3);
|
|
|
+ recharge.setBusinessType(1);
|
|
|
+ recharge.setIsAudit(1);
|
|
|
+ recharge.setStatus(0);
|
|
|
+ rechargeService.insertCompanyRecharge(recharge);
|
|
|
+
|
|
|
+ companyService.redPacketTopUpCompany(companyId, param.getMoney(), "1");
|
|
|
+
|
|
|
+ recharge.setPayTime(new Date());
|
|
|
+ recharge.setStatus(1);
|
|
|
+ rechargeService.updateCompanyRecharge(recharge);
|
|
|
+
|
|
|
+ return R.ok("充值成功,红包余额已立即生效!");
|
|
|
}
|
|
|
}
|