Commit 78862201 authored by 周健威's avatar 周健威

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

parents 992e58c3 d3fbdc7c
...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.common.util.ClientUtil; ...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.common.util.ClientUtil;
import com.github.wxiaoqi.security.common.util.EntityUtils; import com.github.wxiaoqi.security.common.util.EntityUtils;
import com.github.wxiaoqi.security.common.util.IpUtil; import com.github.wxiaoqi.security.common.util.IpUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -217,8 +218,8 @@ public class AuthController { ...@@ -217,8 +218,8 @@ public class AuthController {
} }
@PostMapping("/imi/login") @PostMapping("/imi/login")
public String loginImiWithToken(){ public JSONObject loginImiWithToken(){
return authService.loginImiWithToken(); return JsonResultUtil.createSuccessResultWithObj(authService.loginImiWithToken());
} }
} }
package com.github.wxiaoqi.security.admin.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/18 15:59
*/
@Data
public class PersonalConsumptionDTO {
private Integer userId;
private BigDecimal totalConsumption;
}
...@@ -12,7 +12,7 @@ import lombok.Data; ...@@ -12,7 +12,7 @@ import lombok.Data;
@Data @Data
public class WalletCathFindDTO extends PageParam { public class WalletCathFindDTO extends PageParam {
private String userName; private String username;
private String phone; private String phone;
......
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/18 11:12
*/
@Data
public class WalletDetailFindDTO extends PageParam {
private String username;
private String phone;
private Integer source;
}
...@@ -25,25 +25,28 @@ public class WalletDetailListDTO { ...@@ -25,25 +25,28 @@ public class WalletDetailListDTO {
private String phone; private String phone;
@ApiModelProperty(value = "来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买") @ApiModelProperty(value = "来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买")
private Integer sourceType; private Integer source;
@ApiModelProperty("活动名称或佣金商品名称") @ApiModelProperty("佣金商品名称")
private String source; private String title;
@ApiModelProperty(value = "收入/支出:0-收入,1-支出") @ApiModelProperty("商品价格")
private Integer itype; private BigDecimal price;
@ApiModelProperty(value = "收入/支出的金额(分)") @ApiModelProperty("提成比例")
private BigDecimal amount; private Integer extract;
@ApiModelProperty("入帐状态")
private Integer waiting;
@ApiModelProperty(value = "活动类型") @ApiModelProperty(value = "收入/支出的金额(分)")
private Integer type; private BigDecimal amount;
@ApiModelProperty(value = "活动id") @ApiModelProperty(value = "活动id")
private Integer activityId; private Integer activityId;
@ApiModelProperty(value = "0 收入 1 支出")
private Integer itype;
@ApiModelProperty("活动名称") @ApiModelProperty("活动名称")
private String activityName; private String activityName;
...@@ -52,11 +55,6 @@ public class WalletDetailListDTO { ...@@ -52,11 +55,6 @@ public class WalletDetailListDTO {
@ApiModelProperty(value = "单号") @ApiModelProperty(value = "单号")
private Integer cono; private Integer cono;
@ApiModelProperty(value = "加上当时的收入的余额")
private BigDecimal balance;
@ApiModelProperty(value = "操作时间", hidden = true ) @ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime; private Long crtTime;
......
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/18 10:50
*/
@Data
public class WalletDetailAdminVo {
private Integer id;
private String username;
private String phone;
@ApiModelProperty(value = "来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买")
private Integer source;
@ApiModelProperty("佣金商品名称")
private String title;
@ApiModelProperty("商品价格")
private BigDecimal price;
@ApiModelProperty("提成比例")
private Integer extract;
@ApiModelProperty("入帐状态")
private Integer waiting;
@ApiModelProperty(value = "收入/支出的金额(分)")
private BigDecimal amount;
@ApiModelProperty(value = "0收入 1支出")
private Integer itype;
@ApiModelProperty("活动名称")
private String activityName;
@ApiModelProperty(value = "单号")
private Integer cono;
@ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime;
}
...@@ -30,12 +30,15 @@ public class WalletPageVo { ...@@ -30,12 +30,15 @@ public class WalletPageVo {
@ApiModelProperty(value = "已提现金额") @ApiModelProperty(value = "已提现金额")
private BigDecimal withdrawals; private BigDecimal withdrawals;
@ApiModelProperty(value = "总消费")
private BigDecimal totalConsumption;
@ApiModelProperty(value = "进账总额(元)") @ApiModelProperty(value = "进账总额(元)")
private BigDecimal totalAmount; private BigDecimal totalAmount;
@ApiModelProperty(value = "进账总额(元)") @ApiModelProperty(value = "日收益总额(元)")
private BigDecimal todayAmount; private BigDecimal todayAmount;
......
...@@ -10,14 +10,15 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -10,14 +10,15 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Comparator; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
/** /**
* @author libin * @author libin
...@@ -29,6 +30,8 @@ import java.util.List; ...@@ -29,6 +30,8 @@ import java.util.List;
@Service @Service
public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
@Autowired
private MyWalletDetailBiz myWalletDetailBiz;
public AppletWalletVo findMyWallet(Integer userId) { public AppletWalletVo findMyWallet(Integer userId) {
...@@ -62,6 +65,14 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -62,6 +65,14 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
walletpg.setPhone(wallet.getUsername()); walletpg.setPhone(wallet.getUsername());
walletPageVos.add(walletpg); walletPageVos.add(walletpg);
} }
List<Integer> userIds = wallets.stream().map(WalletListDTO::getUserId).collect(Collectors.toList());
Map<Integer, BigDecimal> userIdAndTotalConsumptionMap = myWalletDetailBiz.finduserIdAndPersonalTotalConsumptionMapByUserIds(userIds);
Optional.ofNullable(userIdAndTotalConsumptionMap).ifPresent(x->{
for (WalletPageVo wtpg : walletPageVos) {
wtpg.setTotalConsumption(x.get(wtpg.getUserId()));
}
});
walletPageVos.sort(Comparator.comparing(WalletPageVo::getTotalAmount).reversed()); walletPageVos.sort(Comparator.comparing(WalletPageVo::getTotalAmount).reversed());
walletPageVo.setPageNum(walletFindDTO.getPage()); walletPageVo.setPageNum(walletFindDTO.getPage());
walletPageVo.setPageSize(walletFindDTO.getLimit()); walletPageVo.setPageSize(walletFindDTO.getLimit());
......
...@@ -87,7 +87,7 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> { ...@@ -87,7 +87,7 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
// List<WalletCathListDTO> walletCathListDTOS = mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUserName(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState()); // List<WalletCathListDTO> walletCathListDTOS = mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUserName(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState());
PageDataVO<WalletCathListDTO> walletCathListDTOPage = PageDataVO.pageInfo(walletCathFindDTO.getPage(), PageDataVO<WalletCathListDTO> walletCathListDTOPage = PageDataVO.pageInfo(walletCathFindDTO.getPage(),
walletCathFindDTO.getLimit(), walletCathFindDTO.getLimit(),
() -> mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUserName(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState())); () -> mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUsername(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState()));
List<WalletCathListDTO> walletCathListDTOList = walletCathListDTOPage.getData(); List<WalletCathListDTO> walletCathListDTOList = walletCathListDTOPage.getData();
if (CollectionUtils.isEmpty(walletCathListDTOList)){ if (CollectionUtils.isEmpty(walletCathListDTOList)){
...@@ -111,4 +111,5 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> { ...@@ -111,4 +111,5 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
return walletCathAdminVoPage; return walletCathAdminVoPage;
} }
} }
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailFindDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailListDTO;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail; import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper; import com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper;
import com.github.wxiaoqi.security.admin.vo.WalletDetailAdminVo;
import com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo; import com.github.wxiaoqi.security.admin.vo.WalletDetailPageVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
...@@ -23,6 +31,7 @@ import java.util.List; ...@@ -23,6 +31,7 @@ import java.util.List;
*/ */
@Transactional @Transactional
@Service @Service
@Data
public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDetail> { public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDetail> {
...@@ -53,4 +62,36 @@ public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDet ...@@ -53,4 +62,36 @@ public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDet
return walletDetailPageVo; return walletDetailPageVo;
} }
public PageDataVO<WalletDetailAdminVo> findWalletDetailPage(WalletDetailFindDTO walletDetailFindDTO){
PageDataVO<WalletDetailAdminVo> pageDataVO = new PageDataVO<>();
PageDataVO<WalletDetailListDTO> walletDetailPage = PageDataVO.pageInfo(walletDetailFindDTO.getPage(),
walletDetailFindDTO.getLimit(),
()->mapper.findWalletDetailsByUserNameOrPhoneOrsourceType(walletDetailFindDTO.getUsername(),walletDetailFindDTO.getPhone(),walletDetailFindDTO.getSource()));
List<WalletDetailListDTO> detailListDTOS = walletDetailPage.getData();
if (CollectionUtils.isEmpty(detailListDTOS)){
return pageDataVO;
}
List<WalletDetailAdminVo> walletDetailAdminVos = new ArrayList<>();
WalletDetailAdminVo walletDetailAdminVo;
for (WalletDetailListDTO detailListDTO : detailListDTOS) {
walletDetailAdminVo = new WalletDetailAdminVo();
BeanUtils.copyProperties(detailListDTO,walletDetailAdminVo);
walletDetailAdminVos.add(walletDetailAdminVo);
}
pageDataVO.setPageNum(walletDetailFindDTO.getPage());
pageDataVO.setPageSize(walletDetailFindDTO.getLimit());
pageDataVO.setTotalCount(walletDetailPage.getTotalCount());
pageDataVO.setTotalPage(walletDetailPage.getTotalPage());
pageDataVO.setData(walletDetailAdminVos);
return pageDataVO;
}
public Map<Integer, BigDecimal> finduserIdAndPersonalTotalConsumptionMapByUserIds(List<Integer> userIds) {
List<PersonalConsumptionDTO> personalConsumptions = mapper.findpersonalConsumptionsByUserIds(userIds);
Map<Integer, BigDecimal> userIdAndPersonalConsumptionMap = personalConsumptions.stream().collect(Collectors.toMap(PersonalConsumptionDTO::getUserId, PersonalConsumptionDTO::getTotalConsumption));
return userIdAndPersonalConsumptionMap;
}
} }
...@@ -19,4 +19,5 @@ public interface MyWalletCathMapper extends Mapper<MyWalletCath> { ...@@ -19,4 +19,5 @@ public interface MyWalletCathMapper extends Mapper<MyWalletCath> {
List<WalletCathListDTO> selectByUserNameOrPhoneOrWithDrawSate(@Param("userName") String userName, List<WalletCathListDTO> selectByUserNameOrPhoneOrWithDrawSate(@Param("userName") String userName,
@Param("phone") String phone, @Param("phone") String phone,
@Param("state") Integer state); @Param("state") Integer state);
} }
package com.github.wxiaoqi.security.admin.mapper; package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletDetailListDTO;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail; import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** /**
* 收入/支持明细表,每笔的进账,出账的详细记录 * 收入/支持明细表,每笔的进账,出账的详细记录
* *
...@@ -11,5 +16,8 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -11,5 +16,8 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-07-11 14:14:54 * @date 2019-07-11 14:14:54
*/ */
public interface MyWalletDetailMapper extends Mapper<MyWalletDetail> { public interface MyWalletDetailMapper extends Mapper<MyWalletDetail> {
List<WalletDetailListDTO> findWalletDetailsByUserNameOrPhoneOrsourceType(@Param("userName") String userName, @Param("phone") String phone, @Param("sourceType") Integer sourceType);
List<PersonalConsumptionDTO> findpersonalConsumptionsByUserIds(@Param("userIds") List<Integer> userIds);
} }
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.MyWalletDetailBiz;
import com.github.wxiaoqi.security.admin.dto.WalletDetailFindDTO;
import com.github.wxiaoqi.security.admin.vo.WalletDetailAdminVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/18 13:30
*/
@RestController
@RequestMapping("/walletdetail/admin")
public class WalletDetailAdminController {
@Autowired
private MyWalletDetailBiz myWalletDetailBiz;
@GetMapping("/page")
public ObjectRestResponse<PageDataVO<WalletDetailAdminVo>> findWalletDetailPage(WalletDetailFindDTO walletDetailFindDTO){
PageDataVO<WalletDetailAdminVo> walletDetailPage = myWalletDetailBiz.findWalletDetailPage(walletDetailFindDTO);
return ObjectRestResponse.succ(walletDetailPage);
}
}
...@@ -730,7 +730,7 @@ public class AppPermissionService { ...@@ -730,7 +730,7 @@ public class AppPermissionService {
public String loginImiWithUserId(Integer userId){ public String loginImiWithUserId(Integer userId){
AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId); AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId);
String token = loginIm(appUserLogin.getUsername(), appUserLogin.getImPassword(), userId); String token = loginIm(appUserLogin.getUsername(), appUserLogin.getImPassword(), appUserLogin.getImUserid());
return token; return token;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper"> <mapper namespace="com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper">
<select id="selectByUserNameOrPhoneOrWithDrawSate" resultType="com.github.wxiaoqi.security.admin.dto.WalletListDTO"> <select id="selectByUserNameOrPhoneOrWithDrawSate" resultType="com.github.wxiaoqi.security.admin.dto.WalletCathListDTO">
SELECT SELECT
wc.id, wc.id,
aud.nickname, aud.nickname,
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
</if>) AS `wc` </if>) AS `wc`
INNER JOIN ( SELECT `id`, `username` FROM `app_user_login` <if test="phone != null and phone != ''"> INNER JOIN ( SELECT `id`, `username` FROM `app_user_login` <if test="phone != null and phone != ''">
WHERE `username`=#{phone} WHERE `username`=#{phone}
</if> ) AS `aul` ON aul.id = w.user_id </if> ) AS `aul` ON aul.id = wc.user_id
INNER JOIN ( SELECT `userid`, `nickname`, `realname` FROM `app_user_detail` <if INNER JOIN ( SELECT `userid`, `nickname`, `realname` FROM `app_user_detail` <if
test="userName != null and userName != ''"> test="userName != null and userName != ''">
WHERE nickname =#{username} OR realname =#{userName} WHERE nickname =#{userName} OR realname =#{userName}
</if> ) AS `aud` ON aud.userid = aul.id </if> ) AS `aud` ON aud.userid = aul.id
</select> </select>
</mapper> </mapper>
\ No newline at end of file
<?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.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper">
<select id="findWalletDetailsByUserNameOrPhoneOrsourceType" resultType="com.github.wxiaoqi.security.admin.dto.WalletDetailListDTO">
SELECT
wd.id,
wd.source,
wd.amount,
wd.cono,
wd.itype,
wd.activity_id AS `activityId`,
wd.activity_name AS `activityName`,
aul.username,
aud.nickname,
aud.realname,
ausw.price,
ausw.extract,
ausw.waiting,
ausw.title
FROM
(select id,user_id,source,amount,cono,itype,activity_id,activity_name FROM `my_wallet_detail` <if test="sourceType != null">
WHERE `source`=#{sourceType}
</if>) AS `wd`
LEFT JOIN (SELECT id,username FROM `app_user_login`<if test="phone != null and phone != ''">
WHERE `username`=#{phone}
</if>) AS `aul` ON aul.id = wd.user_id
LEFT JOIN (SELECT userid,nickname,realname FROM `app_user_detail`<if test="userName != null and userName != ''">
WHERE `nickname`=#{userName} OR `realname`=#{userName}
</if>) AS `aud` ON aud.userid = aul.id
LEFT JOIN (SELECT DISTINCT order_id,id,price,extract,waiting,title FROM `app_user_selling_water`) AS `ausw` ON ausw.order_id = wd.cono
</select>
<select id="findpersonalConsumptionsByUserIds" resultType="com.github.wxiaoqi.security.admin.dto.PersonalConsumptionDTO">
select `user_id` AS `userId`,SUM(amount) AS `totalConsumption` FROM my_wallet_cath <if test="userIds != null and userIds.size() != 0">
WHERE `user_id` IN
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>GROUP BY user_id;
</select>
</mapper>
\ No newline at end of file
...@@ -33,10 +33,10 @@ public interface ActivityFeign { ...@@ -33,10 +33,10 @@ public interface ActivityFeign {
@RequestMapping(value = "/user/use", method = RequestMethod.POST) @RequestMapping(value = "/user/use", method = RequestMethod.POST)
public BigDecimal use( public BigDecimal use(
@RequestParam(value = "userId") Integer userId, @RequestParam(value = "userId") Integer userId,
@RequestParam(value = "TickerNo") String TickerNo, @RequestParam(value = "tickerNo") String tickerNo,
@RequestParam(value = "orderNo") String orderNo, @RequestParam(value = "orderNo") String orderNo,
@RequestParam(value = "channel") Integer channel, @RequestParam(value = "channel") Integer channel,
@RequestParam(value = "amout") BigDecimal amout, @RequestParam(value = "amount") BigDecimal amount,
@RequestParam(value = "type") Integer type); @RequestParam(value = "type") Integer type);
@ApiOperation("优惠卷取消使用") @ApiOperation("优惠卷取消使用")
......
...@@ -109,15 +109,33 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -109,15 +109,33 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
} }
//获取我的优惠卷 //获取我的优惠卷
public ObjectRestResponse getCouponList(Integer userId,int type){ public ObjectRestResponse getCouponList(Integer userId,int type,Integer channel,BigDecimal amout){
if (userId==null||userId==0){ if (userId==null||userId==0){
log.error("----参数不能为空"); log.error("----参数不能为空");
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
} }
Long time=System.currentTimeMillis(); Long time=System.currentTimeMillis();
return ObjectRestResponse.succ(mapper.getUserCouponsByType(userId,type,time)); List<UserCouponVo> list=mapper.getUserCouponsByType(userId,type,time,channel);
if(amout.compareTo(new BigDecimal("0.00"))>0&&list.size()>0){
for (UserCouponVo couponVo:list){
Integer status=2;
if(amout.compareTo(couponVo.getUsedAmount())>=0){
if(couponVo.getChannel()==1){
if (amout.compareTo(couponVo.getWithAmount())>=0){
status=1;
}
}else if (couponVo.getChannel()==3){
status=1;
}
}
couponVo.setStatus(status);
}
}
return ObjectRestResponse.succ(list);
} }
//获取单个优惠卷 //获取单个优惠卷
public UserCouponVo getUserCoupon(String tickerNo){ public UserCouponVo getUserCoupon(String tickerNo){
if (StringUtils.isBlank(tickerNo)){ if (StringUtils.isBlank(tickerNo)){
...@@ -135,14 +153,18 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -135,14 +153,18 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return couponAmout; return couponAmout;
} }
Example example=new Example(UserCoupon.class); Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("TickerNo",TickerNo).andEqualTo("isDel",0); example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example); List<UserCoupon> list=selectByExample(example);
if(list.size()==0){ if(list.size()==0){
log.error(userId+"----已领优惠卷"); log.error(userId+"----没有可用优惠卷--TickerNo==="+TickerNo);
return couponAmout; return couponAmout;
} }
UserCoupon userCoupon=list.get(0); UserCoupon userCoupon=list.get(0);
if(userCoupon!=null&&userCoupon.getIsUse()==1){
log.error(userId+"----该优惠卷已使用--TickerNo=="+TickerNo);
return couponAmout;
}
if (type==1){ if (type==1){
userCoupon.setIsUse(1); userCoupon.setIsUse(1);
userCoupon.setOrderNo(orderNo); userCoupon.setOrderNo(orderNo);
...@@ -163,7 +185,8 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -163,7 +185,8 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
BigDecimal useAmout = coupon.getUsedAmount(); BigDecimal useAmout = coupon.getUsedAmount();
if (amout.compareTo(useAmout) > 0) { if (amout.compareTo(useAmout) > 0) {
if (type == 3 || (type == 1 && (amout.compareTo(coupon.getWithAmount()) >= 0))) { if (type == 3 || (type == 1 && (amout.compareTo(coupon.getWithAmount()) >= 0))) {
couponAmout = amout.subtract(useAmout); //couponAmout = amout.subtract(useAmout);
couponAmout=useAmout;
} }
} }
} }
......
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
public interface UserCouponMapper extends Mapper<UserCoupon> { public interface UserCouponMapper extends Mapper<UserCoupon> {
//我的优惠卷 //我的优惠卷
public List<UserCouponVo> getUserCouponsByType(@Param("userId")Integer userId,@Param("type")int type,@Param("time")Long time); public List<UserCouponVo> getUserCouponsByType(@Param("userId")Integer userId,@Param("type")int type,@Param("time")Long time,@Param("channel")Integer channel);
//单个优惠卷 //单个优惠卷
public UserCouponVo getUserCoupon(@Param("tickerNo")String tickerNo); public UserCouponVo getUserCoupon(@Param("tickerNo")String tickerNo);
......
...@@ -27,15 +27,23 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz> ...@@ -27,15 +27,23 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
return baseBiz.authledCoupon(userId); return baseBiz.authledCoupon(userId);
} }
/**
*
* @param type 0-未使用;1-已使用;3-已过期
* @param channel 1-租车;2-旅游;null-全部
* @return
*/
@ApiOperation("我的优惠卷") @ApiOperation("我的优惠卷")
@RequestMapping(value = "/list/{type}", method = RequestMethod.GET) @RequestMapping(value = "/coupon/list", method = RequestMethod.GET)
public ObjectRestResponse list(@PathVariable Integer type) { public ObjectRestResponse list(@RequestParam(value = "type",defaultValue = "0") Integer type,
@RequestParam(value = "channel") Integer channel,
@RequestParam(value = "amount",defaultValue = "0.00") BigDecimal amount) {
AppUserDTO userInfo = getUserInfo(); AppUserDTO userInfo = getUserInfo();
Integer userId = userInfo.getUserid(); Integer userId = userInfo.getUserid();
if(userId==null){ if(userId==null){
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
return baseBiz.getCouponList(userId,type); return baseBiz.getCouponList(userId,type,channel,amount);
} }
@ApiOperation("单个优惠卷信息") @ApiOperation("单个优惠卷信息")
...@@ -49,13 +57,13 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz> ...@@ -49,13 +57,13 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
@RequestMapping(value = "/use", method = RequestMethod.POST) @RequestMapping(value = "/use", method = RequestMethod.POST)
public BigDecimal use( public BigDecimal use(
@RequestParam(value = "userId",defaultValue ="0" ) Integer userId, @RequestParam(value = "userId",defaultValue ="0" ) Integer userId,
@RequestParam(value = "TickerNo",defaultValue ="" ) String TickerNo, @RequestParam(value = "tickerNo",defaultValue ="" ) String tickerNo,
@RequestParam(value = "orderNo",defaultValue ="" ) String orderNo, @RequestParam(value = "orderNo",defaultValue ="" ) String orderNo,
@RequestParam(value = "channel",defaultValue ="1" ) Integer channel, @RequestParam(value = "channel",defaultValue ="1" ) Integer channel,
@RequestParam(value = "amout",defaultValue ="0.00" ) BigDecimal amout, @RequestParam(value = "amount",defaultValue ="0.00" ) BigDecimal amount,
@RequestParam(value = "type",defaultValue ="1" ) Integer type @RequestParam(value = "type",defaultValue ="1" ) Integer type
) { ) {
return baseBiz.useTickerNo(userId,TickerNo,orderNo,channel,amout,type); return baseBiz.useTickerNo(userId,tickerNo,orderNo,channel,amount,type);
} }
@ApiOperation("优惠卷取消使用") @ApiOperation("优惠卷取消使用")
...@@ -80,4 +88,6 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz> ...@@ -80,4 +88,6 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
} }
\ No newline at end of file
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
<if test="type==2"> <if test="type==2">
and u.is_use=0 and u.expire_time &lt;#{time} and u.is_use=0 and u.expire_time &lt;#{time}
</if> </if>
<if test="channel!=null and channel!=''">
and (c.channel=#{channel} or c.channel=1 )
</if>
<choose> <choose>
<when test="type==1"> <when test="type==1">
ORDER BY u.use_time DESC ORDER BY u.use_time DESC
......
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