| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/12/2 15:04 |
| | |
| | | public R saveUserPoint(UserPoint userPoint) { |
| | | return R.fail("保存积分流水记录失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<UserPoint>> getUserPointList(UserPoint userPoint) { |
| | | return R.fail("获取积分变动明细失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/12/2 15:04 |
| | |
| | | @PostMapping("/user-point/saveUserPoint") |
| | | R saveUserPoint(@RequestBody UserPoint userPoint); |
| | | |
| | | |
| | | /** |
| | | * 获取积分变动明细 |
| | | * @param userPoint |
| | | * @return |
| | | */ |
| | | @PostMapping("/user-point/getUserPointList") |
| | | R<List<UserPoint>> getUserPointList(@RequestBody UserPoint userPoint); |
| | | } |
| | |
| | | @ApiModelProperty(value = "预计提货时间") |
| | | @TableField("expected_delivery_time") |
| | | private String expectedDeliveryTime; |
| | | |
| | | @ApiModelProperty("退款状态(1=退款中,2=已退款)") |
| | | @TableField("refund_status") |
| | | private Integer refundStatus; |
| | | |
| | | @ApiModelProperty("退款流水号") |
| | | @TableField("refund_code") |
| | | private String refundCode; |
| | | |
| | | @ApiModelProperty("退款时间") |
| | | @TableField("refund_time") |
| | | private LocalDateTime refundTime; |
| | | |
| | | |
| | | } |
| | |
| | | private Integer goodsId; |
| | | @ApiModelProperty("数量") |
| | | private Integer number; |
| | | @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)") |
| | | private Integer type; |
| | | @ApiModelProperty("状态(0=临时数据,1=购物车数据)") |
| | | private Integer status; |
| | | } |
| | |
| | | public class ConfirmOrder { |
| | | @ApiModelProperty(value = "购买方式(1=购物车,2=商品详情)", required = true) |
| | | private Integer position; |
| | | @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true) |
| | | @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2,type:1}]", required = true, notes = "type值取值范围(1=普通商品,2=秒杀商品)") |
| | | private String goodsJson; |
| | | @ApiModelProperty(value = "支付方式(1=现金,2=积分)", required = true) |
| | | private Integer paymentType; |
| | |
| | | public class MyShoppingCartVo { |
| | | @ApiModelProperty("数据id") |
| | | private String id; |
| | | @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)") |
| | | private Integer type; |
| | | @ApiModelProperty("商品id") |
| | | private Integer goodsId; |
| | | @ApiModelProperty("封面图") |
| | |
| | | @Data |
| | | @ApiModel |
| | | public class ShoppingCartPayment { |
| | | @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true) |
| | | @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2,type:1}]", required = true) |
| | | private String goodsJson; |
| | | @ApiModelProperty(value = "支付方式(1=微信,2=账户余额,3=积分)", required = true) |
| | | private Integer paymentType; |
| | |
| | | @TableField(exist = false) |
| | | private Integer showStatus; |
| | | |
| | | @TableField(exist = false) |
| | | private String payMethod; |
| | | |
| | | |
| | | public String getIdStr() { |
| | | return String.valueOf(id); |
| | | } |
| | |
| | | public R<List<CouponInfo>> getCouponInfoList(List<Integer> ids) { |
| | | return R.fail("根据id集合获取优惠券数据失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<CouponInfo>> getCouponInfoByPersonType(Integer personType) { |
| | | return R.fail("根据类型获取有效优惠券列表失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/coupon-info/getCouponInfoList") |
| | | R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids); |
| | | |
| | | |
| | | /** |
| | | * 根据类型获取有效优惠券列表 |
| | | * @param personType |
| | | * @return |
| | | */ |
| | | @PostMapping("/coupon-info/getCouponInfoByPersonType") |
| | | R<List<CouponInfo>> getCouponInfoByPersonType(@RequestParam("personType") Integer personType); |
| | | } |
| | |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(Long userId); |
| | | List<SysMenu> selectMenuList(Long userId); |
| | | |
| | | /** |
| | | * 根据用户查询系统菜单列表 |
| | |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(SysMenu menu, Long userId); |
| | | List<SysMenu> selectMenuList(SysMenu menu, Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询权限 |
| | |
| | | * @param userId 用户ID |
| | | * @return 权限列表 |
| | | */ |
| | | public Set<String> selectMenuPermsByUserId(Long userId); |
| | | Set<String> selectMenuPermsByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询权限 |
| | |
| | | * @param roleId 角色ID |
| | | * @return 权限列表 |
| | | */ |
| | | public Set<String> selectMenuPermsByRoleId(Long roleId); |
| | | Set<String> selectMenuPermsByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 根据用户ID查询菜单树信息 |
| | |
| | | * @param userId 用户ID |
| | | * @return 菜单列表 |
| | | */ |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | List<SysMenu> selectMenuTreeByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据角色ID查询菜单树信息 |
| | |
| | | * @param roleId 角色ID |
| | | * @return 选中菜单列表 |
| | | */ |
| | | public List<Long> selectMenuListByRoleId(Long roleId); |
| | | List<Long> selectMenuListByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 构建前端路由所需要的菜单 |
| | |
| | | * @param menus 菜单列表 |
| | | * @return 路由列表 |
| | | */ |
| | | public List<RouterVo> buildMenus(List<SysMenu> menus); |
| | | List<RouterVo> buildMenus(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * 构建前端所需要树结构 |
| | |
| | | * @param menus 菜单列表 |
| | | * @return 树结构列表 |
| | | */ |
| | | public List<SysMenu> buildMenuTree(List<SysMenu> menus); |
| | | List<SysMenu> buildMenuTree(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | |
| | | * @param menus 菜单列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | | public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus); |
| | | List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus); |
| | | |
| | | /** |
| | | * 根据菜单ID查询信息 |
| | |
| | | * @param menuId 菜单ID |
| | | * @return 菜单信息 |
| | | */ |
| | | public SysMenu selectMenuById(Long menuId); |
| | | SysMenu selectMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 是否存在菜单子节点 |
| | |
| | | * @param menuId 菜单ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | public boolean hasChildByMenuId(Long menuId); |
| | | boolean hasChildByMenuId(Long menuId); |
| | | |
| | | /** |
| | | * 查询菜单是否存在角色 |
| | |
| | | * @param menuId 菜单ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | | public boolean checkMenuExistRole(Long menuId); |
| | | boolean checkMenuExistRole(Long menuId); |
| | | |
| | | /** |
| | | * 新增保存菜单信息 |
| | |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertMenu(SysMenu menu); |
| | | int insertMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * 修改保存菜单信息 |
| | |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateMenu(SysMenu menu); |
| | | int updateMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * 删除菜单管理信息 |
| | |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteMenuById(Long menuId); |
| | | int deleteMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 校验菜单名称是否唯一 |
| | |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkMenuNameUnique(SysMenu menu); |
| | | boolean checkMenuNameUnique(SysMenu menu); |
| | | |
| | | List<SysMenus> getAllMenu(); |
| | | |
| | | |
| | | |
| | | List<SysMenu> getAllMenu(Integer roleType); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.system.api.model.UserShop; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/12/2 9:39 |
| | | */ |
| | | public interface UserShopService extends IService<UserShop> { |
| | | |
| | | |
| | | /** |
| | | * 获取关系数据 |
| | | * @param userId |
| | | * @param roleType |
| | | * @return |
| | | */ |
| | | List<UserShop> getUserShop(Long userId, Integer roleType); |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | |
| | | List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();) |
| | | { |
| | | SysMenu menu = (SysMenu) iterator.next(); |
| | | SysMenu menu = iterator.next(); |
| | | // 如果是顶级节点, 遍历该父节点的所有子节点 |
| | | if (!tempList.contains(menu.getParentId())) |
| | | { |
| | |
| | | List<SysMenu> returnList = new ArrayList<SysMenu>(); |
| | | for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();) |
| | | { |
| | | SysMenu t = (SysMenu) iterator.next(); |
| | | SysMenu t = iterator.next(); |
| | | // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 |
| | | if (t.getParentId() == parentId) |
| | | { |
| | |
| | | Iterator<SysMenu> it = list.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | SysMenu n = (SysMenu) it.next(); |
| | | SysMenu n = it.next(); |
| | | if (n.getParentId().longValue() == t.getMenuId().longValue()) |
| | | { |
| | | tlist.add(n); |
| | |
| | | return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." }, |
| | | new String[] { "", "", "", "/" }); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<SysMenu> getAllMenu(Integer roleType) { |
| | | return this.list(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getRoleType, roleType).eq(SysMenu::getVisible, 0) |
| | | .eq(SysMenu::getStatus, 0)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.UserShop; |
| | | import com.ruoyi.system.domain.SysMenu; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.service.ISysPermissionService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户权限处理 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysPermissionServiceImpl implements ISysPermissionService |
| | | { |
| | | public class SysPermissionServiceImpl implements ISysPermissionService { |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Resource |
| | | @Autowired |
| | | private UserShopService userShopService; |
| | | |
| | | /** |
| | | * 获取角色数据权限 |
| | | * |
| | | * @param userId 用户Id |
| | | * @return 角色权限信息 |
| | | */ |
| | | @Override |
| | |
| | | /** |
| | | * 获取菜单数据权限 |
| | | * |
| | | * @param userId 用户Id |
| | | * @return 菜单权限信息 |
| | | */ |
| | | @Override |
| | | public Set<String> getMenuPermission(SysUser user) |
| | | { |
| | | Set<String> perms = new HashSet<String>(); |
| | | List<UserShop> userShop = userShopService.getUserShop(user.getUserId(), 1); |
| | | // 管理员拥有所有权限 |
| | | if (user.isAdmin()) |
| | | { |
| | | perms.add("*:*:*"); |
| | | }else if(user.getRoleType() == 2 && null != userShop && userShop.size() > 0){ |
| | | List<SysMenu> list = menuService.getAllMenu(2); |
| | | return list.stream().map(SysMenu::getPath).collect(Collectors.toSet()); |
| | | } |
| | | else |
| | | { |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.api.model.UserShop; |
| | | import com.ruoyi.system.mapper.UserShopMapper; |
| | | import com.ruoyi.system.service.UserShopService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | |
| | | @Service |
| | | public class UserShopServiceImpl extends ServiceImpl<UserShopMapper, UserShop> implements UserShopService { |
| | | |
| | | @Override |
| | | public List<UserShop> getUserShop(Long userId, Integer roleType) { |
| | | return this.list(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, userId).eq(UserShop::getRoleType, roleType)); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getAppUserById") |
| | | public AppUser getAppUserById(@RequestParam("id") Long id) { |
| | | return appUserService.getById(id); |
| | |
| | | AppUser byId = appUserService.getById(id); |
| | | byId.setVipId(byId.getVipId() - 1); |
| | | appUserService.updateById(byId); |
| | | //执行降级标记代码 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | { |
| | | vipSettingService.downUsers(); |
| | | } |
| | | } |
| | | } |
| | | ).start(); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ResponseBody |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R add(@RequestBody UserAddress userAddress){ |
| | | public R<String> add(@RequestBody UserAddress userAddress){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | |
| | | if (userAddress.getIsDefault()==1){ |
| | | List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); |
| | | for (UserAddress userAddress1 : list) { |
| | |
| | | } |
| | | userAddressService.updateBatchById(list); |
| | | } |
| | | |
| | | userAddress.setAppUserId(userId); |
| | | userAddressService.save(userAddress); |
| | | return R.ok(); |
| | | return R.ok(userAddress.getId().toString()); |
| | | } |
| | | |
| | | @ResponseBody |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.vo.TransferPoint; |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | |
| | | */ |
| | | @PostMapping("/transferPoint") |
| | | @ApiOperation("转赠积分") |
| | | public R<Void> transferPoint(@ApiParam("积分") @RequestParam BigDecimal point, @ApiParam("手机号") @RequestParam String phone) { |
| | | userPointService.transferPoint(point, phone); |
| | | return R.ok(); |
| | | public R<Void> transferPoint(@RequestBody TransferPoint transferPoint) { |
| | | return userPointService.transferPoint(transferPoint.getPoint(), transferPoint.getPhone()); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取积分变动记录 |
| | | * @param userPoint |
| | | * @return |
| | | */ |
| | | @PostMapping("/getUserPointList") |
| | | public R<List<UserPoint>> getUserPointList(@RequestBody UserPoint userPoint){ |
| | | LambdaQueryWrapper<UserPoint> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if(null != userPoint.getType()){ |
| | | queryWrapper.eq(UserPoint::getType, userPoint.getType()); |
| | | } |
| | | if(null != userPoint.getObjectId()){ |
| | | queryWrapper.eq(UserPoint::getObjectId, userPoint.getObjectId()); |
| | | } |
| | | if(null != userPoint.getAppUserId()){ |
| | | queryWrapper.eq(UserPoint::getAppUserId, userPoint.getAppUserId()); |
| | | } |
| | | List<UserPoint> list = userPointService.list(queryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | List<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime startTime, LocalDateTime endTime, Integer type); |
| | | |
| | | void transferPoint(BigDecimal point, String phone); |
| | | R transferPoint(Integer point, String phone); |
| | | |
| | | UserPointStatistics getStatistics(UserPoint userPoint); |
| | | |
| | |
| | | |
| | | VipSetting getVipSettingByUserId(Long appUserId); |
| | | |
| | | void downUsers(); |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | | import com.ruoyi.account.api.model.UserChangeLog; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.mapper.AppUserMapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.AppUserShopService; |
| | | import com.ruoyi.account.service.UserChangeLogService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.SMSUtil; |
| | | import com.ruoyi.account.util.tencentMap.TencentMapUtil; |
| | | import com.ruoyi.account.util.weChat.EnvVersion; |
| | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.PointSetting; |
| | | import com.ruoyi.other.api.domain.Region; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.PointSettingClient; |
| | | import com.ruoyi.other.api.feignClient.RegionClient; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.feignClient.*; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | |
| | | @Resource |
| | | private CouponInfoClient couponInfoClient; |
| | | |
| | | @Resource |
| | | private UserCouponService userCouponService; |
| | | |
| | | |
| | | /** |
| | |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | //获取优惠券 |
| | | if(0 == old){ |
| | | List<CouponInfo> list = couponInfoClient.getCouponInfoByPersonType(4).getData(); |
| | | for (CouponInfo couponInfo : list) { |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setDelFlag(0); |
| | | userCoupon.setCreateTime(LocalDateTime.now()); |
| | | userCoupon.setAppUserId(appUser.getId()); |
| | | userCoupon.setCouponId(couponInfo.getId()); |
| | | LocalDateTime start = couponInfo.getPeriodStartTime().atTime(0, 0, 0); |
| | | LocalDateTime end = couponInfo.getPeriodEndTime().atTime(23, 59, 59); |
| | | if(couponInfo.getPeriodType() == 2){ |
| | | start = LocalDateTime.now(); |
| | | end = start.plusDays(couponInfo.getPeriodDays()); |
| | | } |
| | | userCoupon.setStartTime(start); |
| | | userCoupon.setEndTime(end); |
| | | userCouponService.save(userCoupon); |
| | | } |
| | | } |
| | | //变更等级 |
| | | vipUpgrade(appUser.getId()); |
| | |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) |
| | | .eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipCancelDay + " DAY) <= now()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setInviteUserId(null); |
| | | appUser.setShopId(null); |
| | | this.updateById(appUser); |
| | | UpdateWrapper<AppUser> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("invite_user_id", null).set("shop_id", null).eq("id", appUser.getId()); |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | //可更换推广人 |
| | | list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipChangeDay + " DAY) <= now()")); |
| | | list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .eq(AppUser::getStatus, 1).last(" and ADDDATE(ifnull(last_shop_time, create_time),INTERVAL " + vipChangeDay + " DAY) <= now()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | |
| | | import com.ruoyi.account.vo.UserPointDetailVO; |
| | | import com.ruoyi.account.vo.UserPointStatistics; |
| | | import com.ruoyi.account.vo.UserPointVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.PhoneNumberValidator; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private PointSettingService pointSettingService; |
| | | @Resource |
| | | private UserPointService userPointService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public UserPointVO getUserPoint(Long userId) { |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void transferPoint(BigDecimal point, String phone) { |
| | | public R transferPoint(Integer point, String phone) { |
| | | if (!PhoneNumberValidator.isValidChinaPhoneNumber(phone)) { |
| | | throw new ServiceException("无效的电话号码"); |
| | | return R.fail("无效的电话号码"); |
| | | } |
| | | |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | |
| | | |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userid); |
| | | if (vipSetting == null) { |
| | | throw new ServiceException("VIP 设置未找到"); |
| | | return R.fail("VIP 设置未找到"); |
| | | } |
| | | if (vipSetting.getId() == 0 && vipSetting.getVipGiftRole() == 0) { |
| | | throw new ServiceException("转赠积分权限未开启"); |
| | | return R.fail("转赠积分权限未开启"); |
| | | } |
| | | |
| | | AppUser appUser = appUserService.getById(userid); |
| | | if (appUser == null) { |
| | | throw new ServiceException("用户未找到"); |
| | | return R.fail("用户未找到"); |
| | | } |
| | | |
| | | PointSetting pointSetting = pointSettingService.getPointSettingByAppUserId(userid); |
| | | if (pointSetting == null) { |
| | | throw new ServiceException("积分设置未找到"); |
| | | return R.fail("积分设置未找到"); |
| | | } |
| | | // 可转赠积分总数 |
| | | long adjustedPoint = appUser.getAvailablePoint(); |
| | | |
| | | if (point.compareTo(new BigDecimal(adjustedPoint)) > 0) { |
| | | throw new ServiceException("转赠积分不足"); |
| | | Integer transferablePoint = appUser.getTransferablePoint(); |
| | | if (point > transferablePoint) { |
| | | return R.fail("转赠积分不足"); |
| | | } |
| | | |
| | | AppUser appUserForPhoe = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getPhone, phone)); |
| | | if (appUserForPhoe == null) { |
| | | throw new ServiceException("目标用户未找到"); |
| | | return R.fail("目标用户未找到"); |
| | | } |
| | | |
| | | appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point.intValue()); |
| | | appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point.intValue()); |
| | | Integer lavePoint1 = appUserForPhoe.getLavePoint(); |
| | | appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point); |
| | | appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point); |
| | | appUserForPhoe.setTransferablePoint(transferablePoint + point); |
| | | appUserForPhoe.setAvailablePoint(appUserForPhoe.getAvailablePoint() + point); |
| | | appUserService.updateById(appUserForPhoe); |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(12); |
| | | userPoint.setHistoricalPoint(lavePoint1); |
| | | userPoint.setVariablePoint(point); |
| | | userPoint.setBalance(appUserForPhoe.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUserForPhoe.getId()); |
| | | userPointService.save(userPoint); |
| | | |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | appUser.setLavePoint(lavePoint - point.intValue()); |
| | | appUser.setLavePoint(lavePoint - point); |
| | | Integer totalPoint = appUser.getTotalPoint(); |
| | | appUser.setTotalPoint(totalPoint - point.intValue()); |
| | | appUser.setTotalPoint(totalPoint - point); |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - point); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - point); |
| | | appUserService.updateById(appUser); |
| | | log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint()); |
| | | //构建积分流水记录 |
| | | userPoint = new UserPoint(); |
| | | userPoint.setType(13); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(point); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointService.save(userPoint); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | |
| | | return getVipSettingById(appUser.getVipId()); |
| | | } |
| | | |
| | | @Override |
| | | public void downUsers() { |
| | | //查出可能需要降级的人员 |
| | | List<Integer> vipIds = new ArrayList<>(); |
| | | vipIds.add(5); |
| | | vipIds.add(6); |
| | | vipIds.add(7); |
| | | List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list(); |
| | | VipSetting vipSetting5 = vipSettingClient.getVipSetting(5).getData(); |
| | | VipSetting vipSetting6 = vipSettingClient.getVipSetting(6).getData(); |
| | | VipSetting vipSetting7 = vipSettingClient.getVipSetting(7).getData(); |
| | | LocalDate now = LocalDate.now(); |
| | | //循环判断是否要展示 |
| | | if (list.size()>0){ |
| | | for (AppUser appUser : list){ |
| | | boolean danger = false; |
| | | if (appUser.getVipId()==5){ |
| | | extracted(vipSetting5, now,danger); |
| | | } |
| | | if (appUser.getVipId()==6){ |
| | | extracted(vipSetting6, now,danger); |
| | | } |
| | | if (appUser.getVipId()==7){ |
| | | extracted(vipSetting7, now,danger); |
| | | } |
| | | if (danger){ |
| | | appUser.setIsDanger(1); |
| | | }else { |
| | | appUser.setIsDanger(0); |
| | | } |
| | | } |
| | | appUserService.updateBatchById(list); |
| | | } |
| | | } |
| | | |
| | | private void extracted(VipSetting vipSetting5, LocalDate now,boolean danger) { |
| | | |
| | | if (vipSetting5.getKeepBuyPoint()!=null){ |
| | | //如果消费不为空,查找对应天数的消费积分 |
| | | List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,1).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); |
| | | //如果消费积分小于保级积分,设置用户降级标志并将降级信息 |
| | | Integer point = 0; |
| | | for (UserPoint userPoint : list1) { |
| | | point = point+userPoint.getVariablePoint(); |
| | | } |
| | | if (point<= vipSetting5.getKeepBuyPoint()){ |
| | | danger = true; |
| | | } |
| | | } |
| | | if (vipSetting5.getKeepSharePoint()!=null){ |
| | | //如果消费不为空,查找对应天数的消费积分 |
| | | List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,2).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); |
| | | //如果消费积分小于保级积分,设置用户降级标志并将降级信息 |
| | | Integer point = 0; |
| | | for (UserPoint userPoint : list1) { |
| | | point = point+userPoint.getVariablePoint(); |
| | | } |
| | | if (point<= vipSetting5.getKeepBuyPoint()){ |
| | | danger = true; |
| | | } |
| | | } |
| | | if (vipSetting5.getKeepShopPoint()!=null){ |
| | | //如果消费不为空,查找对应天数的消费积分 |
| | | List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,5).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list(); |
| | | //如果消费积分小于保级积分,设置用户降级标志并将降级信息 |
| | | Integer point = 0; |
| | | for (UserPoint userPoint : list1) { |
| | | point = point+userPoint.getVariablePoint(); |
| | | } |
| | | if (point<= vipSetting5.getKeepBuyPoint()){ |
| | | danger = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | public void sendVipCoupon(){ |
| | | //解绑推广人 |
| | | appUserService.unbindThePromoter(); |
| | | //降级检测 |
| | | appUserService.demotionDetection(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | try { |
| | | |
| | | |
| | | vipSettingService.downUsers(); |
| | | //降级检测 |
| | | appUserService.demotionDetection(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.account.util.payment.model.*; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.*; |
| | |
| | | //APPID |
| | | body.put("q7_AppId", appId); |
| | | //报备商户号 |
| | | body.put("qa_TradeMerchantNo", tradeMerchantNo); |
| | | body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852"); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | |
| | | |
| | | |
| | | public static String sign(JSONObject body) throws Exception{ |
| | | public static String sign(JSONObject body) { |
| | | Set<Map.Entry<String, Object>> entries = body.entrySet(); |
| | | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() { |
| | | public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) { |
| | | return (o1.getKey()).toString().compareTo(o2.getKey()); |
| | | return (o1.getKey()).compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
New file |
| | |
| | | package com.ruoyi.account.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/6 15:35 |
| | | */ |
| | | @Data |
| | | public class TransferPoint { |
| | | /** |
| | | * 转增积分 |
| | | */ |
| | | private Integer point; |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | private String phone; |
| | | } |
| | |
| | | SELECT * |
| | | FROM t_app_user ta |
| | | <where> |
| | | ta.del_flag = 0 |
| | | ta.del_flag = 0 and ta.status != 3 |
| | | <if test="null != appUser.name and '' != appUser.name"> |
| | | and ta.`name` like CONCAT('%',#{appUser.name},'%') |
| | | </if> |
| | |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.service.CommissionService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.util.payment.model.RefundCallbackResult; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.BaseSetting; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单取消支付回退 |
| | | * @param refundCallbackResult |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/refundPayMoneyCallback") |
| | | public void refundPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){ |
| | | R callback = orderService.refundPayMoneyCallback(refundCallbackResult); |
| | | if(callback.getCode() == 200){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消订单快递费回退 |
| | | * @param refundCallbackResult |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/refundExpressPayMoneyCallback") |
| | | public void refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){ |
| | | R callback = orderService.refundExpressPayMoneyCallback(refundCallbackResult); |
| | | if(callback.getCode() == 200){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | @GetMapping("/getGoodsPrice") |
| | | public R<Price> getGoodsPrice(Long appUserId, Integer goodsId, Integer shopId){ |
| | | AppUser appUser = appUserClient.getAppUserById(appUserId); |
| | | Price price = shoppingCartService.getPrice(appUser, goodsId, shopId); |
| | | Price price = shoppingCartService.getPrice(appUser, goodsId, 1, shopId); |
| | | return R.ok(price); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.util.payment.model.RefundCallbackResult; |
| | | import com.ruoyi.order.vo.*; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | |
| | |
| | | * 返回订单支付金额和回退积分和会员等级 |
| | | * @param order |
| | | */ |
| | | void refundPayMoney(Order order); |
| | | |
| | | |
| | | R refundPayMoney(Order order); |
| | | |
| | | /** |
| | | * 取消订单后回调处理 |
| | | * @return |
| | | */ |
| | | R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult); |
| | | |
| | | |
| | | /** |
| | | * 取消订单快递费回退 |
| | | * @return |
| | | */ |
| | | R refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult); |
| | | |
| | | |
| | | /** |
| | | * 收货操作 |
| | | * @param orderId |
| | |
| | | R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult); |
| | | |
| | | |
| | | Price getPrice(AppUser appUser, Integer goodsId, Integer shopId); |
| | | Price getPrice(AppUser appUser, Integer goodsId, Integer type, Integer shopId); |
| | | |
| | | |
| | | /** |
| | |
| | | bdmdsj_point += orderGood.getBoundShopSuperiorsPoints(); |
| | | } |
| | | //直推上级 |
| | | AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId()); |
| | | if(null != inviteUser){ |
| | | BigDecimal balance = inviteUser.getBalance(); |
| | | Integer lavePoint = inviteUser.getLavePoint(); |
| | | if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | if(ztsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | if(null != appUser.getInviteUserId()){ |
| | | AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId()); |
| | | if(null != inviteUser){ |
| | | BigDecimal balance = inviteUser.getBalance(); |
| | | Integer lavePoint = inviteUser.getLavePoint(); |
| | | if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point); |
| | | inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point); |
| | | inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1); |
| | | inviteUser.setTotalAvailablePoint(inviteUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getSharePointGift()){ |
| | | inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1); |
| | | if(ztsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point); |
| | | inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point); |
| | | inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1); |
| | | inviteUser.setTotalAvailablePoint(inviteUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getSharePointGift()){ |
| | | inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point); |
| | | } |
| | | inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point); |
| | | } |
| | | appUserClient.editAppUserById(inviteUser); |
| | | //添加明细记录 |
| | | if(!inviteUser.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(inviteUser.getId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(ztsj_price); |
| | | balanceChangeRecord.setAfterAmount(inviteUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | //添加积分明细 |
| | | if(!inviteUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(2); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(ztsj_point); |
| | | userPoint.setBalance(inviteUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(inviteUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(inviteUser.getId()); |
| | | appUserClient.editAppUserById(inviteUser); |
| | | //添加明细记录 |
| | | if(!inviteUser.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(inviteUser.getId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(ztsj_price); |
| | | balanceChangeRecord.setAfterAmount(inviteUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | //添加积分明细 |
| | | if(!inviteUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(2); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(ztsj_point); |
| | | userPoint.setBalance(inviteUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(inviteUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(inviteUser.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //直帮上级 |
| | | AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData(); |
| | | if(null != superiorLeader){ |
| | |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.model.OrderBalancePayment; |
| | | import com.ruoyi.order.model.OrderGood; |
| | | import com.ruoyi.order.model.RefundPass; |
| | | import com.ruoyi.order.service.CommissionService; |
| | | import com.ruoyi.order.service.OrderBalancePaymentService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.RefundPassService; |
| | | import com.ruoyi.order.util.ExpressDeliveryUtil; |
| | | import com.ruoyi.order.util.payment.PaymentUtil; |
| | | import com.ruoyi.order.util.payment.model.RefundCallbackResult; |
| | | import com.ruoyi.order.util.payment.model.RefundResult; |
| | | import com.ruoyi.order.util.vo.QueryKD100Vo; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.*; |
| | |
| | | |
| | | @Resource |
| | | private GoodsClient goodsClient; |
| | | |
| | | @Resource |
| | | private RefundPassService refundPassService; |
| | | |
| | | |
| | | |
| | |
| | | return R.fail("无效的操作"); |
| | | } |
| | | order.setOrderStatus(5); |
| | | this.updateById(order); |
| | | refundPayMoney(order); |
| | | return R.ok(); |
| | | R r = refundPayMoney(order); |
| | | if(200 == r.getCode()){ |
| | | this.updateById(order); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | |
| | |
| | | * 返回订单支付金额和回退积分和会员等级 |
| | | * @param order |
| | | */ |
| | | public void refundPayMoney(Order order){ |
| | | public R refundPayMoney(Order order){ |
| | | //开始退款 |
| | | Integer payMethod = order.getPayMethod(); |
| | | BigDecimal paymentAmount = order.getPaymentAmount(); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | if(1 == payMethod){ |
| | | //微信退款 |
| | | RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), paymentAmount.doubleValue(), "/order/order/refundPayMoneyCallback"); |
| | | if("100".equals(refund.getRa_Status())){ |
| | | order.setRefundStatus(1); |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(refund.getRc_CodeMsg()); |
| | | } |
| | | } |
| | | if(2 == payMethod){ |
| | | //余额退款 |
| | |
| | | } |
| | | appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //查询最后一次的消费订单 |
| | | Order order1 = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, order.getAppUserId()).eq(Order::getPayStatus, 2).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(2, 3, 4, 8)).ne(Order::getId, order.getId()).last(" order by create_time desc limit 0, 1")); |
| | | if(null != order1){ |
| | | appUser.setLastShopTime(order1.getCreateTime()); |
| | | }else{ |
| | | appUser.setLastShopTime(LocalDateTime.MIN); |
| | | } |
| | | |
| | | //构建账户余额流水明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | if(3 == payMethod){ |
| | | //积分退款 |
| | | appUser.setLavePoint(appUser.getLavePoint() + order.getPoint()); |
| | | |
| | | //开始运费退款,积分支付,运费是单独进行支付的,所以需要单独退款 |
| | | if(null != order.getExpressAmount() && BigDecimal.ZERO.compareTo(order.getExpressAmount()) < 0){ |
| | | BigDecimal expressAmount = order.getExpressAmount(); |
| | | if(1 == order.getExpressPayMethod()){ |
| | | //微信退款 |
| | | RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), expressAmount.doubleValue(), "/order/order/refundExpressPayMoneyCallback"); |
| | | if("100".equals(refund.getRa_Status())){ |
| | | order.setRefundStatus(1); |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(refund.getRc_CodeMsg()); |
| | | } |
| | | } |
| | | if(2 == order.getExpressPayMethod()){ |
| | | //余额退款 |
| | |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | } |
| | | |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | //积分退款 |
| | | appUser.setLavePoint(appUser.getLavePoint() + order.getPoint()); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + order.getPoint()); |
| | | UserPoint userPoint1 = new UserPoint(); |
| | | userPoint1.setType(11); |
| | | userPoint1.setObjectId(order.getId()); |
| | | List<UserPoint> data = userPointClient.getUserPointList(userPoint1).getData(); |
| | | Integer transferablePoint = order.getPoint(); |
| | | if(data.size() > 0){ |
| | | UserPoint userPoint = data.get(0); |
| | | transferablePoint = Integer.valueOf(userPoint.getExtention()); |
| | | } |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint); |
| | | |
| | | //构建积分流水明细 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | //退回获得的消费积分 |
| | | //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | Integer getPoint = order.getGetPoint(); |
| | | boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId()); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData(); |
| | | int earnPoint1 = getPoint; |
| | | int earnPoint1 = 0; |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser.setLavePoint(lavePoint - getPoint); |
| | | appUser.setShopPoint(appUser.getShopPoint() - earnPoint1); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - earnPoint1); |
| | | appUser.setShopPoint(appUser.getShopPoint() - getPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() - getPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1); |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - getPoint); |
| | | if(vipDemotion){ |
| | | appUser.setVipId(appUser.getVipId() - 1); |
| | | } |
| | | |
| | | //构建积分流水明细 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | Integer point = appUser.getLavePoint() - lavePoint; |
| | | userPoint.setVariablePoint(point >= 0 ? point : point * -1); |
| | | userPoint.setVariablePoint(getPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 取消订单后回调处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult) { |
| | | String code = refundCallbackResult.getR3_RefundOrderNo().substring(1); |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() == 1 || order.getOrderStatus() == 6){ |
| | | return R.ok(); |
| | | } |
| | | order.setRefundCode(refundCallbackResult.getR5_RefundTrxNo()); |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | this.updateById(order); |
| | | |
| | | //退回获得的消费积分 |
| | | //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | Integer getPoint = order.getGetPoint(); |
| | | boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId()); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser.setShopPoint(appUser.getShopPoint() - getPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() - getPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1); |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - getPoint); |
| | | if(vipDemotion){ |
| | | appUser.setVipId(appUser.getVipId() - 1); |
| | | } |
| | | |
| | | //构建积分流水明细 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(getPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消订单快递费回退 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult) { |
| | | String code = refundCallbackResult.getR3_RefundOrderNo().substring(1); |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() == 1 || order.getOrderStatus() == 6){ |
| | | return R.ok(); |
| | | } |
| | | order.setRefundCode(refundCallbackResult.getR5_RefundTrxNo()); |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | this.updateById(order); |
| | | |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | //积分退款 |
| | | appUser.setLavePoint(appUser.getLavePoint() + order.getPoint()); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + order.getPoint()); |
| | | UserPoint userPoint1 = new UserPoint(); |
| | | userPoint1.setType(11); |
| | | userPoint1.setObjectId(order.getId()); |
| | | List<UserPoint> data = userPointClient.getUserPointList(userPoint1).getData(); |
| | | Integer transferablePoint = order.getPoint(); |
| | | if(data.size() > 0){ |
| | | UserPoint userPoint = data.get(0); |
| | | transferablePoint = Integer.valueOf(userPoint.getExtention()); |
| | | } |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint); |
| | | |
| | | //构建积分流水明细 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | |
| | | //退回获得的消费积分 |
| | | //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 |
| | | lavePoint = appUser.getLavePoint(); |
| | | Integer getPoint = order.getGetPoint(); |
| | | boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId()); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser.setShopPoint(appUser.getShopPoint() - getPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() - getPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1); |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - getPoint); |
| | | if(vipDemotion){ |
| | | appUser.setVipId(appUser.getVipId() - 1); |
| | | } |
| | | |
| | | //构建积分流水明细 |
| | | userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(getPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 会员降级检测 |
| | | */ |
| | |
| | | refundPass.setStatus(2); |
| | | } |
| | | refundPass.setPassRemark(passRemark); |
| | | this.updateById(refundPass); |
| | | //仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分 |
| | | if(refundPass.getRefundMethod() == 2 && 2 == status){ |
| | | Order order = orderService.getById(refundPass.getOrderId()); |
| | | order.setOrderStatus(6); |
| | | orderService.updateById(order); |
| | | //返回订单支付金额和回退积分和会员等级 |
| | | orderService.refundPayMoney(order); |
| | | R r = orderService.refundPayMoney(order); |
| | | if(200 != r.getCode()){ |
| | | return r; |
| | | } |
| | | orderService.updateById(order); |
| | | } |
| | | this.updateById(refundPass); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | return R.fail("操作失败"); |
| | | } |
| | | refundPass.setStatus(2); |
| | | this.updateById(refundPass); |
| | | //仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分 |
| | | Order order = orderService.getById(refundPass.getOrderId()); |
| | | order.setOrderStatus(6); |
| | | orderService.updateById(order); |
| | | //返回订单支付金额和回退积分和会员等级 |
| | | orderService.refundPayMoney(order); |
| | | R r = orderService.refundPayMoney(order); |
| | | if(200 != r.getCode()){ |
| | | return r; |
| | | } |
| | | this.updateById(refundPass); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | List<Integer> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList()); |
| | | //查询符合商品类型的商品数据 |
| | | List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds)); |
| | | List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) |
| | | .in(ShoppingCart::getGoodsId, goodsIds).eq(ShoppingCart::getStatus, 1)); |
| | | //构建返回数据 |
| | | List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null); |
| | | return page; |
| | |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | public Price getPrice(AppUser appUser, Integer goodsId, Integer shopId){ |
| | | public Price getPrice(AppUser appUser, Integer goodsId, Integer type, Integer shopId){ |
| | | //获取支付价格 |
| | | //秒杀活动>门店特价>地区价格>会员价格 |
| | | //判断是否有秒杀活动 |
| | |
| | | info.setGoodsId(goodsId); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null == goodsSeckill){ |
| | | //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格 |
| | | if(null == goodsSeckill || type == 1){ |
| | | //没有秒杀价,则判断门店特价 |
| | | GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice(); |
| | | goodsBargainPrice.setGoodsId(goodsId); |
| | |
| | | @Override |
| | | public Long addGoods(ShoppingCart shoppingCart) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | shoppingCart.setAppUserId(userid); |
| | | this.save(shoppingCart); |
| | | return shoppingCart.getId(); |
| | | ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) |
| | | .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1)); |
| | | if(null != one){ |
| | | one.setNumber(one.getNumber() + shoppingCart.getNumber()); |
| | | this.updateById(one); |
| | | return one.getId(); |
| | | }else{ |
| | | shoppingCart.setAppUserId(userid); |
| | | shoppingCart.setStatus(1); |
| | | this.save(shoppingCart); |
| | | return shoppingCart.getId(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | JSONArray objects = JSON.parseArray(goodsJson); |
| | | Long id = objects.getJSONObject(0).getLong("id"); |
| | | Integer num1 = objects.getJSONObject(0).getInteger("num"); |
| | | Integer type = objects.getJSONObject(0).getInteger("type"); |
| | | ShoppingCart shoppingCart = new ShoppingCart(); |
| | | shoppingCart.setAppUserId(userid); |
| | | shoppingCart.setGoodsId(id.intValue()); |
| | | shoppingCart.setNumber(num1); |
| | | Long shoppingCarId = addGoods(shoppingCart); |
| | | confirmOrder.setGoodsJson("[{\"id\": " + shoppingCarId + ", \"num\": " + num1 + "}]"); |
| | | shoppingCart.setType(type); |
| | | shoppingCart.setStatus(0); |
| | | this.save(shoppingCart); |
| | | confirmOrder.setGoodsJson("[{\"id\": " + shoppingCart.getId() + ", \"num\": " + num1 + ",\"type\":" + type + "}]"); |
| | | } |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | Integer shopId = confirmOrder.getShopId(); |
| | |
| | | confirmOrderVo.setShopName(shop.getName()); |
| | | //现金支付 |
| | | if(confirmOrder.getPaymentType() == 1){ |
| | | BigDecimal bigDecimal = goodsList.stream().map(MyShoppingCartVo::getCash).reduce(BigDecimal::add).get(); |
| | | BigDecimal bigDecimal = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | bigDecimal = bigDecimal.add(myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber()))); |
| | | } |
| | | confirmOrderVo.setOrderMoney(bigDecimal); |
| | | }else{ |
| | | int sum = goodsList.stream().mapToInt(MyShoppingCartVo::getPoint).sum(); |
| | | int sum = 0; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | sum += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber()); |
| | | } |
| | | confirmOrderVo.setOrderPoint(sum); |
| | | } |
| | | //查询当前是否有订单活动 |
| | |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | MyShoppingCartVo vo = new MyShoppingCartVo(); |
| | | vo.setId(shoppingCart.getId().toString()); |
| | | vo.setType(shoppingCart.getType()); |
| | | vo.setGoodsId(goods.getId()); |
| | | vo.setHomePicture(goods.getHomePagePicture()); |
| | | vo.setName(goods.getName()); |
| | |
| | | } |
| | | } |
| | | //获取支付价格 |
| | | Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId); |
| | | Price price = getPrice(appUser, shoppingCart.getGoodsId(), shoppingCart.getType(), shopId); |
| | | if(null == price){ |
| | | price = new Price(); |
| | | //使用商品的基础价格 |
| | |
| | | //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) |
| | | if(null == goods.getPurchaseLimit() || -1 == goods.getPurchaseLimit()){ |
| | | vo.setPurchaseLimit(false); |
| | | vo.setPurchaseLimitNum(-1); |
| | | }else{ |
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8))); |
| | | List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList()); |
| | |
| | | //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit()){ |
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8))); |
| | | List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).notIn(Order::getOrderStatus, Arrays.asList(5, 6))); |
| | | List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList()); |
| | | int sum = 0; |
| | | if(orderIds.size() > 0){ |
| | |
| | | //调起微信支付 |
| | | String goodsNames = goodsList.stream().map(MyShoppingCartVo::getName).collect(Collectors.joining("\n")); |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber(), paymentMoney.doubleValue(), order.getOrderType() == 1 ? "购买服务商品" : "购买单品商品", |
| | | goodsNames, "", "/order/shopping-cart/shoppingCartPaymentCallback", appUser.getWxOpenid(), ""); |
| | | goodsNames, "", "/order/shopping-cart/shoppingCartPaymentCallback", appUser.getWxOpenid(), null); |
| | | if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){ |
| | | return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg()); |
| | | } |
| | | String rc_result = uniPayResult.getRc_Result(); |
| | | JSONObject jsonObject = JSON.parseObject(rc_result); |
| | | jsonObject.put("orderId", order.getId().toString()); |
| | | //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。 |
| | | long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC); |
| | | redisTemplate.opsForZSet().add("OrderPayment", order.getOrderNumber(), second); |
| | | return R.ok(rc_result); |
| | | return R.ok(jsonObject.toJSONString()); |
| | | } |
| | | //账户余额 |
| | | BigDecimal redPacketAmount = BigDecimal.ZERO; |
| | |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(earnPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | } |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | |
| | | if(shoppingCartPayment.getFreightPaymentType() == 1){ |
| | | //调起微信支付 |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber() + appUser.getId(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费", |
| | | "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), ""); |
| | | "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), null); |
| | | if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){ |
| | | return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg()); |
| | | } |
| | | String rc_result = uniPayResult.getRc_Result(); |
| | | JSONObject jsonObject = JSON.parseObject(rc_result); |
| | | jsonObject.put("orderId", order.getId().toString()); |
| | | //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。 |
| | | long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC); |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber() + appUser.getId(), second); |
| | | return R.ok(rc_result); |
| | | return R.ok(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | //扣减订单支付积分 |
| | | appUser.setLavePoint(appUser.getLavePoint() - orderPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint); |
| | | //可转增积分 |
| | | Integer transferablePoint = appUser.getTransferablePoint(); |
| | | Integer tra = 0; |
| | | if(transferablePoint > 0){ |
| | | tra = transferablePoint - orderPoint; |
| | | appUser.setTransferablePoint(tra >= 0 ? tra : 0); |
| | | } |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - orderPoint); |
| | | |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(orderPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | |
| | | lavePoint = appUser.getLavePoint(); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | //扣减订单支付积分 |
| | | appUser.setLavePoint(appUser.getLavePoint() - orderPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint); |
| | | |
| | | appUser.setShopPoint(appUser.getShopPoint() + earnPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | Integer point = appUser.getLavePoint() - lavePoint; |
| | | userPoint.setVariablePoint(point >= 0 ? point : point * -1); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(earnPoint > 0){ |
| | | userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | //如果有运费,需要先扣除账户积分,再进行支付。支付成功后修改订单状态,未支付成功则回退积分,删除的订单 |
| | | if(expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | if(shoppingCartPayment.getFreightPaymentType() == 2){ |
| | |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + earnPoint1); |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | if(earnPoint > 0){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | } |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | |
| | | Integer earnPoint = order.getGetPoint(); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | Integer orderPoint = order.getPoint(); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = earnPoint; |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = new BigDecimal(earnPoint1).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | //扣减订单支付积分 |
| | | appUser.setLavePoint(appUser.getLavePoint() - orderPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint); |
| | | |
| | | appUser.setShopPoint(appUser.getShopPoint() + earnPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | Integer point = appUser.getLavePoint() - lavePoint; |
| | | userPoint.setVariablePoint(point >= 0 ? point : point * -1); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | | //自提 |
| | |
| | | import cn.hutool.http.*; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.order.util.payment.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | //APPID |
| | | body.put("q7_AppId", appId); |
| | | //报备商户号 |
| | | body.put("qa_TradeMerchantNo", tradeMerchantNo); |
| | | body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852"); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | //退款金额 |
| | | body.put("p4_RefundAmount", refundAmount); |
| | | //服务器异步通知地址 |
| | | body.put("p6_NotifyUrl", notifyUrl); |
| | | body.put("p6_NotifyUrl", callbackUrl + notifyUrl); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | |
| | | |
| | | |
| | | public static String sign(JSONObject body) throws Exception{ |
| | | public static String sign(JSONObject body) { |
| | | Set<Map.Entry<String, Object>> entries = body.entrySet(); |
| | | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() { |
| | | public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) { |
| | | return (o1.getKey()).toString().compareTo(o2.getKey()); |
| | | return (o1.getKey()).compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | |
| | | @ApiOperation(value = "获取基础配置", tags = {"管理后台-基础配置"}) |
| | | public R<BaseSetting> getBaseSetting(@RequestParam("id") Integer id){ |
| | | BaseSetting baseSetting = baseSettingService.getById(id); |
| | | return R.ok(baseSetting); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getBaseSetting1") |
| | | @ApiOperation(value = "获取基础配置", tags = {"小程序-基础配置"}) |
| | | public R<BaseSetting> getBaseSetting1(@RequestParam("id") Integer id){ |
| | | BaseSetting baseSetting = baseSettingService.getById(id); |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | VipSetting vipSetting = vipSettingService.getById(appUser.getVipId()); |
| | |
| | | return R.ok(baseSetting); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存设置 |
| | | */ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据类型获取有效优惠券列表 |
| | | */ |
| | | @PostMapping("/getCouponInfoByPersonType") |
| | | public R<List<CouponInfo>> getCouponInfoByPersonType(@RequestParam("personType") Integer personType){ |
| | | List<CouponInfo> list = couponInfoService.list(new LambdaUpdateWrapper<CouponInfo>().eq(CouponInfo::getPersonType, personType).eq(CouponInfo::getDelFlag, 0).eq(CouponInfo::getShelfStatus, 1).last(" and now() between period_start_time and period_end_time")); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @PostMapping("/getNowOrderActivityInfo") |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .eq(OrderActivityInfo::getIsShelf, 1).eq(OrderActivityInfo::getStatus, 1) |
| | | .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1")); |
| | | return R.ok(one); |
| | | } |
| | |
| | | @ApiOperation(value = "广告管理-分享管理-审核列表", tags = {"管理后台"}) |
| | | @GetMapping("/manage/auth/list") |
| | | public R<Page<Share>> authmanagelist(String name, Integer addType, @RequestParam Integer pageNum, Integer pageSize) { |
| | | Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize)); |
| | | Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).orderByAsc(Share::getAuditStatus).page(Page.of(pageNum, pageSize)); |
| | | for (Share record : page.getRecords()) { |
| | | if (record.getAddType() == 2) { |
| | | AppUser appUserById = appUserClient.getAppUserById(Long.valueOf(record.getObjectId())); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PutMapping("/freezingOrThawing") |
| | | @ApiOperation(value = "门店管理-冻结/解冻门店", tags = {"管理后台-门店管理"}) |
| | | public R freezingOrThawing(@RequestParam("id") Integer id, @RequestParam("status") Integer status){ |
| | | Shop shop = shopService.getById(id); |
| | | if(shop.getStatus().equals(status)){ |
| | | return R.fail("不能重复操作"); |
| | | } |
| | | shop.setStatus(status); |
| | | shopService.updateById(shop); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "门店列表", tags = {"管理后台-门店管理"}) |
| | | public R<IPage<Shop>> list(@ApiParam("页码") @RequestParam Integer pageNum,@ApiParam("每一页数据大小") Integer pageSize,Shop shop){ |
| | |
| | | @ResponseBody |
| | | @PostMapping("/getShopByUserId") |
| | | public R<List<Shop>> getShopByUserId(@RequestParam("id") Long id){ |
| | | List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).list(); |
| | | List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).eq(Shop::getDelFlag,0).list(); |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"}) |
| | | public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude, Integer goodsId){ |
| | | String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false); |
| | | if(null == city){ |
| | | city = "510100"; |
| | | } |
| | | city = city.substring(0, 4) + "00"; |
| | | LambdaQueryWrapper<Shop> wrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getCityCode, city); |
| | | if(null != goodsId){ |
| | | Goods goods = goodsService.getById(goodsId); |
| | | if(1 == goods.getType() && 1 == goods.getAppointStore()){ |
| | | List<Integer> collect = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goods)).stream().map(GoodsShop::getShopId).collect(Collectors.toList()); |
| | | List<Integer> collect = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goods.getId())) |
| | | .stream().map(GoodsShop::getShopId).collect(Collectors.toList()); |
| | | if(collect.size() > 0){ |
| | | wrapper.in(Shop::getId, collect); |
| | | } |
| | |
| | | @ApiOperation(value = "添加编辑", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> add(@RequestBody Technician technician) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | if (technician.getId()==null){ |
| | | technician.setSubscribeStatus(2); |
| | | } |
| | | technician.setShopId(objectId); |
| | | technicianService.saveOrUpdate(technician); |
| | | return R.ok(); |
| | |
| | | * @since 2024-11-20 |
| | | */ |
| | | public interface GoodsMapper extends BaseMapper<Goods> { |
| | | |
| | | List<Goods> selectListByShopId(PageInfo<Goods> pageInfo, @Param("shopId") Integer shopId,@Param("vip") Integer vip); |
| | | |
| | | IPage<Goods> selectManageGoodsList(@Param("page") IPage<Goods> page, @Param("goods") Goods goods); |
| | |
| | | * @param name |
| | | * @return |
| | | */ |
| | | List<GoodsVO> goodsList(PageInfo<GoodsVO> pageInfo, @Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name); |
| | | List<GoodsVO> goodsList(PageInfo<GoodsVO> pageInfo, @Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name, @Param("vip") Integer vip); |
| | | } |
| | |
| | | |
| | | VipSetting getVipSettingByUserId(Long userId); |
| | | |
| | | void downUsers(); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.vo.Price; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.vo.GetGoodsBargainPrice; |
| | | import com.ruoyi.other.api.vo.GetSeckillActivityInfo; |
| | | import com.ruoyi.other.enums.GoodsStatus; |
| | | import com.ruoyi.other.mapper.GoodsAreaMapper; |
| | | import com.ruoyi.other.mapper.GoodsMapper; |
| | |
| | | private GoodsAreaService goodsAreaService; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private SeckillActivityInfoService seckillActivityInfoService; |
| | | @Resource |
| | | private GoodsSeckillService goodsSeckillService; |
| | | @Resource |
| | | private GoodsBargainPriceService goodsBargainPriceService; |
| | | @Resource |
| | | private GoodsBargainPriceDetailService goodsBargainPriceDetailService; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<GoodsVO> goodsList(Goods search) { |
| | | PageInfo<GoodsVO> pageInfo = new PageInfo(search.getPageCurr(), search.getPageSize()); |
| | | List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName()); |
| | | Long userId = null; |
| | | Integer vipId = 0; |
| | | String provinceCode = null; |
| | | String cityCode = null; |
| | | String districtCode = null; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | userId = tokenService.getLoginUserApplet().getUserid(); |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | vipId = appUser.getVipId(); |
| | | provinceCode = appUser.getProvinceCode(); |
| | | cityCode = appUser.getCityCode(); |
| | | districtCode = appUser.getDistrictCode(); |
| | | } |
| | | List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName(), vipId); |
| | | for (GoodsVO goods : list) { |
| | | //游客展示基础售价 |
| | | if(null != userId){ |
| | | R<Price> r = remoteOrderGoodsClient.getGoodsPrice(userId, goods.getGoodsId(), null); |
| | | if (null != r.getData()){ |
| | | Price price = r.getData(); |
| | | goods.setSellingPrice(price.getCash()); |
| | | goods.setIntegral(price.getPoint()); |
| | | } |
| | | Price price = getPrice(vipId, goods.getGoodsId(), 1, null, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | goods.setSellingPrice(price.getCash()); |
| | | goods.setIntegral(price.getPoint()); |
| | | } |
| | | } |
| | | return pageInfo.setRecords(list); |
| | |
| | | throw new NullPointerException("商品ID不能为空"); |
| | | } |
| | | |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); |
| | | BigDecimal sellingPrice = BigDecimal.ZERO; |
| | | Integer integral = 0; |
| | | |
| | | GoodsArea goodsArea = goodsAreaMapper.selectOne(new LambdaQueryWrapper<GoodsArea>() |
| | | .eq(GoodsArea::getGoodsId, goodsId) |
| | | .eq(GoodsArea::getVip, appUser.getVipId()) |
| | | .eq(GoodsArea::getProvinceCode, appUser.getProvinceCode()) |
| | | .eq(StringUtils.isNotEmpty(appUser.getCityCode()), GoodsArea::getCityCode, appUser.getCityCode()) |
| | | .eq(StringUtils.isNotEmpty(appUser.getDistrictCode()), GoodsArea::getDistrictsCode, appUser.getDistrictCode())); |
| | | |
| | | if (Objects.nonNull(goodsArea)){ |
| | | sellingPrice = goodsArea.getSellingPrice(); |
| | | integral = goodsArea.getIntegral(); |
| | | }else { |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); |
| | | GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>() |
| | | .eq(GoodsVip::getVip, vipSetting.getId()) |
| | | .eq(GoodsVip::getGoodsId, goodsId)); |
| | | if(null != goodsVip){ |
| | | sellingPrice = goodsVip.getSellingPrice(); |
| | | integral = goodsVip.getIntegral(); |
| | | } |
| | | Integer vipId = 0; |
| | | String provinceCode = null; |
| | | String cityCode = null; |
| | | String districtCode = null; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | vipId = appUser.getVipId(); |
| | | provinceCode = appUser.getProvinceCode(); |
| | | cityCode = appUser.getCityCode(); |
| | | districtCode = appUser.getDistrictCode(); |
| | | } |
| | | |
| | | Goods goods = this.getById(goodsId); |
| | |
| | | BeanUtils.copyBeanProp(goodsVO, goods); |
| | | goodsVO.setGoodsId(goods.getId()); |
| | | goodsVO.setGoodsName(goods.getName()); |
| | | goodsVO.setSellingPrice(sellingPrice); |
| | | goodsVO.setIntegral(integral); |
| | | Price price = getPrice(vipId, goods.getId(), 1, null, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | goodsVO.setSellingPrice(price.getCash()); |
| | | goodsVO.setIntegral(price.getPoint()); |
| | | } |
| | | |
| | | if(goods.getType() == 1){ |
| | | if(goods.getAppointStore() == 2){ |
| | |
| | | |
| | | @Override |
| | | public List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); |
| | | return goodsMapper.selectListByShopId(pageInfo, shopId, vipSetting.getId()); |
| | | Integer vipId = 0; |
| | | String provinceCode = null; |
| | | String cityCode = null; |
| | | String districtCode = null; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | vipId = appUser.getVipId(); |
| | | provinceCode = appUser.getProvinceCode(); |
| | | cityCode = appUser.getCityCode(); |
| | | districtCode = appUser.getDistrictCode(); |
| | | } |
| | | List<Goods> goods = goodsMapper.selectListByShopId(pageInfo, shopId, vipId); |
| | | for (Goods good : goods) { |
| | | Price price = getPrice(vipId, good.getId(), 1, shopId, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | good.setSellingPrice(price.getCash()); |
| | | good.setIntegral(price.getPoint()); |
| | | } |
| | | } |
| | | return goods; |
| | | } |
| | | |
| | | @Override |
| | |
| | | goodsArea1.setGoodsAreaList(goodsAreas); |
| | | return goodsArea1; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据商品的价格配置体系获取商品当前的价格 |
| | | * @param vip |
| | | * @param goodsId |
| | | * @param type 1普通商品,2秒杀商品 |
| | | * @param shopId |
| | | * @param provinceCode |
| | | * @param cityCode |
| | | * @param districtCode |
| | | * @return |
| | | */ |
| | | public Price getPrice(Integer vip, Integer goodsId, Integer shopId, Integer type, String provinceCode, String cityCode, String districtCode){ |
| | | //获取支付价格 |
| | | //秒杀活动>门店特价>地区价格>会员价格 |
| | | //判断是否有秒杀活动 |
| | | Price price = new Price(); |
| | | SeckillActivityInfo one = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodsId) |
| | | .eq(SeckillActivityInfo::getIsShelves, 1).eq(SeckillActivityInfo::getDelFlag, 0) |
| | | .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) order by create_time desc limit 0, 1")); |
| | | GoodsSeckill goodsSeckill = null; |
| | | if(null != one){ |
| | | goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId()).eq(GoodsSeckill::getVip, vip)); |
| | | } |
| | | //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格 |
| | | if(null == goodsSeckill || type == 1){ |
| | | //没有秒杀价,则判断门店特价 |
| | | GoodsBargainPriceDetail bargainPriceDetail = null; |
| | | if (shopId != null){ |
| | | GoodsBargainPrice priceServiceOne = goodsBargainPriceService.getOne(new LambdaQueryWrapper<GoodsBargainPrice>().eq(GoodsBargainPrice::getGoodsId, goodsId).eq(GoodsBargainPrice::getShopId, shopId) |
| | | .eq(GoodsBargainPrice::getDelFlag, 0).eq(GoodsBargainPrice::getAuditStatus, 1).last(" order by create_time desc limit 0, 1")); |
| | | if(null != priceServiceOne){ |
| | | bargainPriceDetail = goodsBargainPriceDetailService.getOne(new LambdaQueryWrapper<GoodsBargainPriceDetail>().eq(GoodsBargainPriceDetail::getGoodsBargainPriceId, priceServiceOne.getId()).eq(GoodsBargainPriceDetail::getVip, vip)); |
| | | } |
| | | } |
| | | if(null == bargainPriceDetail){ |
| | | //没有门店特价,判断地区价格配置 |
| | | LambdaQueryWrapper<GoodsArea> queryWrapper = new LambdaQueryWrapper<GoodsArea>().eq(GoodsArea::getGoodsId, goodsId).eq(GoodsArea::getVip, vip); |
| | | if(StringUtils.isNotEmpty(districtCode)){ |
| | | queryWrapper.eq(GoodsArea::getDistrictsCode, districtCode); |
| | | } |
| | | if(StringUtils.isNotEmpty(cityCode)){ |
| | | queryWrapper.eq(GoodsArea::getCityCode, cityCode); |
| | | } |
| | | if(StringUtils.isNotEmpty(provinceCode)){ |
| | | queryWrapper.eq(GoodsArea::getProvinceCode, provinceCode); |
| | | } |
| | | GoodsArea goodsArea = goodsAreaService.getOne(queryWrapper); |
| | | if(null == goodsArea){ |
| | | //没有地区价格,则使用会员价格 |
| | | GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>().eq(GoodsVip::getGoodsId, goodsId).eq(GoodsVip::getVip, vip)); |
| | | if(null == goodsVip){ |
| | | //没有配置价格,直接使用原始基础价格 |
| | | return null; |
| | | }else{ |
| | | //构建价格数据 |
| | | if(goodsVip.getCashPayment() == 1 && goodsVip.getPointPayment() == 1){ |
| | | price.setCash(goodsVip.getSellingPrice()); |
| | | price.setPoint(goodsVip.getIntegral()); |
| | | } |
| | | if(goodsVip.getCashPayment() == 1 && goodsVip.getPointPayment() == 0){ |
| | | price.setCash(goodsVip.getSellingPrice()); |
| | | } |
| | | if(goodsVip.getCashPayment() == 0 && goodsVip.getPointPayment() == 1){ |
| | | price.setPoint(goodsVip.getIntegral()); |
| | | } |
| | | price.setCashPayment(goodsVip.getCashPayment() == 1); |
| | | price.setPointPayment(goodsVip.getPointPayment() == 1); |
| | | } |
| | | }else{ |
| | | //构建价格数据 |
| | | if(goodsArea.getCashPayment() == 1 && goodsArea.getPointPayment() == 1){ |
| | | price.setCash(goodsArea.getSellingPrice()); |
| | | price.setPoint(goodsArea.getIntegral()); |
| | | } |
| | | if(goodsArea.getCashPayment() == 1 && goodsArea.getPointPayment() == 0){ |
| | | price.setCash(goodsArea.getSellingPrice()); |
| | | } |
| | | if(goodsArea.getCashPayment() == 0 && goodsArea.getPointPayment() == 1){ |
| | | price.setPoint(goodsArea.getIntegral()); |
| | | } |
| | | price.setCashPayment(goodsArea.getCashPayment() == 1); |
| | | price.setPointPayment(goodsArea.getPointPayment() == 1); |
| | | } |
| | | }else{ |
| | | price.setCash(bargainPriceDetail.getSellingPrice()); |
| | | price.setPoint(bargainPriceDetail.getIntegral()); |
| | | price.setCashPayment(bargainPriceDetail.getSellingPrice() != null); |
| | | price.setPointPayment(bargainPriceDetail.getIntegral() != null); |
| | | } |
| | | }else{ |
| | | //构建价格数据 |
| | | if(goodsSeckill.getCashPayment() == 1 && goodsSeckill.getPointPayment() == 1){ |
| | | price.setCash(goodsSeckill.getSellingPrice()); |
| | | price.setPoint(goodsSeckill.getIntegral()); |
| | | } |
| | | if(goodsSeckill.getCashPayment() == 1 && goodsSeckill.getPointPayment() == 0){ |
| | | price.setCash(goodsSeckill.getSellingPrice()); |
| | | } |
| | | if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){ |
| | | price.setPoint(goodsSeckill.getIntegral()); |
| | | } |
| | | price.setCashPayment(goodsSeckill.getCashPayment() == 1); |
| | | price.setPointPayment(goodsSeckill.getPointPayment() == 1); |
| | | } |
| | | return price; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.mapper.GoodsShopMapper; |
| | | import com.ruoyi.other.mapper.SeckillActivityInfoMapper; |
| | |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); |
| | | goods.setVipId(appUser.getVipId()); |
| | | return seckillActivityInfoMapper.listSeckillActivity(goods); |
| | | List<SeckillActivityVO> seckillActivityVOS = seckillActivityInfoMapper.listSeckillActivity(goods); |
| | | return seckillActivityVOS; |
| | | } |
| | | |
| | | @Override |
| | | public SeckillActivityDetailVO detail(Integer seckillActivityId) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | SeckillActivityDetailVO seckillActivityDetailVO = seckillActivityInfoMapper.selectDetail(seckillActivityId, appUser.getVipId()); |
| | | Integer vipId = 0; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | vipId = appUser.getVipId(); |
| | | } |
| | | SeckillActivityDetailVO seckillActivityDetailVO = seckillActivityInfoMapper.selectDetail(seckillActivityId, vipId); |
| | | Integer goodsId = seckillActivityDetailVO.getGoodsId(); |
| | | |
| | | Goods goods = goodsService.getById(goodsId); |
| | |
| | | public void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) { |
| | | this.baseMapper.insert(seckillActivityInfo); |
| | | List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); |
| | | goodsSeckills.forEach(goodsSeckill -> goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId())); |
| | | for (GoodsSeckill goodsSeckill : goodsSeckills) { |
| | | goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1); |
| | | goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1); |
| | | goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()); |
| | | } |
| | | goodsSeckillService.saveBatch(goodsSeckills); |
| | | } |
| | | |
| | |
| | | this.baseMapper.updateById(seckillActivityInfo); |
| | | goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); |
| | | List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); |
| | | goodsSeckills.forEach(goodsSeckill -> goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId())); |
| | | for (GoodsSeckill goodsSeckill : goodsSeckills) { |
| | | goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1); |
| | | goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1); |
| | | goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()); |
| | | } |
| | | goodsSeckillService.saveBatch(goodsSeckills); |
| | | } |
| | | } |
| | |
| | | return this.getById(appUser.getVipId()); |
| | | } |
| | | |
| | | @Override |
| | | public void downUsers() { |
| | | // //查出可能需要降级的人员 |
| | | // R<List<AppUser>> topUsers = appUserClient.getTopUsers(); |
| | | // //循环判断是否要展示 |
| | | // if (topUsers.getData()!=null && topUsers.getData().size()>0){ |
| | | // for (AppUser appUser : topUsers.getData()){ |
| | | // if (appUser.getVipId()==5){ |
| | | // VipSetting vipSetting = this.baseMapper.selectById(5); |
| | | // if (vipSetting.getKeepBuyPoint()!=null){ |
| | | // //如果消费不为空,查找对应天数的消费积分 |
| | | // |
| | | // //如果消费积分小于保级积分,设置用户降级标志并将降级信息 |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | //然后设置降级提示 |
| | | |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.other.task; |
| | | |
| | | |
| | | import com.ruoyi.other.service.VipSettingService; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | @Component |
| | | public class TaskUtil { |
| | | |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | |
| | | |
| | | /** |
| | | * 每天的凌晨执行的任务 |
| | |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | try { |
| | | |
| | | |
| | | vipSettingService.downUsers(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.other.util.payment.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | //APPID |
| | | body.put("q7_AppId", appId); |
| | | //报备商户号 |
| | | body.put("qa_TradeMerchantNo", tradeMerchantNo); |
| | | body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852"); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | |
| | | |
| | | |
| | | public static String sign(JSONObject body) throws Exception{ |
| | | public static String sign(JSONObject body) { |
| | | Set<Map.Entry<String, Object>> entries = body.entrySet(); |
| | | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() { |
| | | public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) { |
| | | return (o1.getKey()).toString().compareTo(o2.getKey()); |
| | | return (o1.getKey()).compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | |
| | | @ApiModelProperty(value = "基础售价") |
| | | private BigDecimal sellingPrice; |
| | | |
| | | @ApiModelProperty(value = "基础积分") |
| | | private Integer integral; |
| | | |
| | | |
| | | @ApiModelProperty(value = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | |
| | | |
| | | <select id="selectListByShopId" resultType="com.ruoyi.other.api.domain.Goods"> |
| | | SELECT |
| | | tg.id, |
| | | tg.`name`, |
| | | tg.type, |
| | | tg.introduction, |
| | | tg.selling_price, |
| | | tg.original_price, |
| | | tg.sale_num, |
| | | tg.home_page_picture |
| | | FROM |
| | | t_shop ts |
| | | LEFT JOIN t_goods_shop tgs ON ts.id = tgs.shop_id |
| | | LEFT JOIN t_goods tg ON tg.id = tgs.goods_id |
| | | where ts.id = #{shopId} and ts.del_flag = 0 |
| | | tg.id, |
| | | tg.`name`, |
| | | tg.type, |
| | | tg.introduction, |
| | | tg.selling_price as sellingPrice, |
| | | tg.original_price as originalPrice, |
| | | tg.integral as integral, |
| | | tg.sale_num as saleNum, |
| | | tg.home_page_picture as homePagePicture |
| | | FROM t_goods tg |
| | | left join t_goods_shop tgs ON tg.id = tgs.goods_id |
| | | where tg.del_flag = 0 and (tg.appoint_store = 2 or (tg.appoint_store = 1 and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId}))) |
| | | <if test="vip != null"> |
| | | and FIND_IN_SET(#{vip}, tg.commodity_authority) > 0 |
| | | and (tg.commodity_authority like '%-1%' or tg.commodity_authority like CONCAT('%', #{vip}, '%')) |
| | | </if> |
| | | ORDER BY tg.sale_num DESC |
| | | </select> |
| | | <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods"> |
| | | SELECT |
| | | tg.id, |
| | | tg.`name`, |
| | | tg.type, |
| | | tg.goods_category_id, |
| | | tgc.`name`, |
| | | tg.operating_cost, |
| | | tg.shop_cost, |
| | | tg.`status`, |
| | | tg.purchase_limit, |
| | | tg.sale_num, |
| | | tg.cash_payment, |
| | | tg.point_payment |
| | | tg.* |
| | | FROM |
| | | t_goods tg |
| | | LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id |
| | |
| | | <if test="goods.status != null"> |
| | | and tg.`status` = #{goods.status} |
| | | </if> |
| | | |
| | | <if test="goods.payMethod != null and goods.payMethod == 1 "> |
| | | and tg.`cashPayment` = 1 |
| | | </if> |
| | | <if test="goods.payMethod != null and goods.payMethod == 2 "> |
| | | and tg.`point_payment` = 1 |
| | | </if> |
| | | <if test="goods.payMethod != null and goods.payMethod == 3 "> |
| | | and (tg.`point_payment` = 1 or tg.`cashPayment` = 1 ) |
| | | </if> |
| | | |
| | | </where> |
| | | order by tg.sort desc |
| | | </select> |
| | |
| | | <if test="null != name and '' != name"> |
| | | and name like CONCAT('%', #{name}, '%') |
| | | </if> |
| | | <if test="null != vip"> |
| | | and id in (select goods_id from t_goods_vip where vip = #{vip}) |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | SELECT |
| | | tsai.id, |
| | | tg.id as goodsId, |
| | | tg.`name`, |
| | | tg.`name` as goodsName, |
| | | tg.introduction, |
| | | tg.home_page_picture, |
| | | tg.original_price, |
| | | tgs.selling_price, |
| | | tg.sale_num, |
| | | tsai.start_time |
| | | tg.home_page_picture as homePagePicture, |
| | | tg.original_price as originalPrice, |
| | | tgs.selling_price as sellingPrice, |
| | | tg.sale_num as saleNum, |
| | | tsai.start_time as startTime, |
| | | tsai.end_time as endTime |
| | | FROM |
| | | t_seckill_activity_info tsai |
| | | LEFT JOIN t_goods tg ON tsai.good_id = tg.id |
| | | LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id and tgs.vip = #{vipId} |
| | | WHERE tsai.is_shelves = 1 AND tsai.del_flag = 0 |
| | | WHERE tsai.is_shelves = 1 AND tsai.del_flag = 0 and now() between tsai.start_time and tsai.end_time |
| | | <if test="name != null and name != ''"> |
| | | AND tg.`name` LIKE concat('%',#{goodsName},'%') |
| | | AND tg.`name` LIKE concat('%',#{name},'%') |
| | | </if> |
| | | <if test="goodsCategoryId != null"> |
| | | AND tg.goods_category_id = #{goodsCategoryId} |
| | |
| | | tsai.good_id as goodsId, |
| | | tg.`name`, |
| | | tg.introduction, |
| | | tg.home_page_picture, |
| | | tg.original_price, |
| | | tgs.selling_price, |
| | | tg.sale_num, |
| | | tsai.start_time, |
| | | tg.detail_picture, |
| | | tsai.end_time, |
| | | tg.home_page_picture as homePagePicture, |
| | | tg.original_price as originalPrice, |
| | | tgs.selling_price as sellingPrice, |
| | | tgs.integral, |
| | | tg.sale_num as saleNum, |
| | | tsai.start_time as startTime, |
| | | tg.detail_picture as detailPicture, |
| | | tsai.end_time as endTime, |
| | | tg.detail |
| | | FROM |
| | | t_seckill_activity_info tsai |