Commit 74869908 authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents 970e0414 78fbfd46
......@@ -24,6 +24,10 @@ public class CommonBaseController {
@Autowired
public HttpServletRequest request;
public HttpServletRequest getRequest() {
return request;
}
public String getCurrentUserName(){
return BaseContextHandler.getUsername();
}
......
......@@ -36,7 +36,7 @@ public class Query extends LinkedHashMap<String, Object> {
*/
public Query(PageParam pageParam){
this.putAll(BeanUtil.beanToMap(pageParam));
//分页参数
//分页参数
if(pageParam.getPage() != null) {
this.page = pageParam.getPage();
}
......
......@@ -19,7 +19,6 @@ import java.io.Serializable;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "base_user_member_export")
public class BaseUserMemberExportDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String username;
......
......@@ -15,7 +15,7 @@ import lombok.Data;
public class UserMemberDTO {
public static final int ISBIND_BIND = 1;
/**
* 用户id
*/
......
package com.github.wxiaoqi.security.admin.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/11 10:39
*/
@Data
public class UserMemberSaveDTO {
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "会员名")
private String username;
/**
* 会员等级
*/
@ApiModelProperty(value = "会员等级")
private Integer memberLevel;
/**
* 赠送总天数
*/
@ApiModelProperty(value = "赠送总天数")
private Integer totalNumber;
/**
* 剩余天数
*/
@ApiModelProperty(value = "剩余天数")
private Integer rentFreeDays;
}
package com.github.wxiaoqi.security.admin.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 银行卡绑定表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "app_user_bank_card")
public class AppUserBankCard implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("")
private Integer id;
/**
* 用户id
*/
@Column(name = "userid")
@ApiModelProperty(value = "用户id")
private String userid;
/**
* 绑定银行时的流水号,用于支付,退款,提现
*/
@Column(name = "bindingSN")
@ApiModelProperty(value = "绑定银行时的流水号,用于支付,退款,提现")
private String bindingsn;
/**
* 银行编号
*/
@Column(name = "bankID")
@ApiModelProperty(value = "银行编号")
private String bankid;
/**
* 账户名称
*/
@Column(name = "accountName")
@ApiModelProperty(value = "账户名称")
private String accountname;
/**
* 账户银行卡号
*/
@Column(name = "accountNo")
@ApiModelProperty(value = "账户银行卡号")
private String accountno;
/**
* 开户证件 0身份证 1户口簿 2护照
*/
@Column(name = "identificationType")
@ApiModelProperty(value = "开户证件 0身份证 1户口簿 2护照")
private String identificationtype;
/**
* 证件号
*/
@Column(name = "identificationNo")
@ApiModelProperty(value = "证件号")
private String identificationno;
/**
* 手机号 用于收取验证码
*/
@Column(name = "phoneNo")
@ApiModelProperty(value = "手机号 用于收取验证码")
private String phoneno;
/**
* 是否默认 用于提现有指定账户 1表示默认,0表示不默认
*/
@Column(name = "isDefault")
@ApiModelProperty(value = "是否默认 用于提现有指定账户 1表示默认,0表示不默认")
private Integer isdefault;
/**
* 绑定时间
*/
@Column(name = "bindTime")
@ApiModelProperty(value = "绑定时间")
private Integer bindtime;
/**
* 1:绑定,0:解绑
*/
@Column(name = "flag")
@ApiModelProperty(value = "1:绑定,0:解绑")
private Integer flag;
/**
* 解绑时间
*/
@Column(name = "unBindTime")
@ApiModelProperty(value = "解绑时间")
private Integer unbindtime;
/**
* 解绑人员
*/
@Column(name = "unBindUserId")
@ApiModelProperty(value = "解绑人员")
private String unbinduserid;
/**
* 绑定人员
*/
@Column(name = "bundUserId")
@ApiModelProperty(value = "绑定人员")
private String bunduserid;
/**
* 解绑绑定银行时的流水号
*/
@Column(name = "unBindingSN")
@ApiModelProperty(value = "解绑绑定银行时的流水号")
private String unbindingsn;
/**
* 银行名称
*/
@Column(name = "bankname")
@ApiModelProperty(value = "银行名称")
private String bankname;
/**
* 分支行名称
*/
@Column(name = "subbranch_name")
@ApiModelProperty(value = "分支行名称")
private String subbranchName;
/**
* 分支行省份
*/
@Column(name = "subbranch_province")
@ApiModelProperty(value = "分支行省份")
private String subbranchProvince;
/**
* 分支行城市
*/
@Column(name = "subbranch_city")
@ApiModelProperty(value = "分支行城市")
private String subbranchCity;
}
package com.github.wxiaoqi.security.admin.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 拥金明细表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "app_user_selling_water")
public class AppUserSellingWater implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("")
private Integer id;
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 身份职位
*/
@Column(name = "position_id")
@ApiModelProperty(value = "身份职位")
private Integer positionId;
/**
* 来源用户id
*/
@Column(name = "source_id")
@ApiModelProperty(value = "来源用户id")
private Integer sourceId;
/**
* 订单id
*/
@Column(name = "order_id")
@ApiModelProperty(value = "订单id")
private Integer orderId;
/**
* 商品id
*/
@Column(name = "good_id")
@ApiModelProperty(value = "商品id")
private Integer goodId;
/**
* 商品数量
*/
@Column(name = "good_number")
@ApiModelProperty(value = "商品数量")
private Integer goodNumber;
/**
* 类型 1=>一级上线提成
*/
@Column(name = "type")
@ApiModelProperty(value = "类型 1=>一级上线提成")
private Integer type;
/**
* 类别:0-正;1-负
*/
@Column(name = "status")
@ApiModelProperty(value = "类别:0-正;1-负")
private Integer status;
/**
* 商品标题
*/
@Column(name = "title")
@ApiModelProperty(value = "商品标题")
private String title;
/**
* 图片
*/
@Column(name = "img")
@ApiModelProperty(value = "图片")
private String img;
/**
* 售价
*/
@Column(name = "price")
@ApiModelProperty(value = "售价")
private Long price;
/**
* 提成百分比
*/
@Column(name = "extract")
@ApiModelProperty(value = "提成百分比")
private Integer extract;
/**
* 是否入账:0-未入账;1-已入账
*/
@Column(name = "waiting")
@ApiModelProperty(value = "是否入账:0-未入账;1-已入账")
private Integer waiting;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Integer crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Integer updTime;
}
......@@ -135,6 +135,5 @@ public class BaseUserMember implements Serializable {
@Column(name = "recent_recharge")
private Long recentRecharge;
}
package com.github.wxiaoqi.security.admin.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 我的钱包
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "my_wallet")
public class MyWallet implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Column(name = "id")
@ApiModelProperty(value = "id")
private Long id;
/**
* 用户ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("用户ID")
private Integer userId;
/**
* 余额(分)
*/
@Column(name = "balance")
@ApiModelProperty(value = "余额(分)")
private Long balance;
/**
* 已提现金额
*/
@Column(name = "withdrawals")
@ApiModelProperty(value = "已提现金额")
private Long withdrawals;
/**
* 进账总额(分)
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "进账总额(分)")
private Long totalAmount;
/**
* 进账总额(分)
*/
@Column(name = "today_amount")
@ApiModelProperty(value = "进账总额(分)")
private Long todayAmount;
/**
* 未入账金额
*/
@Column(name = "unbooked")
@ApiModelProperty(value = "未入账金额")
private Long unbooked;
/**
* 是否冻结:0-正常,1-冻结
*/
@Column(name = "is_frozen")
@ApiModelProperty(value = "是否冻结:0-正常,1-冻结")
private Integer isFrozen;
/**
* 最后进账时间
*/
@Column(name = "last_intime")
@ApiModelProperty(value = "最后进账时间")
private Long lastIntime;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 版本
*/
@Column(name = "version")
@ApiModelProperty(value = "版本")
private Integer version;
}
package com.github.wxiaoqi.security.admin.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 钱包提现表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "my_wallet_cath")
public class MyWalletCath implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键ID")
private Long id;
/**
* 用户iD
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户iD")
private String userId;
/**
* 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)
*/
@Column(name = "cath_type")
@ApiModelProperty(value = "提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)")
private Integer cathType;
/**
* 商户订单号
*/
@Column(name = "orderno")
@ApiModelProperty(value = "商户订单号")
private String orderno;
/**
* 第三方订单号:如微信,支付宝,银行卡等
*/
@Column(name = "cono")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String cono;
/**
* 提现金额
*/
@Column(name = "amount")
@ApiModelProperty(value = "提现金额")
private Long amount;
/**
* 订单状态:0-未提现,待审核,1-已审核
*/
@Column(name = "stauts")
@ApiModelProperty(value = "订单状态:0-未提现,待审核,1-已审核")
private Integer stauts;
/**
* 提现日期
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "提现日期", hidden = true )
private Long crtTime;
/**
* 审核日期
*/
@Column(name = "finish_time")
@ApiModelProperty(value = "审核日期")
private Long finishTime;
/**
* 操作者ID
*/
@Column(name = "oper_user")
@ApiModelProperty(value = "操作者ID")
private String operUser;
}
package com.github.wxiaoqi.security.admin.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 收入/支持明细表,每笔的进账,出账的详细记录
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Data
@Table(name = "my_wallet_detail")
public class MyWalletDetail implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键ID")
private Long id;
/**
* 用户ID
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户ID")
private String userId;
/**
* 来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买
*/
@Column(name = "source")
@ApiModelProperty(value = "来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买")
private Integer source;
/**
* 收入/支出:0-收入,1-支出
*/
@Column(name = "itype")
@ApiModelProperty(value = "收入/支出:0-收入,1-支出")
private Integer itype;
/**
* 收入/支出的金额(分)
*/
@Column(name = "amount")
@ApiModelProperty(value = "收入/支出的金额(分)")
private Long amount;
/**
* 活动类型
*/
@Column(name = "type")
@ApiModelProperty(value = "活动类型")
private Integer type;
/**
* 活动id
*/
@Column(name = "activity_id")
@ApiModelProperty(value = "活动id")
private Integer activityId;
/**
* 单号
*/
@Column(name = "cono")
@ApiModelProperty(value = "单号")
private String cono;
/**
* 加上当时的收入的余额
*/
@Column(name = "balance")
@ApiModelProperty(value = "加上当时的收入的余额")
private Long balance;
/**
* 操作者ID(如果系统操作,-1)
*/
@Column(name = "oper_user")
@ApiModelProperty(value = "操作者ID(如果系统操作,-1)")
private Integer operUser;
/**
* 操作时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime;
}
package com.github.wxiaoqi.security.admin.biz;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater;
import com.github.wxiaoqi.security.admin.mapper.AppUserSellingWaterMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
/**
* 拥金明细表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
@Service
public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper,AppUserSellingWater> {
}
\ No newline at end of file
......@@ -4,8 +4,6 @@ import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.dto.BaseUserMemberVO;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.entity.UserMemberLevel;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -15,7 +13,6 @@ import org.apache.commons.beanutils.BeanUtilsBean;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.amqp.dsl.Amqp;
import org.springframework.stereotype.Service;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberMapper;
......@@ -26,6 +23,7 @@ import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
/**
......@@ -49,6 +47,9 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
@Autowired
private UserMemberLevelBiz userMemberLevelBiz;
@Autowired
private AppUserLoginBiz appUserLoginBiz;
//获取用户会员信息
@Cache(key = "user:member{1}")
public UserMemberVo getMemberInfoByUserId(Integer userId){
......@@ -233,6 +234,4 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper,BaseUserMemb
}
}
}
\ No newline at end of file
......@@ -2,7 +2,9 @@ package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.dto.BaseUserMemberExportDTO;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.dto.UserMemberSaveDTO;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberExport;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberExportMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -16,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -41,13 +44,50 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
private AppUserLoginBiz appUserLoginBiz;
public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO){
if (userMemberSaveDTO!=null){
UserMemberDTO userMemberDTO = new UserMemberDTO();
BaseUserMemberLevel level = userMemberLevelBiz.getLevel(userMemberSaveDTO.getMemberLevel());
Map<String, Integer> phoneAndUserIdMap = appUserLoginBiz.findPhoneAndUserIdMapByPhones(Arrays.asList(userMemberSaveDTO.getPhone()));
if (phoneAndUserIdMap!=null){
userMemberDTO.setUserId(phoneAndUserIdMap.get(userMemberSaveDTO.getPhone()));
userMemberDTO.setMemberLevel(userMemberSaveDTO.getMemberLevel());
userMemberDTO.setDiscount(level==null?0:(level.getDiscount()==null?0:level.getDiscount()));
userMemberDTO.setTotalNumber(userMemberSaveDTO.getTotalNumber());
userMemberDTO.setRentFreeDays(userMemberSaveDTO.getRentFreeDays());
userMemberDTO.setIsBind(1);
try {
baseUserMemberBiz.updUserMemberByUserId(userMemberDTO);
} catch (Exception e) {
log.error("会员更新或新增错误:【{}】",e.getMessage());
throw new BaseException(e);
}
}
BaseUserMemberExport memberExport = BaseUserMemberExport
.builder()
.username(userMemberSaveDTO.getPhone())
.memberLevel(userMemberSaveDTO.getMemberLevel())
.totalNumber(userMemberSaveDTO.getTotalNumber())
.rentFreeDays(userMemberSaveDTO.getRentFreeDays())
.discount(level==null?0:level.getDiscount()==null?0:level.getDiscount())
.status(phoneAndUserIdMap == null ? 0 : (phoneAndUserIdMap.get(userMemberSaveDTO.getPhone()) == null ? 0 : 1))
.isDel(0)
.build();
if (log.isDebugEnabled()){
log.debug("当前组装的数据:【{}】",memberExport);
}
mapper.insertSelective(memberExport);
}
}
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public int importUserMember(List<String[]> userMemberData){
List<BaseUserMemberExport> baseUserMemberExports = new ArrayList<>();
List<Integer> levels = userMemberData.stream().map(x -> x[1]).map(Integer::valueOf).collect(Collectors.toList());
List<Integer> levels = userMemberData.stream().map(x -> x[1]).map(Integer::valueOf).distinct().collect(Collectors.toList());
Map<Integer, Integer> levelAndDisCountMap= userMemberLevelBiz.getUserMemberLevelAndDisCountMapByLevels(levels);
List<String> phones = userMemberData.stream().map(x -> x[0]).collect(Collectors.toList());
List<String> phones = userMemberData.stream().map(x -> x[0]).distinct().collect(Collectors.toList());
Map<String,Integer> phoneAndUserIdMap = appUserLoginBiz.findPhoneAndUserIdMapByPhones(phones);
for (String[] data : userMemberData) {
......
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserBankCard;
import tk.mybatis.mapper.common.Mapper;
/**
* 银行卡绑定表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface AppUserBankCardMapper extends Mapper<AppUserBankCard> {
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.AppUserSellingWater;
import tk.mybatis.mapper.common.Mapper;
/**
* 拥金明细表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import tk.mybatis.mapper.common.Mapper;
/**
* 钱包提现表
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface MyWalletCathMapper extends Mapper<MyWalletCath> {
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import tk.mybatis.mapper.common.Mapper;
/**
* 收入/支持明细表,每笔的进账,出账的详细记录
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface MyWalletDetailMapper extends Mapper<MyWalletDetail> {
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.MyWallet;
import tk.mybatis.mapper.common.Mapper;
/**
* 我的钱包
*
* @author zjw
* @email 18178966185@163.com
* @date 2019-07-11 14:14:54
*/
public interface MyWalletMapper extends Mapper<MyWallet> {
}
......@@ -91,9 +91,8 @@ public class UserMemberController {
public ResponseEntity<byte[]> dowloadUserMemberExcelModel(HttpServletResponse response){
// 重置response
response.reset();
//设置http头信息的内容
response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.ms-excel");
response.setContentType("multipart/form-data");
response.addHeader("Content-Disposition", "attachment;filename=usermember.xlsx");
InputStream inputStream = AdminBootstrap.class.getClassLoader().getResourceAsStream("file/usermember.xlsx");
try {
......
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.BaseUserMemberExportBiz;
import com.github.wxiaoqi.security.admin.dto.UserMemberSaveDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
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 libin
* @version 1.0
* @description
* @data 2019/7/11 9:58
*/
@RestController
@RequestMapping("/admin/member")
public class UserMemberAdminController {
@Autowired
private BaseUserMemberExportBiz baseUserMemberExportBiz;
@PostMapping("/save")
public ObjectRestResponse<Void> saveUserMember(@RequestBody UserMemberSaveDTO userMemberSaveDTO) {
baseUserMemberExportBiz.saveUserMember(userMemberSaveDTO);
return ObjectRestResponse.succ();
}
}
......@@ -96,7 +96,7 @@ public class IntegralRule{
/**
* 描述
*/
private String desc;
private String detail;
/**
* 规则图片
......@@ -125,4 +125,5 @@ public class IntegralRule{
@Column(name = "other_rule")
private String otherRule;
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ public class IntegralUserRecord {
/**
* 0-获取积分;1-抵扣积分
*/
private Boolean type;
private Integer type;
/**
* 积分数
......
package com.xxfc.platform.activity.util;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class IntegralToolsUtils {
//获取数组中的最大值
public static Integer getMax(Integer point, Integer otherRulePoint, Integer finishPoint) {
int[] arr = {point, otherRulePoint, finishPoint};
Arrays.sort(arr);
return arr[arr.length - 1];
}
//获取两个时间戳相隔的天数
public static int differentDaysByMillisecond(Long date1,Long date2){
Date startDate = new Date();
startDate.setTime(date1);
Date endDate = new Date();
endDate.setTime(date2);
return endDate.getDate() - startDate.getDate();
}
//获取当天的0点
public static Long getDayStart() {
long current = System.currentTimeMillis();
long zero = current/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();
return zero;
}
//获取当前时间的周一
public static Long weekFirstDay(int week, int param) {
Calendar c1 = Calendar.getInstance();
int dow = c1.get(Calendar.DAY_OF_WEEK);
c1.add(Calendar.DATE, -dow - 7 * (week - 1) + param);
return c1.getTime().getTime()/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();
}
public static Integer getQuarter() {
Calendar c = Calendar.getInstance();
int month = c.get(c.MONTH) + 1;
int quarter = 0;
if (month >= 1 && month <= 3) {
quarter = 1;
} else if (month >= 4 && month <= 6) {
quarter = 2;
} else if (month >= 7 && month <= 9) {
quarter = 3;
} else {
quarter = 4;
}
return quarter;
}
public static String[] getCurrQuarter(int num) {
String[] s = new String[2];
String str = "";
// 设置本年的季
Calendar quarterCalendar = null;
switch (num) {
case 1: // 本年到现在经过了一个季度,在加上前4个季度
quarterCalendar = Calendar.getInstance();
quarterCalendar.set(Calendar.MONTH, 3);
quarterCalendar.set(Calendar.DATE, 1);
quarterCalendar.add(Calendar.DATE, -1);
str = formatDate(quarterCalendar.getTime(), "yyyy-MM-dd");
s[0] = str.substring(0, str.length() - 5) + "01-01";
s[1] = str;
break;
case 2: // 本年到现在经过了二个季度,在加上前三个季度
quarterCalendar = Calendar.getInstance();
quarterCalendar.set(Calendar.MONTH, 6);
quarterCalendar.set(Calendar.DATE, 1);
quarterCalendar.add(Calendar.DATE, -1);
str = formatDate(quarterCalendar.getTime(), "yyyy-MM-dd");
s[0] = str.substring(0, str.length() - 5) + "04-01";
s[1] = str;
break;
case 3:// 本年到现在经过了三个季度,在加上前二个季度
quarterCalendar = Calendar.getInstance();
quarterCalendar.set(Calendar.MONTH, 9);
quarterCalendar.set(Calendar.DATE, 1);
quarterCalendar.add(Calendar.DATE, -1);
str = formatDate(quarterCalendar.getTime(), "yyyy-MM-dd");
s[0] = str.substring(0, str.length() - 5) + "07-01";
s[1] = str;
break;
case 4:// 本年到现在经过了四个季度,在加上前一个季度
quarterCalendar = Calendar.getInstance();
str = formatDate(quarterCalendar.getTime(), "yyyy-MM-dd");
s[0] = str.substring(0, str.length() - 5) + "10-01";
s[1] = str.substring(0, str.length() - 5) + "12-31";
break;
}
return s;
}
public static String formatDate(Date currentDate, String pattern){
if(currentDate == null || "".equals(pattern) || pattern == null){
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(currentDate);
}
public static Long parseDate(String currentDate) {
if(StringUtils.isBlank(currentDate)){
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try{
date = sdf.parse(currentDate);
}catch (Exception e){
}
return date == null? null : date.getTime();
}
/**
* 获取指定日期所在月份开始的时间戳
*
* @param date
* 指定日期
* @return
*/
public static Long getMonthBegin(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
// 设置为1号,当前日期既为本月第一天
c.set(Calendar.DAY_OF_MONTH, 1);
// 将小时至0
c.set(Calendar.HOUR_OF_DAY, 0);
// 将分钟至0
c.set(Calendar.MINUTE, 0);
// 将秒至0
c.set(Calendar.SECOND, 0);
// 将毫秒至0
c.set(Calendar.MILLISECOND, 0);
// 获取本月第一天的时间戳
return c.getTimeInMillis();
}
/**
* 获取指定日期所在月份结束的时间戳
*
* @param date
* 指定日期
* @return
*/
public static Long getMonthEnd(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
// 设置为当月最后一天
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
// 将小时至23
c.set(Calendar.HOUR_OF_DAY, 23);
// 将分钟至59
c.set(Calendar.MINUTE, 59);
// 将秒至59
c.set(Calendar.SECOND, 59);
// 将毫秒至999
c.set(Calendar.MILLISECOND, 999);
// 获取本月最后一天的时间戳
return c.getTimeInMillis();
}
public static Long getLastDayOfYear(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
cal.set(Calendar.DAY_OF_YEAR, last);
return cal.getTime().getTime()/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset() + 24 * 60 * 60 * 1000 - 1;
}
public static Long getFirstDayOfYear(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final int first = cal.getActualMinimum(Calendar.DAY_OF_YEAR);
cal.set(Calendar.DAY_OF_YEAR, first);
return cal.getTime().getTime()/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();
}
}
package com.xxfc.platform.activity.vo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class IntegralRuleDto extends PageParam {
/**
* 主键id
*/
private Integer id;
/**
* 周期单位:0-天,1-周;3-月;4-季;5-年
*/
private Integer period;
/**
* 次数
*/
private Integer number;
/**
* 积分
*/
private Integer point;
/**
* 积分兑换:金额/分
*/
private BigDecimal price;
/**
* 是否连续:0-不连续;1-连续
*/
private Boolean isContinuity;
/**
* 多少天后连续算
*/
private Integer finishDay;
/**
* n天获取的积分
*/
private Integer finishPoint;
/**
* 是否启用:1-启用;0-停用
*/
private Boolean status;
/**
* 创建时间
*/
private Long crtTime;
/**
* 是否删除:0-正常;1-删除
*/
private Boolean isdel;
/**
* 规则开始时间
*/
private Long startTime;
/**
* 规则结束时间
*/
private Long endTime;
/**
* 更新时间
*/
private Long updTime;
/**
* 备注
*/
private String remarks;
/**
* 描述
*/
private String desc;
/**
* 规则图片
*/
private String img;
/**
* 排序
*/
private Integer orderId;
/**
* 规则名称
*/
private String name;
/**
* 获取积分规则
*/
private String regulation;
/**
* json字符串 如:[{"day":4,"integeral":8},{"day":4,"integeral":8}]
*/
private String otherRule;
}
package com.xxfc.platform.activity.vo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
@Data
public class IntegralUserRecordDto extends PageParam {
Integer userId;
Long startTime;
Long endTime;
Integer integralRuleId;
}
package com.xxfc.platform.activity.vo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
@Data
public class IntegralUserTotalDto extends PageParam{
Integer userId;
private Integer point;
}
......@@ -4,8 +4,12 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.activity.entity.IntegralRule;
import com.xxfc.platform.activity.mapper.IntegralRuleMapper;
import com.xxfc.platform.activity.vo.IntegralRuleDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -31,10 +35,10 @@ public class IntegralRuleBiz extends BaseBiz<IntegralRuleMapper, IntegralRule> {
return ObjectRestResponse.createDefaultFail();
}
BeanUtil.copyProperties(integralRule, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
mapper.updateByPrimaryKeySelective(oldValue);
updateByIdRe(oldValue);
return ObjectRestResponse.succ();
}
mapper.insertSelective(integralRule);
insertSelective(integralRule);
return ObjectRestResponse.succ();
}
......@@ -52,7 +56,7 @@ public class IntegralRuleBiz extends BaseBiz<IntegralRuleMapper, IntegralRule> {
return ObjectRestResponse.createDefaultFail();
}
oldValue.setIsdel(true);
mapper.updateByPrimaryKeySelective(oldValue);
updateByIdRe(oldValue);
return ObjectRestResponse.succ();
}
......@@ -61,17 +65,14 @@ public class IntegralRuleBiz extends BaseBiz<IntegralRuleMapper, IntegralRule> {
return ObjectRestResponse.paramIsEmpty();
}
IntegralRule oldValue = mapper.selectByPrimaryKey(integralRule.getId());
if(oldValue == null) {
return ObjectRestResponse.createDefaultFail();
}
return ObjectRestResponse.succ(oldValue);
}
public ObjectRestResponse<List<IntegralRule>> getAll(IntegralRule integralRule) {
List<IntegralRule> integralRules = mapper.selectAllByParam(integralRule);
return ObjectRestResponse.succ(integralRules);
public ObjectRestResponse<PageDataVO> getAll(IntegralRuleDto integralRule) {
Query query = new Query(integralRule);
PageDataVO pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectAllByParam(integralRule));
return ObjectRestResponse.succ(pageDataVO);
}
}
package com.xxfc.platform.activity.biz;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.activity.entity.IntegralUserRecord;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.mapper.IntegralUserRecordMapper;
import com.xxfc.platform.activity.user.UserInfoBiz;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import com.xxfc.platform.activity.vo.IntegralUserTotalDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
@Slf4j
......@@ -19,13 +30,46 @@ public class IntegralUserRecordBiz extends BaseBiz<IntegralUserRecordMapper, Int
@Autowired
UserInfoBiz userInfoBiz;
@Autowired
IntegralUserTotalBiz integralUserTotalBiz;
/**
* 添加用户积分记录
* @param integralUserRecord
* @return
*/
public ObjectRestResponse add(IntegralUserRecord integralUserRecord) {
return ObjectRestResponse.succ();
if(integralUserRecord == null) {
return ObjectRestResponse.paramIsEmpty();
}
if(integralUserRecord.getType() == 0) {//获取积分 增加总积分表
ObjectRestResponse<IntegralUserTotal> objectRestResponse = integralUserTotalBiz.getByUser();
if(objectRestResponse.getStatus() == RestCode.SUCCESS.getStatus() && objectRestResponse.getData() != null) {
IntegralUserTotal integralUserTotal = objectRestResponse.getData();
IntegralUserTotalDto integralUserTotalDto = new IntegralUserTotalDto();
integralUserTotalDto.setUserId(integralUserTotal.getUserId());
integralUserTotalDto.setPoint(integralUserRecord.getPoint());
integralUserTotalBiz.add(integralUserTotalDto);
} else {
IntegralUserTotalDto integralUserTotalDto = new IntegralUserTotalDto();
integralUserTotalDto.setUserId(integralUserRecord.getUserId());
integralUserTotalDto.setPoint(integralUserRecord.getPoint());
integralUserTotalBiz.add(integralUserTotalDto);
}
} else if(integralUserRecord.getType() == 1) {//扣减积分
ObjectRestResponse<IntegralUserTotal> objectRestResponse = integralUserTotalBiz.getByUser();
if(objectRestResponse.getStatus() == RestCode.SUCCESS.getStatus() && objectRestResponse.getData() != null) {
IntegralUserTotal integralUserTotal = objectRestResponse.getData();
IntegralUserTotalDto integralUserTotalDto = new IntegralUserTotalDto();
integralUserTotalDto.setUserId(integralUserTotal.getUserId());
integralUserTotalDto.setPoint(- integralUserRecord.getPoint());
integralUserTotalBiz.add(integralUserTotalDto);
} else {
return ObjectRestResponse.createFailedResult(1008,"用户积分不足");
}
}
insertSelective(integralUserRecord);
return ObjectRestResponse.succ();
}
/**
......@@ -43,7 +87,7 @@ public class IntegralUserRecordBiz extends BaseBiz<IntegralUserRecordMapper, Int
return ObjectRestResponse.createDefaultFail();
}
integralUserRecord.setIsdel(true);
mapper.updateByPrimaryKeySelective(integralUserRecord);
updateByIdRe(integralUserRecord);
return ObjectRestResponse.succ();
}
......@@ -51,12 +95,21 @@ public class IntegralUserRecordBiz extends BaseBiz<IntegralUserRecordMapper, Int
* 根据获取某个用户的列表
* @return
*/
public ObjectRestResponse<IntegralUserRecord> getUserList() {
public ObjectRestResponse<PageDataVO> getUserList(IntegralUserRecordDto integralUserRecordDto) {
AppUserDTO appUserDTO = userInfoBiz.getUserInfo();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
return ObjectRestResponse.succ();
Query query = new Query(integralUserRecordDto);
PageDataVO pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectByUserId(appUserDTO.getUserid()));
return ObjectRestResponse.succ(pageDataVO);
}
public ObjectRestResponse<List<IntegralUserRecord>> getByUserAndTime(IntegralUserRecordDto integralUserRecordDto) {
if(integralUserRecordDto == null) {
return ObjectRestResponse.paramIsEmpty();
}
List<IntegralUserRecord> integralUserRecordList = mapper.selectByUserAndTime(integralUserRecordDto);
return ObjectRestResponse.succ(integralUserRecordList);
}
}
......@@ -5,9 +5,13 @@ import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.mapper.IntegralUserTotalMapper;
import com.xxfc.platform.activity.user.UserInfoBiz;
import com.xxfc.platform.activity.vo.IntegralRuleDto;
import com.xxfc.platform.activity.vo.IntegralUserTotalDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -23,34 +27,36 @@ public class IntegralUserTotalBiz extends BaseBiz<IntegralUserTotalMapper, Integ
/**
* 添加用户总积分
* @param integralUserTotal
* @param integralUserTotalDto
* @return
*/
public ObjectRestResponse add(IntegralUserTotal integralUserTotal) {
public ObjectRestResponse add(IntegralUserTotalDto integralUserTotalDto) {
AppUserDTO appUserDTO = userInfoBiz.getUserInfo();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
if(integralUserTotal == null) {
if(integralUserTotalDto == null || integralUserTotalDto.getPoint() == null) {
return ObjectRestResponse.paramIsEmpty();
}
integralUserTotal.setUserId(appUserDTO.getUserid());
if(integralUserTotal.getId() != null) {
IntegralUserTotal oldValue = mapper.selectByPrimaryKey(integralUserTotal.getId());
if(oldValue == null) {
return ObjectRestResponse.createDefaultFail();
integralUserTotalDto.setUserId(appUserDTO.getUserid());
List<IntegralUserTotal> integralUserTotalList = mapper.selectAllByParam(integralUserTotalDto);
if(integralUserTotalList != null && integralUserTotalList.size() > 0) {
integralUserTotalList.get(0).setTotalPoint(integralUserTotalList.get(0).getTotalPoint() + integralUserTotalDto.getPoint());
integralUserTotalList.get(0).setRestPoint(integralUserTotalList.get(0).getRestPoint() + integralUserTotalDto.getPoint());
updateByIdRe( integralUserTotalList.get(0));
return ObjectRestResponse.succ();
}
BeanUtil.copyProperties(integralUserTotal, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
mapper.updateByPrimaryKeySelective(oldValue);
IntegralUserTotal integralUserTotal = new IntegralUserTotal();
integralUserTotal.setUserId(appUserDTO.getUserid());
integralUserTotal.setTotalPoint(integralUserTotalDto.getPoint());
integralUserTotal.setRestPoint(integralUserTotalDto.getPoint());
integralUserTotal.setIsdel(false);
insertSelective(integralUserTotal);
return ObjectRestResponse.succ();
}
mapper.insertSelective(integralUserTotal);
return ObjectRestResponse.succ();
}
/**
* 删除信息
* @param id
* @return
*/
public ObjectRestResponse deleteOne() {
......@@ -58,14 +64,14 @@ public class IntegralUserTotalBiz extends BaseBiz<IntegralUserTotalMapper, Integ
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
IntegralUserTotal integralUserTotal = new IntegralUserTotal();
integralUserTotal.setUserId(appUserDTO.getUserid());
List<IntegralUserTotal> oldValue = mapper.selectAllByParam(integralUserTotal);
IntegralUserTotalDto integralUserTotalDto = new IntegralUserTotalDto();
integralUserTotalDto.setUserId(appUserDTO.getUserid());
List<IntegralUserTotal> oldValue = mapper.selectAllByParam(integralUserTotalDto);
if(oldValue == null || oldValue.size() <= 0) {
return ObjectRestResponse.createDefaultFail();
}
oldValue.get(0).setIsdel(true);
mapper.updateByPrimaryKeySelective(oldValue.get(0));
updateByIdRe(oldValue.get(0));
return ObjectRestResponse.succ();
}
......@@ -78,23 +84,22 @@ public class IntegralUserTotalBiz extends BaseBiz<IntegralUserTotalMapper, Integ
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
IntegralUserTotal integralUserTotal = new IntegralUserTotal();
integralUserTotal.setUserId(appUserDTO.getUserid());
List<IntegralUserTotal> oldValue = mapper.selectAllByParam(integralUserTotal);
if(oldValue == null || oldValue.size() <= 0) {
return ObjectRestResponse.createDefaultFail();
}
return ObjectRestResponse.succ(oldValue.get(0));
IntegralUserTotalDto integralUserTotalDto = new IntegralUserTotalDto();
integralUserTotalDto.setUserId(appUserDTO.getUserid());
List<IntegralUserTotal> oldValue = mapper.selectAllByParam(integralUserTotalDto);
return ObjectRestResponse.succ(oldValue == null || oldValue.size() <=0 ? null : oldValue.get(0));
}
/**
* 获取所有的信息
* @param integralUserTotal
* @return
*/
public ObjectRestResponse<List<IntegralUserTotal>> getAll(IntegralUserTotal integralUserTotal) {
List<IntegralUserTotal> integralUserTotals = mapper.selectAllByParam(integralUserTotal);
return ObjectRestResponse.succ(integralUserTotals);
public ObjectRestResponse<PageDataVO> getAll(IntegralUserTotalDto integralUserTotalDto) {
Query query = new Query(integralUserTotalDto);
PageDataVO pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectAllByParam(integralUserTotalDto));
return ObjectRestResponse.succ(pageDataVO);
}
}
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.IntegralRule;
import com.xxfc.platform.activity.vo.IntegralRuleDto;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface IntegralRuleMapper extends Mapper<IntegralRule> {
public List<IntegralRule> selectAllByParam(IntegralRule integralRule);
public List<IntegralRule> selectAllByParam(IntegralRuleDto integralRuleDto);
}
\ No newline at end of file
......@@ -3,5 +3,8 @@ package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.IntegralSignRecord;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface IntegralSignRecordMapper extends Mapper<IntegralSignRecord> {
List<IntegralSignRecord> selectByUserId(Integer userId);
}
\ No newline at end of file
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.IntegralUserRecord;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface IntegralUserRecordMapper extends Mapper<IntegralUserRecord> {
List<IntegralUserRecord> selectByUserId(Integer userId);
List<IntegralUserRecord> selectByUserAndTime(IntegralUserRecordDto integralUserRecordDto);
}
\ No newline at end of file
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.vo.IntegralUserTotalDto;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
public interface IntegralUserTotalMapper extends Mapper<IntegralUserTotal> {
List<IntegralUserTotal> selectAllByParam(IntegralUserTotal integralUserTotal);
List<IntegralUserTotal> selectAllByParam(IntegralUserTotalDto integralUserTotalDto);
}
\ No newline at end of file
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.biz.IntegralRuleBiz;
import com.xxfc.platform.activity.entity.IntegralRule;
import com.xxfc.platform.activity.vo.IntegralRuleDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -41,8 +43,8 @@ public class IntegralRuleController {
@GetMapping(value = "/list")
@ApiOperation(value = "获取所有的规则")
public ObjectRestResponse<List<IntegralRule>> getList(IntegralRule integralRule) {
return integralRuleBiz.getAll(integralRule);
public ObjectRestResponse<PageDataVO> getList(IntegralRuleDto integralRuleDto) {
return integralRuleBiz.getAll(integralRuleDto);
}
}
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.biz.IntegralSignRecordBiz;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,4 +16,9 @@ public class IntegralSignRecordController {
@Autowired
IntegralSignRecordBiz integralSignRecordBiz;
@PostMapping(value = "/add")
public ObjectRestResponse add(Integer integralRuleId) {
return integralSignRecordBiz.add(integralRuleId);
}
}
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.biz.IntegralUserRecordBiz;
import com.xxfc.platform.activity.entity.IntegralUserRecord;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,4 +19,21 @@ public class IntegralUserRecordController {
@Autowired
IntegralUserRecordBiz integralUserRecordBiz;
@PostMapping(value = "/add")
public ObjectRestResponse add(IntegralUserRecord integralUserRecord) {
return integralUserRecordBiz.add(integralUserRecord);
}
@PostMapping(value = "/delete")
public ObjectRestResponse deleteById(Integer id) {
return integralUserRecordBiz.deleteOne(id);
}
@GetMapping(value = "/getListByUser")
public ObjectRestResponse getByUser(IntegralUserRecordDto integralUserRecordDto) {
return integralUserRecordBiz.getUserList(integralUserRecordDto);
}
}
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.activity.biz.IntegralUserTotalBiz;
import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.vo.IntegralUserTotalDto;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -8,4 +15,29 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(value = "integralUserTotal")
@Api(value = "用户总积分")
public class IntegralUserTotalController {
@Autowired
IntegralUserTotalBiz integralUserTotalBiz;
@PostMapping(value = "/add")
public ObjectRestResponse add(IntegralUserTotalDto integralUserTotalDto) {
return integralUserTotalBiz.add(integralUserTotalDto);
}
@PostMapping(value = "/delete")
public ObjectRestResponse deleteById() {
return integralUserTotalBiz.deleteOne();
}
@GetMapping(value = "/getByUser")
public ObjectRestResponse getByUser() {
return integralUserTotalBiz.getByUser();
}
@GetMapping(value = "/getAll")
public ObjectRestResponse getAll(IntegralUserTotalDto integralUserTotalDto) {
return integralUserTotalBiz.getAll(integralUserTotalDto);
}
}
......@@ -20,7 +20,7 @@
<result column="end_time" property="endTime" jdbcType="BIGINT" />
<result column="upd_time" property="updTime" jdbcType="BIGINT" />
<result column="remarks" property="remarks" jdbcType="VARCHAR" />
<result column="desc" property="desc" jdbcType="VARCHAR" />
<result column="detail" property="detail" jdbcType="VARCHAR" />
<result column="img" property="img" jdbcType="VARCHAR" />
<result column="order_id" property="orderId" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
......@@ -28,16 +28,14 @@
<result column="other_rule" property="otherRule" jdbcType="LONGVARCHAR" />
</resultMap>
<select id="selectAllByParam" resultType="com.xxfc.platform.activity.entity.IntegralRule" parameterType="com.xxfc.platform.activity.entity.IntegralRule">
<select id="selectAllByParam" resultType="com.xxfc.platform.activity.entity.IntegralRule" parameterType="com.xxfc.platform.activity.vo.IntegralRuleDto">
select * from integral_rule
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null">
and name like concat("%", #{name}, "%")
</if>
and isdel = 0 and status = 1
</where>
order by order_id DESC ,crt_time DESC
</select>
......
......@@ -11,4 +11,10 @@
<result column="start_time" property="startTime" jdbcType="BIGINT" />
<result column="last_time" property="lastTime" jdbcType="BIGINT" />
</resultMap>
<select id="selectByUserId" parameterType="java.lang.Integer" resultType="com.xxfc.platform.activity.entity.IntegralSignRecord">
select * from integral_sign_record
where user_id = #{userId} and isdel = 0
order by last_time
</select>
</mapper>
\ No newline at end of file
......@@ -7,7 +7,7 @@
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="BIT" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="point" property="point" jdbcType="INTEGER" />
<result column="integral_rule_id" property="integralRuleId" jdbcType="INTEGER" />
<result column="crt_time" property="crtTime" jdbcType="BIGINT" />
......@@ -15,4 +15,18 @@
<result column="isdel" property="isdel" jdbcType="BIT" />
<result column="channel_id" property="channelId" jdbcType="INTEGER" />
</resultMap>
<select id="selectByUserId" parameterType="java.lang.Integer" resultType="com.xxfc.platform.activity.entity.IntegralUserRecord">
select * from integral_user_record
<where>
<if test="userId != null">
and user_id = #{userId}
</if>
</where>
order by crt_time DESC
</select>
<select id="selectByUserAndTime" resultType="com.xxfc.platform.activity.entity.IntegralUserRecord" parameterType="com.xxfc.platform.activity.vo.IntegralUserRecordDto">
select * from integral_user_record
where user_id = #{userId} and crt_time between #{startTime} and #{endTime} and integral_rule_id = #{integralRuleId}
</select>
</mapper>
\ No newline at end of file
......@@ -13,7 +13,7 @@
<result column="upd_time" property="updTime" jdbcType="BIGINT" />
</resultMap>
<select id="selectAllByParam" parameterType="com.xxfc.platform.activity.entity.IntegralUserTotal" resultType="com.xxfc.platform.activity.entity.IntegralUserTotal">
<select id="selectAllByParam" parameterType="com.xxfc.platform.activity.vo.IntegralUserTotalDto" resultType="com.xxfc.platform.activity.entity.IntegralUserTotal">
select * from integral_user_total
<where>
<if test="userId != null">
......
......@@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
public enum OrderTypeEnum {
RentVehicle(1, "租车订单"),
RENT_VEHICLE(1, "租车订单"),
TOUR(2, "旅游订单"),
MEMBER(3, "会员订单"),
;
......@@ -18,13 +18,6 @@ public enum OrderTypeEnum {
private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap();
// static{
// for(VehicleBookRecordStatus constantType : VehicleBookRecordStatus.values()){
// codeAndDesc.put(constantType.getCode(),constantType.getDesc());
// }
// }
OrderTypeEnum(Integer code, String desc){
this.code=code;
......@@ -50,4 +43,13 @@ public enum OrderTypeEnum {
public static Boolean exists(Integer code){
return codeAndDesc.containsKey(code);
}
public static OrderTypeEnum get(Integer code) {
for(OrderTypeEnum enumE : OrderTypeEnum.values()) {
if (enumE.getCode().equals(code)) {
return enumE;
}
}
return null;
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ import javax.persistence.Id;
import java.time.format.DateTimeFormatter;
@Data
public class AddMemberDTO {
public class AddMemberDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ApiModelProperty(value = "会员等级id")
......@@ -18,9 +18,4 @@ public class AddMemberDTO {
@ApiModelProperty(value = "会员等级")
private Integer memberLevel;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
}
package com.xxfc.platform.order.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AddOrderCommonDTO {
/**
*
*/
@ApiModelProperty(value = "下单来源,1--app;2--小程序")
private Integer orderOrigin;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
}
......@@ -10,7 +10,7 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
@Data
public class AddRentVehicleDTO{
public class AddRentVehicleDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
......@@ -94,19 +94,6 @@ public class AddRentVehicleDTO{
@ApiModelProperty(value = "是否使用出租免费天数")
private Integer rentFreeDay;
/**
*
*/
@ApiModelProperty(value = "下单来源,1--app;2--小程序")
private Integer orderOrigin;
/**
* 优惠券ids
*/
@ApiModelProperty(value = "优惠券ids")
private String couponIds;
public void setStartTime(Long startTime) {
this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
......
......@@ -10,7 +10,7 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
@Data
public class AddTourDTO {
public class AddTourDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
......
......@@ -2,7 +2,6 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -97,7 +96,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
private static Map<Integer, List<Integer>> cancelAble;
static {
cancelAble = new HashMap<Integer, List<Integer>>();
cancelAble.put(OrderTypeEnum.RentVehicle.getCode(), new LinkedList<Integer>(){{
cancelAble.put(OrderTypeEnum.RENT_VEHICLE.getCode(), new LinkedList<Integer>(){{
add(OrderStatusEnum.ORDER_UNPAY.getCode());
add(OrderStatusEnum.ORDER_TOSTART.getCode());
}});
......@@ -186,7 +185,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//判断是否已支付
if(SYS_TRUE.equals(baseOrder.getHasPay())) {
//判断订单类型
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
}});
......@@ -221,7 +220,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
}
//处理取消流程
if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
}});
......@@ -267,24 +266,33 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
}
/**
* 租车退款流程(含押金)
* 租车(包括旅游)退款流程(含押金)
* @param baseOrder
* @param depositAmont
* @param depositAmount
* @param timeLag 与开始时间的时间差
* @param dicParentKey
*/
private void rentRefundProcess(BaseOrder baseOrder, BigDecimal depositAmont, Long timeLag, String dicParentKey) {
private void rentRefundProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey) {
//计算退款金额
// 1、押金 + 租金(规则扣除)
BigDecimal refundGoodsAmount = baseOrder.getGoodsAmount();
// 1、押金 + 租金(规则扣除)
//BigDecimal refundGoodsAmount = baseOrder.getGoodsAmount();
String refundDesc = "取消订单退款:";
BigDecimal refundGoodsAmont = baseOrder.getGoodsAmount();
if(null == depositAmont) {
depositAmont = BigDecimal.ZERO;
if(null == depositAmount) {
depositAmount = BigDecimal.ZERO;
}
BigDecimal refundGoodsAmount = calculateRefund(baseOrder.getGoodsAmount(), timeLag, dicParentKey, refundDesc);
//退款金额
BigDecimal refundAmount = depositAmount.add(refundGoodsAmount);
//退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDesc, refundAmount, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.ALL.getCode());
}
public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, String refundDesc) {
BigDecimal refundGoodsAmount = goodsAmount;
//根据时间处理goodsAmount
//获取出发时间 到现在 距离时间
//获取出发时间 到现在 距离时间
Integer hourLag = Long.valueOf(timeLag/(1000L * 60L * 60L)).intValue();
Map<String, com.xxfc.platform.universal.entity.Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
......@@ -301,40 +309,37 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//符合范围
if(IntervalUtil.staticIsInTheInterval(hourLag.toString(), names[0])){
refundGoodsAmont = new BigDecimal((IntervalUtil.evaluate(dic.getDetail(), new MapContext(){{
refundGoodsAmount = new BigDecimal((IntervalUtil.evaluate(dic.getDetail(), new MapContext(){{
//ga : goodsAmount
set("ga", baseOrder.getGoodsAmount());
set("ga", goodsAmount);
}})).toString());
refundDesc = names[1]+ ","+ refundDesc;
break;
}
}
//退款金额
BigDecimal refundAmont = depositAmont.add(refundGoodsAmont);
//退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.ALL.getCode());
return refundGoodsAmount;
}
/**
* 退款子流程
* @param baseOrder
* @param refundDesc
* @param refundAmont
* @param refundAmount
* @param refundType
* @param refundStatus
*/
public void refundSubProcess(BaseOrder baseOrder, String refundDesc, BigDecimal refundAmont, Integer refundType, Integer refundStatus) {
public void refundSubProcess(BaseOrder baseOrder, String refundDesc, BigDecimal refundAmount, Integer refundType, Integer refundStatus) {
OrderRefundVo orv = new OrderRefundVo(){{
setAmount(baseOrder.getRealAmount().multiply(new BigDecimal("100")).intValue());
setOrderNo(baseOrder.getNo());
}};
orv.setRefundDesc(refundDesc+ refundAmont.toString());
orv.setRefundAmount(refundAmont.multiply(new BigDecimal("100")).intValue());
orv.setRefundDesc(refundDesc+ refundAmount.toString());
orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
String refundTradeNo = thirdFeign.refund(orv).getData();
//记录订单退款记录
Integer flag = addOrderRefund(baseOrder.getId(), refundDesc, refundAmont, refundTradeNo, refundType);
Integer flag = addOrderRefund(baseOrder.getId(), refundDesc, refundAmount, refundTradeNo, refundType);
//更新订单的退款状态和退款时间
if(SYS_TRUE.equals(flag) && null != refundStatus) {
......@@ -351,10 +356,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
* 记录订单退款记录
* @param orderId
* @param refundDesc
* @param refundAmont
* @param refundAmount
* @param refundTradeNo
*/
private Integer addOrderRefund(Integer orderId, String refundDesc, BigDecimal refundAmont, String refundTradeNo, Integer refundType) {
private Integer addOrderRefund(Integer orderId, String refundDesc, BigDecimal refundAmount, String refundTradeNo, Integer refundType) {
//如果返回的流水为空,则当做失败
Integer refundStatus = SYS_TRUE;
if(StrUtil.isBlank(refundTradeNo)) {
......@@ -368,7 +373,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
setTradeNo(refundTradeNo);
setRefundType(RefundTypeEnum.RentVehicle.getCode());
}};
orderRefund.setRefundAmount(refundAmont);
orderRefund.setRefundAmount(refundAmount);
orderRefund.setRefundDesc(refundDesc);
orderRefund.setRefundStatus(refundStatus);
orderRefund.setRefundType(refundType);
......@@ -415,7 +420,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
setTotalNumber(omd.getRentFreeNum());
}});
log.info("orr.getStatus() : " + orr.getStatus() );
}else if(OrderTypeEnum.RentVehicle.getCode().equals(baseOrder.getType())) {
}else if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId());
......
......@@ -56,7 +56,8 @@ public class WebConfiguration implements WebMvcConfigurer {
"/orderRentVehicle/**",
"/baseOrder/**",
"/orderTour/**",
"/orderMember/**"
"/orderMember/**",
"/orderRefund/**"
};
Collections.addAll(list, urls);
return list;
......
......@@ -61,7 +61,7 @@ public class RentDepositHandler extends IJobHandler {
if(IntervalUtil.staticIsInTheInterval(String.valueOf(i), idLastNumInterval)) {
List<BaseOrder> lists = baseOrderBiz.selectByExample(new Example.Builder(BaseOrder.class)
//订单已完成的租车订单
.where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RentVehicle)
.where(WeekendSqls.<BaseOrder>custom().andEqualTo(BaseOrder::getType, OrderTypeEnum.RENT_VEHICLE)
.andEqualTo(BaseOrder::getStatus, OrderStatusEnum.ORDER_FINISH)
.andLike(BaseOrder::getId, "%"+ String.valueOf(i))).build());
......@@ -89,7 +89,7 @@ public class RentDepositHandler extends IJobHandler {
}else if(RefundStatusEnum.RESIDUE_ILLEGAL.getCode().equals(baseOrder.getRefundStatus())){
//判断是否违章
//扣违章的钱
//baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RentVehicle.getCode(), RefundStatusEnum.RESIDUE_ILLEGAL.getCode());
//baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont, RefundTypeEnum.RENT_VEHICLE.getCode(), RefundStatusEnum.RESIDUE_ILLEGAL.getCode());
}
// baseOrderBiz.refundSubProcess(baseOrder, refundDesc, refundAmont);
}
......
......@@ -25,6 +25,7 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.*;
import com.xxfc.platform.order.pojo.pay.OrderPayDTO;
import com.xxfc.platform.order.rest.common.CommonInterface;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
......@@ -57,7 +58,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
@RequestMapping("baseOrder")
@Api(value = "订单", tags = {"订单"})
@Slf4j
public class BaseOrderController extends CommonBaseController {
public class BaseOrderController extends CommonBaseController implements CommonInterface {
public static final Integer STATUS_SUCCESS = 1;
@Autowired
......@@ -74,6 +75,11 @@ public class BaseOrderController extends CommonBaseController {
@Autowired
OrderMemberDetailBiz orderMemberDetailBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@Value("${gateway.insideHost}")
String insideHost;
......@@ -237,11 +243,9 @@ public class BaseOrderController extends CommonBaseController {
@ResponseBody
public ObjectRestResponse<OrderPageVO> get(@PathVariable String no) {
log.info("no:"+ no + ",时间戳:"+ System.currentTimeMillis());
//查询列表数据
if (StringUtils.isBlank(BaseContextHandler.getUserID())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
checkAppUser();
//查询列表数据
Query query = initQuery(no);
PageDataVO<OrderPageVO> page = PageDataVO.pageInfo(query, () -> baseOrderBiz.pageByParm(query.getSuper()));
if (page.getData().isEmpty()) {
......
package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRefundBiz;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderRefund;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.rest.common.CommonInterface;
import com.xxfc.platform.universal.constant.DictionaryKey;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.math.BigDecimal;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
@Controller
@RequestMapping("orderRefund")
public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRefund> {
public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRefund> implements CommonInterface {
@Autowired
BaseOrderBiz baseOrderBiz;
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@RequestMapping(value = "/price/calculate/{type}/{no}", method = RequestMethod.GET)
@ResponseBody
@IgnoreClientToken
public ObjectRestResponse getOrderParam(@PathVariable(value = "no") String type, @PathVariable(value = "no") String no) {
checkAppUser();
//根据no 查订单
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
setLimit(1);
setPage(1);
}}){{put("no", no); }}.getSuper()).get(0);
OrderRefundPriceVO orp = new OrderRefundPriceVO(){{
setRealAmount(orderPageVO.getRealAmount());
}};
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
switch (orderTypeEnum) {
case RENT_VEHICLE:
// orp.setRefundGoodsAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
// , System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
// , DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
// , "取消订单退款:"));
break;
case TOUR:
String dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_REFUND;
//不是省外,
if(SYS_FALSE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_IN_REFUND;
}
orp.setRefundAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
, System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
, DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
, "取消订单退款:"));
break;
default:
// orp.setRefundAmount(orderPageVO);
break;
}
return null;
}
@Data
public class OrderRefundPriceVO {
BigDecimal refundAmount;
BigDecimal realAmount;
BigDecimal cutAmount;
public void setRefundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
this.cutAmount = realAmount.multiply(refundAmount);
}
}
}
\ No newline at end of file
package com.xxfc.platform.order.rest.common;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import javax.servlet.http.HttpServletRequest;
public interface CommonInterface {
public UserFeign getUserFeign();
public HttpServletRequest getRequest();
default AppUserDTO getAppUser(){
return getUserFeign().userDetailByToken(BaseContextHandler.getToken()).getData();
}
default void checkAppUser(){
if(null == getAppUser()) {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
}
}
......@@ -26,7 +26,6 @@ import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -70,7 +69,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@PostConstruct
public void init(){
this.orderTypeEnum = OrderTypeEnum.RentVehicle;
this.orderTypeEnum = OrderTypeEnum.RENT_VEHICLE;
}
......
......@@ -152,7 +152,10 @@
<if test="no != null">
and no like CONCAT ("%", #{no}, "%")
</if>
<if test="startTime != null">
<if test="startTime != null and status == 4">
and r.start_time between #{startTime} and #{endTime}
</if>
<if test="startTime != null and status == 5">
and r.start_time between #{startTime} and #{endTime}
</if>
<if test="startCompanyId != null">
......
......@@ -72,6 +72,7 @@ public class TourUserController extends TourBaseController<TourUserBiz> {
TourUser tourUser1=new TourUser();
tourUser1.setUserid(userid);
tourUser1.setIdCard(tourUser.getIdCard());
tourUser1.setIsdel(0);
tourUser1=baseBiz.selectOne(tourUser1);
if(tourUser1!=null){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"出游人证件号一样");
......
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