Commit 3a9c5cf1 authored by libin's avatar libin

Merge remote-tracking branch 'origin/base-modify' into base-modify

parents e7b00a53 1faf4505
......@@ -91,6 +91,26 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
log.error(userId+"----已领优惠卷");
return null;
}
falg=checkLed(userId,couponId,coupon.getLimitCollar(),coupon.getQuota());
if(falg){
log.error(userId+"----已超过领取限制");
return null;
}
return led(coupon,userId);
}
//后台领劵(一个劵可以发多张)
public String adminUserLedCoupon(Integer userId,Integer couponId){
Coupon coupon=couponBiz.selectById(couponId);
if (coupon==null||coupon.getIsDel()!=0||coupon.getStatus()!=1){
log.error(userId+"----无可领取优惠卷");
return null;
}
boolean falg=checkLed(userId,couponId,coupon.getLimitCollar(),coupon.getQuota());
if(falg){
log.error(userId+"----已超过领取限制");
return null;
}
return led(coupon,userId);
}
......@@ -123,7 +143,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
//检查用户是否领卷
public boolean checkUserLed(Integer userId,Integer id){
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example);
if(list.size()>0){
log.error(userId+"----已领优惠卷");
......@@ -132,6 +152,31 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return false;
}
//检查用户是否可领卷
public boolean checkLed(Integer userId,Integer id,Integer limitCollar,Integer quota){
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id).andEqualTo("isDel",0);
Integer num=selectCountByExample(example);
log.info("-用户已领劵--userId==="+userId+"----num==="+num+"----couponid==="+id);
if(num==null||num==0){
log.error(userId+"----无领此优惠卷----couponid==="+id);
return false;
}
if (limitCollar==null||num>=limitCollar){
log.error(userId+"----此优惠卷超过每人限领次数----couponid==="+id+"----limitCollar==="+limitCollar);
return true;
}
example.clear();
example.createCriteria().andEqualTo("couponId",id).andEqualTo("isDel",0);
num=selectCountByExample(example);
log.info("---发劵数量----num==="+num+"----limitCollar==="+limitCollar+"----quota==="+quota+"----couponid==="+id);
if (quota==null||quota==0||(num!=null&&num>0&&num>=quota)){
log.error(userId+"----此优惠卷超过发券数量----couponid==="+id+"----quota==="+quota);
return true;
}
return false;
}
//获取我的优惠卷
public ObjectRestResponse getCouponList(Integer userId,int type,Integer channel,BigDecimal amout){
if (userId==null||userId==0){
......@@ -206,7 +251,6 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
result.put("array",array);
return ObjectRestResponse.succ(result);
}
//获取我的优惠卷
public ObjectRestResponse getUserCouponList(Integer userId,int type,Integer channel,BigDecimal amout) {
if (userId == null || userId == 0) {
......@@ -378,16 +422,17 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
UserCoupon userCoupon;
List<UserCoupon> userCoupons = new ArrayList<>();
for (int i=0;i<userCouponSendDTO.getCouponNum();i++){
userCoupon = new UserCoupon();
/*userCoupon = new UserCoupon();
userCoupon.setCouponId(userCouponSendDTO.getCouponId());
userCoupon.setUserId(appUserLogin.getId());
userCoupon.setCrtTime(Instant.now().toEpochMilli());
userCoupon.setStartTime(couponVo.getValidStartTime());
userCoupon.setExpireTime(couponVo.getValidEndTime());
userCoupon.setTickerNo(Snowflake.build()+"");
userCoupons.add(userCoupon);
userCoupons.add(userCoupon);*/
adminUserLedCoupon(appUserLogin.getId(),userCouponSendDTO.getCouponId());
}
return mapper.inserBatch(userCoupons);
return 1;
}
public long importUserCoupon(Integer couponId,List<String[]> userCounponData) {
......@@ -426,6 +471,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
UserCoupon userCoupon=new UserCoupon();
userCoupon.setUserId(userId);
userCoupon.setIsUse(0);
userCoupon.setIsDel(0);
Long couponNumber=selectCount(userCoupon);
userInfoDTO.setCouponNumber(couponNumber);
return userInfoDTO;
......
......@@ -40,7 +40,8 @@ public class BranchCompanyStockRight{
*/
private Integer type;
private Integer state;
@Column(name = "stock_state")
private Integer stockState;
/**
......
package com.xxfc.platform.vehicle.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 分公司信息
*/
@Data
public class CompanyVo {
/**
* 公司基本信息表
*/
@ApiModelProperty("公司基本信息id")
Integer id;
@ApiModelProperty("公司全名称")
String name;
@ApiModelProperty("公司封面")
String cover;
@ApiModelProperty("轮播图")
String images;
@ApiModelProperty("片区id")
Integer zoneId;
@ApiModelProperty("公司简介")
String describes;
@ApiModelProperty("详情")
String content;
@ApiModelProperty("地址-省/直辖市(编码)")
Integer addrProvince;
@ApiModelProperty("地址-市(编码)")
Integer addrCity;
@ApiModelProperty("地址-镇/县(编码)")
Integer addrTown;
/**
* 分支机构
*/
@ApiModelProperty("分支机构id")
Integer companyId;
@ApiModelProperty("分支机构名称")
String companyName;
@ApiModelProperty("详细地址")
String addrDetail;
@ApiModelProperty("上下架:1-上架;2-下架")
Integer state;
@ApiModelProperty("负责人")
private String leader;
@ApiModelProperty("负责人联系方式")
private String leaderContactInfo;
@ApiModelProperty("公司状态")
private Integer status;
@ApiModelProperty("公司地址-纬度")
private BigDecimal latitude;
@ApiModelProperty("公司地址-经度")
private BigDecimal longitude;
@ApiModelProperty("租车客服电话")
private String vehiceServicePhone;
@ApiModelProperty("旅游客服电话")
private String tourServicePhone;
/**
* 股权信息
*/
@ApiModelProperty("股份id")
Integer stockId;
@ApiModelProperty("剩余股份")
Integer balance;
@ApiModelProperty("股份总数")
Integer total;
@ApiModelProperty("股份单价")
BigDecimal price;
@ApiModelProperty("排序")
Integer rank;
@ApiModelProperty("(-1:下架,0:筹备中,1:筹备完成,2:上架)")
Integer stockState;
@ApiModelProperty("股价类型:1-万/股;2-港万/股")
Integer type;
}
......@@ -3,18 +3,140 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper;
import com.xxfc.platform.vehicle.mapper.CompanyBaseMapper;
import com.xxfc.platform.vehicle.pojo.vo.CompanyVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
@Service
@Slf4j
public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
@Autowired
BranchCompanyStockRightBiz stockRightBiz;
@Autowired
BranchCompanyStockInfoMapper stockInfoMapper;
@Value("${branchCompanyPic.url}")
private String companyUrl;
//临时数据同步
// public ObjectRestResponse
public ObjectRestResponse synchro(){
List<BranchCompanyStockInfo> list= stockInfoMapper.selectAll();
if (list.size()>0){
for (BranchCompanyStockInfo companyStockInfo:list){
int num=0;
String companyName=companyStockInfo.getCompanyName();
Integer balance=companyStockInfo.getBalance();
Integer total=companyStockInfo.getTotal();
BigDecimal price=companyStockInfo.getPrice();
CompanyBase companyBase=new CompanyBase();
companyBase.setAddrCity(companyStockInfo.getAddrCity());
companyBase.setAddrProvince(companyStockInfo.getAddrProvince());
companyBase.setName(companyName);
companyBase.setCover(companyUrl+"/image/admin/upload"+companyStockInfo.getCompanyPic());
companyBase.setImages(companyUrl+"/image/admin/upload"+companyStockInfo.getCompanyPic());
insertSelective(companyBase);
Integer companyBaseId=companyBase.getId();
if (companyBaseId!=null){
BranchCompanyStockRight branchCompanyStockRight=new BranchCompanyStockRight();
branchCompanyStockRight.setBalance(balance);
branchCompanyStockRight.setPrice(price);
branchCompanyStockRight.setTotal(total);
branchCompanyStockRight.setCompanyBaseId(companyBaseId);
branchCompanyStockRight.setStockState(2);
stockRightBiz.insertSelective(branchCompanyStockRight);
}
num++;
log.info("----成功---num=="+num+"---companyBaseId==="+companyBaseId);
}
}
return ObjectRestResponse.succ();
}
//设置基础信息
public ObjectRestResponse updCompany(CompanyVo companyVo){
if (companyVo==null|| StringUtils.isBlank(companyVo.getCompanyName())|| StringUtils.isBlank(companyVo.getName())||
companyVo.getZoneId()==null||companyVo.getZoneId()==0|| companyVo.getAddrProvince()==null||companyVo.getAddrProvince()==0
|| companyVo.getAddrCity()==null||companyVo.getAddrCity()==0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Integer state=companyVo.getState()==null?2:companyVo.getState();
if (state==1&&(StringUtils.isBlank(companyVo.getAddrDetail())||StringUtils.isBlank(companyVo.getImages())||StringUtils.isBlank(companyVo.getDescribes())||StringUtils.isBlank(companyVo.getContent())
||StringUtils.isBlank(companyVo.getLeader())||StringUtils.isBlank(companyVo.getLeaderContactInfo())||StringUtils.isBlank(companyVo.getTourServicePhone())||StringUtils.isBlank(companyVo.getVehiceServicePhone()))){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"上架时参数不能为空");
}
CompanyBase companyBase=new CompanyBase();
BeanUtils.copyProperties(companyVo,companyBase);
Integer companyBaseId=companyVo.getId();
if (companyBaseId==null||companyBaseId==0){
insertSelective(companyBase);
companyBaseId=companyBase.getId();
}else {
updateSelectiveById(companyBase);
}
BranchCompany branchCompany=new BranchCompany();
BeanUtils.copyProperties(companyVo,branchCompany);
branchCompany.setCompanyBaseId(companyBaseId);
branchCompany.setName(companyVo.getCompanyName());
Integer companyId=companyVo.getCompanyId();
if (companyId==null||companyId==0){
branchCompany.setId(null);
insertSelective(companyBase);
}else {
branchCompany.setId(companyId);
updateSelectiveById(companyBase);
}
return ObjectRestResponse.succ();
}
//设置股权信息
public ObjectRestResponse updStockInfo(CompanyVo companyVo){
if (companyVo==null|| StringUtils.isBlank(companyVo.getCompanyName())|| StringUtils.isBlank(companyVo.getName())||
companyVo.getZoneId()==null||companyVo.getZoneId()==0|| companyVo.getAddrProvince()==null||companyVo.getAddrProvince()==0
|| companyVo.getAddrCity()==null||companyVo.getAddrCity()==0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Integer state=companyVo.getState()==null?2:companyVo.getState();
if (state==1&&(StringUtils.isBlank(companyVo.getAddrDetail())||StringUtils.isBlank(companyVo.getImages())||StringUtils.isBlank(companyVo.getDescribes())||StringUtils.isBlank(companyVo.getContent())
||StringUtils.isBlank(companyVo.getLeader())||StringUtils.isBlank(companyVo.getLeaderContactInfo())||StringUtils.isBlank(companyVo.getTourServicePhone())||StringUtils.isBlank(companyVo.getVehiceServicePhone()))){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"上架时参数不能为空");
}
CompanyBase companyBase=new CompanyBase();
BeanUtils.copyProperties(companyVo,companyBase);
Integer companyBaseId=companyVo.getId();
if (companyBaseId==null||companyBaseId==0){
insertSelective(companyBase);
companyBaseId=companyBase.getId();
}else {
updateSelectiveById(companyBase);
}
BranchCompany branchCompany=new BranchCompany();
BeanUtils.copyProperties(companyVo,branchCompany);
branchCompany.setCompanyBaseId(companyBaseId);
branchCompany.setName(companyVo.getCompanyName());
Integer companyId=companyVo.getCompanyId();
if (companyId==null||companyId==0){
branchCompany.setId(null);
insertSelective(companyBase);
}else {
branchCompany.setId(companyId);
updateSelectiveById(companyBase);
}
return ObjectRestResponse.succ();
}
}
......@@ -437,17 +437,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
//检验时间是否可以预定
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate(), bookVehicleVo.getNotCheckTimeLegal());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
}
}
Map<String, Integer> map = new HashMap<>();
//加入预定申请记录
VehicleBookRecord vehicleBookRecord = null;
if(bookVehicleVo.getVehicleBookRecordId() == null) {
map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate(), bookVehicleVo.getNotCheckTimeLegal());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
}
}
vehicleBookRecord = new VehicleBookRecord();
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate());
......@@ -468,6 +469,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
unbookVehicle(bookVehicleVo);
map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate(), bookVehicleVo.getNotCheckTimeLegal());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
}
}
vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecordBiz.updateSelectiveByIdRe(vehicleBookRecord);
......@@ -524,7 +532,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){//已经被预定
//当天已经被预定检查小时是否也被预定
return filterHourInfoBooked(vehicleId, hourInfo);
} else if ((vehicleBookInfo.getBookedDate() & andOperationFactor) == 0){//未被预定,查看时间是否被预定
} else if (vehicleBookInfo != null && vehicleBookInfo.getBookedDate() != null &&(vehicleBookInfo.getBookedDate() & andOperationFactor) == 0){//未被预定,查看时间是否被预定
return filterHourInfoBooked(vehicleId, hourInfo);
}
return Boolean.TRUE;
......
package com.xxfc.platform.vehicle.rest.admin;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.biz.BranchCompanyStockApplyInfoBiz;
import com.xxfc.platform.vehicle.biz.CompanyBaseBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo;
import com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@RestController
@IgnoreClientToken
@IgnoreUserToken
@RequestMapping("company/base")
public class CompanyBaseController extends BaseController<CompanyBaseBiz> {
@PostMapping("synchro")
public ObjectRestResponse<String> synchro() {
return baseBiz.synchro();
}
}
......@@ -588,7 +588,7 @@
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
hasVehicle desc,
</if>
distance asc
distance asc, model_id asc
</if>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment