账户门店
This commit is contained in:
@ -37,7 +37,7 @@ public class CardApiImpl implements CardApi{
|
||||
giftMoney = giftMoney.add(recharge.getDonateMoney());
|
||||
}
|
||||
|
||||
wxRechargeService.wxRecharge(money, money.subtract(giftMoney),giftMoney,userId);
|
||||
wxRechargeService.wxRecharge(money.add(giftMoney), money,giftMoney,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,8 +111,8 @@ public class CardController {
|
||||
|
||||
@GetMapping("/getMoney")
|
||||
@Operation(summary = "获取余额")
|
||||
public CommonResult<BigDecimal> getMoney() {
|
||||
return success(cardService.getMoney());
|
||||
public CommonResult<BigDecimal> getMoney(Long carteenId) {
|
||||
return success(cardService.getMoney(carteenId));
|
||||
}
|
||||
|
||||
@PutMapping("/rechargeByAdmin")
|
||||
@ -125,14 +125,14 @@ public class CardController {
|
||||
|
||||
@GetMapping("/getCashMoney")
|
||||
@Operation(summary = "获取现金充值")
|
||||
public CommonResult<BigDecimal> getCashMoney(Long userId) {
|
||||
return success(cardService.getCashMoney(userId));
|
||||
public CommonResult<BigDecimal> getCashMoney(Long userId,Long carteenId) {
|
||||
return success(cardService.getCashMoney(userId,carteenId));
|
||||
}
|
||||
|
||||
@GetMapping("/cashDraw")
|
||||
@Operation(summary = "现金提现")
|
||||
public CommonResult<Boolean> cashDraw(Long userId,BigDecimal money) {
|
||||
return success(cardService.cashDraw(userId,money));
|
||||
public CommonResult<Boolean> cashDraw(Long userId,BigDecimal money,Long carteenId) {
|
||||
return success(cardService.cashDraw(userId,money,carteenId));
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,4 +34,7 @@ public class CardPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "门店", example = "23469")
|
||||
private Long carteenId;
|
||||
|
||||
}
|
@ -39,4 +39,16 @@ public class CardRespVO {
|
||||
|
||||
@Schema(description = "消费类型")
|
||||
private String type;
|
||||
|
||||
private Long carteenId;
|
||||
|
||||
/**
|
||||
* 现金金额
|
||||
*/
|
||||
private BigDecimal cashAmount;
|
||||
|
||||
/**
|
||||
* 微信充值金额
|
||||
*/
|
||||
private BigDecimal wxAmount;
|
||||
}
|
@ -15,5 +15,5 @@ public class RechargeVO {
|
||||
private List<Long> userIds;
|
||||
private Long groupId;
|
||||
private BigDecimal money;
|
||||
|
||||
private Long carteenId;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class ExcelImportController {
|
||||
private CashRechargeService cashRechargeService;
|
||||
|
||||
@PostMapping("/easyExcelImport")
|
||||
public void importExcel(MultipartFile file, HttpServletResponse response) {
|
||||
public void importExcel(MultipartFile file, HttpServletResponse response,Long storeId) {
|
||||
if (!file.isEmpty()) {
|
||||
//文件名称
|
||||
int begin = Objects.requireNonNull(file.getOriginalFilename()).indexOf(".");
|
||||
@ -52,7 +52,7 @@ public class ExcelImportController {
|
||||
throw new IllegalArgumentException("文件不能为空");
|
||||
}
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
List<RechargeExcel> rechargeExcels = simpleRead(inputStream);
|
||||
List<RechargeExcel> rechargeExcels = simpleRead(inputStream,storeId);
|
||||
ExcelUtils.write(response, "人员不存在.xlsx", "数据", RechargeExcel.class,
|
||||
rechargeExcels);
|
||||
} catch (IOException e) {
|
||||
@ -63,7 +63,7 @@ public class ExcelImportController {
|
||||
/**
|
||||
* 最简单的读的监听器
|
||||
*/
|
||||
public List<RechargeExcel> simpleRead(InputStream inputStream) {
|
||||
public List<RechargeExcel> simpleRead(InputStream inputStream,Long storeId) {
|
||||
//获取正确数据
|
||||
ArrayList<RechargeExcel> successArrayList = new ArrayList<>();
|
||||
EasyExcel.read(inputStream)
|
||||
@ -89,7 +89,7 @@ public class ExcelImportController {
|
||||
}
|
||||
List<Long> ids = new ArrayList<>();
|
||||
ids.add(userByMobile.getId());
|
||||
cashRechargeService.rechargeByAdmin(ids,null,excel.getMoney());
|
||||
cashRechargeService.rechargeByAdmin(ids,null,excel.getMoney(),storeId);
|
||||
}
|
||||
return notExist;
|
||||
}
|
||||
|
@ -23,4 +23,6 @@ public class MemberGroupPageVO extends PageParam {
|
||||
private Integer limitOne;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private Long carteenId;
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ public class OrderController {
|
||||
@GetMapping("/user/money")
|
||||
@Operation(summary = "根据会员编号,获得会员余额,充值金额,消费金额")
|
||||
@PreAuthorize("@ss.hasPermission('member:order:query')")
|
||||
public CommonResult<OrderMoneyRespVO> getUserMeney(@RequestParam("userId")Long userId){
|
||||
return CommonResult.success(orderService.getUserMeney(userId));
|
||||
public CommonResult<OrderMoneyRespVO> getUserMeney(Long userId,Long carteenId){
|
||||
return CommonResult.success(orderService.getUserMeney(userId,carteenId));
|
||||
}
|
||||
|
||||
@GetMapping("/reduction")
|
||||
|
@ -14,10 +14,20 @@ import java.math.BigDecimal;
|
||||
public class OrderMoneyRespVO {
|
||||
//会员编号
|
||||
private Long userId;
|
||||
//当前余额
|
||||
//当前微信余额
|
||||
private BigDecimal currentMoney;
|
||||
//充值金额
|
||||
//现金充值金额
|
||||
private BigDecimal rechargeMoney;
|
||||
//消费金额
|
||||
private BigDecimal consumeMoney;
|
||||
|
||||
//当前现金余额
|
||||
private BigDecimal cashMoney;
|
||||
|
||||
//微信充值
|
||||
private BigDecimal wxRechargeMoney;
|
||||
|
||||
//欠款
|
||||
private BigDecimal debtMoney;
|
||||
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class AppCardController {
|
||||
|
||||
@GetMapping("/getMoney")
|
||||
@Operation(summary = "获取余额")
|
||||
public CommonResult<BigDecimal> getMoney() {
|
||||
return success(cardService.getMoney());
|
||||
public CommonResult<BigDecimal> getMoney(Long carteenId) {
|
||||
return success(cardService.getMoney(carteenId));
|
||||
}
|
||||
|
||||
@GetMapping("/month")
|
||||
|
@ -1,15 +1,19 @@
|
||||
package cn.iocoder.yudao.module.member.controller.app.user;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.*;
|
||||
import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.userexpand.UserExpandDO;
|
||||
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.member.service.userexpand.UserExpandService;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import cn.iocoder.yudao.module.system.api.dishesnutrition.dto.DishesNutritionRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -19,7 +23,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -40,16 +46,34 @@ public class AppMemberUserController {
|
||||
private MemberLevelService levelService;
|
||||
@Resource
|
||||
private UserExpandService userExpandService;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private DeviceInfoApi deviceInfoApi;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得基本信息")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppMemberUserInfoRespVO> getUserInfo() {
|
||||
public CommonResult<AppMemberUserInfoRespVO> getUserInfo(Long carteenId) {
|
||||
MemberUserDO user = userService.getUser(getLoginUserId());
|
||||
MemberLevelDO level = levelService.getLevel(user.getLevelId());
|
||||
UserExpandDO userExpandByuserId = userExpandService.getUserExpandByuserId(getLoginUserId());
|
||||
AppMemberUserInfoRespVO convert = MemberUserConvert.INSTANCE.convert(user, level);
|
||||
convert.setUserExpandDO(userExpandByuserId);
|
||||
if(carteenId!=null){
|
||||
MoneyDO moneyDO = moneyService.getMoney(user.getId(), carteenId);
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
convert.setCashAmount(moneyDO.getCashAmount());
|
||||
convert.setDebtAmount(moneyDO.getDebtAmount());
|
||||
}else {
|
||||
convert.setCashAmount(BigDecimal.ZERO);
|
||||
convert.setDebtAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
}
|
||||
return success(convert);
|
||||
}
|
||||
|
||||
@ -147,9 +171,11 @@ public class AppMemberUserController {
|
||||
}
|
||||
|
||||
@GetMapping("/getInfoByCardOrFace")
|
||||
@Operation(summary = "获取用户绑定的卡号")
|
||||
@Operation(summary = "获取用户信息")
|
||||
public CommonResult<Map<String,Object>> getInfoByCard(String cardId,Long mobile){
|
||||
return success(userService.getInfoByCard(cardId,mobile));
|
||||
String authorization = httpServletRequest.getHeader("Authorization");
|
||||
Long carteen = deviceInfoApi.getCarteen(authorization);
|
||||
return success(userService.getInfoByCard(cardId,mobile,carteen));
|
||||
}
|
||||
|
||||
@GetMapping("/getQRCode")
|
||||
@ -157,5 +183,6 @@ public class AppMemberUserController {
|
||||
public CommonResult<String> getQRCode(){
|
||||
return success(userService.getQRCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,4 +85,9 @@ public class AppMemberUserInfoRespVO {
|
||||
*/
|
||||
private BigDecimal wxAmount;
|
||||
|
||||
/**
|
||||
* 欠款
|
||||
*/
|
||||
private BigDecimal debtAmount;
|
||||
|
||||
}
|
||||
|
@ -80,4 +80,8 @@ public class CardDO extends BaseDO {
|
||||
* 开票编号
|
||||
*/
|
||||
private String billingNum;
|
||||
/**
|
||||
* 门店
|
||||
*/
|
||||
private Long carteenId;
|
||||
}
|
@ -45,6 +45,7 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
||||
.eqIfPresent(CardDO::getFlag, reqVO.getFlag())
|
||||
.eqIfPresent(CardDO::getChangeMoney, reqVO.getChangeMoney())
|
||||
.betweenIfPresent(CardDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(CardDO::getCarteenId,reqVO.getCarteenId())
|
||||
.orderByDesc(CardDO::getId));
|
||||
}
|
||||
|
||||
@ -60,9 +61,10 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
||||
|
||||
@Select("select IFNULL(sum(change_money),0) as money,count(*) as count FROM member_card where user_id = #{userId} and flag = #{flag} and create_time BETWEEN #{startTime} and #{endTime}")
|
||||
AppCardMonthVO selectMonth(@Param("userId") Long userId,@Param("flag") String flag, @Param("startTime") LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
|
||||
@Select("select SUM(change_money) from member_card where user_id= #{userId} and flag= #{flag}")
|
||||
BigDecimal selectAddMoney(@Param("userId") Long userId,@Param("flag") String flag);
|
||||
|
||||
@Select("select SUM(change_money) from member_card where user_id= #{userId} and flag= #{flag} and carteen_id = #{carteenId}")
|
||||
BigDecimal selectAddMoney(@Param("userId") Long userId,@Param("flag") String flag,@Param("carteenId") Long carteenId);
|
||||
@Select("select sum(change_money) from member_card where user_id= #{userId} and type= '1'")
|
||||
BigDecimal selectWxMoney(@Param("userId") Long userId);
|
||||
|
||||
List<CardDO> selectMoneyList(List<Long> list);
|
||||
|
||||
|
@ -60,4 +60,6 @@ public interface MemberGroupMapper extends BaseMapperX<MemberGroupDO> {
|
||||
|
||||
@Delete("delete from member_group_member where group_id = #{groupId}")
|
||||
void deleteAssociation(Long groupId);
|
||||
|
||||
Long getCarteenId(Long userId);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public interface AmountService {
|
||||
|
||||
void operateAmount(Long userId, BigDecimal money, BigDecimal cashAmount, BigDecimal giftAmount, BigDecimal wxAmount);
|
||||
|
||||
BigDecimal getAmount(Long userId);
|
||||
BigDecimal getAmount(Long userId,Long storeId);
|
||||
|
||||
BigDecimal getCashAmount(Long userId);
|
||||
BigDecimal getCashAmount(Long userId,Long storeId);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.rechargelog.RechargeLogDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.appup.AppUpService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@ -44,7 +46,8 @@ public class AmountServiceImpl implements AmountService {
|
||||
|
||||
@Resource
|
||||
private MemberUserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
|
||||
@Override
|
||||
public void operateAmount(Long userId, BigDecimal money, BigDecimal cashAmount, BigDecimal giftAmount, BigDecimal wxAmount) {
|
||||
@ -61,20 +64,27 @@ public class AmountServiceImpl implements AmountService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getAmount(Long userId) {
|
||||
public BigDecimal getAmount(Long userId,Long storeId) {
|
||||
MemberUserDO memberUserDO = userMapper.selectById(userId);
|
||||
if (memberUserDO == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
return memberUserDO.getMoney();
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
|
||||
if (moneyDO != null) {
|
||||
cashAmount = moneyDO.getCashAmount();
|
||||
}
|
||||
|
||||
return memberUserDO.getWxAmount().add(cashAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCashAmount(Long userId) {
|
||||
MemberUserDO memberUserDO = userMapper.selectById(userId);
|
||||
if (memberUserDO == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
public BigDecimal getCashAmount(Long userId,Long storeId) {
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
if (moneyDO == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return memberUserDO.getCashAmount();
|
||||
return moneyDO.getCashAmount();
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ import java.util.List;
|
||||
public interface CashRechargeService {
|
||||
|
||||
|
||||
void rechargeByAdmin(List<Long> userIds, Long groupId, BigDecimal money);
|
||||
void rechargeByAdmin(List<Long> userIds, Long groupId, BigDecimal money,Long storeId);
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.member.service.amount;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.math.Money;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
@ -14,6 +17,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@ -47,13 +51,15 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
private IntegralRefundMapper refundMapper;
|
||||
@Resource
|
||||
private MemberGroupMapper memberGroupMapper;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate cashRechargeRedisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
public void rechargeByAdmin(List<Long> userIds, Long groupId, BigDecimal money) {
|
||||
public void rechargeByAdmin(List<Long> userIds, Long groupId, BigDecimal money, Long storeId) {
|
||||
List<Long> memberList = new ArrayList<>();
|
||||
if (groupId != null) {
|
||||
memberList.addAll(memberGroupMapper.getMemberList(groupId));
|
||||
@ -65,7 +71,6 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
|
||||
for (Long userId : memberList) {
|
||||
|
||||
BigDecimal newMoney;
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewAmount;
|
||||
@ -73,24 +78,28 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO memberUserDO = userMapper.selectById(userId);
|
||||
//金额变动
|
||||
BigDecimal oldMoney = memberUserDO.getMoney();
|
||||
System.out.println(oldMoney);
|
||||
memberUserDO.setMoney(memberUserDO.getMoney().add(money));
|
||||
if (memberUserDO.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (oldMoney.compareTo(BigDecimal.ZERO) > 0) {
|
||||
memberUserDO.setCashAmount(memberUserDO.getCashAmount().add(money));
|
||||
} else {
|
||||
memberUserDO.setCashAmount(memberUserDO.getMoney());
|
||||
}
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
BigDecimal debtAmount = BigDecimal.ZERO;
|
||||
if (ObjectUtil.isEmpty(moneyDO)) {
|
||||
MoneyDO add = new MoneyDO();
|
||||
add.setCashAmount(money);
|
||||
add.setDebtAmount(debtAmount);
|
||||
add.setUserId(userId);
|
||||
add.setCarteenId(storeId);
|
||||
moneyService.insertOne(add);
|
||||
cashNewAmount = add.getCashAmount();
|
||||
} else {
|
||||
debtAmount = moneyDO.getDebtAmount();
|
||||
//金额变动
|
||||
money = money.add(debtAmount);
|
||||
moneyDO.setCashAmount(money.add(moneyDO.getCashAmount()));
|
||||
moneyDO.setDebtAmount(BigDecimal.ZERO);
|
||||
cashNewAmount = moneyDO.getCashAmount();
|
||||
moneyService.updateById(moneyDO);
|
||||
}
|
||||
userMapper.updateById(memberUserDO);
|
||||
|
||||
newMoney = memberUserDO.getMoney();
|
||||
wxNewMoney = memberUserDO.getWxAmount();
|
||||
giftNewMoney = memberUserDO.getGiftAmount();
|
||||
cashNewAmount = memberUserDO.getCashAmount();
|
||||
name = memberUserDO.getNickname();
|
||||
}
|
||||
|
||||
@ -100,30 +109,30 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
add.setFlag(CardDO.ADD);
|
||||
add.setChangeMoney(money);
|
||||
add.setType(CostTypeEnum.ADMIN_PAY.getCode());
|
||||
add.setMoney(newMoney);
|
||||
add.setCashAmount(cashNewAmount);
|
||||
add.setWxAmount(wxNewMoney);
|
||||
add.setGiftAmount(giftNewMoney);
|
||||
add.setCarteenId(storeId);
|
||||
addList.add(add);
|
||||
|
||||
//更新缓存
|
||||
String redisKey = "USER_" + userId;
|
||||
AppUserInfoCardVO appUserInfoCardVO = new AppUserInfoCardVO();
|
||||
appUserInfoCardVO.setName(name);
|
||||
appUserInfoCardVO.setMoney(newMoney);
|
||||
appUserInfoCardVO.setMoney(wxNewMoney);
|
||||
cashRechargeRedisTemplate.opsForValue().set(redisKey, JSONUtil.toJsonStr(appUserInfoCardVO));
|
||||
|
||||
}
|
||||
|
||||
//处理订单
|
||||
handleOrderCash(memberList, money);
|
||||
handleOrderCash(memberList, money, storeId);
|
||||
|
||||
//批量添加
|
||||
cardMapper.insertBatch(addList);
|
||||
}
|
||||
|
||||
|
||||
void handleOrderCash(List<Long> userIds, BigDecimal money) {
|
||||
void handleOrderCash(List<Long> userIds, BigDecimal money, Long storeId) {
|
||||
ArrayList<DishOrderDO> updateList = new ArrayList<>();
|
||||
List<Long> refundOrder = getRefundOrder();
|
||||
//查询出所有未完全支付订单
|
||||
@ -131,7 +140,8 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
BigDecimal cashMoney = money;
|
||||
|
||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(Wrappers.<DishOrderDO>lambdaQuery()
|
||||
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE));
|
||||
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE)
|
||||
.eq(DishOrderDO::getStoreId, storeId));
|
||||
|
||||
if (CollectionUtil.isNotEmpty(dishOrderDOS)) {
|
||||
for (DishOrderDO dishOrderDO : dishOrderDOS) {
|
||||
|
@ -14,7 +14,7 @@ public interface DeductionService {
|
||||
/**
|
||||
* 现金提现
|
||||
*/
|
||||
void cashDraw(Long userId, BigDecimal money,String type);
|
||||
void cashDraw(Long userId, BigDecimal money,String type,Long storeId);
|
||||
|
||||
/**
|
||||
* 微信提现 金额单位:分
|
||||
@ -29,19 +29,17 @@ public interface DeductionService {
|
||||
/**
|
||||
* 减免、退款
|
||||
*/
|
||||
void reduction(Long userId, BigDecimal money, BigDecimal giftAmount, BigDecimal cashAmount, BigDecimal wxAmount);
|
||||
void reduction(Long userId, BigDecimal money, BigDecimal giftAmount, BigDecimal cashAmount, BigDecimal wxAmount,Long storeId);
|
||||
|
||||
/**
|
||||
* 超市扣款
|
||||
*/
|
||||
BigDecimal storeDeduction(BigDecimal total, Long userId);
|
||||
BigDecimal storeDeduction(BigDecimal total, Long userId,Long storeId);
|
||||
|
||||
/**
|
||||
* 扣款
|
||||
*/
|
||||
void deduct(Long userId, BigDecimal money,String type);
|
||||
|
||||
|
||||
void deduct(Long userId, BigDecimal money,String type,Long storeId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,15 @@ import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import com.sun.istack.NotNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -49,6 +52,9 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
private MemberUserService userService;
|
||||
@Resource
|
||||
private BusinessService businessService;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
|
||||
|
||||
private static final List<String> CHECK_LIST = Arrays.asList(CostTypeEnum.SHOPPING.getCode());
|
||||
|
||||
@ -56,7 +62,6 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
public void deduction(DishOrderDO dishOrderDO) {
|
||||
Long userId = dishOrderDO.getUserId();
|
||||
|
||||
BigDecimal newMoney;
|
||||
BigDecimal changeMoney;
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
@ -66,12 +71,12 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(dishOrderDO.getUserId(), dishOrderDO.getStoreId());
|
||||
//新的总价
|
||||
String s = deductionRedisTemplate.opsForValue().get(dishOrderDO.getDiningPlatesNum() + "-" + dishOrderDO.getStoreId());
|
||||
BigDecimal total = new BigDecimal(StrUtil.isBlank(s) ? "0" : s);
|
||||
//现有金额
|
||||
BigDecimal money = user.getMoney();
|
||||
//BigDecimal money = user.getMoney();
|
||||
//计算减免价格
|
||||
BigDecimal reductionAmount = BigDecimal.ZERO;
|
||||
if (total.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@ -90,13 +95,13 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
} else {
|
||||
total = total.subtract(reductionAmount);
|
||||
}
|
||||
|
||||
//当前金额
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
BigDecimal giftAmount = user.getGiftAmount();
|
||||
BigDecimal cashAmount = user.getCashAmount();
|
||||
|
||||
user.setMoney(money.subtract(total));
|
||||
BigDecimal cashAmount = moneyDO.getCashAmount();
|
||||
|
||||
BigDecimal money = wxAmount.add(giftAmount).add(cashAmount);
|
||||
// user.setMoney(money.subtract(total));
|
||||
//待支付金额 最大退款金额
|
||||
dishOrderDO.setRefundAmount(total);
|
||||
if (money.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
@ -116,16 +121,17 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
dishOrderDO.setGiftAmount(giftAmount);
|
||||
|
||||
user.setWxAmount(BigDecimal.ZERO);
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
moneyDO.setCashAmount(BigDecimal.ZERO);
|
||||
user.setGiftAmount(BigDecimal.ZERO);
|
||||
moneyDO.setDebtAmount(money.subtract(total).add(moneyDO.getDebtAmount()));
|
||||
} else {
|
||||
dishOrderDO.setOrderStatus(DishOrderDO.COMPLETE);
|
||||
//计算金额
|
||||
if (total.compareTo(cashAmount) <= 0) {
|
||||
user.setCashAmount(cashAmount.subtract(total));
|
||||
moneyDO.setCashAmount(cashAmount.subtract(total));
|
||||
dishOrderDO.setCashAmount(total);
|
||||
} else {
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
moneyDO.setCashAmount(BigDecimal.ZERO);
|
||||
dishOrderDO.setCashAmount(cashAmount);
|
||||
BigDecimal total1 = total.subtract(cashAmount);
|
||||
if (total1.compareTo(giftAmount) <= 0) {
|
||||
@ -141,27 +147,27 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修改
|
||||
userService.updateById(user);
|
||||
newMoney = user.getMoney();
|
||||
moneyService.updateById(moneyDO);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
cashNewMoney = moneyDO.getCashAmount();
|
||||
changeMoney = total;
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
|
||||
//记录消费记录
|
||||
CardDO cardDO = new CardDO();
|
||||
cardDO.setType(TimePeriodEnum.getTimePeriod(dishOrderDO.getCreateTime()));
|
||||
cardDO.setUserId(userId);
|
||||
cardDO.setChangeMoney(changeMoney);
|
||||
cardDO.setFlag(CardDO.MINUS);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setCarteenId(dishOrderDO.getStoreId());
|
||||
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
@ -182,14 +188,13 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void cashDraw(Long userId, BigDecimal money, String type) {
|
||||
public void cashDraw(Long userId, BigDecimal money, String type, Long storeId) {
|
||||
|
||||
BigDecimal newMoney;
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
@ -197,17 +202,17 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
if (ObjectUtil.isEmpty(user) || user.getCashAmount().compareTo(BigDecimal.ZERO) < 1
|
||||
|| money.compareTo(user.getCashAmount()) > 0) {
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
if (ObjectUtil.isEmpty(moneyDO) || moneyDO.getCashAmount().compareTo(BigDecimal.ZERO) < 1
|
||||
|| money.compareTo(moneyDO.getCashAmount()) > 0) {
|
||||
throw exception(CASH_AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
user.setMoney(user.getMoney().subtract(money));
|
||||
user.setCashAmount(user.getCashAmount().subtract(money));
|
||||
userService.updateById(user);
|
||||
newMoney = user.getMoney();
|
||||
moneyDO.setCashAmount(moneyDO.getCashAmount().subtract(money));
|
||||
moneyService.updateById(moneyDO);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
cashNewMoney = moneyDO.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
@ -218,18 +223,18 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setType(type);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void wxDraw(Integer amount, Long userId) {
|
||||
BigDecimal newMoney;
|
||||
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
@ -239,9 +244,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
user.setWxAmount(user.getWxAmount().subtract(changeMoney));
|
||||
user.setMoney(user.getMoney().subtract(changeMoney));
|
||||
userService.updateById(user);
|
||||
newMoney = user.getMoney();
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
@ -255,16 +258,13 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setFlag(CardDO.MINUS);
|
||||
cardDO.setChangeMoney(changeMoney);
|
||||
cardDO.setType("7");
|
||||
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -278,25 +278,27 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
BigDecimal oldMoney = user.getMoney();
|
||||
|
||||
user.setMoney(oldMoney.add(money));
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, dishOrderDO.getStoreId());
|
||||
|
||||
//用户当前金额
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
BigDecimal cashAmount = user.getCashAmount();
|
||||
BigDecimal giftAmount = user.getGiftAmount();
|
||||
BigDecimal cashAmount = moneyDO.getCashAmount();
|
||||
BigDecimal debtAmount = moneyDO.getDebtAmount();
|
||||
|
||||
|
||||
//订单消费金额
|
||||
BigDecimal dishWxAmount = dishOrderDO.getWxAmount();
|
||||
BigDecimal dishCashAmount = dishOrderDO.getCashAmount();
|
||||
BigDecimal dishGiftAmount = dishOrderDO.getGiftAmount();
|
||||
|
||||
BigDecimal newMoney = money;
|
||||
if (oldMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||
newMoney = user.getMoney();
|
||||
|
||||
if (debtAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
newMoney = debtAmount.add(newMoney);
|
||||
}
|
||||
|
||||
|
||||
if (user.getMoney().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
if (newMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||
user.setWxAmount(BigDecimal.ZERO);
|
||||
user.setGiftAmount(BigDecimal.ZERO);
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
@ -308,9 +310,9 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
BigDecimal money1 = newMoney.subtract(dishGiftAmount);
|
||||
|
||||
if (money1.compareTo(dishCashAmount) <= 0) {
|
||||
user.setCashAmount(cashAmount.add(money1));
|
||||
moneyDO.setCashAmount(cashAmount.add(money1));
|
||||
} else {
|
||||
user.setCashAmount(cashAmount.add(dishCashAmount));
|
||||
moneyDO.setCashAmount(cashAmount.add(dishCashAmount));
|
||||
BigDecimal money2 = money1.subtract(dishCashAmount);
|
||||
if (money2.compareTo(dishWxAmount) <= 0) {
|
||||
user.setWxAmount(wxAmount.add(money2));
|
||||
@ -322,10 +324,10 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
}
|
||||
userService.updateById(user);
|
||||
newMoney2 = user.getMoney();
|
||||
moneyService.updateById(moneyDO);
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
cashNewMoney = moneyDO.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
@ -336,19 +338,17 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setType(CostTypeEnum.REFUND.getCode());
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setMoney(newMoney2);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
|
||||
cardDO.setCarteenId(dishOrderDO.getStoreId());
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney2);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reduction(Long userId, BigDecimal money, BigDecimal giftAmount, BigDecimal cashAmount, BigDecimal wxAmount) {
|
||||
public void reduction(Long userId, BigDecimal money, BigDecimal giftAmount, BigDecimal cashAmount, BigDecimal wxAmount, Long storeId) {
|
||||
|
||||
BigDecimal newMoney;
|
||||
BigDecimal giftNewAmount;
|
||||
BigDecimal cashNewAmount;
|
||||
BigDecimal wxNewAmount;
|
||||
@ -356,16 +356,17 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
user.setMoney(user.getMoney().add(money));
|
||||
user.setCashAmount(user.getCashAmount().add(cashAmount));
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
|
||||
moneyDO.setCashAmount(moneyDO.getCashAmount().add(cashAmount));
|
||||
user.setGiftAmount(user.getGiftAmount().add(giftAmount));
|
||||
user.setWxAmount(user.getWxAmount().add(wxAmount));
|
||||
userService.updateById(user);
|
||||
moneyService.updateById(moneyDO);
|
||||
|
||||
newMoney = user.getMoney();
|
||||
wxNewAmount = user.getWxAmount();
|
||||
giftNewAmount = user.getGiftAmount();
|
||||
cashNewAmount = user.getCashAmount();
|
||||
cashNewAmount = moneyDO.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
CardDO cardDO = new CardDO();
|
||||
@ -373,40 +374,42 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setFlag(CardDO.ADD);
|
||||
cardDO.setChangeMoney(money);
|
||||
cardDO.setType(CostTypeEnum.REFUND.getCode());
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setWxAmount(wxNewAmount);
|
||||
cardDO.setCashAmount(cashNewAmount);
|
||||
cardDO.setGiftAmount(giftNewAmount);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal storeDeduction(BigDecimal total, @NotNull Long userId) {
|
||||
public BigDecimal storeDeduction(BigDecimal total, @NotNull Long userId, Long storeId) {
|
||||
|
||||
BigDecimal newMoney;
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
String name;
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
BigDecimal money = user.getMoney();
|
||||
if (total.compareTo(money) > 0){
|
||||
return money.subtract(total);
|
||||
}
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
BigDecimal giftAmount = user.getGiftAmount();
|
||||
BigDecimal cashAmount = user.getCashAmount();
|
||||
user.setMoney(money.subtract(total));
|
||||
BigDecimal cashAmount = moneyDO.getCashAmount();
|
||||
|
||||
BigDecimal money = wxAmount.add(giftAmount).add(cashAmount);
|
||||
|
||||
if (total.compareTo(money) > 0) {
|
||||
return money.subtract(total);
|
||||
}
|
||||
|
||||
//计算金额
|
||||
if (total.compareTo(cashAmount) <= 0) {
|
||||
user.setCashAmount(cashAmount.subtract(total));
|
||||
moneyDO.setCashAmount(cashAmount.subtract(total));
|
||||
} else {
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
moneyDO.setCashAmount(BigDecimal.ZERO);
|
||||
BigDecimal total1 = total.subtract(cashAmount);
|
||||
if (total1.compareTo(giftAmount) <= 0) {
|
||||
user.setGiftAmount(giftAmount.subtract(total1));
|
||||
@ -417,10 +420,11 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
}
|
||||
userService.updateById(user);
|
||||
newMoney = user.getMoney();
|
||||
moneyService.updateById(moneyDO);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
cashNewMoney = moneyDO.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
@ -428,22 +432,22 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setUserId(userId);
|
||||
cardDO.setChangeMoney(total);
|
||||
cardDO.setFlag(CardDO.MINUS);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setType(CostTypeEnum.SHOPPING.getCode());
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
|
||||
return cardDO.getMoney();
|
||||
return wxNewMoney.add(giftNewMoney).add(cashNewMoney);
|
||||
}
|
||||
|
||||
|
||||
public void updateRedis(Long userId,String name, BigDecimal newMoney) {
|
||||
public void updateRedis(Long userId, String name, BigDecimal newMoney) {
|
||||
//更新缓存
|
||||
String redisKey = "USER_" + userId;
|
||||
AppUserInfoCardVO appUserInfoCardVO = new AppUserInfoCardVO();
|
||||
@ -453,8 +457,8 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deduct(Long userId, BigDecimal money, String type) {
|
||||
BigDecimal newMoney;
|
||||
public void deduct(Long userId, BigDecimal money, String type,Long storeId) {
|
||||
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
@ -462,23 +466,25 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
MemberUserDO user = userService.getUser(userId);
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, storeId);
|
||||
|
||||
|
||||
if (user.getMoney().compareTo(money) < 0) {
|
||||
if (CHECK_LIST.contains(type)) {
|
||||
throw exception(CASH_AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
user.setWxAmount(BigDecimal.ZERO);
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
moneyDO.setCashAmount(BigDecimal.ZERO);
|
||||
user.setGiftAmount(BigDecimal.ZERO);
|
||||
}else {
|
||||
} else {
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
BigDecimal giftAmount = user.getGiftAmount();
|
||||
BigDecimal cashAmount = user.getCashAmount();
|
||||
BigDecimal cashAmount = moneyDO.getCashAmount();
|
||||
//计算金额
|
||||
if (money.compareTo(cashAmount) <= 0) {
|
||||
user.setCashAmount(cashAmount.subtract(money));
|
||||
moneyDO.setCashAmount(cashAmount.subtract(money));
|
||||
} else {
|
||||
user.setCashAmount(BigDecimal.ZERO);
|
||||
moneyDO.setCashAmount(BigDecimal.ZERO);
|
||||
BigDecimal total1 = money.subtract(cashAmount);
|
||||
if (total1.compareTo(giftAmount) <= 0) {
|
||||
user.setGiftAmount(giftAmount.subtract(total1));
|
||||
@ -489,13 +495,12 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.setMoney(user.getMoney().subtract(money));
|
||||
userService.updateById(user);
|
||||
newMoney = user.getMoney();
|
||||
moneyService.updateById(moneyDO);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
giftNewMoney = user.getGiftAmount();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
cashNewMoney = moneyDO.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
|
||||
@ -506,12 +511,13 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setType(type);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
updateRedis(userId,name,newMoney);
|
||||
updateRedis(userId, name, wxNewMoney);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.rechargelog.RechargeLogDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.refund.RefundDO;
|
||||
@ -15,6 +16,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.rechargelog.RechargeLogMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.refund.IntegralRefundMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@ -50,56 +52,85 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
@Resource
|
||||
private RechargeLogMapper rechargeLogMapper;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
@Resource
|
||||
private StringRedisTemplate wxRechargeRedisTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
public void wxRecharge(BigDecimal money, BigDecimal wxAmount, BigDecimal giftAmount, Long userId) {
|
||||
|
||||
BigDecimal newMoney;
|
||||
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal giftNewMoney;
|
||||
BigDecimal cashNewAmount;
|
||||
String name;
|
||||
|
||||
synchronized (getUserLock(userId)) {
|
||||
//获取最新余额
|
||||
MemberUserDO memberUserDO = userMapper.selectById(userId);
|
||||
|
||||
BigDecimal oldMoney = memberUserDO.getMoney();
|
||||
List<MoneyDO> allDebt = moneyService.getAllDebt(userId);
|
||||
BigDecimal debtAmount = BigDecimal.ZERO;
|
||||
if(CollectionUtil.isNotEmpty(allDebt)){
|
||||
debtAmount = allDebt.stream().map(MoneyDO::getDebtAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
BigDecimal wxOldMoney = memberUserDO.getWxAmount();
|
||||
BigDecimal giftOldMoney = memberUserDO.getGiftAmount();
|
||||
BigDecimal cashAmount = memberUserDO.getCashAmount();
|
||||
|
||||
memberUserDO.setMoney(oldMoney.add(money));
|
||||
memberUserDO.setCashAmount(cashAmount);
|
||||
memberUserDO.setGiftAmount(giftOldMoney);
|
||||
memberUserDO.setWxAmount(wxOldMoney);
|
||||
BigDecimal computeMoney = money;
|
||||
//处理负债
|
||||
if( computeMoney.add(debtAmount).compareTo(BigDecimal.ZERO) < 0){
|
||||
memberUserDO.setWxAmount(BigDecimal.ZERO);
|
||||
memberUserDO.setGiftAmount(BigDecimal.ZERO);
|
||||
|
||||
if (memberUserDO.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal computeWxMoney = wxAmount;
|
||||
BigDecimal computeGiftMoney = giftAmount;
|
||||
|
||||
if (oldMoney.compareTo(BigDecimal.ZERO) < 0) {
|
||||
if (wxAmount.add(oldMoney).compareTo(BigDecimal.ZERO) >= 0) {
|
||||
memberUserDO.setWxAmount(wxAmount.add(oldMoney));
|
||||
memberUserDO.setGiftAmount(giftOldMoney.add(giftAmount));
|
||||
} else {
|
||||
BigDecimal left = wxAmount.add(oldMoney);
|
||||
memberUserDO.setWxAmount(BigDecimal.ZERO);
|
||||
memberUserDO.setGiftAmount(giftAmount.add(left));
|
||||
for (MoneyDO moneyDO : allDebt) {
|
||||
if (computeMoney.add(moneyDO.getDebtAmount()).compareTo(BigDecimal.ZERO) >= 0) {
|
||||
BigDecimal debtAmount1 = moneyDO.getDebtAmount();
|
||||
computeMoney = computeMoney.add(debtAmount1);
|
||||
moneyDO.setDebtAmount(BigDecimal.ZERO);
|
||||
//处理未完全支付订单
|
||||
BigDecimal paramWxMoney = BigDecimal.ZERO;
|
||||
BigDecimal paramGiftMoney = BigDecimal.ZERO;
|
||||
|
||||
if(computeWxMoney.add(moneyDO.getDebtAmount()).compareTo(BigDecimal.ZERO)>=0){
|
||||
computeWxMoney = computeWxMoney.add(moneyDO.getDebtAmount());
|
||||
paramWxMoney = debtAmount1;
|
||||
}else {
|
||||
paramWxMoney = computeWxMoney;
|
||||
paramGiftMoney = debtAmount1.abs().subtract(paramWxMoney);
|
||||
computeWxMoney = BigDecimal.ZERO;
|
||||
computeGiftMoney = computeGiftMoney.add(moneyDO.getDebtAmount());
|
||||
|
||||
}
|
||||
handleOrderWx(userId, debtAmount1, paramWxMoney, paramGiftMoney,moneyDO.getCarteenId());
|
||||
}else {
|
||||
moneyDO.setDebtAmount(computeMoney.add(moneyDO.getDebtAmount()));
|
||||
|
||||
//处理未完全支付订单
|
||||
handleOrderWx(userId, computeMoney, computeWxMoney, computeGiftMoney,moneyDO.getCarteenId());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
memberUserDO.setWxAmount(wxOldMoney.add(wxAmount));
|
||||
memberUserDO.setGiftAmount(giftOldMoney.add(giftAmount));
|
||||
|
||||
}
|
||||
moneyService.updateList(allDebt);
|
||||
}else {
|
||||
moneyService.cleanDebt(userId);
|
||||
//处理未完全支付订单
|
||||
handleOrderWx(userId, money, wxAmount, giftAmount,null);
|
||||
if(wxAmount.add(debtAmount).compareTo(BigDecimal.ZERO) >= 0){
|
||||
memberUserDO.setWxAmount(wxAmount.add(debtAmount).add(wxOldMoney));
|
||||
memberUserDO.setGiftAmount(giftAmount.add(giftOldMoney));
|
||||
}else {
|
||||
memberUserDO.setWxAmount(BigDecimal.ZERO);
|
||||
memberUserDO.setGiftAmount(money.add(debtAmount));
|
||||
}
|
||||
}
|
||||
|
||||
userMapper.updateById(memberUserDO);
|
||||
|
||||
newMoney = memberUserDO.getMoney();
|
||||
wxNewMoney = memberUserDO.getWxAmount();
|
||||
giftNewMoney = memberUserDO.getGiftAmount();
|
||||
cashNewAmount = memberUserDO.getCashAmount();
|
||||
name = memberUserDO.getNickname();
|
||||
}
|
||||
|
||||
@ -110,24 +141,21 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
cardDO.setFlag(CardDO.ADD);
|
||||
cardDO.setChangeMoney(money);
|
||||
cardDO.setType(CostTypeEnum.WX_PAY.getCode());
|
||||
cardDO.setMoney(newMoney);
|
||||
cardDO.setCashAmount(cashNewAmount);
|
||||
cardDO.setGiftAmount(giftNewMoney);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
//处理未完全支付订单
|
||||
handleOrderWx(cardDO.getUserId(), money, wxAmount, giftAmount);
|
||||
|
||||
cardMapper.insert(cardDO);
|
||||
|
||||
|
||||
//更新缓存
|
||||
String redisKey = "USER_" + userId;
|
||||
AppUserInfoCardVO appUserInfoCardVO = new AppUserInfoCardVO();
|
||||
appUserInfoCardVO.setName(name);
|
||||
appUserInfoCardVO.setMoney(newMoney);
|
||||
appUserInfoCardVO.setMoney(wxNewMoney);
|
||||
wxRechargeRedisTemplate.opsForValue().set(redisKey, JSONUtil.toJsonStr(appUserInfoCardVO));
|
||||
|
||||
}
|
||||
|
||||
void handleOrderWx(Long userId, BigDecimal money, BigDecimal wxMoney, BigDecimal giftMoney) {
|
||||
void handleOrderWx(Long userId, BigDecimal money, BigDecimal wxMoney, BigDecimal giftMoney,Long storeId) {
|
||||
|
||||
//开始的微信金额
|
||||
BigDecimal wxStart = wxMoney;
|
||||
@ -136,7 +164,8 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
|
||||
//查询出所有未完全支付订单
|
||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(Wrappers.<DishOrderDO>lambdaQuery()
|
||||
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE));
|
||||
.eq(DishOrderDO::getUserId, userId).eq(DishOrderDO::getOrderStatus, DishOrderDO.TOCOMPLETE)
|
||||
.eq(storeId != null ,DishOrderDO::getStoreId,storeId));
|
||||
|
||||
ArrayList<DishOrderDO> updateList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(dishOrderDOS)) {
|
||||
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 余额变动明细 Service 接口
|
||||
@ -74,12 +73,12 @@ public interface CardService {
|
||||
/**
|
||||
* 获取余额
|
||||
*/
|
||||
BigDecimal getMoney();
|
||||
BigDecimal getMoney(Long storeId);
|
||||
|
||||
/**
|
||||
* 获取余额
|
||||
*/
|
||||
BigDecimal getMoneyByUserId(Long userId);
|
||||
BigDecimal getMoneyByUserId(Long userId,Long storeId);
|
||||
|
||||
CardDO getCardDoByUserId(Long userId);
|
||||
|
||||
@ -96,7 +95,7 @@ public interface CardService {
|
||||
|
||||
void refund(Long userId,BigDecimal money,Long orderId);
|
||||
|
||||
BigDecimal getCashMoney(Long userId);
|
||||
BigDecimal getCashMoney(Long userId,Long storeId);
|
||||
|
||||
Boolean cashDraw(Long userId,BigDecimal money);
|
||||
Boolean cashDraw(Long userId,BigDecimal money,Long storeId);
|
||||
}
|
@ -143,13 +143,13 @@ public class CardServiceImpl implements CardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMoney() {
|
||||
return amountService.getAmount( SecurityFrameworkUtils.getLoginUserId());
|
||||
public BigDecimal getMoney(Long storeId) {
|
||||
return amountService.getAmount(SecurityFrameworkUtils.getLoginUserId(),storeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMoneyByUserId(Long userId) {
|
||||
return amountService.getAmount(userId);
|
||||
public BigDecimal getMoneyByUserId(Long userId,Long storeId) {
|
||||
return amountService.getAmount(userId,storeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,7 +192,7 @@ public class CardServiceImpl implements CardService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void rechargeByAdmin(RechargeVO vo) {
|
||||
cashRechargeService.rechargeByAdmin(vo.getUserIds(),vo.getGroupId(),vo.getMoney());
|
||||
cashRechargeService.rechargeByAdmin(vo.getUserIds(),vo.getGroupId(),vo.getMoney(),vo.getCarteenId());
|
||||
}
|
||||
|
||||
|
||||
@ -425,13 +425,13 @@ public class CardServiceImpl implements CardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCashMoney(Long userId) {
|
||||
return amountService.getCashAmount(userId);
|
||||
public BigDecimal getCashMoney(Long userId,Long storeId) {
|
||||
return amountService.getCashAmount(userId,storeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean cashDraw(Long userId, BigDecimal money) {
|
||||
deductionService.cashDraw(userId, money, CostTypeEnum.CASH_WITHDRAW.getCode());
|
||||
public Boolean cashDraw(Long userId, BigDecimal money, Long storeId) {
|
||||
deductionService.cashDraw(userId, money, CostTypeEnum.CASH_WITHDRAW.getCode(), storeId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.AppUserInfo
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.admincard.AdminCardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.diningplates.DiningPlatesMapper;
|
||||
@ -24,6 +25,7 @@ import cn.iocoder.yudao.module.member.service.admincard.AdminCardService;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.async.MemberAsyncService;
|
||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
@ -83,6 +85,8 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
private MemberAsyncService asyncService;
|
||||
@Resource
|
||||
private DeductionService deductionService;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
|
||||
@Override
|
||||
public Long createDiningPlates(DiningPlatesSaveReqVO createReqVO) {
|
||||
@ -373,8 +377,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
wrapper.eq(DishOrderDO::getOrderStatus,DishOrderDO.TOCOMPLETE);
|
||||
|
||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
|
||||
BigDecimal moneyByUserId = cardService.getMoneyByUserId(userId);
|
||||
ErrorCode code = new ErrorCode(1_004_099_008, "存在未支付完的订单,待支付金额:"+moneyByUserId.abs()+"元");
|
||||
ErrorCode code = new ErrorCode(1_004_099_008, "存在未支付完的订单");
|
||||
if(CollectionUtil.isNotEmpty(dishOrderDOS)){
|
||||
throw exception(code);
|
||||
}
|
||||
@ -477,11 +480,13 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
|
||||
DishesRespDto dish = dishesApi.getDish(dishId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(memberUserDO.getId(), storeId);
|
||||
|
||||
AppUserInfo appUserInfo = new AppUserInfo();
|
||||
appUserInfo.setNickname(StrUtil.isNotBlank(memberUserDO.getName())?memberUserDO.getName():memberUserDO.getNickname())
|
||||
.setDishesName(dish.getDishesName())
|
||||
.setDishesBasePrice(dish.getDishesBasePrice()).setDishesSumPrice(dish.getDishesSumPrice())
|
||||
.setMoney(memberUserDO.getMoney())
|
||||
.setMoney(memberUserDO.getWxAmount().add(moneyDO.getCashAmount()))
|
||||
.setOrderMoney(new BigDecimal(stringRedisTemplate.opsForValue().get(diningPlatesNum+"-"+storeId)))
|
||||
.setReception(memberUserDO.getReception()).setLimitAmount(memberUserDO.getLimitAmount());
|
||||
return appUserInfo;
|
||||
|
@ -131,4 +131,6 @@ public interface MemberGroupService {
|
||||
void updateAdmin(MemberGroupUpdateReqVO updateReqVO);
|
||||
|
||||
void setAdmin(GroupAdminReqVO vo);
|
||||
|
||||
Long getCarteenId(Long userId);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
List<MemberUserDO> list = memberGroupMapper.getMemberByGroupId(vo);
|
||||
ArrayList<MemberUserVO> userList = new ArrayList<>();
|
||||
for (MemberUserDO memberUserDO:list){
|
||||
BigDecimal money = cardService.getMoneyByUserId(memberUserDO.getId());
|
||||
BigDecimal money = cardService.getMoneyByUserId(memberUserDO.getId(),vo.getCarteenId());
|
||||
MemberUserVO memberUserVO = new MemberUserVO();
|
||||
BeanUtil.copyProperties(memberUserDO,memberUserVO);
|
||||
memberUserVO.setMoney(money);
|
||||
@ -197,4 +197,9 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
||||
wrapper.set(MemberGroupDO::getUserId, vo.getUserId()).in(MemberGroupDO::getId, vo.getGroupIds());
|
||||
memberGroupMapper.update(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCarteenId(Long userId) {
|
||||
return memberGroupMapper.getCarteenId(userId);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.member.service.money;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||
@ -52,4 +53,20 @@ public interface MoneyService {
|
||||
*/
|
||||
PageResult<MoneyDO> getMoneyPage(MoneyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得金额
|
||||
*
|
||||
* @return 金额
|
||||
*/
|
||||
MoneyDO getMoney(Long userId, Long carteenId);
|
||||
|
||||
List<MoneyDO> getAllDebt(Long userId);
|
||||
|
||||
void updateById(MoneyDO moneyDO);
|
||||
|
||||
void insertOne(MoneyDO moneyDO);
|
||||
|
||||
void updateList(List<MoneyDO> moneyDOs);
|
||||
|
||||
void cleanDebt(Long userId);
|
||||
}
|
@ -1,10 +1,15 @@
|
||||
package cn.iocoder.yudao.module.member.service.money;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
@ -71,4 +76,35 @@ public class MoneyServiceImpl implements MoneyService {
|
||||
return moneyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoneyDO getMoney(Long userId, Long carteenId) {
|
||||
return moneyMapper.selectOne(new LambdaQueryWrapper<MoneyDO>().eq(MoneyDO::getUserId, userId).eq(MoneyDO::getCarteenId, carteenId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MoneyDO> getAllDebt(Long userId) {
|
||||
|
||||
return moneyMapper.selectList(new LambdaQueryWrapper<MoneyDO>().eq(MoneyDO::getUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateById(MoneyDO moneyDO) {
|
||||
moneyMapper.updateById(moneyDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOne(MoneyDO moneyDO) {
|
||||
moneyMapper.insert(moneyDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateList(List<MoneyDO> moneyDOs) {
|
||||
moneyMapper.updateBatch(moneyDOs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanDebt(Long userId) {
|
||||
moneyMapper.update(new LambdaUpdateWrapper<MoneyDO>().eq(MoneyDO::getUserId, userId)
|
||||
.set(MoneyDO::getDebtAmount, BigDecimal.ZERO));
|
||||
}
|
||||
}
|
@ -119,7 +119,7 @@ public interface OrderService {
|
||||
* @Date: 2024/4/24 上午9:52
|
||||
* @return
|
||||
*/
|
||||
OrderMoneyRespVO getUserMeney(Long userId);
|
||||
OrderMoneyRespVO getUserMeney(Long userId,Long carteenId);
|
||||
|
||||
|
||||
Map<String,Object> getMoneyAndPeople(Long storeId);
|
||||
|
@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.order.vo.AppPageVo;
|
||||
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailRespVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.card.CardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
@ -32,6 +33,7 @@ import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||
import cn.iocoder.yudao.module.member.service.refund.RefundService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
@ -90,6 +92,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
private DeductionService deductionService;
|
||||
@Resource
|
||||
private DiningPlatesService diningPlatesService;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
|
||||
@Override
|
||||
public Long createOrder(AppOrderSaveReqVO createReqVO) {
|
||||
@ -387,30 +391,42 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
* @param carteenId
|
||||
* @return
|
||||
* @Description: 根据会员编号,获得会员余额,充值金额,消费金额
|
||||
* @Author: qjq
|
||||
* @Date: 2024/4/24 上午9:52
|
||||
*/
|
||||
@Override
|
||||
public OrderMoneyRespVO getUserMeney(Long userId) {
|
||||
public OrderMoneyRespVO getUserMeney(Long userId, Long carteenId) {
|
||||
OrderMoneyRespVO orderMoneyRespVO = new OrderMoneyRespVO();
|
||||
//获取充值的金额
|
||||
BigDecimal add = cardMapper.selectAddMoney(userId, CardDO.ADD);
|
||||
BigDecimal add = cardMapper.selectAddMoney(userId, CardDO.ADD,carteenId);
|
||||
if (add == null) {
|
||||
add = BigDecimal.ZERO;
|
||||
}
|
||||
orderMoneyRespVO.setRechargeMoney(add);
|
||||
//消费的金额
|
||||
BigDecimal minus = cardMapper.selectAddMoney(userId, CardDO.MINUS);
|
||||
BigDecimal minus = cardMapper.selectAddMoney(userId, CardDO.MINUS,carteenId);
|
||||
if (minus == null) {
|
||||
minus = BigDecimal.ZERO;
|
||||
}
|
||||
orderMoneyRespVO.setConsumeMoney(minus);
|
||||
//获取会员余额
|
||||
BigDecimal subtract = add.subtract(minus);
|
||||
orderMoneyRespVO.setCurrentMoney(subtract);
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
|
||||
orderMoneyRespVO.setCurrentMoney(memberUserDO.getWxAmount());
|
||||
orderMoneyRespVO.setUserId(userId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, carteenId);
|
||||
orderMoneyRespVO.setCashMoney(BigDecimal.ZERO);
|
||||
orderMoneyRespVO.setDebtMoney(BigDecimal.ZERO);
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
orderMoneyRespVO.setCashMoney(moneyDO.getCashAmount());
|
||||
orderMoneyRespVO.setDebtMoney(moneyDO.getDebtAmount());
|
||||
}
|
||||
|
||||
BigDecimal wxRechargeMoney = cardMapper.selectWxMoney(userId);
|
||||
orderMoneyRespVO.setWxRechargeMoney(wxRechargeMoney);
|
||||
return orderMoneyRespVO;
|
||||
}
|
||||
|
||||
@ -467,7 +483,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
//退款
|
||||
deductionService.reduction(dishOrderDO.getUserId(), money, giftAmount, cashAmount, wxAmount);
|
||||
deductionService.reduction(dishOrderDO.getUserId(), money, giftAmount, cashAmount, wxAmount, dishOrderDO.getStoreId());
|
||||
|
||||
//更新营业数据
|
||||
if (dishOrderDO.getOrderStatus().equals(DishOrderDO.COMPLETE)) {
|
||||
@ -532,7 +548,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderDetailDO.setDishesId(-1L);
|
||||
orderDetailService.insertOne(orderDetailDO);
|
||||
//扣费处理
|
||||
deductionService.deduct(memberUserDO.getId(), money, type);
|
||||
deductionService.deduct(memberUserDO.getId(), money, type,carteenId);
|
||||
//更新营业数据
|
||||
StatisticsVo statisticsVo = new StatisticsVo();
|
||||
statisticsVo.setCarteenId(dishOrderDO.getStoreId());
|
||||
|
@ -1,47 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.service.orderspacecapsule;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.orderspacecapsule.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderspacecapsule.OrderSpaceCapsuleDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.spacecapsule.SpaceCapsuleDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.statisticsspacecapsuleorder.StatisticsSpaceCapsuleOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.orderspacecapsule.OrderSpaceCapsuleMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.statisticsspacecapsuleorder.StatisticsSpaceCapsuleOrderMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.*;
|
||||
import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.carteenmoney.CarteenMoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.spacecapsule.SpaceCapsuleService;
|
||||
import cn.iocoder.yudao.module.member.service.statisticsspacecapsuleorder.StatisticsSpaceCapsuleOrderService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -99,7 +84,7 @@ public class OrderSpaceCapsuleServiceImpl implements OrderSpaceCapsuleService {
|
||||
BigDecimal multiply = orderSpaceCapsule.getComboPrice().multiply(BigDecimal.valueOf(orderSpaceCapsule.getComboNum()));
|
||||
orderSpaceCapsule.setMoney(multiply);
|
||||
// 扣除余额
|
||||
deductionService.deduct(orderSpaceCapsule.getUserId(), orderSpaceCapsule.getMoney(), CostTypeEnum.SHOPPING.getCode());
|
||||
deductionService.deduct(orderSpaceCapsule.getUserId(), orderSpaceCapsule.getMoney(), CostTypeEnum.SHOPPING.getCode(),createReqVO.getCarteenId());
|
||||
// 设置变动后的余额
|
||||
orderSpaceCapsule.setEndMoney(initialMoney.subtract(orderSpaceCapsule.getMoney()));
|
||||
// 设置支付方式
|
||||
@ -169,7 +154,7 @@ public class OrderSpaceCapsuleServiceImpl implements OrderSpaceCapsuleService {
|
||||
BigDecimal refundAmount = calculateRefundAmount(updateObj, currentStatus);
|
||||
updateObj.setRefundMoney(refundAmount);
|
||||
// 进行余额退款
|
||||
deductionService.reduction(updateObj.getUserId(), refundAmount, BigDecimal.ZERO, refundAmount, BigDecimal.ZERO);
|
||||
deductionService.reduction(updateObj.getUserId(), refundAmount, BigDecimal.ZERO, refundAmount, BigDecimal.ZERO, null);
|
||||
// 设置变动后的余额
|
||||
updateObj.setEndMoney(startMoney.add(refundAmount));
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -187,7 +186,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
Double totalPrice = storeOrderDO.getTotalPrice();
|
||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||
MemberUserDO userDO = userService.getByFaceId(Long.valueOf(dto.getOpenId()));
|
||||
BigDecimal compute = compute(total, userDO.getId());
|
||||
BigDecimal compute = compute(total, userDO.getId(), storeOrderDO.getCarteenId());
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
userInfoVo.setUserName(userDO.getNickname());
|
||||
userInfoVo.setAvatar("https://yclhit.com:8896" + userDO.getAvatar());
|
||||
@ -198,7 +197,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String cardPay(StoreOrderDto dto) {
|
||||
|
||||
Long storeId = cashregisterinfoApi.getStoreId(dto.getEquipmentCode());
|
||||
MemberUserDO userDO = userService.getByCardId(dto.getCardNumber());
|
||||
if (ObjectUtil.isEmpty(userDO)) {
|
||||
return "该卡未绑定用户";
|
||||
@ -207,7 +206,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
Double totalPrice = createOrder(dto, StoreOrderStatusEnum.COMPLETE.getCode()).getTotalPrice();
|
||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
BigDecimal compute = compute(total, userDO.getId());
|
||||
BigDecimal compute = compute(total, userDO.getId(),storeId);
|
||||
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
||||
return "false";
|
||||
} else {
|
||||
@ -262,7 +261,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
Double totalPrice = order.getTotalPrice();
|
||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
BigDecimal compute = compute(total, user.getId());
|
||||
BigDecimal compute = compute(total, user.getId(),storeId);
|
||||
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
||||
storeOrderMapper.deleteById(order.getOrderId());
|
||||
orderDetailService.deleteByOrderNo(order.getOrderId());
|
||||
@ -306,8 +305,8 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
//todo:订单结算
|
||||
}
|
||||
|
||||
public BigDecimal compute(BigDecimal total, Long userId) {
|
||||
return deductionService.storeDeduction(total, userId);
|
||||
public BigDecimal compute(BigDecimal total, Long userId,Long storeId) {
|
||||
return deductionService.storeDeduction(total, userId,storeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -327,9 +326,6 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
public void reduction(Long orderId, BigDecimal money) {
|
||||
StoreOrderDO storeOrderDO = storeOrderMapper.selectById(orderId);
|
||||
|
||||
|
||||
|
||||
|
||||
Double totalPrice = storeOrderDO.getTotalPrice();
|
||||
BigDecimal total = BigDecimal.valueOf(totalPrice).setScale(2, RoundingMode.HALF_UP);
|
||||
Double reductionPrice = storeOrderDO.getReductionPrice();
|
||||
@ -337,7 +333,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
storeOrderDO.setReductionPrice(reduction.add(money).doubleValue());
|
||||
storeOrderDO.setTotalPrice(total.subtract(money).doubleValue());
|
||||
storeOrderMapper.updateById(storeOrderDO);
|
||||
deductionService.reduction(storeOrderDO.getUserId(), money, BigDecimal.ZERO,money, BigDecimal.ZERO);
|
||||
deductionService.reduction(storeOrderDO.getUserId(), money, BigDecimal.ZERO,money, BigDecimal.ZERO, storeOrderDO.getCarteenId());
|
||||
//营业数据
|
||||
StatisticsVo statisticsVo = new StatisticsVo();
|
||||
statisticsVo.setCarteenId(storeOrderDO.getCarteenId());
|
||||
@ -351,7 +347,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AddReqVO appCreate(CardDto dto) {
|
||||
BigDecimal amount = amountService.getAmount(dto.getUserId());
|
||||
BigDecimal amount = amountService.getAmount(dto.getUserId(),dto.getCarteenId());
|
||||
BigDecimal total = BigDecimal.valueOf(dto.getTotalPrice());
|
||||
if(amount.compareTo(total) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
@ -386,7 +382,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
orderDetailService.saveBatch(addList);
|
||||
|
||||
//扣款
|
||||
BigDecimal compute = compute(total, dto.getUserId());
|
||||
BigDecimal compute = compute(total, dto.getUserId(),dto.getCarteenId());
|
||||
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
||||
storeOrderMapper.deleteById(storeOrderDO.getOrderId());
|
||||
orderDetailService.deleteByOrderNo(storeOrderDO.getOrderId());
|
||||
@ -458,7 +454,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
|
||||
BigDecimal total = BigDecimal.valueOf(sum).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
BigDecimal compute = compute(total, user.getId());
|
||||
BigDecimal compute = compute(total, user.getId(),dto.getCarteenId());
|
||||
if (compute.compareTo(BigDecimal.ZERO) < 0) {
|
||||
storeOrderMapper.deleteById(storeOrderDO.getOrderId());
|
||||
orderDetailService.deleteByOrderNo(storeOrderDO.getOrderId());
|
||||
@ -534,7 +530,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
|
||||
//退款
|
||||
deductionService.reduction(storeOrderDO.getUserId(),BigDecimal.valueOf(storeOrderDO.getTotalPrice())
|
||||
,BigDecimal.ZERO,BigDecimal.valueOf(storeOrderDO.getTotalPrice()),BigDecimal.ZERO);
|
||||
,BigDecimal.ZERO,BigDecimal.valueOf(storeOrderDO.getTotalPrice()),BigDecimal.ZERO, storeOrderDO.getCarteenId());
|
||||
|
||||
//更新库存
|
||||
List<StoreOrderDetailDO> listByOrderId = orderDetailService.getListByOrderId(storeOrderDO.getOrderId());
|
||||
@ -617,7 +613,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
|
||||
//退款
|
||||
deductionService.reduction(storeOrderDO.getUserId(),BigDecimal.valueOf(storeOrderDO.getTotalPrice())
|
||||
,BigDecimal.ZERO,BigDecimal.valueOf(storeOrderDO.getTotalPrice()),BigDecimal.ZERO);
|
||||
,BigDecimal.ZERO,BigDecimal.valueOf(storeOrderDO.getTotalPrice()),BigDecimal.ZERO, storeOrderDO.getCarteenId());
|
||||
|
||||
//更新库存
|
||||
List<StoreOrderDetailDO> listByOrderId = orderDetailService.getListByOrderId(storeOrderDO.getOrderId());
|
||||
|
@ -255,7 +255,7 @@ public interface MemberUserService {
|
||||
MemberUserDO getByMobile(Long mobile);
|
||||
MemberUserDO getByCardId(String cardId);
|
||||
|
||||
Map<String,Object> getInfoByCard(String cardId,Long mobile);
|
||||
Map<String,Object> getInfoByCard(String cardId,Long mobile,Long storeId);
|
||||
|
||||
boolean delete(Long userId);
|
||||
|
||||
@ -264,4 +264,5 @@ public interface MemberUserService {
|
||||
List<MemberUserDO> getByMobiles(List<String> mobiles);
|
||||
|
||||
List<MemberUserDO> getListByMobile(String mobiles);
|
||||
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
Long userId = diningPlatesDO.getUserId();
|
||||
//获取用户名称
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
|
||||
BigDecimal moneyByUserId = cardService.getMoneyByUserId(userId);
|
||||
BigDecimal moneyByUserId = cardService.getMoneyByUserId(userId,diningPlatesDO.getStoreId());
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("name",memberUserDO.getName());
|
||||
map.put("money", String.valueOf(moneyByUserId));
|
||||
@ -826,14 +826,14 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInfoByCard(String cardId,Long mobile) {
|
||||
public Map<String, Object> getInfoByCard(String cardId,Long mobile,Long storeId) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
if(ObjectUtil.isNotEmpty(cardId)){
|
||||
MemberUserDO byCardId = getByCardId(cardId);
|
||||
if(ObjectUtil.isEmpty(byCardId)){
|
||||
throw exception(CARD_USER_NOT_EXISTS);
|
||||
}
|
||||
BigDecimal money = cardService.getMoneyByUserId(byCardId.getId());
|
||||
BigDecimal money = cardService.getMoneyByUserId(byCardId.getId(),storeId);
|
||||
map.put("money",money);
|
||||
map.put("userName",byCardId.getNickname());
|
||||
}
|
||||
@ -842,7 +842,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
if(ObjectUtil.isEmpty(byFaceId)){
|
||||
throw exception(FACE_USER_NOT_EXISTS);
|
||||
}
|
||||
BigDecimal money = cardService.getMoneyByUserId(byFaceId.getId());
|
||||
BigDecimal money = cardService.getMoneyByUserId(byFaceId.getId(),storeId);
|
||||
map.put("money",money);
|
||||
map.put("userName",byFaceId.getNickname());
|
||||
}
|
||||
|
@ -86,4 +86,9 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getCarteenId" resultType="long">
|
||||
SELECT carteen_id FROM member_group WHERE
|
||||
id = (select group_id from member_group_member where member_id = #{userId})
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user