19 changed files with 966 additions and 8 deletions
@ -0,0 +1,125 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.GoodsVo; |
||||
|
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderCardVo; |
||||
|
import com.yxt.yyth.api.lpkstore.StoreSelect; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 11:26 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpAppletVo { |
||||
|
private String dateStart; |
||||
|
private String dateEnd; |
||||
|
private String customerSid; |
||||
|
private String giftbagSid; |
||||
|
private String code; |
||||
|
private String sid ; |
||||
|
private String state; |
||||
|
private String states; |
||||
|
private boolean showBtn=true; |
||||
|
private boolean showRecord=true; |
||||
|
private String time; |
||||
|
private String name="卡号:"; |
||||
|
private String pName; |
||||
|
private String start; |
||||
|
private String end; |
||||
|
private String store; //门店
|
||||
|
private String reserveDate; //预约时间
|
||||
|
private List<GoodsVo> goodsVos; |
||||
|
private List<StoreSelect> select; |
||||
|
private String storeSid;//上次提货地点
|
||||
|
private String addressName; |
||||
|
private String isReservation;//是否超过预约时间 0 否 1是
|
||||
|
private boolean notRese=true; //是否能预约
|
||||
|
private List<LpkReserveOrderCardVo> orderCardVoList; |
||||
|
private String value; |
||||
|
private String serialNumber; |
||||
|
|
||||
|
|
||||
|
public String getStart() { |
||||
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
start=sdf.format(DateUtil.offsetDay(new Date(),+2)); |
||||
|
if(StringUtils.isNotBlank(dateEnd)){ |
||||
|
int i=DateUtil.parse(sdf.format(DateUtil.parse(start))).compareTo(DateUtil.parse(sdf.format(DateUtil.parse(dateEnd)))); |
||||
|
if(String.valueOf(i).equals("-1")){ |
||||
|
end=sdf.format(DateUtil.parse(dateEnd)); |
||||
|
}else{ |
||||
|
end=sdf.format(DateUtil.offsetDay(DateUtil.parse(dateEnd),2)); |
||||
|
} |
||||
|
} |
||||
|
return start; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
name=name+code; |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public String getTime() { |
||||
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy.MM.dd"); |
||||
|
if(StringUtils.isNotBlank(dateStart)){ |
||||
|
if(StringUtils.isNotBlank(dateEnd)){ |
||||
|
time=sdf.format(DateUtil.parse(dateStart))+"~"+sdf.format(DateUtil.parse(dateEnd)); |
||||
|
} |
||||
|
} |
||||
|
return time; |
||||
|
} |
||||
|
|
||||
|
public boolean isShowBtn() { |
||||
|
if(states.equals("5")){ |
||||
|
if(isReservation.equals("1")){ |
||||
|
this.state="已完成"; |
||||
|
showBtn=false; |
||||
|
} |
||||
|
} |
||||
|
return showBtn; |
||||
|
} |
||||
|
|
||||
|
public String getState() { |
||||
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
if(StringUtils.isNotBlank(dateEnd)){ |
||||
|
int i=DateUtil.parse(sdf.format(DateUtil.parse(dateEnd))).compareTo(DateUtil.parse(sdf.format(DateUtil.date()))); |
||||
|
if( String.valueOf(i).equals("-1")){ |
||||
|
state="已过期"; |
||||
|
showBtn=false; |
||||
|
}else{ |
||||
|
state="待提货"; |
||||
|
if(states.equals("5")){ |
||||
|
if(isReservation.equals("0")){ |
||||
|
this.state="已预约"; |
||||
|
this.notRese=false; |
||||
|
}else{ |
||||
|
this.state="已完成"; |
||||
|
showBtn=false; |
||||
|
} |
||||
|
}else if(states.equals("4")){ |
||||
|
if(isReservation.equals("0")){ |
||||
|
this.state="已预约"; |
||||
|
}else{ |
||||
|
this.state="待提货"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}else{ |
||||
|
state="待提货"; |
||||
|
if(states.equals("5")){ |
||||
|
if(isReservation.equals("0")){ |
||||
|
this.state="已预约"; |
||||
|
}else{ |
||||
|
this.state="已完成"; |
||||
|
showBtn=false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return state; |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:10 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCard { |
||||
|
private String id; |
||||
|
private String sid= UUID.randomUUID().toString(); |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String recordId; |
||||
|
private String recordSid; |
||||
|
private String giftbagSid; |
||||
|
private String serialNumber; |
||||
|
private String code; |
||||
|
private String codeKey; |
||||
|
private String state; |
||||
|
private String grantName; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date grantDate; |
||||
|
private String customerSid; |
||||
|
private String customerMobile; |
||||
|
private Date bindDate; |
||||
|
|
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardDto implements Dto { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String recordId; |
||||
|
private String recordSid; |
||||
|
private String serialNumber; |
||||
|
private String code; |
||||
|
private String codeKey; |
||||
|
private String state; |
||||
|
private String grantName; |
||||
|
private String grantDate; |
||||
|
private String customerSid; |
||||
|
private String customerMobile; |
||||
|
|
||||
|
private String giftbagSid; |
||||
|
private String num; |
||||
|
private String cardArea; |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import com.yxt.common.core.utils.ExportEntityMap; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 11:29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardExport { |
||||
|
@ExportEntityMap(CnName = "企业卡二维码", EnName = "pic") |
||||
|
private String pic; |
||||
|
@ExportEntityMap(CnName = "企业卡编码第一行", EnName = "code1") |
||||
|
private String code1; |
||||
|
@ExportEntityMap(CnName = "企业卡编码第二行", EnName = "code2") |
||||
|
private String code2; |
||||
|
@ExportEntityMap(CnName = "企业卡密码", EnName = "codeKey") |
||||
|
private String codeKey; |
||||
|
@ExportEntityMap(CnName = "序列号", EnName = "serialNumber") |
||||
|
private String serialNumber; |
||||
|
private String code; |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardQuery implements Query { |
||||
|
private String state; |
||||
|
private String noEnd; |
||||
|
private String noStart; |
||||
|
|
||||
|
private String number; |
||||
|
private String sid; |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.yxt.yyth.api.empcard; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardVo implements Vo { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
private String createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String recordId; |
||||
|
private String recordSid; |
||||
|
private String giftbagSid; |
||||
|
private String serialNumber; |
||||
|
private String code; |
||||
|
private String codeKey; |
||||
|
private String state; |
||||
|
private String grantName; |
||||
|
private String grantDate; |
||||
|
private String customerSid; |
||||
|
private String customerMobile; |
||||
|
|
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.yxt.yyth.api.empcardbuildrecord; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:10 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardBuildRecord { |
||||
|
private String id; |
||||
|
private String sid= UUID.randomUUID().toString(); |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
// private String isEnable;
|
||||
|
private String giftbagSid; |
||||
|
|
||||
|
private String startNumber; |
||||
|
private String endNumber; |
||||
|
private String countNumber; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date buildDate; |
||||
|
private String cardArea; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.yxt.yyth.api.empcardbuildrecord; |
||||
|
|
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardBuildRecordDto implements Dto { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
private String createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String recordId; |
||||
|
private String recordSid; |
||||
|
private String giftbagSid; |
||||
|
private String serialNumber; |
||||
|
private String code; |
||||
|
private String codeKey; |
||||
|
private String state; |
||||
|
private String grantName; |
||||
|
private String grantDate; |
||||
|
private String customerSid; |
||||
|
private String customerMobile; |
||||
|
private String Num; |
||||
|
private String cardArea; |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.yyth.api.empcardbuildrecord; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardBuildRecordQuery implements Query { |
||||
|
private String startDate; //开始时间
|
||||
|
private String endDate; //结束时间
|
||||
|
private String countNumber; //总数
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.yxt.yyth.api.empcardbuildrecord; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EmpCardBuildRecordVo implements Vo { |
||||
|
private String sid; |
||||
|
private String buildDate; //创建时间
|
||||
|
private String countNumber; //总数
|
||||
|
private String startNumber; //起始号
|
||||
|
private String endNumber; //结束号
|
||||
|
private String bagName; |
||||
|
private String grantCountNumber; //发放总数
|
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.yxt.yyth.biz.empcard; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.yyth.api.empcard.EmpAppletVo; |
||||
|
import com.yxt.yyth.api.empcard.EmpCard; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardExport; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardVo; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.AppletVo; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCard; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface EmpCardMapper extends BaseMapper<EmpCard> { |
||||
|
String selctMaxSerNum(@Param("cardArea") String cardArea); |
||||
|
IPage<EmpCardVo> cardList(IPage<EmpCard> page, @Param(Constants.WRAPPER) QueryWrapper<EmpCard> qw); |
||||
|
IPage<EmpCardVo> recordDetails(IPage<EmpCard> page, @Param(Constants.WRAPPER) QueryWrapper<EmpCard> qw); |
||||
|
@Select("SELECT card.*, case card.state WHEN 3 then '未提货' WHEN 4 then '已经预约提货(预约部分提货)' WHEN 5 then '已经提取完成' end stateValue,\n" + |
||||
|
"bag.dateStart as dateStart,bag.dateEnd as dateEnd,bag.name as pname,card.state as states,card.serialNumber as serialNumber\n" + |
||||
|
"FROM emp_card card LEFT JOIN lpk_giftbag bag on card.giftbagSid=bag.sid where card.sid=#{sid}") |
||||
|
EmpAppletVo getEmpCardBySid(@Param("sid") String sid); |
||||
|
|
||||
|
List<EmpCardExport> exportExcel(@Param(Constants.WRAPPER) QueryWrapper<LpkGiftCard> qw); |
||||
|
@Select("select count(id) from emp_card where recordSid=#{recordSid} and grantRecordSid is not null") |
||||
|
Integer cardGrantCount(@Param("recordSid") String recordSid); |
||||
|
|
||||
|
IPage<AppletVo> getGifCardByCustomerSid(IPage<LpkGiftCard> page, @Param(Constants.WRAPPER) QueryWrapper<LpkGiftCard> qw); |
||||
|
} |
@ -0,0 +1,104 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.yyth.biz.empcard.EmpCardMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
|
||||
|
<select id="ListPageVo" resultType="com.yxt.yyth.api.empcard.EmpCardVo"> |
||||
|
select |
||||
|
* |
||||
|
from emp_card |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
<select id="selctMaxSerNum" resultType="java.lang.String"> |
||||
|
SELECT MAX(serialNumber) as sNo |
||||
|
FROM emp_card |
||||
|
WHERE LENGTH(serialNumber) = 8 |
||||
|
AND LEFT (serialNumber |
||||
|
, 2) = #{cardArea} |
||||
|
</select> |
||||
|
<select id="cardList" resultType="com.yxt.yyth.api.empcard.EmpCardVo"> |
||||
|
SELECT |
||||
|
sid, |
||||
|
date_format(createTime, '%Y-%m-%d') as createTime, |
||||
|
remarks, |
||||
|
giftbagSid, |
||||
|
serialNumber, |
||||
|
code, |
||||
|
codeKey, |
||||
|
CASE card.state |
||||
|
WHEN 1 THEN '未绑定' |
||||
|
WHEN 2 THEN '已绑定客户' |
||||
|
WHEN 3 THEN '已完成' END AS `state`, |
||||
|
grantName, |
||||
|
date_format(grantDate, '%Y-%m-%d') as grantDate, |
||||
|
customerMobile, |
||||
|
customerSid |
||||
|
FROM |
||||
|
emp_card |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="exportExcel" resultType="com.yxt.yyth.api.empcard.EmpCardExport"> |
||||
|
SELECT |
||||
|
serialNumber, |
||||
|
code, |
||||
|
codeKey |
||||
|
FROM |
||||
|
emp_card |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="recordDetails" resultType="com.yxt.yyth.api.empcard.EmpCardVo"> |
||||
|
SELECT |
||||
|
card.sid, |
||||
|
card.recordId, |
||||
|
date_format(card.createTime, '%Y-%m-%d') as createTime, |
||||
|
card.remarks, |
||||
|
card.giftbagSid, |
||||
|
card.serialNumber, |
||||
|
card.code, |
||||
|
card.codeKey, |
||||
|
CASE card.state |
||||
|
WHEN 1 THEN '未绑定' |
||||
|
WHEN 2 THEN '已绑定客户' |
||||
|
WHEN 3 THEN '已完成' |
||||
|
END AS `state`, |
||||
|
grantName, |
||||
|
date_format(card.grantDate, '%Y-%m-%d') as grantDate, |
||||
|
card.customerMobile, |
||||
|
card.customerSid |
||||
|
FROM |
||||
|
emp_card card |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
<select id="getGifCardByCustomerSid" resultType="com.yxt.yyth.api.lpkgiftcard.AppletVo"> |
||||
|
SELECT |
||||
|
card.*, |
||||
|
case card.state |
||||
|
WHEN 2 then '已绑定' |
||||
|
WHEN 3 then '已完成' |
||||
|
end stateValue, |
||||
|
bag.dateStart as dateStart |
||||
|
,bag.dateEnd as dateEnd |
||||
|
,bag.name as pname, |
||||
|
card.state as states, |
||||
|
card.serialNumber as serialNumber |
||||
|
FROM |
||||
|
emp_card card |
||||
|
LEFT JOIN lpk_giftbag bag on card.giftbagSid=bag.sid |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
ORDER BY card.state desc,card.bindDate desc |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,67 @@ |
|||||
|
package com.yxt.yyth.biz.empcard; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardDto; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardQuery; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardVo; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.BindCardDto; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListQuery; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListVo; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardQuery; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Api(tags = "礼品卡信息") |
||||
|
@RestController |
||||
|
@RequestMapping("empcard") |
||||
|
public class EmpCardRest { |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Autowired |
||||
|
EmpCardService empCardService; |
||||
|
|
||||
|
@PostMapping("/bindCard") |
||||
|
@ApiOperation(value = "客户绑定企业卡") |
||||
|
public ResultBean wxBindMobile(@RequestBody EmpCardDto dto) { |
||||
|
return empCardService.bindCard(dto); |
||||
|
} |
||||
|
@PostMapping("/generateCard") |
||||
|
@ApiOperation(value = "生成企业卡信息") |
||||
|
public ResultBean generateCard(@RequestBody EmpCardDto dto) { |
||||
|
return empCardService.generateCard(dto); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/cardList") |
||||
|
@ApiOperation(value = "企业卡信息列表") |
||||
|
public ResultBean<PagerVo<EmpCardVo>> cardList(@RequestBody PagerQuery<EmpCardQuery> pq) { |
||||
|
return empCardService.cardList(pq); |
||||
|
} |
||||
|
@ApiOperation("查看记录详情列表") |
||||
|
@PostMapping("/recordDetails") |
||||
|
public ResultBean<PagerVo<EmpCardVo>> recordDetails(@RequestBody PagerQuery<EmpCardQuery> pq) { |
||||
|
return empCardService.recordDetails(pq); |
||||
|
} |
||||
|
@ApiOperation(value = "企业卡信息列表导出") |
||||
|
@PostMapping("/exportExcel") |
||||
|
public void exportExcel(@RequestBody LpkGiftCardListQuery query) { |
||||
|
empCardService.exportExcel(query); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/gifCardByCustomerSid") |
||||
|
@ApiOperation(value = "获取客户绑定的礼包卡") |
||||
|
public ResultBean gifCardByCustomerSid(@RequestBody PagerQuery<LpkGiftCardQuery> query) { |
||||
|
return empCardService.getGifCardByCustomerSid(query); |
||||
|
} |
||||
|
} |
@ -0,0 +1,227 @@ |
|||||
|
package com.yxt.yyth.biz.empcard; |
||||
|
|
||||
|
import cn.hutool.core.date.DateTime; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.ExportExcelUtils; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.empcard.*; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecord; |
||||
|
import com.yxt.yyth.api.lpkgiftcard.*; |
||||
|
import com.yxt.yyth.biz.empcardbuildrecord.EmpCardBuildRecordService; |
||||
|
import com.yxt.yyth.biz.lpkgiftcard.generateRule.UniqueIdGenerator; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> { |
||||
|
|
||||
|
@Autowired |
||||
|
EmpCardBuildRecordService empCardBuildRecordService; |
||||
|
@Autowired |
||||
|
private HttpServletResponse response; |
||||
|
|
||||
|
|
||||
|
|
||||
|
public ResultBean bindCard(EmpCardDto bindCardDto) { |
||||
|
ResultBean rb = new ResultBean().fail(); |
||||
|
EmpCard lpkGiftCard = baseMapper.selectOne(new QueryWrapper<EmpCard>().eq("code", bindCardDto.getCode()) |
||||
|
.eq("codeKey", bindCardDto.getCodeKey())); |
||||
|
if (null == lpkGiftCard) { |
||||
|
return rb.setMsg("请核对卡号和密钥"); |
||||
|
} |
||||
|
EmpAppletVo vo = baseMapper.getEmpCardBySid(lpkGiftCard.getSid()); |
||||
|
if (vo.getState().equals("已过期")) { |
||||
|
return rb.setMsg("该卡已过期"); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(lpkGiftCard.getCustomerSid())) { |
||||
|
return rb.setMsg("该卡已绑定"); |
||||
|
} |
||||
|
lpkGiftCard.setCustomerSid(bindCardDto.getCustomerSid()); |
||||
|
lpkGiftCard.setState("2"); |
||||
|
lpkGiftCard.setBindDate(new Date()); |
||||
|
baseMapper.updateById(lpkGiftCard); |
||||
|
return rb.success().setMsg("绑定成功"); |
||||
|
} |
||||
|
|
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public ResultBean generateCard(EmpCardDto dto) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
if (StringUtils.isBlank(dto.getGiftbagSid())) { |
||||
|
return rb.setMsg("请添加礼包"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(dto.getNum())) { |
||||
|
return rb.setMsg("请输入生成卡片的数量"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(dto.getCardArea())) { |
||||
|
return rb.setMsg("请输入区域号"); |
||||
|
} |
||||
|
int i = Integer.parseInt(dto.getNum()); |
||||
|
String cardArea = dto.getCardArea(); |
||||
|
EmpCardBuildRecord record = new EmpCardBuildRecord(); |
||||
|
record.setCountNumber(dto.getNum()); |
||||
|
record.setBuildDate(new DateTime()); |
||||
|
record.setCreateTime(new DateTime()); |
||||
|
record.setGiftbagSid(dto.getGiftbagSid()); |
||||
|
String startNum = ""; |
||||
|
String endNum = ""; |
||||
|
record.setCardArea(cardArea); |
||||
|
empCardBuildRecordService.insert(record); |
||||
|
EmpCardBuildRecord cardBuildRecord = empCardBuildRecordService.fetchBySid(record.getSid()); |
||||
|
if (null != cardBuildRecord) { |
||||
|
for (int j = 0; j < i; j++) { |
||||
|
EmpCard card = new EmpCard(); |
||||
|
card.setRecordSid(record.getSid()); |
||||
|
card.setState("1"); |
||||
|
card.setCreateTime(new DateTime()); |
||||
|
card.setGiftbagSid(dto.getGiftbagSid()); |
||||
|
String uuid = UniqueIdGenerator.generateUniqueID(); |
||||
|
int randomNumber = new Random().nextInt(900000) + 100000; |
||||
|
card.setCodeKey(String.valueOf(randomNumber)); |
||||
|
card.setCode(uuid); |
||||
|
String maxSerNum = baseMapper.selctMaxSerNum(cardArea); |
||||
|
if (StringUtils.isBlank(maxSerNum)) { |
||||
|
card.setSerialNumber(cardArea + "000001"); |
||||
|
} else { |
||||
|
String substringSer = maxSerNum.substring(cardArea.length()); |
||||
|
int i1 = Integer.parseInt(substringSer); |
||||
|
int finNum = i1 + 1; |
||||
|
int length = String.valueOf(finNum).length(); |
||||
|
int len = 6 - length; |
||||
|
String num = String.valueOf(finNum); |
||||
|
for (int a = 0; a < len; a++) { |
||||
|
num = "0" + num; |
||||
|
} |
||||
|
card.setSerialNumber(cardArea + num); |
||||
|
} |
||||
|
if (j == 0) { |
||||
|
startNum = card.getSerialNumber(); |
||||
|
} |
||||
|
if (j == i - 1) { |
||||
|
endNum = card.getSerialNumber(); |
||||
|
} |
||||
|
card.setRecordId(cardBuildRecord.getId()); |
||||
|
//生成二维码转base64
|
||||
|
// genarateQRCodesToBase64(card.getCode(),card.getSid());
|
||||
|
baseMapper.insert(card); |
||||
|
} |
||||
|
} |
||||
|
cardBuildRecord.setStartNumber(startNum); |
||||
|
cardBuildRecord.setEndNumber(endNum); |
||||
|
empCardBuildRecordService.updateById(cardBuildRecord); |
||||
|
return rb.success(); |
||||
|
} |
||||
|
public ResultBean<PagerVo<EmpCardVo>> cardList(PagerQuery<EmpCardQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
EmpCardQuery query = pq.getParams(); |
||||
|
QueryWrapper<EmpCard> qw = new QueryWrapper<>(); |
||||
|
if (StringUtils.isNotBlank(query.getState())) { |
||||
|
qw.eq("state", query.getState()); |
||||
|
} |
||||
|
qw.eq("1", "1"); |
||||
|
String sNoStart = query.getNoStart(); |
||||
|
String sNoEnd = query.getNoEnd(); |
||||
|
qw.apply(StringUtils.isNotBlank(sNoStart), "serialNumber >=" + sNoStart). |
||||
|
apply(StringUtils.isNotBlank(sNoEnd), "serialNumber <=" + sNoEnd |
||||
|
); |
||||
|
qw.orderByDesc("id"); |
||||
|
IPage<EmpCard> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<EmpCardVo> pagging = baseMapper.cardList(page, qw); |
||||
|
PagerVo<EmpCardVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return rb.success().setData(p); |
||||
|
} |
||||
|
public ResultBean<PagerVo<EmpCardVo>> recordDetails(PagerQuery<EmpCardQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
EmpCardQuery query = pq.getParams(); |
||||
|
QueryWrapper<EmpCard> qw = new QueryWrapper<>(); |
||||
|
qw.eq("1", "1"); |
||||
|
if (StringUtils.isNotBlank(query.getState())) { |
||||
|
qw.eq("state", query.getState()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getNumber())) { |
||||
|
qw.like("serialNumber", query.getNumber()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getSid())) { |
||||
|
qw.eq("recordSid", query.getSid()); |
||||
|
} |
||||
|
qw.orderByDesc("serialNumber"); |
||||
|
IPage<EmpCard> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<EmpCardVo> pagging = baseMapper.recordDetails(page, qw); |
||||
|
PagerVo<EmpCardVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return rb.success().setData(p); |
||||
|
} |
||||
|
public void exportExcel(LpkGiftCardListQuery query) { |
||||
|
|
||||
|
String finUrl = "https://supervise.yxtsoft.com/lpkapi?qy="; |
||||
|
QueryWrapper<LpkGiftCard> qw = new QueryWrapper<>(); |
||||
|
qw.eq("1", "1"); |
||||
|
if (StringUtils.isNotBlank(query.getState())) { |
||||
|
qw.eq("state", query.getState()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getNumber())) { |
||||
|
qw.like("serialNumber", query.getNumber()); |
||||
|
} |
||||
|
// qw.eq("recordSid", query.getSid());
|
||||
|
//得到所有要导出的数据
|
||||
|
List<EmpCardExport> exportList = baseMapper.exportExcel(qw); |
||||
|
if (!exportList.isEmpty()) { |
||||
|
for (EmpCardExport lpkGiftCardExport : exportList) { |
||||
|
if (StringUtils.isNotBlank(lpkGiftCardExport.getCode())) { |
||||
|
lpkGiftCardExport.setPic(finUrl + lpkGiftCardExport.getCode()); |
||||
|
lpkGiftCardExport.setCode1(lpkGiftCardExport.getCode().substring(0, 10)); |
||||
|
lpkGiftCardExport.setCode2(lpkGiftCardExport.getCode().substring(lpkGiftCardExport.getCode().length() - 10)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//定义导出的excel名字
|
||||
|
String excelName = "1"; |
||||
|
String fileNameURL = "1"; |
||||
|
// try {
|
||||
|
// fileNameURL = URLEncoder.encode(excelName, "UTF-8");
|
||||
|
// fileNameURL = URLEncoder.encode(excelName, "UTF-8");
|
||||
|
// } catch (UnsupportedEncodingException e) {
|
||||
|
// e.printStackTrace();
|
||||
|
// }
|
||||
|
//导出提货卡信息列表
|
||||
|
ExportExcelUtils.export(fileNameURL, exportList, EmpCardExport.class, response); |
||||
|
|
||||
|
} |
||||
|
public ResultBean<Integer> cardGrantCount(String recordSid) { |
||||
|
ResultBean rb = new ResultBean().fail(); |
||||
|
Integer i = baseMapper.cardGrantCount(recordSid); |
||||
|
return rb.success().setData(i); |
||||
|
} |
||||
|
public ResultBean getGifCardByCustomerSid(PagerQuery<LpkGiftCardQuery> pq) { |
||||
|
ResultBean rb = new ResultBean().fail(); |
||||
|
LpkGiftCardQuery query = pq.getParams(); |
||||
|
if (StringUtils.isBlank(query.getCustomerSid())) { |
||||
|
return rb.setMsg("参数不能为空"); |
||||
|
} |
||||
|
QueryWrapper<LpkGiftCard> qw = new QueryWrapper<>(); |
||||
|
// updateIsItInvalid(query.getCustomerSid());
|
||||
|
if (StringUtils.isNotBlank(query.getCustomerSid())) { |
||||
|
qw.eq("customerSid", query.getCustomerSid()); |
||||
|
} |
||||
|
IPage<LpkGiftCard> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<AppletVo> list = baseMapper.getGifCardByCustomerSid(page, qw); |
||||
|
PagerVo<AppletVo> p = PagerUtil.pageToVo(list, null); |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
return rb.success().setData(p); |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.yxt.yyth.biz.empcardbuildrecord; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.yyth.api.empcard.EmpCard; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecord; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordVo; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecord; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface EmpCardBuildRecordMapper extends BaseMapper<EmpCardBuildRecord> { |
||||
|
IPage<EmpCardBuildRecordVo> recordListPage(IPage<EmpCardBuildRecord> page, @Param(Constants.WRAPPER) QueryWrapper<EmpCardBuildRecord> qw); |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.yyth.biz.empcardbuildrecord.EmpCardBuildRecordMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
|
||||
|
<select id="recordListPage" resultType="com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordVo"> |
||||
|
select |
||||
|
r.sid, |
||||
|
date_format(r.buildDate, '%Y-%m-%d') as buildDate, |
||||
|
r.countNumber, |
||||
|
r.startNumber, |
||||
|
r.endNumber, |
||||
|
g.name as bagName |
||||
|
from emp_card_build_record as r |
||||
|
left join lpk_giftbag as g on r.giftbagSid = g.sid |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,34 @@ |
|||||
|
package com.yxt.yyth.biz.empcardbuildrecord; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardDto; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordQuery; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordVo; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordQuery; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Api(tags = "礼品卡信息") |
||||
|
@RestController |
||||
|
@RequestMapping("empcardbuildrecord") |
||||
|
public class EmpCardBuildRecordRest { |
||||
|
@Autowired |
||||
|
EmpCardBuildRecordService empCardBuildRecordService; |
||||
|
@ApiOperation("创建记录列表") |
||||
|
@PostMapping("/recordListPage") |
||||
|
public ResultBean<PagerVo<EmpCardBuildRecordVo>> recordListPage(@RequestBody PagerQuery<EmpCardBuildRecordQuery> pq) { |
||||
|
return empCardBuildRecordService.recordListPage(pq); |
||||
|
} |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package com.yxt.yyth.biz.empcardbuildrecord; |
||||
|
|
||||
|
import cn.hutool.core.date.DateTime; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.base.utils.StringUtils; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.yyth.api.empcard.EmpCard; |
||||
|
import com.yxt.yyth.api.empcard.EmpCardDto; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecord; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordQuery; |
||||
|
import com.yxt.yyth.api.empcardbuildrecord.EmpCardBuildRecordVo; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecord; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordQuery; |
||||
|
import com.yxt.yyth.api.lpkcardbuildrecord.LpkCardBuildRecordVo; |
||||
|
import com.yxt.yyth.biz.empcard.EmpCardService; |
||||
|
import com.yxt.yyth.biz.lpkgiftcard.generateRule.UniqueIdGenerator; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Random; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/8 9:19 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class EmpCardBuildRecordService extends MybatisBaseService<EmpCardBuildRecordMapper, EmpCardBuildRecord> { |
||||
|
|
||||
|
@Autowired |
||||
|
EmpCardService empCardService; |
||||
|
public ResultBean<PagerVo<EmpCardBuildRecordVo>> recordListPage(PagerQuery<EmpCardBuildRecordQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
EmpCardBuildRecordQuery query = pq.getParams(); |
||||
|
QueryWrapper<EmpCardBuildRecord> qw = new QueryWrapper<>(); |
||||
|
qw.eq("1", "1"); |
||||
|
if (StringUtils.isNotBlank(query.getCountNumber())) { |
||||
|
qw.eq("r.countNumber", query.getCountNumber()); |
||||
|
} |
||||
|
String startDate = query.getStartDate(); |
||||
|
String effEndTime = query.getEndDate(); |
||||
|
qw.apply(org.apache.commons.lang3.StringUtils.isNotEmpty(startDate), "date_format (r.buildDate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')"). |
||||
|
apply(org.apache.commons.lang3.StringUtils.isNotEmpty(effEndTime), "date_format (r.buildDate,'%Y-%m-%d') <= date_format('" + effEndTime + "','%Y-%m-%d')" |
||||
|
); |
||||
|
qw.orderByDesc("r.createTime"); |
||||
|
IPage<EmpCardBuildRecord> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<EmpCardBuildRecordVo> pagging = baseMapper.recordListPage(page, qw); |
||||
|
// for(EmpCardBuildRecordVo vo:pagging.getRecords()){
|
||||
|
// vo.setGrantCountNumber(String.valueOf(empCardService.cardGrantCount(vo.getSid()).getData()));
|
||||
|
// }
|
||||
|
PagerVo<EmpCardBuildRecordVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return rb.success().setData(p); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue