Merge remote-tracking branch 'origin/master'
107个文件已修改
3个文件已删除
7个文件已添加
| | |
| | | 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); |
| | | } |
| | |
| | | |
| | | @TableField(exist = false) |
| | | private String idStr; |
| | | @TableField(exist = false) |
| | | private Integer vipId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:25 |
| | | */ |
| | | @Data |
| | | @TableName("t_balance_payment") |
| | | public class BalancePayment { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.NONE) |
| | | private Long id; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | | /** |
| | | * 支付金额 |
| | | */ |
| | | @TableField("money") |
| | | private BigDecimal money; |
| | | /** |
| | | * 微信支付流水 |
| | | */ |
| | | @TableField("serial_number") |
| | | private String serialNumber; |
| | | /** |
| | | * 微信支付状态(1=待支付,2=已支付) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 完成支付时间 |
| | | */ |
| | | @TableField("payment_time") |
| | | private LocalDateTime paymentTime; |
| | | /** |
| | | * 余额变更记录id |
| | | */ |
| | | @TableField("balance_change_record_id") |
| | | private Long balanceChangeRecordId; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("create_time") |
| | | private LocalDateTime createTime; |
| | | } |
| | |
| | | package com.ruoyi.account.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | |
| | | @ApiModelProperty(value = "添加时间") |
| | | @TableField("create_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
New file |
| | |
| | | package com.ruoyi.order.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/7 14:38 |
| | | */ |
| | | public class OrderClientFallbackFactory implements FallbackFactory<OrderClient> { |
| | | @Override |
| | | public OrderClient create(Throwable cause) { |
| | | return new OrderClient(){ |
| | | |
| | | @Override |
| | | public R<Integer> getGoodsSaleNum(Integer goodsId, Integer type) { |
| | | return R.fail("获取商品销售数量失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R<Integer> getShopSaleNum(Integer shopId, Integer type) { |
| | | return R.fail("获取门店销售订单数量失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Set<Long>> getAppUserByShoppingShop(Integer shopId) { |
| | | return R.fail("获取所有在指定门店消费的用户id失败:" + cause); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.feignClient; |
| | | |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.factory.OrderClientFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/7 14:37 |
| | | */ |
| | | @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderClientFallbackFactory.class) |
| | | public interface OrderClient { |
| | | |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @param type 购买类型(1=普通商品,2=秒杀商品) |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getGoodsSaleNum") |
| | | R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type); |
| | | |
| | | |
| | | /** |
| | | * 获取门店销售订单数量 |
| | | * @param shopId 门店id |
| | | * @param type 1:服务订单,2:单品订单 |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getShopSaleNum") |
| | | R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type); |
| | | |
| | | |
| | | /** |
| | | * 获取所有在指定门店消费的用户id |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getAppUserByShoppingShop") |
| | | R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId); |
| | | } |
| | |
| | | @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; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "绑定门店上级门店可获得返佣积分") |
| | | @TableField("bound_shop_superiors_points") |
| | | private Integer boundShopSuperiorsPoints; |
| | | @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)") |
| | | @TableField("type") |
| | | private Integer type; |
| | | |
| | | |
| | | } |
| | |
| | | @TableField("pass_status") |
| | | private Integer passStatus; |
| | | |
| | | @ApiModelProperty(value = "审核时间") |
| | | @TableField("auth_time") |
| | | private LocalDateTime authTime; |
| | | |
| | | @ApiModelProperty(value = "后台审核备注") |
| | | @TableField("pass_remark") |
| | | private String passRemark; |
| | |
| | | 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; |
| | |
| | | private Integer shopId; |
| | | @ApiModelProperty(value = "商品类型(1=服务商品,2=单品商品)", required = true) |
| | | private Integer type; |
| | | @ApiModelProperty("优惠券id") |
| | | private Long couponId; |
| | | } |
| | |
| | | public class MyShoppingCartVo { |
| | | @ApiModelProperty("数据id") |
| | | private String id; |
| | | @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)") |
| | | private Integer type; |
| | | @ApiModelProperty("商品id") |
| | | private Integer goodsId; |
| | | @ApiModelProperty("封面图") |
| | |
| | | @ApiModelProperty(value = "实际支付价格") |
| | | private BigDecimal paymentAmount; |
| | | |
| | | @ApiModelProperty(value = "快递费") |
| | | private BigDecimal expressAmount; |
| | | |
| | | |
| | | } |
| | |
| | | @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; |
| | |
| | | com.ruoyi.order.factory.RemoteOrderGoodsFallbackFactory |
| | | com.ruoyi.order.factory.RemoteOrderGoodsFallbackFactory |
| | | com.ruoyi.order.factory.OrderClientFallbackFactory |
| | |
| | | @TableField(exist = false) |
| | | private Integer showStatus; |
| | | |
| | | @TableField(exist = false) |
| | | private String payMethod; |
| | | |
| | | |
| | | public String getIdStr() { |
| | | return String.valueOf(id); |
| | | } |
| | |
| | | @TableField("district_code") |
| | | private String districtCode; |
| | | |
| | | |
| | | @TableField(exist = false) |
| | | private Double distance; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId("id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | |
| | | @ApiModelProperty("跳转内容2") |
| | | private String content2; |
| | | @ApiModelProperty("跳转类型2 - 1无2外部链接3商品详情4秒杀商品详情5领卷中心") |
| | | private String direct2; |
| | | private Integer direct2; |
| | | @ApiModelProperty("公司简介") |
| | | private String companyInfo; |
| | | |
| | |
| | | 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()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | public class OrderActivityInfoClientFallbackFactory implements FallbackFactory<OrderActivityInfoClient> { |
| | | @Override |
| | | public OrderActivityInfoClient create(Throwable cause) { |
| | | return new OrderActivityInfoClient(){ |
| | | @Override |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(Integer vip) { |
| | | public R<List<OrderActivityInfo>> getNowOrderActivityInfo(Integer vip) { |
| | | return R.fail("获取当前生效的活动失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.GoodsSeckill; |
| | | import com.ruoyi.other.api.domain.SeckillActivityInfo; |
| | | import com.ruoyi.other.api.feignClient.SeckillActivityInfoClient; |
| | | import com.ruoyi.other.api.vo.GetSeckillActivityInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public R<GoodsSeckill> getSeckillActivityInfo(GetSeckillActivityInfo info) { |
| | | return R.fail("根据商品id和会员等级获取对应的秒杀活动失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<SeckillActivityInfo> getSeckillActivityInfoById(Integer id) { |
| | | return R.fail("根据id获取秒杀活动失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | public void updateShop(Shop shop) { |
| | | R.fail("编辑门店失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Shop>> getAllShop() { |
| | | 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); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/29 10:55 |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/order-activity-info/getNowOrderActivityInfo") |
| | | R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip); |
| | | R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip); |
| | | } |
| | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.GoodsSeckill; |
| | | import com.ruoyi.other.api.domain.SeckillActivityInfo; |
| | | import com.ruoyi.other.api.factory.SeckillActivityInfoClientFallbackFactory; |
| | | import com.ruoyi.other.api.vo.GetSeckillActivityInfo; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | */ |
| | | @PostMapping("/seckill-activity-info/getSeckillActivityInfo") |
| | | R<GoodsSeckill> getSeckillActivityInfo(@RequestBody GetSeckillActivityInfo info); |
| | | |
| | | |
| | | /** |
| | | * 根据id获取秒杀活动 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/seckill-activity-info/getSeckillActivityInfoById") |
| | | R<SeckillActivityInfo> getSeckillActivityInfoById(@RequestParam("id") Integer id); |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/shop/updateShop") |
| | | void updateShop(Shop shop); |
| | | |
| | | |
| | | /** |
| | | * 获取所有门店 |
| | | * @return |
| | | */ |
| | | @PostMapping("/shop/getAllShop") |
| | | R<List<Shop>> getAllShop(); |
| | | } |
| | |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 角色类型 1=平台 2=公司 3=门店 4=修理厂 |
| | | * 角色类型 1=平台 2=门店 |
| | | */ |
| | | @ApiModelProperty(value = "角色类型 1=平台 2=门店") |
| | | @TableField("role_type") |
| | |
| | | * @param roleType |
| | | * @return |
| | | */ |
| | | @PostMapping("/user/delShopUser") |
| | | @PostMapping("/user/user/delShopUser") |
| | | R delShopUser(@RequestParam("objectId") Integer objectId, @RequestParam("roleType") Integer roleType); |
| | | |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | */ |
| | | @TableField("role_id") |
| | | private Long roleId; |
| | | |
| | | /** 部门ID */ |
| | | @TableField("dept_id") |
| | | private Long deptId; |
| | | |
| | | /** 用户昵称 */ |
| | | @TableField("nick_name") |
| | | private String nickName; |
| | | |
| | | @TableField("create_time") |
| | | private LocalDateTime createTime; |
| | | } |
| | |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员"); |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | // throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | throw new ServiceException("您的账号已被禁用,请联系平台"); |
| | | } |
| | | passwordService.validate(user, password, request); |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "登录成功"); |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | String encode = passwordEncoder.encode("49a15811ea47e8e9c6d8f3ef4d7bbc54"); |
| | | String encode = passwordEncoder.encode("31dc4a464b71db3ddaea244410af4833"); |
| | | System.err.println(encode); |
| | | } |
| | | } |
| | |
| | | SysUser sysUser = sysUserService.getById(userid); |
| | | if(sysUser.getRoleType() == 2){ |
| | | wrapper.eq(SysRole::getShopId, sysUser.getObjectId()); |
| | | }else{ |
| | | wrapper.isNull(SysRole::getShopId); |
| | | } |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, wrapper.orderByDesc(SysRole::getCreateTime)); |
| | | for (SysRole record : page.getRecords()) { |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | user.setUserName(user.getPhonenumber()); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser1 = userService.getById(userid); |
| | | if(sysUser1.getRoleType() == 2){ |
| | | user.setObjectId(sysUser1.getObjectId()); |
| | | } |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | | } |
| | |
| | | if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) { |
| | | return error("登录账号重复"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | | user.setRoleType(sysUser1.getRoleType()); |
| | | userService.insertUser(user); |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(user.getRoleId()); |
| | | sysUserRole.setUserId(user.getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | //添加门店员工关系数据 |
| | | if(2 == user.getRoleType()){ |
| | | //门店员工添加数据,需要判断账号是否存在,共用同一个账号 |
| | | if(2 == sysUser1.getRoleType()){ |
| | | SysUser one = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, user.getPhonenumber()) |
| | | .eq(SysUser::getDelFlag, "0").eq(SysUser::getStatus, "0").eq(SysUser::getRoleType, 2)); |
| | | if(null == one){ |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | | user.setRoleType(sysUser1.getRoleType()); |
| | | user.setObjectId(sysUser1.getObjectId()); |
| | | userService.insertUser(user); |
| | | one = user; |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(user.getRoleId()); |
| | | sysUserRole.setUserId(user.getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | } |
| | | //添加门店员工关系数据 |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(user.getUserId()); |
| | | userShop.setShopId(user.getObjectId()); |
| | | userShop.setUserId(one.getUserId()); |
| | | userShop.setShopId(sysUser1.getObjectId()); |
| | | userShop.setRoleType(2); |
| | | userShop.setRoleId(user.getRoleId()); |
| | | userShop.setDeptId(user.getDeptId()); |
| | | userShop.setNickName(user.getNickName()); |
| | | userShop.setCreateTime(LocalDateTime.now()); |
| | | userShopService.save(userShop); |
| | | }else{ |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | | user.setRoleType(sysUser1.getRoleType()); |
| | | userService.insertUser(user); |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(user.getRoleId()); |
| | | sysUserRole.setUserId(user.getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | if (StringUtils.isNotNull(userId)) { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | if(sysUser.getRoleType() == 2){ |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser1 = userService.selectUserById(userid); |
| | | UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, sysUser.getUserId()).eq(UserShop::getShopId, sysUser1.getObjectId())); |
| | | sysUser.setDeptId(one.getDeptId()); |
| | | sysUser.setNickName(one.getNickName()); |
| | | SysDept sysDept = deptService.selectDeptById(one.getDeptId()); |
| | | sysUser.setDept(sysDept); |
| | | sysUser.setRoleId(one.getRoleId()); |
| | | } |
| | | |
| | | ajax.put("data", sysUser); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | | ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); |
| | |
| | | |
| | | //添加门店员工关系数据 |
| | | if(2 == user.getRoleType()){ |
| | | userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId())); |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(user.getUserId()); |
| | | userShop.setShopId(user.getObjectId()); |
| | | userShop.setRoleType(2); |
| | | userShop.setRoleId(user.getRoleId()); |
| | | userShopService.save(userShop); |
| | | UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId())); |
| | | one.setUserId(user.getUserId()); |
| | | one.setShopId(user.getObjectId()); |
| | | one.setRoleType(one.getRoleType()); |
| | | one.setRoleId(user.getRoleId()); |
| | | one.setDeptId(user.getDeptId()); |
| | | one.setNickName(user.getNickName()); |
| | | userShopService.updateById(one); |
| | | } |
| | | return success(); |
| | | } |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/switchShop") |
| | | @PutMapping("/switchShop/{shopId}") |
| | | @ApiOperation(value = "切换门店", tags = {"门店后台-首页"}) |
| | | public R<Set<String>> switchShop(@PathVariable("shopId") Integer shopId){ |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | |
| | | @Data |
| | | @ApiModel |
| | | public class GetSysUserList extends BasePage { |
| | | @ApiModelProperty(value = "人员搜索") |
| | | @ApiModelProperty(value = "账号名称") |
| | | private String search; |
| | | @ApiModelProperty(value = "充电站id") |
| | | private Integer siteId; |
| | | @ApiModelProperty(value = "角色id") |
| | | private List<Integer> roleIds; |
| | | @ApiModelProperty(value = "账户状态(0=正常,1=禁用)") |
| | | private Integer status; |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phonenumber; |
| | | @ApiModelProperty(value = "所属部门") |
| | | private Integer deptId; |
| | | private Integer objectId; |
| | | } |
| | |
| | | * @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 |
| | | { |
| | |
| | | for (SysUser user : sysUsers) { |
| | | if(2 == user.getRoleType()){ |
| | | userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId())); |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(user.getUserId()); |
| | | userShop.setShopId(user.getObjectId()); |
| | | userShop.setRoleType(2); |
| | | userShop.setRoleId(user.getRoleId()); |
| | | userShopService.save(userShop); |
| | | } |
| | | } |
| | | return i; |
| | |
| | | } |
| | | List<SysUser> list = this.baseMapper.getList(pageInfo, getSysUserList); |
| | | for (SysUser sysUser : list) { |
| | | List<SysUserRole> list1 = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId())); |
| | | List<String> roleNames = new ArrayList<>(); |
| | | for (SysUserRole sysUserRole : list1) { |
| | | SysRole sysRole = sysRoleService.selectRoleById(sysUserRole.getRoleId()); |
| | | if(null == sysRole){ |
| | | continue; |
| | | if(sysUser.getRoleType() == 2){ |
| | | UserShop userShop = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getShopId, sysUser1.getObjectId()).eq(UserShop::getUserId, sysUser.getUserId())); |
| | | SysRole sysRole = roleMapper.selectRoleById(userShop.getRoleId()); |
| | | Long[] roleIds = new Long[]{userShop.getRoleId()}; |
| | | sysUser.setNickName(userShop.getNickName()); |
| | | sysUser.setRoleIds(roleIds); |
| | | sysUser.setRoleNames(Arrays.asList(sysRole.getRoleName())); |
| | | SysDept sysDept = deptService.selectDeptById(userShop.getDeptId()); |
| | | sysUser.setDept(sysDept); |
| | | }else{ |
| | | List<SysUserRole> list1 = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId())); |
| | | List<String> roleNames = new ArrayList<>(); |
| | | for (SysUserRole sysUserRole : list1) { |
| | | SysRole sysRole = sysRoleService.selectRoleById(sysUserRole.getRoleId()); |
| | | if(null == sysRole){ |
| | | continue; |
| | | } |
| | | roleNames.add(sysRole.getRoleName()); |
| | | } |
| | | roleNames.add(sysRole.getRoleName()); |
| | | Long[] roleIds = new Long[]{}; |
| | | sysUser.setRoleIds(list1.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()).toArray(roleIds)); |
| | | sysUser.setRoleNames(roleNames); |
| | | SysDept sysDept = deptService.selectDeptById(sysUser.getDeptId()); |
| | | sysUser.setDept(sysDept); |
| | | } |
| | | Long[] roleIds = new Long[]{}; |
| | | sysUser.setRoleIds(list1.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()).toArray(roleIds)); |
| | | sysUser.setRoleNames(roleNames); |
| | | SysDept sysDept = deptService.selectDeptById(sysUser.getDeptId()); |
| | | sysUser.setDept(sysDept); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | |
| | | 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)); |
| | | } |
| | | } |
| | |
| | | <if test="shopId != null"> |
| | | AND shop_id = #{shopId} |
| | | </if> |
| | | <if test="shopId == null"> |
| | | AND shop_id is null |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | order by d.parent_id, d.order_num |
| | |
| | | select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 |
| | | </select> |
| | | <select id="getList" resultMap="SysUserResult"> |
| | | select * from sys_user where 1=1 |
| | | <if test="req.search !=null and req.search !=''"> |
| | | and (phonenumber like concat("%", #{req.search},"%") or nick_name like concat("%", #{req.search},"%")) |
| | | select * from sys_user where del_flag = '0' and status = '0' |
| | | <if test="null != req.phonenumber and '' != req.phonenumber"> |
| | | and phonenumber like CONCAT('%', #{req.phonenumber}, '%') |
| | | </if> |
| | | <if test="null != req.siteId"> |
| | | and user_id in (select user_id from t_user_site where site_id = #{req.siteId}) |
| | | and user_id in (select user_id from sys_user_role where role_id in (select role_id from t_role_site where site_id = #{req.siteId})) |
| | | </if> |
| | | <if test="null != req.roleIds and req.roleIds.size() > 0"> |
| | | and user_id in (select user_id from sys_user_role where role_id in |
| | | <foreach collection="req.roleIds" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <if test="null != req.status"> |
| | | and status = #{req.status} |
| | | </if> |
| | | <if test="null != req.objectId"> |
| | | and objectId = #{req.objectId} |
| | | </if> |
| | | and del_flag = '0' |
| | | <choose> |
| | | <when test="null != req.objectId"> |
| | | and user_id in (select user_id from t_user_shop where shop_id = #{req.objectId} |
| | | <if test="null != req.deptId"> |
| | | and dept_id = #{req.deptId} |
| | | </if> |
| | | <if test="req.search !=null and req.search !=''"> |
| | | and nick_name like concat("%", #{req.search},"%") |
| | | </if> |
| | | ) |
| | | </when> |
| | | <otherwise> |
| | | and role_type = 1 |
| | | <if test="null != req.deptId"> |
| | | and dept_id = #{req.deptId} |
| | | </if> |
| | | <if test="req.search !=null and req.search !=''"> |
| | | and nick_name like concat("%", #{req.search},"%") |
| | | </if> |
| | | </otherwise> |
| | | </choose> |
| | | order by create_time desc |
| | | </select> |
| | | <select id="getAllList" resultType="com.ruoyi.system.api.domain.SysUser"> |
| | |
| | | @PostMapping("/page") |
| | | @ApiOperation(value = "会员申请列表", tags = {"后台"}) |
| | | public R<IPage<AgentApplication>> page(@RequestBody AgentQuery agentQuery) { |
| | | |
| | | return R.ok(agentApplicationService.pageList(agentQuery)); |
| | | IPage<AgentApplication> agentApplicationIPage = agentApplicationService.pageList(agentQuery); |
| | | for (AgentApplication record : agentApplicationIPage.getRecords()) { |
| | | AppUser byId = appUserService.getById(record.getAppUserId()); |
| | | if (byId!=null){ |
| | | record.setVipId(byId.getVipId()); |
| | | } |
| | | } |
| | | return R.ok(agentApplicationIPage); |
| | | } |
| | | @Resource |
| | | private VipSettingClient vipSettingClient; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.StoreClient; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private AppUserMapper appUserMapper; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getAppUserById") |
| | | public AppUser getAppUserById(@RequestParam("id") Long id) { |
| | | return appUserService.getById(id); |
| | |
| | | userCancellationLog.setAppUserId(user.getId()); |
| | | userCancellationLog.setVipId(user.getVipId()); |
| | | userCancellationLogService.save(userCancellationLog); |
| | | |
| | | |
| | | user.setStatus(3); |
| | | appUserService.updateById(user); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | user.setShopName(storeById.getData().getName()); |
| | | } |
| | | } |
| | | Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).count(); |
| | | Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | user.setCount1(count1); |
| | | user.setCount2(count2); |
| | | user.setCount3(count3); |
| | |
| | | public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | |
| | | |
| | | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | |
| | | |
| | | @PostMapping("/getAppUserByPhone1") |
| | | public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone) { |
| | | AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1) |
| | | AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 3) |
| | | .eq(AppUser::getPhone, phone)); |
| | | return R.ok(appUser); |
| | | } |
| | |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) |
| | | public R<UserStatistics> statistics() { |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId); |
| | | return R.ok(userStatistics); |
| | | } |
| | | |
| | |
| | | @GetMapping("/statistics/detail") |
| | | @ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"}) |
| | | public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userIds = null; |
| | | if(null != userId){ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | if(null == userId){ |
| | | userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | }else{ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | } |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds); |
| | | return R.ok(userStatisticsDetail); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/commissionDetail") |
| | | @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") |
| | | public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) { |
| | | List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList()); |
| | | |
| | | public R<CommissionDetail> commissionDetail() { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0); |
| | | if(sysUser.getRoleType() == 2){ |
| | | queryWrapper.eq(AppUser::getShopId, sysUser.getObjectId()); |
| | | } |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | if (appUserList.isEmpty()) { |
| | | return R.ok(new CommissionDetail()); |
| | | } |
| | | |
| | | BigDecimal totalCommission = BigDecimal.ZERO; |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>(); |
| | | |
| | | for (AppUser appUser : appUserList) { |
| | | BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO); |
| | | BigDecimal serviceFee = Optional.ofNullable(appUser.getShopServiceFee()).orElse(BigDecimal.ZERO); |
| | | BigDecimal userCommission = Optional.ofNullable(appUser.getShopCommission()).orElse(BigDecimal.ZERO); |
| | | |
| | | totalCommission = totalCommission.add(distributionAmount); |
| | | totalServiceFee = totalServiceFee.add(serviceFee); |
| | | totalUserCommission = totalUserCommission.add(userCommission); |
| | | |
| | | Integer vipId = appUser.getVipId(); |
| | | if (vipId != null && vipId >= 1 && vipId <= 7) { |
| | | vipCommissions.merge(vipId, distributionAmount, BigDecimal::add); |
| | |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | | .merge(vipId, distributionAmount, BigDecimal::add); |
| | | } |
| | | } |
| | | List<Shop> data = shopClient.getAllShop().getData(); |
| | | if(sysUser.getRoleType() == 2){ |
| | | data = Arrays.asList(shopClient.getShopById(sysUser.getObjectId()).getData()); |
| | | } |
| | | for (Shop shop : data) { |
| | | totalServiceFee = totalServiceFee.add(shop.getServerGiveawayMoney()); |
| | | totalUserCommission = totalUserCommission.add(shop.getGiveawayMoney()); |
| | | } |
| | | |
| | | CommissionDetail commissionDetail = new CommissionDetail(); |
| | |
| | | BigDecimal add = commissionDate.getNormalCommission().add(commissionDate.getGoldCommission()).add(commissionDate.getDiamondCommission()).add(commissionDate.getAgentCommission()) |
| | | .add(commissionDate.getSuperAgentCommission()).add(commissionDate.getTopAgentCommission()).add(commissionDate.getPartnerCommission()); |
| | | commissionDate.setTotalCommission(add); |
| | | |
| | | // commissionDate.setServiceChargeCommission(); |
| | | // commissionDate.setAssociatedUserCommission(); |
| | | // commissionDate.setBindLowerLevelStoresCommission(); |
| | | return commissionDate; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | commissionDetail.setCommissionDateList(commissionDateList); |
| | | |
| | | return R.ok(commissionDetail); |
| | | } |
| | | |
| | |
| | | @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.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | |
| | | import com.ruoyi.account.service.UserCouponService; |
| | | import com.ruoyi.account.service.UserPointService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.account.api.vo.PaymentUserCoupon; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/mine/list1") |
| | | @ApiOperation(value = "已领取列表", tags = {"管理后台-优惠劵"}) |
| | | public R<Page<UserCoupon>> list1(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status, Integer id) { |
| | | Page<UserCoupon> page = userCouponService.lambdaQuery() |
| | | .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime) |
| | | .isNotNull(status!=null&&status==2,UserCoupon::getUseTime) |
| | | .eq(UserCoupon::getCouponId, id) |
| | | .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()).page(Page.of(pageNum-1, pageSize)); |
| | | for (UserCoupon record : page.getRecords()) { |
| | | record.setIdStr(record.getId().toString()); |
| | | CouponInfo data = couponClient.detail(record.getCouponId()).getData(); |
| | | CouponInfoVo vo = new CouponInfoVo(); |
| | | BeanUtils.copyProperties(data,vo); |
| | | //如果是商品券,将商品名称返回 |
| | | if (vo.getCouponType()==4){ |
| | | List<String> goodNames = new ArrayList<>(); |
| | | if (vo.getForGoodIds().equals("-1")){ |
| | | goodNames.add("全部商品"); |
| | | }else{ |
| | | String[] split = vo.getForGoodIds().split(","); |
| | | R<List<Goods>> goodsById = goodsClient.getGoodsById(split); |
| | | if (goodsById.getData()!=null){ |
| | | for (Goods datum : goodsById.getData()) { |
| | | goodNames.add(datum.getName()); |
| | | } |
| | | } |
| | | vo.setGoodNames(goodNames); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | | if (record.getEndTime().isBefore(LocalDateTime.now())){ |
| | | record.setStatus(3); |
| | | } |
| | | }else { |
| | | record.setStatus(2); |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | | record.setPhone(appUser.getPhone()); |
| | | } |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/get") |
| | | @ApiOperation(value = "领取或者兑换优惠券", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<Page<UserCoupon>> get(@RequestParam Integer couponId) { |
| | |
| | | userPoint.setBalance(byId.getLavePoint()); |
| | | userPoint.setAppUserId(userid); |
| | | userPoint.setObjectId(Long.valueOf(data.getId())); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPointService.save(userPoint); |
| | | } |
| | | //增加优惠券记录,根据时间类型设置开始结束时间 |
| | |
| | | public R<UserCoupon> getCouponInfoInfo(String id){ |
| | | UserCoupon userCoupon = userCouponService.getById(id); |
| | | CouponInfo couponInfo = couponClient.detail(userCoupon.getCouponId()).getData(); |
| | | List<Goods> goods = null; |
| | | if("-1".equals(couponInfo.getForGoodIds())){ |
| | | goods = goodsClient.getGoodsByType(2).getData(); |
| | | List<String> goodNames = new ArrayList<>(); |
| | | if(!"null".equals(couponInfo.getGoodsNameJson()) && StringUtils.isNotEmpty(couponInfo.getGoodsNameJson())){ |
| | | goodNames = JSON.parseArray(couponInfo.getGoodsNameJson(), String.class); |
| | | }else{ |
| | | goods = goodsClient.getGoodsById(couponInfo.getForGoodIds().split(",")).getData(); |
| | | List<Goods> goods = null; |
| | | if("-1".equals(couponInfo.getForGoodIds())){ |
| | | goods = goodsClient.getGoodsByType(2).getData(); |
| | | }else{ |
| | | goods = goodsClient.getGoodsById(couponInfo.getForGoodIds().split(",")).getData(); |
| | | } |
| | | goodNames = goods.stream().map(Goods::getName).collect(Collectors.toList()); |
| | | } |
| | | |
| | | CouponInfoVo couponInfoVo = new CouponInfoVo(); |
| | | BeanUtils.copyProperties(couponInfo, couponInfoVo); |
| | | couponInfoVo.setGoodNames(goods.stream().map(Goods::getName).collect(Collectors.toList())); |
| | | couponInfoVo.setGoodNames(goodNames); |
| | | userCoupon.setCouponInfoVo(couponInfoVo); |
| | | if (userCoupon.getUseTime()==null){ |
| | | userCoupon.setStatus(1); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecord; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.service.WalletService; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.payment.PaymentUtil; |
| | | import com.ruoyi.account.util.payment.model.UniPayCallbackResult; |
| | | import com.ruoyi.account.util.payment.model.UniPayResult; |
| | | import com.ruoyi.account.vo.WalletVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.YearMonth; |
| | | import java.time.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private BalancePaymentService balancePaymentService; |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 钱包详情 |
| | |
| | | */ |
| | | @GetMapping("recharge") |
| | | @ApiOperation(value = "充值", notes = "钱包充值") |
| | | public R<Void> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) { |
| | | public R<String> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); |
| | | String wxOpenid = appUser.getWxOpenid(); |
| | | // 商户号 |
| | | String partnerTradeNo; |
| | | // TODO 充值 |
| | | return R.ok(); |
| | | BalancePayment balancePayment = new BalancePayment(); |
| | | balancePayment.setAppUserId(appUser.getId()); |
| | | balancePayment.setMoney(amount); |
| | | balancePayment.setStatus(1); |
| | | balancePayment.setCreateTime(LocalDateTime.now()); |
| | | balancePaymentService.save(balancePayment); |
| | | //调起支付 |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(balancePayment.getId().toString(), amount.doubleValue(), "余额充值", "余额充值", "", |
| | | "/account/wallet/rechargeCallback", 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); |
| | | //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。 |
| | | long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC); |
| | | redisTemplate.opsForZSet().add("BalanceRecharge", balancePayment.getId(), second); |
| | | return R.ok(jsonObject.toJSONString()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充值支付回调 |
| | | * @param callback |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/rechargeCallback") |
| | | public void rechargeCallback(UniPayCallbackResult callback, HttpServletResponse response){ |
| | | String r2_orderNo = callback.getR2_OrderNo(); |
| | | BalancePayment balancePayment = balancePaymentService.getById(r2_orderNo); |
| | | if(null == balancePayment || balancePayment.getStatus() != 1){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | return; |
| | | } |
| | | if("100".equals(callback.getR6_Status())){ |
| | | //添加账户变动流水 |
| | | BigDecimal money = balancePayment.getMoney(); |
| | | AppUser appUser = appUserService.getById(balancePayment.getAppUserId()); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | appUser.setBalance(appUser.getBalance().add(money)); |
| | | appUser.setWithdrawableAmount(appUser.getWithdrawableAmount().add(money)); |
| | | appUser.setTotalRechargeAmount(appUser.getTotalRechargeAmount().add(money)); |
| | | appUserService.updateById(appUser); |
| | | //流水 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setOrderId(balanceChangeRecord.getId()); |
| | | balanceChangeRecord.setChangeType(1); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(money); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | |
| | | balancePayment.setStatus(2); |
| | | balancePayment.setPaymentTime(LocalDateTime.now()); |
| | | balancePayment.setSerialNumber(callback.getR8_BankOrderNo()); |
| | | balancePayment.setBalanceChangeRecordId(balanceChangeRecord.getId()); |
| | | balancePaymentService.updateById(balancePayment); |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping("/auth") |
| | | @ApiOperation(value = "提现申请审批", tags = {"后台"}) |
| | | public R auth(@RequestParam Long id,@ApiParam("2'审核通过',3'审核拒绝'") Integer auditStatus){ |
| | | public R auth(@RequestParam("id") Long id,@ApiParam("2'审核通过',3'审核拒绝'") @RequestParam("auditStatus") Integer auditStatus){ |
| | | WithdrawalRequests withdrawal = withdrawalRequestsService.getById(id); |
| | | BigDecimal withdrawalAmount = withdrawal.getWithdrawalAmount(); |
| | | if(withdrawal.getAuditStatus() != 1){ |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | List<NearbyReferrerVo> getNearbyReferrer(@Param("cityCode") String cityCode, @Param("nearbyReferrer") NearbyReferrer nearbyReferrer); |
| | | |
| | | IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser); |
| | | IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser, @Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds); |
| | | IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,@Param("objectId")Integer objectId,@Param("userIds")List<Long> userIds); |
| | | |
| | | UserStatistics getUserStatistics(); |
| | | UserStatistics getUserStatistics(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userId); |
| | | |
| | | UserStatisticsDetail getUserStatisticsDetail(Long userId); |
| | | UserStatisticsDetail getUserStatisticsDetail(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds); |
| | | |
| | | |
| | | |
New file |
| | |
| | | package com.ruoyi.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | public interface BalancePaymentMapper extends BaseMapper<BalancePayment> { |
| | | } |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | void onlineRecord(); |
| | | |
| | | IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser); |
| | | IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId); |
| | | IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds); |
| | | |
| | | /** |
| | |
| | | * 降级检测 |
| | | */ |
| | | void demotionDetection(); |
| | | |
| | | |
| | | /** |
| | | * 定时任务关闭订单 |
| | | */ |
| | | void closeOrder(); |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | public interface BalancePaymentService extends IService<BalancePayment> { |
| | | } |
| | |
| | | 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.payment.PaymentUtil; |
| | | import com.ruoyi.account.util.payment.model.CloseOrderResult; |
| | | import com.ruoyi.account.util.tencentMap.TencentMapUtil; |
| | | import com.ruoyi.account.util.weChat.EnvVersion; |
| | | import com.ruoyi.account.util.weChat.WXCore; |
| | |
| | | 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; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @author luodangjia |
| | | * @since 2024-11-21 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService { |
| | | |
| | |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | |
| | | @Resource |
| | | private CouponInfoClient couponInfoClient; |
| | | |
| | | @Resource |
| | | private UserCouponService userCouponService; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | @Resource |
| | | private BalancePaymentService balancePaymentService; |
| | | |
| | | |
| | | /** |
| | |
| | | appUser.setProvinceCode(region.getCode()); |
| | | } |
| | | this.save(appUser); |
| | | //添加定时任务队列 |
| | | VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData(); |
| | | Integer vipCancelDay = vipSetting.getVipCancelDay(); |
| | | Integer vipChangeDay = vipSetting.getVipChangeDay(); |
| | | //解绑推广人 |
| | | redisTemplate.opsForZSet().add("unbind_promoter", appUser.getId().toString(), LocalDateTime.now().plusDays(vipCancelDay).toEpochSecond(ZoneOffset.UTC)); |
| | | //可更换推广人 |
| | | redisTemplate.opsForZSet().add("replaceable", appUser.getId().toString(), LocalDateTime.now().plusDays(vipChangeDay).toEpochSecond(ZoneOffset.UTC)); |
| | | |
| | | //增加积分变动记录 |
| | | if(0 == old && regisPoint > 0){ |
| | | //构建积分流水记录 |
| | |
| | | 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()); |
| | |
| | | public List<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) { |
| | | //使用地图获取省市区数据 |
| | | String citycode = TencentMapUtil.inverseGeographicalAnalysis(nearbyReferrer.getLongitude(), nearbyReferrer.getLatitude(), false); |
| | | if(StringUtils.isEmpty(citycode)){ |
| | | citycode = "510100"; |
| | | } |
| | | if(null != citycode){ |
| | | String cityCode = citycode.substring(0, 4) + "00"; |
| | | List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer); |
| | |
| | | @Override |
| | | public void unbindThePromoter() { |
| | | //注册X天后没有升级成黄金会员则自动解绑推广人 |
| | | VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData(); |
| | | Integer vipCancelDay = vipSetting.getVipCancelDay(); |
| | | Integer vipChangeDay = vipSetting.getVipChangeDay(); |
| | | 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); |
| | | |
| | | //解绑推广人 |
| | | Set<Long> unbind_promoter = redisTemplate.opsForZSet().range("unbind_promoter", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(unbind_promoter.size() > 0){ |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) |
| | | .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter)); |
| | | for (AppUser appUser : list) { |
| | | 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()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | | Set<Long> replaceable = redisTemplate.opsForZSet().range("replaceable", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(replaceable.size() > 0){ |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter)); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser) { |
| | | public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId) { |
| | | if (StringUtils.isNotEmpty(appUser.getShopName())){ |
| | | R<Set<Integer>> shopR = shopClient.getShopIdByName(appUser.getShopName()); |
| | | if (R.isSuccess(shopR)){ |
| | |
| | | } |
| | | } |
| | | } |
| | | return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser); |
| | | return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser, shopId, userId); |
| | | } |
| | | @Override |
| | | public IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds) { |
| | |
| | | this.updateBatchById(appUserList); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 定时任务关闭订单 |
| | | */ |
| | | @Override |
| | | public void closeOrder() { |
| | | //订单支付数据 |
| | | long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); |
| | | Set<String> orderPayment = redisTemplate.opsForZSet().range("BalanceRecharge", 0, second); |
| | | if(orderPayment.size() > 0){ |
| | | List<BalancePayment> list = balancePaymentService.list(new LambdaQueryWrapper<BalancePayment>().in(BalancePayment::getId, orderPayment)); |
| | | for (BalancePayment order : list) { |
| | | if(null == order || order.getStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getId().toString()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("BalanceRecharge", order.getId(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getId(), com.alibaba.fastjson2.JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | import com.ruoyi.account.mapper.BalancePaymentMapper; |
| | | import com.ruoyi.account.service.BalancePaymentService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | @Service |
| | | public class BalancePaymentServiceImpl extends ServiceImpl<BalancePaymentMapper, BalancePayment> implements BalancePaymentService { |
| | | } |
| | |
| | | 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(); |
| | | //关闭充值订单 |
| | | appUserService.closeOrder(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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; |
| | | } |
| | |
| | | and t1.status = #{agentQuery.status} |
| | | </if> |
| | | </where> |
| | | order by t1.status asc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | 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> |
| | |
| | | and ta.shop_id in |
| | | <foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")"> |
| | | #{shopId} |
| | | </foreach> |
| | | </if> |
| | | <if test="null != shopId"> |
| | | and ta.shop_id = #{shopId} or ta.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | |
| | | SUM(CASE WHEN tau.vip_id = 7 THEN 1 ELSE 0 END) AS partnerUser |
| | | FROM |
| | | t_app_user tau |
| | | <where> |
| | | <if test="null != shopId"> |
| | | tau.shop_id = #{shopId} or tau.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail"> |
| | | SELECT |
| | |
| | | FROM |
| | | t_app_user tau |
| | | <where> |
| | | <if test="null != userName and '' != userName"> |
| | | and tau.id = #{userId} |
| | | <if test="null != shopId"> |
| | | tau.shop_id = #{shopId} or |
| | | </if> |
| | | <if test="null != userId and userId.size() > 0"> |
| | | tau.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | from t_user_cancellation_log t1 |
| | | left join t_app_user t2 on t1.app_user_id = t2.id |
| | | <where> |
| | | <if test="agentQuery.name != null and agentQuery.name != ''"> |
| | | and t2.name like concat('%',#{agentQuery.name},'%') |
| | | <if test="agentQuery.userName != null and agentQuery.userName != ''"> |
| | | and t2.name like concat('%',#{agentQuery.userName},'%') |
| | | </if> |
| | | <if test="agentQuery.phone != null and agentQuery.phone != ''"> |
| | | and t2.phone like concat('%',#{agentQuery.phone},'%') |
| | | <if test="agentQuery.userPhone != null and agentQuery.userPhone != ''"> |
| | | and t2.phone like concat('%',#{agentQuery.userPhone},'%') |
| | | </if> |
| | | <if test="agentQuery.vipId != null"> |
| | | and t1.vip_id = #{agentQuery.vipId} |
| | |
| | | and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2} |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | select t1.*,t2.name as userName,t2.phone as userPhone |
| | | from t_withdrawal_requests t1 |
| | | left join t_app_user t2 on t1.app_user_id = t2.id |
| | | |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | 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 com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private BaseSettingClient baseSettingClient; |
| | | @Resource |
| | | private OrderMapper orderMapper; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(value = "订单核销", tags = {"小程序-个人中心-门店管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单号", name = "code", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "String"), |
| | | }) |
| | | @GetMapping("/writeOff/{code}/{shopId}") |
| | | public R<Void> writeOff(@PathVariable("code") String code, @PathVariable("shopId") Integer shopId){ |
| | | orderService.writeOff(code, shopId); |
| | | @GetMapping("/writeOff/{id}/{shopId}") |
| | | public R<Void> writeOff(@PathVariable("id") String id, @PathVariable("shopId") Integer shopId){ |
| | | orderService.writeOff(id, shopId); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | }) |
| | | @GetMapping("/cancel/{orderId}") |
| | | public R<Void> cancel(@PathVariable("orderId") Long orderId){ |
| | | orderService.update(new LambdaUpdateWrapper<Order>() |
| | | .eq(Order::getId, orderId) |
| | | .set(Order::getOrderStatus, OrderStatus.CANCELLED.getCode())); |
| | | return R.ok(); |
| | | public R cancel(@PathVariable("orderId") Long orderId){ |
| | | return orderService.cancel(orderId); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<OrderStatistics> getOrderStatistics(@RequestParam("startTime") String startTime, |
| | | @RequestParam("endTime") String endTime){ |
| | | |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>() |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>().eq(sysUser.getRoleType() == 2, Order::getShopId, sysUser.getObjectId()) |
| | | .between(Order::getCreateTime, LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
| | | |
| | | |
| | |
| | | orderStatisticsDetail.setTotal(total); |
| | | orderStatisticsDetails.add(orderStatisticsDetail); |
| | | }); |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime); |
| | | Integer shopId = null; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime, shopId); |
| | | if(null != orderStatistics){ |
| | | orderStatistics.setOrderStatisticsDetailList(orderStatisticsDetails); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单取消支付回退 |
| | | * @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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getGoodsSaleNum") |
| | | public R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type){ |
| | | Integer goodsSaleNum = orderService.getGoodsSaleNum(goodsId, type); |
| | | return R.ok(goodsSaleNum); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取门店销售订单数量 |
| | | * @param shopId 门店id |
| | | * @param type 1:服务订单,2:单品订单 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getShopSaleNum") |
| | | public R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type){ |
| | | Integer shopSaleNum = orderService.getShopSaleNum(shopId, type); |
| | | return R.ok(shopSaleNum); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有在指定门店消费的用户id |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAppUserByShoppingShop") |
| | | public R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId){ |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getShopId, shopId).eq(Order::getDelFlag, 0).eq(Order::getPayStatus, 2).in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8))); |
| | | Set<Long> collect = list.stream().map(Order::getAppUserId).collect(Collectors.toSet()); |
| | | return R.ok(collect); |
| | | } |
| | | } |
| | | |
| | |
| | | @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); |
| | | } |
| | | |
| | |
| | | List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList); |
| | | |
| | | OrderStatistics getOrderStatistics(@Param("startTime")String startTime, |
| | | @Param("endTime") String endTime); |
| | | @Param("endTime") String endTime, @Param("shopId") Integer shopId); |
| | | |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | Integer getGoodsSaleNum(@Param("goodsId") Integer goodsId, @Param("type") Integer type); |
| | | |
| | | |
| | | /** |
| | | * 获取店铺订单数量 |
| | | * @param shopId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | Integer getShopSaleNum(@Param("shopId") Integer shopId, @Param("type") Integer type); |
| | | } |
| | |
| | | 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.omg.CORBA.INTERNAL; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | boolean check(Order order, Integer shopId, Long userId); |
| | | |
| | | void writeOff(String code,Integer shopId); |
| | | void writeOff(String id,Integer shopId); |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList); |
| | | |
| | | |
| | | /** |
| | | * 小程序取消订单 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | R cancel(Long orderId); |
| | | |
| | | /** |
| | | * 确认发货操作 |
| | |
| | | * 返回订单支付金额和回退积分和会员等级 |
| | | * @param order |
| | | */ |
| | | void refundPayMoney(Order order); |
| | | |
| | | |
| | | R refundPayMoney(Order order); |
| | | |
| | | /** |
| | | * 取消订单后回调处理 |
| | | * @return |
| | | */ |
| | | R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult); |
| | | |
| | | |
| | | /** |
| | | * 取消订单快递费回退 |
| | | * @return |
| | | */ |
| | | R refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult); |
| | | |
| | | |
| | | /** |
| | | * 收货操作 |
| | | * @param orderId |
| | |
| | | * @return |
| | | */ |
| | | OrderInfoVo getOrderInfo(Long orderId); |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | Integer getGoodsSaleNum(Integer goodsId, Integer type); |
| | | |
| | | |
| | | /** |
| | | * 获取店铺订单数量 |
| | | * @param shopId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | Integer getShopSaleNum(Integer shopId, Integer type); |
| | | } |
| | |
| | | R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult); |
| | | |
| | | |
| | | Price getPrice(AppUser appUser, Integer goodsId, Integer shopId); |
| | | Price getPrice(AppUser appUser, Integer goodsId, Integer type, Integer shopId); |
| | | |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void calculationCommission() { |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getIsCommission, 0).isNotNull(Order::getAfterSaleTime) |
| | | .eq(Order::getDelFlag, 0).last(" and after_sale_time <= now()")); |
| | | .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()")); |
| | | List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | |
| | | for (Order order : list) { |
| | | if(order.getPayMethod() == 3){ |
| | | continue; |
| | | } |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .eq(OrderGood::getOrderId, order.getId())); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | |
| | | 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){ |
| | |
| | | } |
| | | |
| | | //上级门店分佣 |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | if(null != shop1){ |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | order.setIsCommission(1); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient; |
| | |
| | | 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; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void writeOff(String code,Integer shopId) { |
| | | public void writeOff(String id,Integer shopId) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getId, code)); |
| | | Order order = orderMapper.selectById(id); |
| | | boolean check = check(order, shopId, loginUserApplet.getUserid()); |
| | | if (!check){ |
| | | throw new ServiceException("订单不存在"); |
| | |
| | | for (OrderPageListVo orderPageListVo : list) { |
| | | Long appUserId = orderPageListVo.getAppUserId(); |
| | | AppUser appUser = appUserClient.getAppUserById(appUserId); |
| | | orderPageListVo.setUserName(appUser.getName()); |
| | | orderPageListVo.setPhone(appUser.getPhone()); |
| | | if(null != appUser){ |
| | | orderPageListVo.setUserName(appUser.getName()); |
| | | orderPageListVo.setPhone(appUser.getPhone()); |
| | | } |
| | | RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0, 1")); |
| | | orderPageListVo.setRefundPassId(null != one ? one.getId().toString() : null); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 小程序取消订单 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R cancel(Long orderId) { |
| | | Order order = this.getById(orderId); |
| | | if(null == order){ |
| | | return R.fail("取消失败"); |
| | | } |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | if(!order.getAppUserId().equals(userid)){ |
| | | return R.fail("取消失败"); |
| | | } |
| | | if(!Arrays.asList(1, 2, 3).contains(order.getOrderStatus())){ |
| | | return R.fail("订单取消失败"); |
| | | } |
| | | if(null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())){ |
| | | return R.fail("订单取消失败"); |
| | | } |
| | | order.setOrderStatus(5); |
| | | R r = refundPayMoney(order); |
| | | if(200 == r.getCode()){ |
| | | this.updateById(order); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * 确认发货操作 |
| | | * @param orderId |
| | |
| | | if(Arrays.asList(5, 6, 7).contains(order.getOrderStatus())){ |
| | | return R.fail("无效的操作"); |
| | | } |
| | | if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){ |
| | | 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()){ |
| | | //余额退款 |
| | | OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderBalancePayment){ |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //构建账户余额流水明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 会员降级检测 |
| | | */ |
| | |
| | | return R.fail("无效的操作"); |
| | | } |
| | | order.setOrderStatus(4); |
| | | R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5); |
| | | if (R.isError(baseSettingR)) { |
| | | return R.fail("售后设置获取失败"); |
| | | } |
| | | BaseSetting baseSetting = baseSettingR.getData(); |
| | | if (baseSetting == null) { |
| | | return R.fail("售后设置获取失败"); |
| | | } |
| | | String content = baseSetting.getContent(); |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | Long days = jsonObject.getLong("days"); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | this.updateById(order); |
| | | return R.ok(); |
| | | } |
| | |
| | | orderInfo.setOrderStatus(order.getOrderStatus()); |
| | | orderInfo.setCreateTime(order.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | orderInfo.setUserName(appUser.getName()); |
| | | orderInfo.setPhone(appUser.getPhone()); |
| | | if(null != appUser){ |
| | | orderInfo.setUserName(appUser.getName()); |
| | | orderInfo.setPhone(appUser.getPhone()); |
| | | } |
| | | orderInfo.setOrderType(order.getOrderType() == 1 ? "服务" : (StringUtils.isNotEmpty(order.getExpressJson()) ? "单品-快递配送" : "单品-自提")); |
| | | Shop shop = shopClient.getShopById(order.getShopId()).getData(); |
| | | if(null != shop){ |
| | |
| | | orderInfo.setGoodsJson(JSON.toJSONString(goodsJson)); |
| | | return orderInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getGoodsSaleNum(Integer goodsId, Integer type) { |
| | | return this.baseMapper.getGoodsSaleNum(goodsId, type); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取店铺订单数量 |
| | | * @param shopId |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getShopSaleNum(Integer shopId, Integer type) { |
| | | return this.baseMapper.getShopSaleNum(shopId, type); |
| | | } |
| | | } |
| | |
| | | List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); |
| | | for (OrderRefundPassList refundPassList : orderRefundPassList) { |
| | | AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId()); |
| | | refundPassList.setUserName(appUser.getName()); |
| | | refundPassList.setPhone(appUser.getPhone()); |
| | | if(null != appUser){ |
| | | refundPassList.setUserName(appUser.getName()); |
| | | refundPassList.setPhone(appUser.getPhone()); |
| | | } |
| | | } |
| | | return pageInfo.setRecords(orderRefundPassList); |
| | | } |
| | |
| | | return R.fail("不能重复操作"); |
| | | } |
| | | refundPass.setPassStatus(status); |
| | | refundPass.setAuthTime(LocalDateTime.now()); |
| | | //退货退款 |
| | | if(refundPass.getRefundMethod() == 1 && 2 == status){ |
| | | refundPass.setStatus(4); |
| | |
| | | if(refundPass.getRefundMethod() == 2 && 2 == status){ |
| | | refundPass.setStatus(2); |
| | | } |
| | | if(3 == status){ |
| | | refundPass.setStatus(3); |
| | | } |
| | | 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); |
| | |
| | | area.setProvinceCode(appUser.getProvinceCode()); |
| | | area.setVip(appUser.getVipId()); |
| | | GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); |
| | | price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsArea.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsArea.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); |
| | | if(null != goodsArea){ |
| | | price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsArea.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsArea.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); |
| | | }else{ |
| | | GoodsVip goodsVip = goodsVipClient.getGoodsVip(goodsId, appUser.getVipId()).getData(); |
| | | price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsVip.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsVip.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsVip.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsVip.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsVip.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsVip.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsVip.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsVip.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsVip.getBoundShopSuperiorsPoints()); |
| | | } |
| | | } |
| | | }else{ |
| | | //构建价格数据 |
| | |
| | | @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); |
| | | } |
| | | //查询当前是否有订单活动 |
| | | OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | |
| | | BigDecimal orderMoney = confirmOrderVo.getOrderMoney(); |
| | | BigDecimal paymentMoney = orderMoney; |
| | | //满XX才打折,只有现金才能优惠 |
| | | if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1 && orderActivityInfo.getConditionAmount().compareTo(orderMoney) <= 0){ |
| | | confirmOrderVo.setActivityName(orderActivityInfo.getActivityName()); |
| | | paymentMoney = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(orderMoney); |
| | | confirmOrderVo.setDiscountAmount(orderMoney.subtract(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //总优惠金额 |
| | | BigDecimal activityAmount = BigDecimal.ZERO; |
| | | |
| | | //减去优惠券优惠金额 |
| | | CouponInfoVo couponInfoVo = null; |
| | | if(null != confirmOrder.getCouponId() && 2 != confirmOrder.getPaymentType()){ |
| | | couponInfoVo = userCouponClient.getCouponInfo(confirmOrder.getCouponId()).getData(); |
| | | String forGoodIds = couponInfoVo.getForGoodIds(); |
| | | String[] split = forGoodIds.split(","); |
| | | List<String> parseArray = Arrays.asList(split); |
| | | //全部商品 |
| | | if("-1".equals(forGoodIds)){ |
| | | //满减 |
| | | if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | paymentMoney = paymentMoney.subtract(couponInfoVo.getDiscountAmount()); |
| | | activityAmount = activityAmount.add(couponInfoVo.getDiscountAmount()); |
| | | } |
| | | //代金券 |
| | | if(2 == couponInfoVo.getCouponType()){ |
| | | paymentMoney = paymentMoney.subtract(couponInfoVo.getMoneyAmount()); |
| | | activityAmount = activityAmount.add(couponInfoVo.getMoneyAmount()); |
| | | if(paymentMoney.compareTo(BigDecimal.ZERO) < 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | | } |
| | | //折扣券 |
| | | if(3 == couponInfoVo.getCouponType()){ |
| | | BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | paymentMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | } |
| | | }else{ |
| | | //部分商品,需要计算参与优惠商品的支付金额,然后再对商品进行优惠券处理 |
| | | paymentMoney = BigDecimal.ZERO; |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | String goodsId = myShoppingCartVo.getGoodsId().toString(); |
| | | BigDecimal cash = myShoppingCartVo.getCash(); |
| | | if(parseArray.contains(goodsId)){ |
| | | goodsMoney = goodsMoney.add(cash); |
| | | }else{ |
| | | paymentMoney = paymentMoney.add(cash); |
| | | } |
| | | } |
| | | |
| | | //满减 |
| | | if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(goodsMoney) <= 0){ |
| | | goodsMoney = goodsMoney.subtract(couponInfoVo.getDiscountAmount()); |
| | | activityAmount = activityAmount.add(couponInfoVo.getDiscountAmount()); |
| | | } |
| | | //代金券 |
| | | if(2 == couponInfoVo.getCouponType()){ |
| | | goodsMoney = goodsMoney.subtract(couponInfoVo.getMoneyAmount()); |
| | | activityAmount = activityAmount.add(couponInfoVo.getMoneyAmount()); |
| | | if(goodsMoney.compareTo(BigDecimal.ZERO) < 0){ |
| | | goodsMoney = BigDecimal.ZERO; |
| | | } |
| | | } |
| | | //折扣券 |
| | | if(3 == couponInfoVo.getCouponType()){ |
| | | BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(goodsMoney); |
| | | BigDecimal bigDecimal = goodsMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | goodsMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | } |
| | | paymentMoney = paymentMoney.add(goodsMoney); |
| | | } |
| | | } |
| | | |
| | | //查询当前是否有订单活动 |
| | | List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | //满XX才打折,只有现金才能优惠 |
| | | if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1){ |
| | | for (OrderActivityInfo activityInfo : orderActivityInfo) { |
| | | if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | confirmOrderVo.setActivityName(activityInfo.getActivityName()); |
| | | //优惠后的支付金额 |
| | | BigDecimal multiply = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | //优惠金额 |
| | | BigDecimal bigDecimal = paymentMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN); |
| | | paymentMoney = multiply; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | confirmOrderVo.setDiscountAmount(activityAmount); |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | | confirmOrderVo.setUseSimultaneously(JSON.parseObject(baseSetting.getContent()).getInteger("status") == 1); |
| | | int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).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()); |
| | |
| | | for (int i = 0; i < objects.size(); i++) { |
| | | Long id = objects.getJSONObject(i).getLong("id"); |
| | | Integer num1 = objects.getJSONObject(i).getInteger("num"); |
| | | Integer type = objects.getJSONObject(i).getInteger("type"); |
| | | num += num1; |
| | | ShoppingCart shoppingCart = this.getById(id); |
| | | //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) |
| | | Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type); |
| | | 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<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList()); |
| | | int sum = 0; |
| | | if(orderIds.size() > 0){ |
| | | List<OrderGood> orderGoodList = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().in(OrderGood::getOrderId, orderIds) |
| | | .eq(OrderGood::getGoodsId, shoppingCart.getGoodsId()).eq(OrderGood::getDelFlag, 0)); |
| | | sum = orderGoodList.stream().mapToInt(OrderGood::getNum).sum(); |
| | | } |
| | | if((num1 + sum) > goods.getPurchaseLimit()){ |
| | | if(1 == type){ |
| | | if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + num1) > goods.getPurchaseLimit()){ |
| | | return R.fail(goods.getName() + "已超出购买上限"); |
| | | } |
| | | }else{ |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(shoppingCart.getGoodsId()); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null != goodsSeckill ){ |
| | | SeckillActivityInfo activityInfo = seckillActivityInfoClient.getSeckillActivityInfoById(goodsSeckill.getSeckillActivityInfoId()).getData(); |
| | | if(null != activityInfo.getMaxNum() && -1 != activityInfo.getMaxNum() && (goodsSaleNum + num1) > activityInfo.getMaxNum()){ |
| | | return R.fail(goods.getName() + "已超出秒杀活动购买上限"); |
| | | } |
| | | } |
| | | } |
| | | ids.add(id); |
| | |
| | | } |
| | | |
| | | //查询当前是否有订单活动 |
| | | OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | | //系统活动设置(优惠券和活动能否同时使用) |
| | | boolean useSimultaneously = baseSetting.getContent().equals("1"); |
| | | Integer status = JSON.parseObject(baseSetting.getContent()).getInteger("status"); |
| | | //满XX才打折,只有现金才能优惠 |
| | | //如果使用优惠券,则需要判断是否可以和同时使用,且活动满足使用条件。 |
| | | //没有使用优惠券,只需要判断是都满足使用条件 |
| | | if((useSimultaneously || null == shoppingCartPayment.getUserCouponId()) && |
| | | null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3 && orderActivityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | BigDecimal paymentMoney1 = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | discount = orderActivityInfo.getDiscount(); |
| | | paymentMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | OrderActivityInfo orderActivityInfo1 = null; |
| | | if((1 == status || null == shoppingCartPayment.getUserCouponId()) && |
| | | null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3){ |
| | | for (OrderActivityInfo activityInfo : orderActivityInfo) { |
| | | if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | BigDecimal paymentMoney1 = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | discount = activityInfo.getDiscount(); |
| | | paymentMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | orderActivityInfo1 = activityInfo; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //可获得的消费积分 |
| | |
| | | order.setCouponJson(JSON.toJSONString(couponInfoVo)); |
| | | } |
| | | if(activityAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo)); |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo1)); |
| | | } |
| | | if(null != shoppingCartPayment.getUserAddressId()){ |
| | | UserAddress address = userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData(); |
| | |
| | | OrderGood orderGood = new OrderGood(); |
| | | orderGood.setGoodsId(myShoppingCartVo.getGoodsId()); |
| | | orderGood.setOrderId(order.getId()); |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(myShoppingCartVo.getGoodsId()); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null != goodsSeckill){ |
| | | orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill)); |
| | | } |
| | | for (int i = 0; i < objects.size(); i++) { |
| | | Long id = objects.getJSONObject(i).getLong("id"); |
| | | if(myShoppingCartVo.getId().equals(id.toString())){ |
| | | ShoppingCart shoppingCart = this.getById(id); |
| | | Integer num1 = objects.getJSONObject(i).getInteger("num"); |
| | | Integer type = objects.getJSONObject(i).getInteger("type"); |
| | | orderGood.setNum(num1); |
| | | orderGood.setType(type); |
| | | if(2 == type){ |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(myShoppingCartVo.getGoodsId()); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null != goodsSeckill){ |
| | | orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill)); |
| | | } |
| | | } |
| | | Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | orderGood.setGoodJson(JSON.toJSONString(goods1)); |
| | | break; |
| | |
| | | //调起微信支付 |
| | | 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(expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | if(shoppingCartPayment.getFreightPaymentType() == 1){ |
| | | //调起微信支付 |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber() + appUser.getId(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费", |
| | | "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), ""); |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay("K" + order.getOrderNumber(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费", |
| | | "快递费", "", "/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); |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", "K" + order.getOrderNumber(), second); |
| | | 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()); |
| | |
| | | @Override |
| | | public R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult) { |
| | | String r2_orderNo = uniPayCallbackResult.getR2_OrderNo(); |
| | | r2_orderNo = r2_orderNo.substring(0, 23); |
| | | r2_orderNo = r2_orderNo.substring(1); |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, r2_orderNo)); |
| | | if(null == order || order.getPayStatus() == 2){ |
| | | return R.ok(); |
| | |
| | | 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); |
| | | //自提 |
| | |
| | | //订单支付数据 |
| | | long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); |
| | | Set<String> orderPayment = redisTemplate.opsForZSet().range("OrderPayment", 0, second); |
| | | for (String code : orderPayment) { |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("OrderPayment", code, 0); |
| | | log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult)); |
| | | if(orderPayment.size() > 0){ |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, orderPayment)); |
| | | for (Order order : list) { |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getOrderNumber()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("OrderPayment", order.getOrderNumber(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber()); |
| | | } |
| | | } |
| | | |
| | | //快递支付 |
| | | Set<String> materialFlowPayment = redisTemplate.opsForZSet().range("MaterialFlowPayment", 0, second); |
| | | for (String code : materialFlowPayment) { |
| | | code = code.substring(0, 23); |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", code, 0); |
| | | log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult)); |
| | | if(materialFlowPayment.size() > 0){ |
| | | materialFlowPayment.forEach(s->s.substring(1)); |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, materialFlowPayment)); |
| | | for (Order order : list) { |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder("K" + order.getOrderNumber()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber()); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | |
| | | private BigDecimal orderMoney; |
| | | @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | private Long appUserId; |
| | | @ApiModelProperty("售后订单id") |
| | | private String refundPassId; |
| | | } |
| | |
| | | private Integer refundMethod; |
| | | @ApiModelProperty("申请原因") |
| | | private String refundReason; |
| | | @ApiModelProperty("1待审核2已完成3已拒绝4待退货5待平台收货") |
| | | private Integer status; |
| | | @ApiModelProperty("状态(1待审核2同意3拒绝)") |
| | | private Integer passStatus; |
| | | /** |
| | |
| | | o.num, |
| | | o.point, |
| | | o.payment_amount, |
| | | o.express_amount, |
| | | COUNT(o.id) AS order_count |
| | | FROM |
| | | t_order o |
| | | <where> |
| | | <if test="status != null"> |
| | | o.order_status = #{status} |
| | | <choose> |
| | | <when test="status == 4"> |
| | | o.order_status in (4, 8) |
| | | </when> |
| | | <otherwise> |
| | | o.order_status = #{status} |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | <if test="userId != null"> |
| | | AND o.app_user_id = #{userId} |
| | |
| | | o.num, |
| | | o.point, |
| | | o.payment_amount, |
| | | o.create_time |
| | | o.create_time, |
| | | o.express_amount |
| | | ORDER BY |
| | | o.create_time DESC |
| | | </select> |
| | |
| | | <if test="startTime != null and '' != startTime and endTime != null and '' != endTime"> |
| | | and tor.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | <if test="null != shopId"> |
| | | and tor.shop_id = #{shopId} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="getGoodsSaleNum" resultType="int"> |
| | | select |
| | | ifnull(sum(a.num), 0) |
| | | from t_order_good a |
| | | left join t_order b on (a.order_id = b.id) |
| | | where b.del_flag = 0 and b.pay_status = 2 and b.order_status in (1, 2, 3, 4, 7, 8) and a.goods_id = #{goodsId} |
| | | <if test="null != type"> |
| | | and a.type = #{type} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="getShopSaleNum" resultType="int"> |
| | | select |
| | | ifnull(count(1), 0) |
| | | from t_order a |
| | | where del_flag = 0 and pay_status = 2 and order_status in (1, 2, 3, 4, 7, 8) |
| | | <if test="null != shopId and 0 != shopId"> |
| | | and shop_id = #{shopId} |
| | | </if> |
| | | <if test="null != type"> |
| | | and order_type = #{type} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m:%s') as createTime, |
| | | a.refund_method as refundMethod, |
| | | a.refund_reason as refundReason, |
| | | a.pass_status as passStatus |
| | | a.pass_status as passStatus, |
| | | a.status |
| | | from t_refund_pass a |
| | | left join t_order b on (a.order_id = b.id) |
| | | where a.del_flag = 0 |
| | |
| | | @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); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @GetMapping("/goodsDetail/{goodsId}") |
| | | @ApiOperation(value = "商品详情", tags = {"小程序-商城-首页"}) |
| | | public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId){ |
| | | return R.ok(goodsService.goodsDetail(goodsId)); |
| | | public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId, String longitude, String latitude){ |
| | | return R.ok(goodsService.goodsDetail(goodsId, longitude, latitude)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getNowOrderActivityInfo") |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1")); |
| | | public R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | List<OrderActivityInfo> one = orderActivityInfoService.list(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .eq(OrderActivityInfo::getIsShelf, 1).last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids)")); |
| | | return R.ok(one); |
| | | } |
| | | |
| | |
| | | Page<OrderActivityInfo> page = orderActivityInfoService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<OrderActivityInfo>() |
| | | .eq(orderActivityInfo.getId() != null, OrderActivityInfo::getId, orderActivityInfo.getId()) |
| | | .eq(StringUtils.isNotEmpty(orderActivityInfo.getActivityName()), OrderActivityInfo::getActivityName, orderActivityInfo.getActivityName()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, orderActivityInfo.getStartTime()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf())); |
| | | .gt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, LocalDateTime.now()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()).orderByDesc(OrderActivityInfo::getCreateTime)); |
| | | page.getRecords().forEach(item -> { |
| | | LocalDateTime startTime = item.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | */ |
| | | @GetMapping("/detail/{id}") |
| | | @ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页"}) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id, String latitude, String longitude) |
| | | { |
| | | return R.ok(seckillActivityInfoService.detail(id)); |
| | | return R.ok(seckillActivityInfoService.detail(id, latitude, longitude)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取商品秒杀活动 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSeckillActivityInfoById") |
| | | public R<SeckillActivityInfo> getSeckillActivityInfoById(@RequestParam("id") Integer id){ |
| | | SeckillActivityInfo one = seckillActivityInfoService.getById(id); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 秒杀活动列表 |
| | | */ |
| | | @GetMapping("/manageList") |
| | |
| | | import com.ruoyi.other.enums.ShareAddType; |
| | | import com.ruoyi.other.enums.ShareAuditStatus; |
| | | import com.ruoyi.other.service.ShareService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | |
| | | public R<List<Share>> recommandlist() { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | return R.ok(shareService.list(new LambdaQueryWrapper<Share>().eq(Share::getAddType, 2) |
| | | .eq(Share::getObjectId, userid))); |
| | | .eq(Share::getObjectId, userid).or().eq(Share::getAddType, 1).eq(Share::getAuditStatus, 1).eq(Share::getDelFlag, 0))); |
| | | } |
| | | |
| | | |
| | |
| | | public R<Void> manage(@RequestBody Share share) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Long userid = loginUser.getSysUser().getUserId(); |
| | | share.setAddType(1); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | share.setAddType(sysUser.getRoleType() == 1 ? 1 : 3); |
| | | share.setAppletShare(0); |
| | | share.setAuditStatus(ShareAuditStatus.SUCCESS.getCode()); |
| | | share.setObjectId(userid.toString()); |
| | | if(sysUser.getRoleType() == 2){ |
| | | share.setObjectId(sysUser.getObjectId().toString()); |
| | | } |
| | | share.setDelFlag(0); |
| | | shareService.save(share); |
| | | return R.ok(); |
| | |
| | | @ApiOperation(value = "广告管理-分享管理-编辑", tags = {"管理后台"}) |
| | | @PostMapping("/manage/edit") |
| | | public R<Void> manageedit(@RequestBody Share share) { |
| | | |
| | | shareService.updateById(share); |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiOperation(value = "广告管理-分享管理-删除", tags = {"管理后台"}) |
| | | @GetMapping("/manage/delete") |
| | | public R<Void> managedelete(@RequestParam Integer id) { |
| | | |
| | | shareService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | |
| | | public R<Page<Share>> managelist(String name, Integer addType, @RequestParam Integer pageNum, Integer pageSize) { |
| | | //判断当前登陆人是平台还是门店 |
| | | if (tokenService.getLoginUser().getSysUser().getRoleType()==1) { |
| | | Page<Share> page = shareService.lambdaQuery().eq(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().eq(Share::getAuditStatus, 1).like(name != null, Share::getName, name) |
| | | .eq(Share::getAddType, 1).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | }else { |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, tokenService.getLoginUser().getSysUser().getObjectId()).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize)); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, sysUser.getObjectId()) |
| | | .like(name != null, Share::getName, name).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | } |
| | |
| | | @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())); |
| | |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.vo.VerifiableShopVo; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | | import com.ruoyi.other.api.domain.GoodsShop; |
| | |
| | | private GoodsService goodsService; |
| | | @Resource |
| | | private GoodsShopService goodsShopService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | |
| | |
| | | Shop shop = shopService.getById(id); |
| | | shop.setDelFlag(1); |
| | | shopService.updateById(shop); |
| | | //获取门店的员工数据 |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setShopId(shop.getId()); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | |
| | | sysUserClient.delShopUser(shop.getId(), 2); |
| | | //修改小程序用户类型和门店数据 |
| | | for (SysUser sysUser : sysUserList) { |
| | | String userName = sysUser.getUserName(); |
| | | //通过电话号码查询小程序用户和门店关系数据 |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(userName).getData(); |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(sysUser.getUserName()).getData(); |
| | | //需要先判断用户是否没有关联任何门店 |
| | | List<AppUserShop> userShops = appUserShopClient.getAppUserShop(appUser.getId()).getData(); |
| | | if(userShops.size() == 1 && userShops.get(0).getShopId().equals(shop.getId())){ |
| | | appUser.setUserType(1); |
| | | appUserClient.editAppUserById(appUser); |
| | | } |
| | | |
| | | //删除用户门店关系表数据 |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(shop.getId()); |
| | | appUserShopClient.delAppUserShop(appUserShop); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | 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 = {"管理后台-门店管理"}) |
| | |
| | | @ApiOperation(value = "绑定门店", tags = {"小程序-个人中心"}) |
| | | public R<Void> bindShop(@ApiParam("门店id") @RequestParam Integer shopId) { |
| | | AppUser appUser = appUserClient.getAppUserById(SecurityUtils.getUserId()); |
| | | if(null != appUser.getShopId()){ |
| | | return R.fail("不能重复绑定门店"); |
| | | } |
| | | appUser.setShopId(shopId); |
| | | return appUserClient.editAppUserById(appUser); |
| | | } |
| | |
| | | @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<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) { |
| | | ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId); |
| | | if(null == shopId){ |
| | | shopId = 0; |
| | | } |
| | | Integer serviceOrder = orderClient.getShopSaleNum(shopId, 1).getData(); |
| | | Integer goodsOrder = orderClient.getShopSaleNum(shopId, 2).getData(); |
| | | shopStatistics.setTotalOrder(serviceOrder + goodsOrder); |
| | | shopStatistics.setServiceOrder(serviceOrder); |
| | | shopStatistics.setGoodsOrder(goodsOrder); |
| | | return R.ok(shopStatistics); |
| | | } |
| | | |
| | |
| | | @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); |
| | | } |
| | |
| | | shopService.saveWithdrawalAccount(saveWithdrawalAccount); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有门店 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAllShop") |
| | | public R<List<Shop>> getAllShop(){ |
| | | List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import com.ruoyi.other.service.ShopPointService; |
| | | import com.ruoyi.other.vo.ShopPointStatistics; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private ShopPointService shopPointService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | /** |
| | |
| | | @GetMapping("/shop/statistics") |
| | | @ApiOperation(value = "门店积分统计", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<ShopPointStatistics> shopstatistics(ShopPoint shopPoint) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | shopPoint.setShopId(objectId); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | shopPoint.setShopId(sysUser.getObjectId()); |
| | | ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint); |
| | | return R.ok(statistics); |
| | | } |
| | | @GetMapping("/shop/statistics/list") |
| | | @ApiOperation(value = "门店积分统计列表", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<Page<ShopPoint>> shopstatisticslist(ShopPoint shopPoint,Integer pageNum,Integer pageSize) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, objectId).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, sysUser.getObjectId()).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) |
| | | .like(shopPoint.getOrderNum()!=null,ShopPoint::getOrderNum, shopPoint.getOrderNum()) |
| | | .orderByDesc(ShopPoint::getCreateTime) |
| | | .page(Page.of(pageNum, pageSize)); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | @PostMapping("/manage/addorupdate") |
| | | @ApiOperation(value = "添加编辑", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> add(@RequestBody Technician technician) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | if (technician.getId()==null) { |
| | | technician.setSubscribeStatus(2); |
| | | List<Technician> list = technicianService.lambdaQuery().eq(Technician::getPhone, technician.getPhone()).list(); |
| | | if (!list.isEmpty()) { |
| | | return R.fail("当前号码已经添加"); |
| | | } |
| | | R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone()); |
| | | if (appUserByPhone1.getData()==null){ |
| | | return R.fail("当前号码暂无注册用户"); |
| | | } |
| | | }else { |
| | | Technician byId = technicianService.getById(technician.getId()); |
| | | if (byId.getPhone()!=technician.getPhone()){ |
| | | List<Technician> list = technicianService.lambdaQuery().eq(Technician::getPhone, technician.getPhone()).list(); |
| | | if (!list.isEmpty()) { |
| | | return R.fail("当前号码已经添加"); |
| | | } |
| | | R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone()); |
| | | if (appUserByPhone1.getData()==null){ |
| | | return R.fail("当前号码暂无注册用户"); |
| | | } |
| | | } |
| | | } |
| | | technician.setShopId(objectId); |
| | | R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone()); |
| | | if (appUserByPhone1.getData()!=null){ |
| | | technician.setAppUserId(appUserByPhone1.getData().getId()); |
| | | } |
| | | technicianService.saveOrUpdate(technician); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.ruoyi.other.api.domain.TechnicianSubscribe; |
| | | import com.ruoyi.other.service.TechnicianSubscribeService; |
| | | import com.ruoyi.other.vo.TechnicianSubscribeVO; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private TechnicianSubscribeService technicianSubscribeService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/shop/list") |
| | |
| | | @ApiParam("电话")String phone, |
| | | @ApiParam("姓名")String name, |
| | | @ApiParam("服务方式:1=上门服务,2=到店服务")Integer serviceMode, Integer pageCurr, Integer pageSize) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(objectId), status, phone, name, serviceMode, pageCurr, pageSize); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(sysUser.getObjectId()), status, phone, name, serviceMode, pageCurr, pageSize); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | |
| | | @GetMapping("/cancel") |
| | | @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理,小程序-个人中心-我的预约","门店-预约管理"}) |
| | | public R<Void> cancel(@ApiParam(value = "预约id") @RequestParam Long id) { |
| | | |
| | | TechnicianSubscribe subscribe = technicianSubscribeService.getOne(new LambdaQueryWrapper<TechnicianSubscribe>() |
| | | .eq(TechnicianSubscribe::getId, id) |
| | | .eq(TechnicianSubscribe::getStatus, 0)); |
| | |
| | | * @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); |
| | | } |
| | |
| | | |
| | | List<NearbyShopVO> selectNearbyShopList(@Param("longitude") BigDecimal longitude,@Param("latitude") BigDecimal latitude); |
| | | |
| | | ShopDetailVO selectShopDetail(Integer shopId); |
| | | ShopDetailVO selectShopDetail(@Param("shopId") Integer shopId); |
| | | |
| | | ShopStatistics getShopStatistics(@Param("shopId") Integer shopId); |
| | | |
| | |
| | | |
| | | PageInfo<GoodsVO> goodsList(Goods goods); |
| | | |
| | | GoodsVO goodsDetail(Long goodsId); |
| | | GoodsVO goodsDetail(Long goodsId, String longitude, String latitude); |
| | | |
| | | List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId); |
| | | |
| | |
| | | |
| | | List<SeckillActivityVO> listSeckillActivity(Goods goods); |
| | | |
| | | SeckillActivityDetailVO detail(Integer seckillActivityId); |
| | | SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude); |
| | | |
| | | void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo); |
| | | |
| | |
| | | IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status); |
| | | |
| | | void subscribe(TechnicianSubscribe technicianSubscribe); |
| | | |
| | | |
| | | /** |
| | | * 定时修改到期状态 |
| | | */ |
| | | void taskEditStstus(); |
| | | } |
| | |
| | | |
| | | 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.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | 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; |
| | | import com.ruoyi.other.mapper.GoodsShopMapper; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.util.GeodesyUtil; |
| | | import com.ruoyi.other.vo.GoodsVO; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.jetbrains.annotations.NotNull; |
| | |
| | | private GoodsAreaService goodsAreaService; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private SeckillActivityInfoService seckillActivityInfoService; |
| | | @Resource |
| | | private GoodsSeckillService goodsSeckillService; |
| | | @Resource |
| | | private GoodsBargainPriceService goodsBargainPriceService; |
| | | @Resource |
| | | private GoodsBargainPriceDetailService goodsBargainPriceDetailService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | |
| | | @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(), null, 1, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | goods.setCashPayment(price.getCashPayment() ? 1 : 0); |
| | | goods.setPointPayment(price.getPointPayment() ? 1 : 0); |
| | | goods.setSellingPrice(price.getCash()); |
| | | goods.setIntegral(price.getPoint()); |
| | | } |
| | | Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData(); |
| | | goods.setSaleNum(data); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | @Override |
| | | public GoodsVO goodsDetail(Long goodsId) { |
| | | public GoodsVO goodsDetail(Long goodsId, String longitude, String latitude) { |
| | | if (goodsId == null || goodsId <= 0) { |
| | | 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(), null, 1, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | goodsVO.setPointPayment(price.getPointPayment() ? 1 : 0); |
| | | goodsVO.setCashPayment(price.getCashPayment() ? 1 : 0); |
| | | goodsVO.setSellingPrice(price.getCash()); |
| | | goodsVO.setIntegral(price.getPoint()); |
| | | } |
| | | |
| | | if(goods.getType() == 1){ |
| | | if(goods.getAppointStore() == 2){ |
| | |
| | | .in(Shop::getDelFlag, 0)); |
| | | goodsVO.setShopList(shopList); |
| | | } |
| | | List<Shop> shopList = goodsVO.getShopList(); |
| | | for (Shop shop : shopList) { |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | shop.setDistance(wgs84); |
| | | } |
| | | shopList.sort(new Comparator<Shop>() { |
| | | @Override |
| | | public int compare(Shop o1, Shop o2) { |
| | | return o1.getDistance().compareTo(o2.getDistance()); |
| | | } |
| | | }); |
| | | goodsVO.setShopList(shopList); |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); |
| | | goodsVO.setSaleNum(integer); |
| | | return goodsVO; |
| | | } |
| | | |
| | | |
| | | @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(), shopId, 1, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | good.setCashPayment(price.getCashPayment() ? 1 : 0); |
| | | good.setPointPayment(price.getPointPayment() ? 1 : 0); |
| | | good.setSellingPrice(price.getCash()); |
| | | good.setIntegral(price.getPoint()); |
| | | } |
| | | Integer data = orderClient.getGoodsSaleNum(good.getId(), 1).getData(); |
| | | good.setSaleNum(data); |
| | | } |
| | | return goods; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (!CollectionUtils.isEmpty(goodsAreaList)){ |
| | | for (GoodsArea goodsArea : goodsAreaList) { |
| | | List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList(); |
| | | List<GoodsArea> goodsAreaList2 = new ArrayList<>(); |
| | | for (GoodsArea area : goodsAreaList1) { |
| | | area.setId(null); |
| | | area.setGoodsId(id); |
| | |
| | | area.setProvinceCode(goodsArea.getProvinceCode()); |
| | | area.setCityCode(goodsArea.getCityCode()); |
| | | area.setDistrictsCode(goodsArea.getDistrictsCode()); |
| | | if(null != area.getSellingPrice() && null != area.getIntegral()){ |
| | | goodsAreaList2.add(area); |
| | | } |
| | | } |
| | | goodsAreaService.saveBatch(goodsAreaList1); |
| | | goodsAreaService.saveBatch(goodsAreaList2); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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.order.feignClient.OrderClient; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.mapper.GoodsShopMapper; |
| | | import com.ruoyi.other.mapper.SeckillActivityInfoMapper; |
| | |
| | | import com.ruoyi.other.service.GoodsSeckillService; |
| | | import com.ruoyi.other.service.GoodsService; |
| | | import com.ruoyi.other.service.SeckillActivityInfoService; |
| | | import com.ruoyi.other.util.GeodesyUtil; |
| | | import com.ruoyi.other.vo.SeckillActivityDetailVO; |
| | | import com.ruoyi.other.vo.SeckillActivityVO; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private GoodsSeckillService goodsSeckillService; |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | @Override |
| | | public List<SeckillActivityVO> listSeckillActivity(Goods goods) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); |
| | | goods.setVipId(appUser.getVipId()); |
| | | return seckillActivityInfoMapper.listSeckillActivity(goods); |
| | | List<SeckillActivityVO> seckillActivityVOS = seckillActivityInfoMapper.listSeckillActivity(goods); |
| | | for (SeckillActivityVO seckillActivityVO : seckillActivityVOS) { |
| | | Integer data = orderClient.getGoodsSaleNum(seckillActivityVO.getGoodsId(), 2).getData(); |
| | | seckillActivityVO.setSaleNum(data); |
| | | LocalDateTime startTime = seckillActivityVO.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime endTime = seckillActivityVO.getEndTime(); |
| | | if (endTime.isBefore(now)){ |
| | | seckillActivityVO.setStatus(3); //已结束 |
| | | }else if (startTime.isBefore(now)){ |
| | | seckillActivityVO.setStatus(2); // 已开始 |
| | | }else { |
| | | seckillActivityVO.setStatus(1); // 未开始 |
| | | } |
| | | } |
| | | 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()); |
| | | public SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude) { |
| | | 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); |
| | |
| | | }else{ |
| | | shops = shopMapper.selectList(new LambdaUpdateWrapper<Shop>().eq(Shop::getDelFlag, 0)); |
| | | } |
| | | |
| | | for (Shop shop : shops) { |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | shop.setDistance(wgs84); |
| | | } |
| | | shops.sort(new Comparator<Shop>() { |
| | | @Override |
| | | public int compare(Shop o1, Shop o2) { |
| | | return o1.getDistance().compareTo(o2.getDistance()); |
| | | } |
| | | }); |
| | | seckillActivityDetailVO.setShopList(shops); |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 2).getData(); |
| | | seckillActivityDetailVO.setSaleNum(integer); |
| | | return seckillActivityDetailVO; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude); |
| | | if(null != appUser && null != appUser.getShopId()){ |
| | | AppUser finalAppUser = appUser; |
| | | NearbyShopVO nearbyShopVO = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst().get(); |
| | | if(null != nearbyShopVO){ |
| | | nearbyShopVOS.remove(nearbyShopVO); |
| | | Optional<NearbyShopVO> first = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst(); |
| | | if(first.isPresent()){ |
| | | NearbyShopVO nearbyShopVO = first.get(); |
| | | if(null != nearbyShopVO){ |
| | | nearbyShopVOS.remove(nearbyShopVO); |
| | | } |
| | | } |
| | | |
| | | Shop shop = shopMapper.selectById(appUser.getShopId()); |
| | | NearbyShopVO vo = new NearbyShopVO(); |
| | | vo.setId(appUser.getShopId().longValue()); |
| | | vo.setName(shop.getName()); |
| | | vo.setAddress(shop.getAddress()); |
| | | vo.setHomePicture(shop.getHomePicture()); |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | vo.setDistance(wgs84.toString()); |
| | | nearbyShopVOS.add(0, vo); |
| | | if(null != shop){ |
| | | NearbyShopVO vo = new NearbyShopVO(); |
| | | vo.setId(appUser.getShopId().longValue()); |
| | | vo.setName(shop.getName()); |
| | | vo.setAddress(shop.getAddress()); |
| | | vo.setHomePicture(shop.getHomePicture()); |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | vo.setDistance(wgs84.toString()); |
| | | nearbyShopVOS.add(0, vo); |
| | | } |
| | | } |
| | | if (nearbyShopVOS == null || nearbyShopVOS.isEmpty()) { |
| | | return Collections.emptyList(); |
| | |
| | | |
| | | @Override |
| | | public ShopDetailVO getShopDetail(Integer shopId, BigDecimal longitude, BigDecimal latitude) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | // 查询店铺详情 |
| | | ShopDetailVO shopDetailVO = shopMapper.selectShopDetail(shopId); |
| | | if (shopDetailVO == null) { |
| | | throw new ServiceException("查询店铺不存在"); |
| | | } |
| | | |
| | | ShopScore one = shopScoreService.getOne(new LambdaQueryWrapper<ShopScore>().eq(ShopScore::getAppUserId, userid).eq(ShopScore::getShopId, shopId).last(" order by create_time desc limit 0, 1")); |
| | | shopDetailVO.setScore(null == one ? BigDecimal.ZERO : one.getScore()); |
| | | // 计算距离 |
| | | if (shopDetailVO.getLongitude() != null && shopDetailVO.getLatitude() != null){ |
| | | String shopLocation = String.format("%s,%s", shopDetailVO.getLongitude(), shopDetailVO.getLatitude()); |
| | |
| | | package com.ruoyi.other.service.impl; |
| | | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize); |
| | | List<TechnicianSubscribeVO> list = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(pageInfo, shopId, status); |
| | | for (TechnicianSubscribeVO technicianSubscribeVO : list) { |
| | | Long id = technicianSubscribeVO.getId(); |
| | | String id = technicianSubscribeVO.getId(); |
| | | TechnicianSubscribe technicianSubscribe = this.getById(id); |
| | | AppUser appUser = appUserClient.getAppUserById(technicianSubscribe.getAppUserId()); |
| | | technicianSubscribeVO.setUserName(appUser.getName()); |
| | |
| | | Integer serviceMode, Integer pageCurr, Integer pageSize) { |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize); |
| | | List<TechnicianSubscribeVO> technicianSubscribeByUserAndShop1 = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop1(pageInfo, shopId, status, phone, name, serviceMode); |
| | | for (TechnicianSubscribeVO technicianSubscribeVO : technicianSubscribeByUserAndShop1) { |
| | | AppUser appUser = appUserClient.getAppUserById(technicianSubscribeVO.getAppUserId()); |
| | | technicianSubscribeVO.setUserName(appUser.getName()); |
| | | technicianSubscribeVO.setPhone(appUser.getPhone()); |
| | | } |
| | | return pageInfo.setRecords(technicianSubscribeByUserAndShop1); |
| | | } |
| | | @Override |
| | |
| | | if (subscribe.getOrderId() != null){ |
| | | orderGoodsClient.subscribe(subscribe.getOrderId(), subscribe.getTechnicianId()); |
| | | } |
| | | LocalDateTime subscribeTime = subscribe.getSubscribeTime(); |
| | | long deadlineTimestamp = subscribeTime.atZone(ZoneId.systemDefault()).toEpochSecond(); |
| | | redisTemplate.opsForZSet().add("delay_queue:subscribe", subscribe.getId().toString(), deadlineTimestamp); |
| | | //添加到redis有序队列中用于定时处理状态 |
| | | redisTemplate.opsForZSet().add("technician_subscribe", subscribe.getId().toString(), subscribe.getSubscribeTime().toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时修改到期状态 |
| | | */ |
| | | @Override |
| | | public void taskEditStstus() { |
| | | Set<String> technician_subscribe = redisTemplate.opsForZSet().range("technician_subscribe", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(technician_subscribe.size() > 0){ |
| | | List<TechnicianSubscribe> list = this.listByIds(technician_subscribe); |
| | | list.forEach(s->s.setStatus(3)); |
| | | this.updateBatchById(list); |
| | | redisTemplate.opsForZSet().remove("technician_subscribe", technician_subscribe.toArray()); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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 com.ruoyi.other.service.TechnicianSubscribeService; |
| | | 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; |
| | | @Resource |
| | | private TechnicianSubscribeService technicianSubscribeService; |
| | | |
| | | |
| | | /** |
| | | * 每分钟定时 |
| | | */ |
| | | @Scheduled(fixedRate = 60000) |
| | | public void taskMonth() { |
| | | technicianSubscribeService.taskEditStstus(); |
| | | } |
| | | |
| | | /** |
| | | * 每天的凌晨执行的任务 |
| | |
| | | @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()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | |
| | | package com.ruoyi.other.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @ApiModelProperty(value = "详情图,多个逗号分隔") |
| | | private String detailPicture; |
| | | |
| | | |
| | | @ApiModelProperty(value = "现金支付(0=否,1=是)") |
| | | private Integer cashPayment; |
| | | |
| | | @ApiModelProperty(value = "积分支付(0=否,1=是)") |
| | | private Integer pointPayment; |
| | | |
| | |
| | | @ApiModelProperty(value = "基础售价") |
| | | private BigDecimal sellingPrice; |
| | | |
| | | @ApiModelProperty(value = "基础积分") |
| | | private Integer integral; |
| | | |
| | | |
| | | @ApiModelProperty(value = "开始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | |
| | | public class TechnicianSubscribeVO { |
| | | |
| | | @ApiModelProperty(value = "预约id") |
| | | private Long id; |
| | | private String id; |
| | | |
| | | /** |
| | | * 门店名称 |
| | |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phone; |
| | | |
| | | private Long appUserId; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | <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 |
| | | where tg.del_flag = 0 and tg.status = 2 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}))) |
| | | and tg.type = 1 |
| | | <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> |
| | | |
| | | |
| | | <select id="goodsList" resultType="com.ruoyi.other.vo.GoodsVO"> |
| | | select *, id as goodsId, name as goodsName from t_goods where status = 2 and del_flag = 0 |
| | | select *, id as goodsId, name as goodsName from t_goods where status = 2 and del_flag = 0 and `type` = 2 |
| | | <if test="null != goodsCategoryId"> |
| | | and goods_category_id = #{goodsCategoryId} |
| | | </if> |
| | | <if test="null != name and '' != name"> |
| | | and name like CONCAT('%', #{name}, '%') |
| | | </if> |
| | | <if test="null != vip"> |
| | | and (FIND_IN_SET(#{vip}, commodity_authority) or commodity_authority like '%-1%') |
| | | </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, |
| | | tgs.integral as integral, |
| | | 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 |
| | | <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, |
| | | tsai.max_num as maxNum, |
| | | tg.detail |
| | | FROM |
| | | t_seckill_activity_info tsai |
| | |
| | | ts.start_time, |
| | | ts.end_time, |
| | | ts.longitude, |
| | | ts.latitude, |
| | | AVG( tss.score ) score |
| | | ts.latitude |
| | | FROM |
| | | t_shop ts |
| | | LEFT JOIN t_shop_score tss ON ts.id = tss.shop_id |
| | | WHERE |
| | | ts.del_flag = 0 |
| | | AND ts.`status` = 1 |
| | | AND ts.id = #{id} |
| | | GROUP BY |
| | | ts.id, |
| | | ts.details_picture, |
| | | ts.certification, |
| | | ts.`name`, |
| | | ts.address, |
| | | ts.business_date, |
| | | ts.start_time, |
| | | ts.end_time, |
| | | ts.longitude, |
| | | ts.latitude |
| | | WHERE ts.del_flag = 0 AND ts.`status` = 1 AND ts.id = #{shopId} |
| | | </select> |
| | | <select id="selectShopList" resultType="com.ruoyi.other.api.domain.Shop"> |
| | | SELECT |
| | |
| | | ts.phone, |
| | | tsp.type, |
| | | tsp.create_time, |
| | | tsp.variable_point |
| | | tsp.variable_point, |
| | | tsp.order_num |
| | | FROM |
| | | t_shop_point tsp |
| | | LEFT JOIN t_shop ts ON tsp.shop_id = ts.id |
| | |
| | | <if test="shopPoint.startTime !=null and shopPoint.endTime !=null"> |
| | | AND tsp.create_time BETWEEN #{shopPoint.startTime} AND #{shopPoint.endTime} |
| | | </if> |
| | | |
| | | <if test="shopPoint.shopId !=null"> |
| | | AND tsp.shop_id = #{shopPoint.shopId} |
| | | </if> |
| | | </where> |
| | | order by tsp.create_time desc |
| | | </sql> |
| | | |
| | | <select id="selectShopPointList" resultType="com.ruoyi.other.api.domain.ShopPoint"> |
| | |
| | | </select> |
| | | <select id="getTechnicianSubscribeByUserAndShop1" resultType="com.ruoyi.other.vo.TechnicianSubscribeVO"> |
| | | SELECT |
| | | CAST(tts.id AS CHAR) id, |
| | | tts.id, |
| | | tts.user_address, |
| | | ts.`name` shopName, |
| | | ts.address shopAddress, |
| | |
| | | ts.latitude, |
| | | tts.subscribe_time, |
| | | tts.service_mode, |
| | | tts.status |
| | | tts.status, |
| | | tts.app_user_id as appUserId |
| | | FROM |
| | | t_technician_subscribe tts |
| | | LEFT JOIN t_technician tt ON tts.technician_id = tt.id AND tt.del_flag = 0 |