Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<List<AppUser>> setLowerUserShop(Long userId, Integer shopId) { |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public List<AppUser> listByIds(List<Long> list) { |
| | | log.error("获取用户失败: "+cause.getMessage()); |
| | | return Collections.emptyList(); |
| | |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | return R.fail("删除用户门店关系数据失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @PostMapping("/saveAppUserShop/delAppUserShop") |
| | | @Override |
| | | public void saveAppUserShop(AppUserShop appUserShop) { |
| | | R.fail("保存用户门店关系数据失败:" + cause.getMessage()); |
| | |
| | | package com.ruoyi.account.api.factory; |
| | | |
| | | import com.ruoyi.account.api.feignClient.UserCouponClient; |
| | | import com.ruoyi.account.api.model.UserCoupon; |
| | | import com.ruoyi.account.api.vo.CouponInfoVo; |
| | | import com.ruoyi.account.api.vo.PaymentUserCoupon; |
| | | import com.ruoyi.account.api.vo.PaymentUserCouponVo; |
| | |
| | | public R<Long> getCouponCount(Integer couponId) { |
| | | return R.fail("根据优惠券id获取优惠券数量失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<UserCoupon> getUserCoupon(Long id) { |
| | | return R.fail("获取用户优惠券失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R editUserCoupon(UserCoupon userCoupon) { |
| | | return R.fail("编辑用户优惠券失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R editReturnUse(UserCoupon userCoupon) { |
| | | return R.fail("编辑用户优惠券使用时间失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | public R<List<UserPoint>> getUserPointList(UserPoint userPoint) { |
| | | return R.fail("获取积分变动明细失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Boolean> judgmentDailyShare(Long appUserId) { |
| | | return R.fail("判断当天是否分享获得过积分失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ); |
| | | |
| | | |
| | | @GetMapping("/app-user/listByIds") |
| | | @PostMapping("/app-user/listByIds") |
| | | List<AppUser> listByIds(@RequestParam("ids") List<Long> list); |
| | | |
| | | /** |
| | |
| | | |
| | | @PostMapping("/app-user/getAppUserByPhone1") |
| | | R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone); |
| | | |
| | | /** |
| | | * 获得指定用户的下级用户 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @PostMapping("/app-user/setLowerUserShop") |
| | | R<List<AppUser>> setLowerUserShop(@RequestParam("userId") Long userId,@RequestParam("shopId") Integer shopId); |
| | | |
| | | |
| | | |
| | |
| | | * 保存关系数据 |
| | | * @param appUserShop |
| | | */ |
| | | @PostMapping("/saveAppUserShop/delAppUserShop") |
| | | @PostMapping("/appUserShop/saveAppUserShop") |
| | | void saveAppUserShop(@RequestBody AppUserShop appUserShop); |
| | | } |
| | |
| | | package com.ruoyi.account.api.feignClient; |
| | | |
| | | import com.ruoyi.account.api.factory.UserCouponClientFallbackFactory; |
| | | import com.ruoyi.account.api.model.UserCoupon; |
| | | import com.ruoyi.account.api.vo.CouponInfoVo; |
| | | import com.ruoyi.account.api.vo.PaymentUserCoupon; |
| | | import com.ruoyi.account.api.vo.PaymentUserCouponVo; |
| | |
| | | |
| | | @GetMapping("/user-coupon/getCouponCount") |
| | | R<Long> getCouponCount(@RequestParam("couponId") Integer couponId); |
| | | |
| | | |
| | | /** |
| | | * 获取用户优惠券 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/user-coupon/getUserCoupon") |
| | | R<UserCoupon> getUserCoupon(@RequestParam("id") Long id); |
| | | |
| | | |
| | | /** |
| | | * 编辑用户优惠券 |
| | | * @param userCoupon |
| | | * @return |
| | | */ |
| | | @PostMapping("/user-coupon/editUserCoupon") |
| | | R editUserCoupon(@RequestBody UserCoupon userCoupon); |
| | | |
| | | |
| | | /** |
| | | * 编辑用户优惠券使用时间 |
| | | * @param userCoupon |
| | | * @return |
| | | */ |
| | | @PostMapping("/user-coupon/editReturnUse") |
| | | R editReturnUse(@RequestBody UserCoupon userCoupon); |
| | | } |
| | |
| | | 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; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | @PostMapping("/user-point/getUserPointList") |
| | | R<List<UserPoint>> getUserPointList(@RequestBody UserPoint userPoint); |
| | | |
| | | |
| | | /** |
| | | * 判断当天是否分享获得过积分 |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @PostMapping("/user-point/judgmentDailyShare") |
| | | R<Boolean> judgmentDailyShare(@RequestParam("appUserId") Long appUserId); |
| | | } |
| | |
| | | @ApiModelProperty("用户id") |
| | | private Long appUserId; |
| | | |
| | | @ApiModelProperty("vip等级id") |
| | | private Integer vipId; |
| | | |
| | | @ApiModelProperty("订单id") |
| | | private Long orderId; |
| | | |
| | |
| | | @ApiModelProperty(value = "收件人电话") |
| | | @TableField("recieve_phone") |
| | | private String recievePhone; |
| | | |
| | | @ApiModelProperty(value = "省") |
| | | @TableField("province") |
| | | private String province; |
| | | |
| | | @ApiModelProperty(value = "省编号") |
| | | @TableField("province_code") |
| | | private String provinceCode; |
| | | |
| | | @ApiModelProperty(value = "市") |
| | | @TableField("city") |
| | | private String city; |
| | | |
| | | @ApiModelProperty(value = "市编号") |
| | | @TableField("city_code") |
| | | private String cityCode; |
| | | |
| | | @ApiModelProperty(value = "区") |
| | | @TableField("district") |
| | | private String district; |
| | | |
| | | @ApiModelProperty(value = "区编号") |
| | | @TableField("district_code") |
| | | private String districtCode; |
| | | |
| | | @ApiModelProperty(value = "收件人地址") |
| | | @TableField("recieve_address") |
| | |
| | | @ApiModelProperty(value = "可领取对应的ids,用find_in_set查询") |
| | | @TableField("person_ids") |
| | | private String personIds; |
| | | |
| | | |
| | | @ApiModelProperty(value = "商品卷对应的商品名称") |
| | | @TableField(exist = false) |
| | | private List<String> goodNames; |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | |
| | | |
| | | @Override |
| | | public R<Set<Long>> getAppUserByShoppingShop(Integer shopId) { |
| | | return R.fail("获取所有在指定门店消费的用户id失败:" + cause); |
| | | return R.fail("获取所有在指定门店消费的用户id失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Order> getOrderById(Long id) { |
| | | return R.fail("根据id获取订单详情失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R editOrder(Order order) { |
| | | return R.fail("编辑订单详情失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.factory.OrderClientFallbackFactory; |
| | | import com.ruoyi.order.model.Order; |
| | | 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; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | @PostMapping("/order/getAppUserByShoppingShop") |
| | | R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId); |
| | | |
| | | |
| | | /** |
| | | * 根据id获取订单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getOrderById") |
| | | R<Order> getOrderById(@RequestParam("id") Long id); |
| | | |
| | | |
| | | /** |
| | | * 编辑订单详情 |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/editOrder") |
| | | R editOrder(@RequestBody Order order); |
| | | } |
| | |
| | | @ApiModelProperty(value = "1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价") |
| | | @TableField("order_status") |
| | | private Integer orderStatus; |
| | | |
| | | @ApiModelProperty(value = "1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价") |
| | | @TableField("old_order_status") |
| | | private Integer oldOrderStatus; |
| | | |
| | | @ApiModelProperty(value = "是否已分佣: 0-否 1-是") |
| | | @TableField("is_commission") |
| | |
| | | @TableField("good_amount") |
| | | private BigDecimal goodAmount; |
| | | |
| | | @ApiModelProperty(value = "用户优惠券id") |
| | | @TableField("user_coupon_id") |
| | | private Long userCouponId; |
| | | |
| | | @ApiModelProperty(value = "活动优惠金额") |
| | | @TableField("activity_amount") |
| | | private BigDecimal activityAmount; |
| | |
| | | @TableField("express_json") |
| | | private String expressJson; |
| | | |
| | | @ApiModelProperty(value = "第三方快递结果") |
| | | @TableField("express_result") |
| | | private String expressResult; |
| | | |
| | | @ApiModelProperty(value = "发货省") |
| | | @TableField("deliver_province") |
| | | private String deliverProvince; |
| | | |
| | | @ApiModelProperty(value = "发货省编号") |
| | | @TableField("deliver_province_code") |
| | | private String deliverProvinceCode; |
| | | |
| | | @ApiModelProperty(value = "发货市") |
| | | @TableField("deliver_city") |
| | | private String deliverCity; |
| | | |
| | | @ApiModelProperty(value = "发货市编号") |
| | | @TableField("deliver_city_code") |
| | | private String deliverCityCode; |
| | | |
| | | @ApiModelProperty(value = "发货区") |
| | | @TableField("deliver_district") |
| | | private String deliverDistrict; |
| | | |
| | | @ApiModelProperty(value = "发货区编号") |
| | | @TableField("deliver_district_code") |
| | | private String deliverDistrictCode; |
| | | |
| | | @ApiModelProperty(value = "收货地址信息") |
| | | @TableField("address_json") |
| | | private String addressJson; |
| | |
| | | @TableField(exist = false) |
| | | private List<AppUser> appUserList; |
| | | |
| | | @TableField(exist = false) |
| | | private String phone; |
| | | |
| | | |
| | | public String getIdStr(){ |
| | | return String.valueOf(id); |
| | |
| | | @TableField(exist = false) |
| | | private String payMethod; |
| | | |
| | | /** |
| | | * 排序字段 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String orderByColumn; |
| | | |
| | | /** |
| | | * 排序方式 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String isAsc; |
| | | |
| | | |
| | | public String getIdStr() { |
| | | return String.valueOf(id); |
| | |
| | | private Long appUserId; |
| | | |
| | | @TableField(exist = false) |
| | | private String appUserIdStr; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "用户名称") |
| | | private String userName; |
| | | |
| | |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId("id") |
| | | private Long id; |
| | | @TableField(exist = false) |
| | | private String idStr; |
| | | |
| | | @ApiModelProperty(value = "门店id") |
| | | @TableField("shop_id") |
| | |
| | | public R<List<Goods>> getGoodsById(String [] ids) { |
| | | return R.fail("根据ids获取商品详情失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R editGoodsList(List<Goods> goods) { |
| | | return R.fail("编辑商品信息失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Void> editGoodsNum(Integer goodsId, Integer num) { |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Goods>> getAllGoods() { |
| | | return R.fail("获取所有商品失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.other.api.feignClient.ShopBalanceStatementClient; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | |
| | | public R<List<ShopBalanceStatement>> getShopBalanceStatementList(Collection<Integer> types, Long objectId) { |
| | | return R.fail("获取门店余额流水失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<ShopBalanceStatement>> getShopBalanceStatementList2(Integer type, LocalDateTime date) { |
| | | return R.fail(); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.other.api.factory.GoodsClientFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | @PostMapping("/goods/getGoodsById") |
| | | R<Goods> getGoodsById(@RequestParam("id") Integer id); |
| | | |
| | | |
| | | @PostMapping("/goods/getGoodsByIds") |
| | | R<List<Goods>> getGoodsById(@RequestParam("ids") String[] ids); |
| | | |
| | | |
| | | /** |
| | | * 编辑商品信息 |
| | | * @param goods |
| | | * @return |
| | | */ |
| | | @PostMapping("/goods/editGoods") |
| | | R editGoodsList(@RequestBody List<Goods> goods); |
| | | |
| | | /** |
| | | * 商品销量增加 |
| | | */ |
| | | @PutMapping("/goods/editGoodsNum") |
| | | R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num); |
| | | |
| | | |
| | | /** |
| | | * 获取所有商品 |
| | | * @return |
| | | */ |
| | | @PostMapping("/goods/getAllGoods") |
| | | R<List<Goods>> getAllGoods(); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/shop-balance-statement/getShopBalanceStatementList") |
| | | R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestParam("types") Collection<Integer> types, @RequestParam("objectId") Long objectId); |
| | | R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestParam("types") Collection<Integer> types, @RequestParam(value = "objectId",required = false) Long objectId); |
| | | |
| | | @PostMapping("/shop-balance-statement/getShopBalanceStatementList2") |
| | | R<List<ShopBalanceStatement>> getShopBalanceStatementList2(@RequestParam("type") Integer type, |
| | | @RequestParam(value = "date") LocalDateTime date); |
| | | } |
| | |
| | | @PostMapping("/shop/getShopByUserIds") |
| | | R<List<Shop>> getShopByUserIds(@RequestBody List<Long> userIds); |
| | | |
| | | @GetMapping("/shop/getShopIdByName") |
| | | R<Set<Integer>> getShopIdByName(String shopName); |
| | | @PostMapping("/shop/getShopIdByName") |
| | | R<Set<Integer>> getShopIdByName(@RequestParam("shopName") String shopName); |
| | | |
| | | @PostMapping("/shop-balance-statement/getList") |
| | | R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestBody ShopBalanceStatement shopBalanceStatement); |
| | |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @PostMapping("/technician-subscribe/getTechnicianByIds") |
| | | @PostMapping("/technician/getTechnicianByIds") |
| | | R<List<Technician>> getTechnicianByIds(@RequestParam("ids") Collection<Integer> ids); |
| | | } |
| | |
| | | private RedisService redisService; |
| | | |
| | | private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT; |
| | | |
| | | private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME; |
| | | |
| | | @Autowired |
| | |
| | | throw new ServiceException(errMsg); |
| | | } |
| | | |
| | | // if (!matches(user, password)) |
| | | // { |
| | | |
| | | // if (!user.getPassword().equals(password)){ |
| | | // retryCount = retryCount + 1; |
| | | // recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, String.format("密码输入错误%s次", retryCount)); |
| | | // redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.ruoyi.common.core.exception.auth.NotPermissionException; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | public LoginUser getLoginUserApplet() { |
| | | LoginUser loginUserAppletToken = getLoginUserAppletToken(ServletUtils.getRequest()); |
| | | if (loginUserAppletToken == null) { |
| | | throw new RuntimeException("令牌已过期,请重新登录!"); |
| | | throw new NotPermissionException("令牌已过期,请重新登录!"); |
| | | } |
| | | return loginUserAppletToken; |
| | | } |
| | |
| | | public LoginUser getLoginUser() { |
| | | LoginUser loginUser = getLoginUser(ServletUtils.getRequest()); |
| | | if (loginUser == null) { |
| | | throw new RuntimeException("令牌已过期,请重新登录!"); |
| | | throw new NotPermissionException("令牌已过期,请重新登录!"); |
| | | } |
| | | if(null == loginUser.getUserid()){ |
| | | loginUser.setUserid(loginUser.getSysUser().getUserId()); |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | String encode = passwordEncoder.encode("31dc4a464b71db3ddaea244410af4833"); |
| | | String encode = passwordEncoder.encode("123456"); |
| | | System.err.println(encode); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import com.ruoyi.common.core.exception.auth.NotPermissionException; |
| | | import com.ruoyi.gateway.config.properties.AntiShakeProperties; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | /** |
| | | * 防抖处理 |
| | | */ |
| | | public void antiShake(ServerHttpRequest request) throws Exception{ |
| | | public void antiShake(ServerHttpRequest request) { |
| | | HttpMethod method = request.getMethod(); |
| | | if(HttpMethod.OPTIONS == method || !antiShakeProperties.getEnable()){ |
| | | return; |
| | |
| | | /** |
| | | * 验证token |
| | | * @param request |
| | | * @throws Exception |
| | | */ |
| | | public void verifyToken(ServerHttpRequest request) throws Exception{ |
| | | public void verifyToken(ServerHttpRequest request) { |
| | | String token = getToken(request); |
| | | if (StringUtils.isEmpty(token)) { |
| | | throw new RuntimeException("令牌不能为空"); |
| | | throw new NotPermissionException("令牌不能为空"); |
| | | } |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | if (claims == null) { |
| | | throw new RuntimeException("令牌已过期或验证不正确!"); |
| | | throw new NotPermissionException("令牌已过期或验证不正确!"); |
| | | } |
| | | String userid = JwtUtils.getUserId(claims); |
| | | if (StringUtils.isEmpty(userid)) { |
| | | throw new RuntimeException("令牌验证失败"); |
| | | throw new NotPermissionException("令牌验证失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.ruoyi.system.api.domain.SysFile; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.dto.UpdatePassword; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation(value = "个人信息-修改密码") |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/updatePwd") |
| | | public AjaxResult updatePwd(String username,String oldPassword, String newPassword) |
| | | public AjaxResult updatePwd(@RequestBody UpdatePassword updatePassword) |
| | | { |
| | | String newPassword = updatePassword.getNewPassword(); |
| | | String oldPassword = updatePassword.getOldPassword(); |
| | | String username = updatePassword.getUsername(); |
| | | System.err.println(oldPassword); |
| | | System.err.println(newPassword); |
| | | // String username = SecurityUtils.getUsername(); |
| | |
| | | // tokenService.setLoginUser(loginUser); |
| | | return success(); |
| | | } |
| | | |
| | | return error("修改密码异常,请联系管理员"); |
| | | } |
| | | |
| | |
| | | }else{ |
| | | wrapper.isNull(SysRole::getShopId); |
| | | } |
| | | wrapper.ne(SysRole::getRoleId,2);//过滤门店管理员 |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, wrapper.orderByDesc(SysRole::getCreateTime)); |
| | | for (SysRole record : page.getRecords()) { |
| | | long count = sysUserRoleService.count(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, record.getRoleId())); |
| | |
| | | } |
| | | //门店员工添加数据,需要判断账号是否存在,共用同一个账号 |
| | | if(2 == sysUser1.getRoleType()){ |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(user.getPhonenumber()).getData(); |
| | | if(null == appUser){ |
| | | return error("请先注册小程序账号"); |
| | | } |
| | | 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){ |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(user.getPhonenumber()).getData(); |
| | | if(null == appUser){ |
| | | return error("请先注册小程序账号"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | | user.setRoleType(sysUser1.getRoleType()); |
| | |
| | | sysUserRole.setRoleId(user.getRoleId()); |
| | | sysUserRole.setUserId(user.getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | //添加小程序店员关系数据 |
| | | if(null != appUser){ |
| | | |
| | | } |
| | | //添加小程序店员关系数据 |
| | | if(null != appUser){ |
| | | List<AppUserShop> data = appUserShopClient.getAppUserShop(appUser.getId()).getData(); |
| | | Optional<AppUserShop> first = data.stream().filter(s -> s.getShopId().equals(sysUser1.getObjectId())).findFirst(); |
| | | if(!first.isPresent()){ |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(sysUser1.getObjectId()); |
| | |
| | | appUserClient.editAppUserById(appUser); |
| | | } |
| | | } |
| | | |
| | | //添加门店员工关系数据 |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(one.getUserId()); |
New file |
| | |
| | | package com.ruoyi.system.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/11 20:21 |
| | | */ |
| | | @Data |
| | | public class UpdatePassword { |
| | | private String username; |
| | | |
| | | private String newPassword; |
| | | |
| | | private String oldPassword; |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserShopClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.SpringUtils; |
| | |
| | | |
| | | @Resource |
| | | private UserShopService userShopService; |
| | | |
| | | @Resource |
| | | private AppUserShopClient appUserShopClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | /** |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteUserByIds(Long[] userIds) { |
| | | for (Long userId : userIds) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = this.getById(userid); |
| | | for (Long userId : userIds) { |
| | | checkUserAllowed(new SysUser(userId)); |
| | | // checkUserDataScope(userId); |
| | | } |
| | |
| | | // userRoleMapper.deleteUserRole(userIds); |
| | | // // 删除用户与岗位关联 |
| | | // userPostMapper.deleteUserPost(userIds); |
| | | int i = userMapper.deleteUserByIds(userIds); |
| | | // int i = userMapper.deleteUserByIds(userIds); |
| | | List<SysUser> sysUsers = this.listByIds(Arrays.asList(userIds)); |
| | | for (SysUser user : sysUsers) { |
| | | if(2 == user.getRoleType()){ |
| | | userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId())); |
| | | } |
| | | userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, sysUser.getObjectId())); |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(user.getPhonenumber()).getData(); |
| | | if(null != appUser){ |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(sysUser.getObjectId()); |
| | | appUserShopClient.delAppUserShop(appUserShop); |
| | | int size = appUserShopClient.getAppUserShop(appUser.getId()).getData().size(); |
| | | if(size == 0){ |
| | | appUser.setUserType(1); |
| | | appUserClient.editAppUserById(appUser); |
| | | } |
| | | } |
| | | long count = userShopService.count(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId())); |
| | | if(0 == count){ |
| | | user.setDelFlag("2"); |
| | | this.updateById(user); |
| | | } |
| | | }else{ |
| | | user.setDelFlag("2"); |
| | | this.updateById(user); |
| | | } |
| | | } |
| | | return i; |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserCancellationLog; |
| | | import com.ruoyi.account.api.model.UserCoupon; |
| | |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.domain.ShopBalanceStatement; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.factory.ShopBalanceStatementClientFallbackFactory; |
| | | import com.ruoyi.other.api.feignClient.ShopBalanceStatementClient; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import com.ruoyi.account.vo.*; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private ShopBalanceStatementClient shopBalanceStatementClient; |
| | | @Resource |
| | | private UserCancellationLogService userCancellationLogService; |
| | | @Resource |
| | | private BalanceChangeRecordService balanceChangeRecordService; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | @ResponseBody |
| | | @PostMapping("/getCouponCount") |
| | | public R<Long> getCouponCount(@RequestParam("userId") Long userId, @RequestParam("couponId") Integer couponId) { |
| | | Long count = userCouponService.lambdaQuery().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getCouponId, couponId).count(); |
| | | LambdaQueryChainWrapper<UserCoupon> chainWrapper = userCouponService.lambdaQuery().eq(UserCoupon::getCouponId, couponId); |
| | | if(null != userId && -1 == userId){ |
| | | chainWrapper.eq(UserCoupon::getAppUserId, userId); |
| | | } |
| | | Long count = chainWrapper.count(); |
| | | return R.ok(count); |
| | | } |
| | | |
| | |
| | | return R.ok(user); |
| | | } |
| | | |
| | | @Resource |
| | | private UserCancellationLogService userCancellationLogService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/unregis") |
| | |
| | | if (user.getShopId() != null) { |
| | | R<Shop> storeById = shopClient.getShopById(user.getShopId()); |
| | | if (storeById.getData() != null) { |
| | | user.setShopName(storeById.getData().getName()); |
| | | Shop shop = storeById.getData(); |
| | | user.setShopName(shop.getName()); |
| | | } |
| | | } |
| | | Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | |
| | | public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageCurr, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | R<SysUser> sysUserR = sysUserClient.getSysUser(userid); |
| | | SysUser sysUser = sysUserR.getData(); |
| | | |
| | | List<Long> userIds = new ArrayList<>(); |
| | | userIds.add(-1L); |
| | | //获取在该本店下单的用户ids |
| | | Integer objectId = sysUser.getObjectId(); |
| | | R<List<Order>> listR = remoteOrderGoodsClient.byShopId(objectId); |
| | | for (Order datum : listR.getData()) { |
| | | userIds.add(datum.getAppUserId()); |
| | |
| | | @ApiOperation(value = "用户列表-更换绑定人", tags = {"管理后台"}) |
| | | public R<AppUser> select(Long id, Long inviteId) { |
| | | AppUser byId = appUserService.getById(id); |
| | | Long userId = byId.getId(); |
| | | if (userId.equals(inviteId)) { |
| | | return R.fail("不能选择自己为绑定人。"); |
| | | } |
| | | byId.setInviteUserId(inviteId); |
| | | byId.setTopInviteId(getTop(inviteId)); |
| | | appUserService.updateById(byId); |
| | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "用户列表-详情", tags = {"管理后台"}) |
| | | public R<AppUser> detail(Long id) { |
| | | |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | AppUser byId = appUserService.getById(id); |
| | | if (byId.getShopId() != null) { |
| | | R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId()))); |
| | |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list(); |
| | | byId.setBottomUsers(list); |
| | | //消费总金额 |
| | | R<List<Order>> orderR = remoteOrderGoodsClient.byShopId(sysUser.getObjectId()); |
| | | List<Order> orderList = orderR.getData(); |
| | | if (!CollectionUtils.isEmpty(orderList)){ |
| | | BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | byId.setShopAmount(paymentAmount); |
| | | }else { |
| | | byId.setShopAmount(BigDecimal.ZERO); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/listByIds") |
| | | List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) { |
| | | @PostMapping("/listByIds") |
| | | public List<AppUser> listByIds(@RequestParam("ids") List<Long> ids) { |
| | | if(ids.size() == 0){ |
| | | return new ArrayList<>(); |
| | | } |
| | |
| | | .eq(AppUser::getPhone, phone)); |
| | | return R.ok(appUser); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置指定用户的下级用户绑定门店 |
| | | */ |
| | | @PostMapping("/setLowerUserShop") |
| | | public R<Void> setLowerUserShop(@RequestParam("userId") Long userId,@RequestParam("shopId") Integer shopId) { |
| | | appUserService.update(new LambdaUpdateWrapper<AppUser>() |
| | | .set(AppUser::getShopId,shopId) |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户统计 |
| | |
| | | */ |
| | | @GetMapping("/commissionDetail") |
| | | @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") |
| | | public R<CommissionDetail> commissionDetail() { |
| | | public R<CommissionDetail> commissionDetail(CommissionDetail cd) { |
| | | 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()); |
| | | } |
| | | LocalDateTime startTime = cd.getStartTime(); |
| | | LocalDateTime endTime = cd.getEndTime(); |
| | | queryWrapper.ge(null != startTime, AppUser::getCreateTime, startTime); |
| | | queryWrapper.le(null != endTime, AppUser::getCreateTime, endTime); |
| | | queryWrapper.orderByAsc(AppUser::getCreateTime); |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | if (appUserList.isEmpty()) { |
| | | return R.ok(new CommissionDetail()); |
| | |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>(); |
| | | for (AppUser appUser : appUserList) { |
| | | BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO); |
| | | totalCommission = totalCommission.add(distributionAmount); |
| | |
| | | totalServiceFee = totalServiceFee.add(shop.getServerGiveawayMoney()); |
| | | totalUserCommission = totalUserCommission.add(shop.getGiveawayMoney()); |
| | | } |
| | | |
| | | R<List<ShopBalanceStatement>> r = shopBalanceStatementClient.getShopBalanceStatementList(Arrays.asList(1, 2, 3), null); |
| | | List<ShopBalanceStatement> data1 = r.getData(); |
| | | if (!CollectionUtils.isEmpty(data1)){ |
| | | for (ShopBalanceStatement shopBalanceStatement : data1) { |
| | | String dateKey = shopBalanceStatement.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Integer type = shopBalanceStatement.getType(); |
| | | if (type == 1){ |
| | | type = 8; |
| | | }else if (type == 2){ |
| | | type = 9; |
| | | }else { |
| | | type = 10; |
| | | } |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | | .merge(type, shopBalanceStatement.getVariableAmount(), BigDecimal::add); |
| | | } |
| | | } |
| | | |
| | | |
| | | CommissionDetail commissionDetail = new CommissionDetail(); |
| | | commissionDetail.setTotalCommission(totalCommission); |
| | |
| | | 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(dailyCommissions.getOrDefault(10, BigDecimal.ZERO)); |
| | | commissionDate.setAssociatedUserCommission(dailyCommissions.getOrDefault(8, BigDecimal.ZERO)); |
| | | commissionDate.setBindLowerLevelStoresCommission(dailyCommissions.getOrDefault(9, BigDecimal.ZERO)); |
| | | return commissionDate; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | |
| | | commissionDetail.setCommissionDateList(commissionDateList); |
| | | return R.ok(commissionDetail); |
| | | } |
| | | |
| | | |
| | | public R<CommissionDetail> commissionDetail2(CommissionDetail cd) { |
| | | if (cd.getStartTime() == null || cd.getEndTime() == null) { |
| | | return R.fail("请选择时间"); |
| | | } |
| | | if (cd.getStartTime().isAfter(cd.getEndTime())) { |
| | | return R.fail("开始时间不能大于结束时间"); |
| | | } |
| | | |
| | | |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>(); |
| | | getDatesBetween(cd.getStartTime(), cd.getEndTime()).forEach(date -> { |
| | | for (int i = 1; i < 8; i++){ |
| | | List<BalanceChangeRecord> list = balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() |
| | | .eq(BalanceChangeRecord::getCreateTime, date) |
| | | .eq(BalanceChangeRecord::getChangeType,4) |
| | | .eq(BalanceChangeRecord::getVipId, i)); |
| | | BigDecimal reduce = list.stream().map(BalanceChangeRecord::getChangeAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | String dateKey = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | | .merge(i, reduce, BigDecimal::add); |
| | | } |
| | | |
| | | for (int i = 1; i < 4; i++){ |
| | | R<List<ShopBalanceStatement>> r = shopBalanceStatementClient.getShopBalanceStatementList2(i, date); |
| | | if (!CollectionUtils.isEmpty(r.getData())){ |
| | | List<ShopBalanceStatement> list = r.getData(); |
| | | BigDecimal reduce = list.stream().map(ShopBalanceStatement::getVariableAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | String dateKey = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | int type; |
| | | if (i == 1){ |
| | | type = 8; |
| | | }else if (i == 2){ |
| | | type = 9; |
| | | }else { |
| | | type = 10; |
| | | } |
| | | dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) |
| | | .merge(type, reduce, BigDecimal::add); |
| | | } |
| | | } |
| | | }); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取指定时间段内每一天的列表 |
| | | * |
| | | * @param startDate 开始日期时间 |
| | | * @param endDate 结束日期时间 |
| | | * @return 包含每天日期时间的列表 |
| | | */ |
| | | private static List<LocalDateTime> getDatesBetween(LocalDateTime startDate, LocalDateTime endDate) { |
| | | // 计算开始日期和结束日期之间的天数差(忽略时间部分) |
| | | long daysBetween = ChronoUnit.DAYS.between(startDate.toLocalDate(), endDate.toLocalDate()); |
| | | |
| | | // 使用Stream.iterate从开始日期开始迭代,每次增加一天,直到达到天数差+1 |
| | | return Stream.iterate(startDate, date -> date.plus(1, ChronoUnit.DAYS)) |
| | | .limit(daysBetween + 1) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserCoupon; |
| | |
| | | @ApiOperation(value = "已领取列表", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<Page<UserCoupon>> minelist(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Page<UserCoupon> page = userCouponService.lambdaQuery() |
| | | .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime) |
| | | .isNotNull(status!=null&&status==2,UserCoupon::getUseTime) |
| | | .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()) |
| | | .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum-1, pageSize)); |
| | | LambdaQueryChainWrapper<UserCoupon> chainWrapper = userCouponService.lambdaQuery() |
| | | .eq(UserCoupon::getAppUserId, userid); |
| | | if(null != status && 1 == status){ |
| | | chainWrapper.isNull(UserCoupon::getUseTime).gt(UserCoupon::getEndTime, LocalDateTime.now()); |
| | | } |
| | | if(null != status && 2 == status){ |
| | | chainWrapper.isNotNull(UserCoupon::getUseTime); |
| | | } |
| | | if(null != status && 3 == status){ |
| | | chainWrapper.isNull(UserCoupon::getUseTime).lt(UserCoupon::getEndTime, LocalDateTime.now()); |
| | | } |
| | | Page<UserCoupon> page = chainWrapper.page(Page.of(pageNum-1, pageSize)); |
| | | for (UserCoupon record : page.getRecords()) { |
| | | record.setIdStr(record.getId().toString()); |
| | | CouponInfo data = couponClient.detail(record.getCouponId()).getData(); |
| | |
| | | if (vo.getCouponType()==4){ |
| | | List<String> goodNames = new ArrayList<>(); |
| | | if (vo.getForGoodIds().equals("-1")){ |
| | | goodNames.add("全部商品"); |
| | | List<Goods> data1 = goodsClient.getAllGoods().getData(); |
| | | List<String> collect = data1.stream().map(Goods::getName).collect(Collectors.toList()); |
| | | goodNames.addAll(collect); |
| | | }else{ |
| | | String[] split = vo.getForGoodIds().split(","); |
| | | R<List<Goods>> goodsById = goodsClient.getGoodsById(split); |
| | |
| | | goodNames.add(datum.getName()); |
| | | } |
| | | } |
| | | vo.setGoodNames(goodNames); |
| | | } |
| | | vo.setGoodNames(goodNames); |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | | if (record.getEndTime().isBefore(LocalDateTime.now())){ |
| | | record.setStatus(3); |
| | | } |
| | | }else { |
| | | if(null != record.getUseTime()){ |
| | | record.setStatus(2); |
| | | }else{ |
| | | if(record.getEndTime().isBefore(LocalDateTime.now())){ |
| | | record.setStatus(3); |
| | | }else{ |
| | | record.setStatus(1); |
| | | } |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | | record.setPhone(appUser.getPhone()); |
| | |
| | | |
| | | @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) { |
| | | public R<Page<UserCoupon>> list1(@RequestParam Integer pageNum, |
| | | @RequestParam Integer pageSize, |
| | | @ApiParam("1未使用2已使用3已过期") Integer status, |
| | | String phone, |
| | | Integer id) { |
| | | |
| | | Long appUserId = null; |
| | | if (!StringUtils.isEmpty(phone)){ |
| | | AppUser appUser1 = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | .like(AppUser::getPhone, phone)); |
| | | if (appUser1 != null){ |
| | | appUserId = appUser1.getId(); |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | .eq(appUserId != null,UserCoupon::getAppUserId, appUserId) |
| | | .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()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | |
| | | }else { |
| | | record.setStatus(2); |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | |
| | | if (data==null){ |
| | | return R.fail("当前优惠券不存在,请刷新后重试"); |
| | | } |
| | | long count = userCouponService.count(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId, couponId).eq(UserCoupon::getDelFlag, 0)); |
| | | if(data.getSendNum() <= count){ |
| | | return R.fail("当前优惠券已全部领取完毕"); |
| | | } |
| | | count = userCouponService.count(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId, couponId) |
| | | .eq(UserCoupon::getAppUserId, userid).eq(UserCoupon::getDelFlag, 0)); |
| | | if(data.getMaxNum() <= count){ |
| | | return R.fail("当前优惠券已达到最大领取限制"); |
| | | } |
| | | |
| | | if (data.getSendType()!=1&& byId.getLavePoint().compareTo(data.getNeedPoint().intValue()) < 0){ |
| | | return R.fail("当前积分不足,兑换失败"); |
| | | } |
| | |
| | | appUserService.updateById(byId); |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(4); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(point); |
| | | userPoint.setBalance(byId.getLavePoint()); |
| | |
| | | userCouponService.updateById(userCoupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户优惠券详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getUserCoupon") |
| | | public R<UserCoupon> getUserCoupon(@RequestParam("id") Long id){ |
| | | UserCoupon userCoupon = userCouponService.getById(id); |
| | | return R.ok(userCoupon); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑用户优惠券 |
| | | * @return |
| | | */ |
| | | @PostMapping("/editUserCoupon") |
| | | public R editUserCoupon(@RequestBody UserCoupon userCoupon){ |
| | | userCouponService.updateById(userCoupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑用户优惠券使用时间 |
| | | * @param userCoupon |
| | | * @return |
| | | */ |
| | | @PostMapping("/editReturnUse") |
| | | public R editReturnUse(@RequestBody UserCoupon userCoupon){ |
| | | userCouponService.update(new LambdaUpdateWrapper<UserCoupon>().eq(UserCoupon::getId, userCoupon.getId()) |
| | | .set(UserCoupon::getUseTime, userCoupon.getUseTime())); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | |
| | | List<UserPoint> list = userPointService.list(queryWrapper); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断当天是否分享获得过积分 |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @PostMapping("/judgmentDailyShare") |
| | | public R<Boolean> judgmentDailyShare(@RequestParam("appUserId") Long appUserId){ |
| | | long count = userPointService.count(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUserId) |
| | | .eq(UserPoint::getType, 4).last(" and DATE_FORMAT(NOW(), '%Y-%m-%d') = DATE_FORMAT(create_time, '%Y-%m-%d')")); |
| | | return R.ok(count != 0); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.account.api.model.UserSignRecord; |
| | |
| | | @ApiOperation(value = "签到", tags = {"小程序-签到"}) |
| | | public R<SignBackRDto> sign(){ |
| | | Long userId1 = tokenService.getLoginUserApplet().getUserid(); |
| | | UserSignRecord one = userSignRecordService.getOne(new LambdaQueryWrapper<UserSignRecord>().eq(UserSignRecord::getAppUserId, userId1) |
| | | .eq(UserSignRecord::getDelFlag, 0).last(" and DATE_FORMAT(NOW(), '%Y-%m-%d') = DATE_FORMAT(create_time, '%Y-%m-%d')")); |
| | | if(null != one){ |
| | | return R.fail("今天已经签过到了"); |
| | | } |
| | | AppUser appUser = appUserService.getById(userId1); |
| | | //获取当前用户的会员信息 |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | |
| | | } |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + signPoint); |
| | | appUser.setTotalSignPoint(appUser.getTotalSignPoint() + signPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + signPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + signPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + signPoint1); |
| | |
| | | |
| | | |
| | | |
| | | |
| | | private Map<Integer, R<GoodsVip>> getGoodsVips(List<Integer> vipIds) { |
| | | Map<Integer, R<GoodsVip>> result = new HashMap<>(); |
| | | for (Integer vipId : vipIds) { |
| | | R<GoodsVip> goodsVipR = goodsVipClient.getGoodsVip(null, vipId); |
| | | result.put(vipId, goodsVipR); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Map<Integer, R<List<VipGood>>> getVipGoods(List<Integer> vipIds) { |
| | | Map<Integer, R<List<VipGood>>> result = new HashMap<>(); |
| | | for (Integer vipId : vipIds) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | private boolean isValidJson(String json) { |
| | | try { |
| | | JSONObject.parseObject(json); |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | List<BalanceChangeRecord> list = balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() |
| | | .eq(changeType != null, BalanceChangeRecord::getChangeType, changeType) |
| | | .between(startTime != null, BalanceChangeRecord::getCreateTime, startTime, endTime) |
| | | .eq(BalanceChangeRecord::getAppUserId, userId)); |
| | | .eq(BalanceChangeRecord::getAppUserId, userId).orderByDesc(BalanceChangeRecord::getCreateTime)); |
| | | |
| | | List<Long> orderIds = list.stream().map(BalanceChangeRecord::getOrderId).collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(orderIds)){ |
| | |
| | | //流水 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(balanceChangeRecord.getId()); |
| | | balanceChangeRecord.setChangeType(1); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | import com.ruoyi.account.util.payment.model.SinglePay; |
| | | import com.ruoyi.account.util.payment.model.SinglePayCallbackResult; |
| | | import com.ruoyi.account.util.payment.model.SinglePayResult; |
| | | import com.ruoyi.account.vo.WithdrawalAuth; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | @PostMapping("/auth") |
| | | @ApiOperation(value = "提现申请审批", tags = {"后台"}) |
| | | public R auth(@RequestParam("id") Long id,@ApiParam("2'审核通过',3'审核拒绝'") @RequestParam("auditStatus") Integer auditStatus){ |
| | | WithdrawalRequests withdrawal = withdrawalRequestsService.getById(id); |
| | | public R auth(@RequestBody WithdrawalAuth withdrawalAuth){ |
| | | WithdrawalRequests withdrawal = withdrawalRequestsService.getById(withdrawalAuth.getId()); |
| | | BigDecimal withdrawalAmount = withdrawal.getWithdrawalAmount(); |
| | | if(withdrawal.getAuditStatus() != 1){ |
| | | return R.fail("不能重复审核"); |
| | | } |
| | | Integer auditStatus = withdrawalAuth.getAuditStatus(); |
| | | if (auditStatus==2){ |
| | | //先检查账户余额是否充足 |
| | | AccountBalanceQueryResult accountBalanceQueryResult = TransferUtil.accountBalanceQuery(); |
| | | if(null == accountBalanceQueryResult){ |
| | | return R.fail("查询账户余额出错"); |
| | | } |
| | | Double useAbleSettAmount = accountBalanceQueryResult.getUseAbleSettAmount(); |
| | | if(useAbleSettAmount < withdrawal.getArrivalAmount().doubleValue()){ |
| | | return R.fail("账户可用余额不足,请先补充账户余额"); |
| | | } |
| | | //执行转账操作 |
| | | if(withdrawal.getWithdrawalMethod() == 2){ |
| | | //先检查账户余额是否充足 |
| | | AccountBalanceQueryResult accountBalanceQueryResult = TransferUtil.accountBalanceQuery(); |
| | | if(null == accountBalanceQueryResult){ |
| | | return R.fail("查询账户余额出错"); |
| | | } |
| | | Double useAbleSettAmount = accountBalanceQueryResult.getUseAbleSettAmount(); |
| | | //计算代付手续费 |
| | | if(useAbleSettAmount < (withdrawal.getArrivalAmount().doubleValue() + 1)){ |
| | | return R.fail("账户可用余额不足,请先补充账户余额"); |
| | | } |
| | | //银行卡转账 |
| | | SinglePay singlePay = new SinglePay(); |
| | | singlePay.setTradeMerchantNo(""); |
| | | singlePay.setTradeMerchantNo(TransferUtil.sysTradeMerchantNo); |
| | | singlePay.setMerchantOrderNo(withdrawal.getId().toString()); |
| | | singlePay.setReceiverAccountNoEnc(withdrawal.getBankCardNumber()); |
| | | singlePay.setReceiverNameEnc(withdrawal.getAccountHolder()); |
| | |
| | | withdrawal.setStatus(1); |
| | | }else{ |
| | | //微信转账 |
| | | return R.fail("微信转账开发中"); |
| | | } |
| | | } |
| | | if(3 == auditStatus){ |
| | |
| | | //添加变动明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(withdrawal.getId()); |
| | | balanceChangeRecord.setChangeType(2); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | @PostMapping("/withdrawalCallback") |
| | | public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){ |
| | | Integer status = singlePayCallbackResult.getStatus(); |
| | | if(203 == status){ |
| | | if(203 == status || 205 == status){ |
| | | String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); |
| | | WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo); |
| | | if(1 == withdrawalRequests.getStatus()){ |
| | |
| | | void onlineRecord(); |
| | | |
| | | 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); |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | public void apply(AgentApplication agentApplication) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); |
| | | |
| | | Long aLong = agentApplicationMapper.selectCount(new QueryWrapper<AgentApplication>().eq("app_user_id", appUser.getId()) |
| | | .eq("application_vip_id", agentApplication.getApplicationVipId()).eq("status", 1).eq("del_flag", 0)); |
| | | if(0 != aLong){ |
| | | throw new RuntimeException("已发起申请,请等待平台工作人员与您联系"); |
| | | } |
| | | agentApplication.setAppUserId(loginUserApplet.getUserid()); |
| | | agentApplication.setStatus(1); |
| | | agentApplication.setApplicationTime(LocalDateTime.now()); |
| | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation.ANONYMOUS.optional; |
| | | import static sun.plugin.util.ProgressMonitor.get; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | appUser = appUser1; |
| | | }else if(null == appUser){ |
| | | appUser = new AppUser(); |
| | | appUser.setAvatar(registerAccount.getAvatar()); |
| | | appUser.setName(registerAccount.getName()); |
| | | appUser.setPhone(registerAccount.getPhone()); |
| | | appUser.setWxOpenid(openid); |
| | |
| | | String cityCode = citycode.substring(0, 4) + "00"; |
| | | PageInfo<NearbyReferrerVo> pageInfo = new PageInfo(nearbyReferrer.getPageCurr(), nearbyReferrer.getPageSize()); |
| | | List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(pageInfo, cityCode, nearbyReferrer); |
| | | for (NearbyReferrerVo nearbyReferrerVo : list) { |
| | | switch (nearbyReferrerVo.getVip()){ |
| | | case "1": |
| | | nearbyReferrerVo.setVip("普通会员"); |
| | | break; |
| | | case "2": |
| | | nearbyReferrerVo.setVip("黄金会员"); |
| | | break; |
| | | case "3": |
| | | nearbyReferrerVo.setVip("钻石会员"); |
| | | break; |
| | | case "4": |
| | | nearbyReferrerVo.setVip("准代理"); |
| | | break; |
| | | case "5": |
| | | nearbyReferrerVo.setVip("代理"); |
| | | break; |
| | | case "6": |
| | | nearbyReferrerVo.setVip("总代"); |
| | | break; |
| | | case "7": |
| | | nearbyReferrerVo.setVip("合伙人"); |
| | | break; |
| | | } |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | return null; |
| | |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setType(1); |
| | | |
| | | R<List<ShopBalanceStatement>> r; |
| | | try { |
| | | r = shopClient.getShopBalanceStatementList(shopBalanceStatement); |
| | | } catch (Exception e) { |
| | | log.error("获取店铺余额对账单列表时出错", e); |
| | | return null; |
| | | } |
| | | |
| | | if (R.isError(r)) { |
| | | return null; |
| | | } |
| | | |
| | | List<BalanceChangeRecord> balanceChangeRecordList = this.baseMapper.selectBalanceChangeRecordList(balanceChangeRecord); |
| | | List<WalletStatisticsDetail> walletStatisticsDetailList = new ArrayList<>(); |
| | | for (BalanceChangeRecord changeRecord : balanceChangeRecordList) { |
| | |
| | | walletStatisticsDetailList.add(walletStatisticsDetail); |
| | | } |
| | | |
| | | List<WalletStatisticsDetail> collect = r.getData().stream().map(this::createWalletStatisticsDetail).collect(Collectors.toList()); |
| | | // 根据门店名称、用户姓名、联系电话进行模糊过滤 |
| | | collect = collect.stream() |
| | | .filter(e -> { |
| | | if (StringUtils.isNotEmpty(balanceChangeRecord.getShopName())) { |
| | | return e.getShopName().contains(balanceChangeRecord.getShopName()); |
| | | } else if (StringUtils.isNotEmpty(balanceChangeRecord.getUserName())) { |
| | | return e.getUserName().contains(balanceChangeRecord.getUserName()); |
| | | } else if (StringUtils.isNotEmpty(balanceChangeRecord.getUserPhone())) { |
| | | return e.getUserPhone().contains(balanceChangeRecord.getUserPhone()); |
| | | } |
| | | // 根据时间进行范围过滤 |
| | | if (balanceChangeRecord.getStartTime() != null && balanceChangeRecord.getEndTime() != null) { |
| | | return e.getCreateTime().isAfter(balanceChangeRecord.getStartTime()) && e.getCreateTime().isBefore(balanceChangeRecord.getEndTime()); |
| | | } |
| | | return false; |
| | | }).collect(Collectors.toList()); |
| | | walletStatisticsDetailList.addAll(collect); |
| | | |
| | | // 按时间排序(倒序) |
| | | walletStatisticsDetailList.sort(Comparator.comparing(WalletStatisticsDetail::getCreateTime).reversed()); |
| | |
| | | int fromIndex = (int) ((current - 1) * size); |
| | | int toIndex = (int) Math.min(fromIndex + size, walletStatisticsDetailList.size()); |
| | | |
| | | |
| | | Page<WalletStatisticsDetail> walletStatisticsDetailPage = new Page<>(); |
| | | WalletStatistics walletStatistics = new WalletStatistics(); |
| | | if (fromIndex >= walletStatisticsDetailList.size()) { |
| | | throw new ServiceException("页面参数无效"); |
| | | walletStatistics.setPage(walletStatisticsDetailPage); |
| | | return walletStatistics; |
| | | } |
| | | |
| | | List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex); |
| | | |
| | | |
| | | Map<Integer, BigDecimal> shopCommissionMap = walletStatisticsDetailList.stream() |
| | | .collect(Collectors.groupingBy( |
| | |
| | | BigDecimal totalWithdraw = shopCommissionMap.get(2); |
| | | BigDecimal totalShopWithdraw = shopCommissionMap.get(7); |
| | | |
| | | List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex); |
| | | |
| | | WalletStatistics walletStatistics = new WalletStatistics(); |
| | | Page<WalletStatisticsDetail> page1 = new Page<>(); |
| | | page1.setRecords(walletStatisticsDetailList2); |
| | | page1.setTotal(walletStatisticsDetailList.size()); |
| | | page1.setCurrent(current); |
| | | page1.setSize(size); |
| | | walletStatistics.setPage(page1); |
| | | walletStatisticsDetailPage.setCurrent(current); |
| | | walletStatisticsDetailPage.setSize(size); |
| | | walletStatisticsDetailPage.setTotal(walletStatisticsDetailList.size()); |
| | | walletStatisticsDetailPage.setRecords(walletStatisticsDetailList2); |
| | | walletStatistics.setPage(walletStatisticsDetailPage); |
| | | walletStatistics.setTotalRecharge(totalRecharge); |
| | | walletStatistics.setTotalWithdraw(totalWithdraw); |
| | | walletStatistics.setTotalShopWithdraw(totalShopWithdraw); |
| | | return walletStatistics; |
| | | } |
| | | |
| | | private WalletStatisticsDetail createWalletStatisticsDetail(ShopBalanceStatement item) { |
| | | WalletStatisticsDetail walletStatisticsDetail = new WalletStatisticsDetail(); |
| | | walletStatisticsDetail.setShopName(item.getShopName()); |
| | | walletStatisticsDetail.setUserName(item.getShopManagerName()); |
| | | walletStatisticsDetail.setUserPhone(item.getPhone()); |
| | | walletStatisticsDetail.setChangeType(4); |
| | | walletStatisticsDetail.setCreateTime(item.getCreateTime()); |
| | | walletStatisticsDetail.setChangeAmount(item.getVariableAmount()); |
| | | return walletStatisticsDetail; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | @Override |
| | | public List<PaymentUserCouponVo> getUserCoupon(Long userId, Integer type) { |
| | | List<UserCoupon> list = this.list(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getDelFlag, 0) |
| | | .last(" and now() between start_time and end_time")); |
| | | .isNull(UserCoupon::getUseTime).gt(UserCoupon::getEndTime, LocalDateTime.now()).last(" and now() between start_time and end_time")); |
| | | List<Integer> couponIds = list.stream().map(UserCoupon::getCouponId).collect(Collectors.toList()); |
| | | if(couponIds.size() == 0){ |
| | | return null; |
| | | } |
| | | List<CouponInfo> couponInfoList = couponInfoClient.getCouponInfoList(couponIds).getData(); |
| | | //构建返回数据 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | List<PaymentUserCouponVo> infoVoList = new ArrayList<>(); |
| | | for (UserCoupon userCoupon : list) { |
| | | CouponInfo couponInfo = couponInfoList.stream().filter(s -> s.getId().equals(userCoupon.getCouponId())).findFirst().get(); |
| | |
| | | if (vipSetting == null) { |
| | | return R.fail("VIP 设置未找到"); |
| | | } |
| | | if (vipSetting.getId() == 0 && vipSetting.getVipGiftRole() == 0) { |
| | | if (vipSetting.getVipGiftRole() == 0) { |
| | | return R.fail("转赠积分权限未开启"); |
| | | } |
| | | |
| | |
| | | if (appUser == null) { |
| | | return R.fail("用户未找到"); |
| | | } |
| | | |
| | | PointSetting pointSetting = pointSettingService.getPointSettingByAppUserId(userid); |
| | | if (pointSetting == null) { |
| | | return R.fail("积分设置未找到"); |
| | | } |
| | | // 可转赠积分总数 |
| | | Integer transferablePoint = appUser.getTransferablePoint(); |
| | | if (point > transferablePoint) { |
| | | return R.fail("转赠积分不足"); |
| | | return R.fail("可转赠积分不足"); |
| | | } |
| | | |
| | | AppUser appUserForPhoe = appUserService.getOne(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getPhone, phone)); |
| | | .eq(AppUser::getPhone, phone).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 3)); |
| | | if (appUserForPhoe == null) { |
| | | return R.fail("目标用户未找到"); |
| | | return R.fail("目标用户不存在"); |
| | | } |
| | | if(appUserForPhoe.getStatus() == 2){ |
| | | return R.fail("目标用户已被冻结"); |
| | | } |
| | | if(appUserForPhoe.getId().equals(userid)){ |
| | | return R.fail("不能转增给自己"); |
| | | } |
| | | Integer lavePoint1 = appUserForPhoe.getLavePoint(); |
| | | appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point); |
| | | appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point); |
| | | appUserForPhoe.setTransferablePoint(transferablePoint + point); |
| | | appUserForPhoe.setAvailablePoint(appUserForPhoe.getAvailablePoint() + point); |
| | | appUserForPhoe.setTotalAvailablePoint(appUserForPhoe.getTotalAvailablePoint() + point); |
| | | appUserService.updateById(appUserForPhoe); |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | |
| | | userPointService.save(userPoint); |
| | | |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | appUser.setLavePoint(lavePoint - point); |
| | | Integer totalPoint = appUser.getTotalPoint(); |
| | | appUser.setTotalPoint(totalPoint - point); |
| | | appUser.setLavePoint(appUser.getLavePoint() - point); |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() - point); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - point); |
| | | appUserService.updateById(appUser); |
| | |
| | | package com.ruoyi.account.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 com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecord; |
| | | import com.ruoyi.account.api.model.UserClickLog; |
| | | import com.ruoyi.account.api.model.WithdrawalRequests; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.dto.WithQuery; |
| | | import com.ruoyi.account.dto.WithdrawalRequestsDTO; |
| | | import com.ruoyi.account.mapper.WithdrawalRequestsMapper; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.service.WithdrawalRequestsService; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | |
| | | public static final BigDecimal MAX_WITHDRAWAL_AMOUNT = new BigDecimal("200"); |
| | | public static final BigDecimal VIP_WITHDRAWAL_FEE_DENOMINATOR = new BigDecimal("100"); |
| | | |
| | | @Resource |
| | | private AppUserBankService appUserBankService; |
| | | |
| | | @Override |
| | | public void withdrawalApply(WithdrawalRequestsDTO params) { |
| | |
| | | |
| | | WithdrawalRequests withdrawalRequests = new WithdrawalRequests(); |
| | | BeanUtils.copyBeanProp(withdrawalRequests, params); |
| | | if(2 == params.getWithdrawalMethod()){ |
| | | AppUserBank appUserBank = appUserBankService.getOne(new LambdaQueryWrapper<AppUserBank>().eq(AppUserBank::getAppUserId, loginUserApplet.getUserid())); |
| | | if(null == appUserBank){ |
| | | throw new ServiceException("请先添加提款账户!"); |
| | | } |
| | | withdrawalRequests.setAccountHolder(appUserBank.getBankName()); |
| | | withdrawalRequests.setBankCardNumber(appUserBank.getBankNumber()); |
| | | } |
| | | withdrawalRequests.setWithdrawalAmount(withdrawalAmount); |
| | | withdrawalRequests.setArrivalAmount(withdrawalRequests.getWithdrawalAmount()); |
| | | withdrawalRequests.setServiceCharge(multiply); |
| | |
| | | //添加变动明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(withdrawalRequests.getId()); |
| | | balanceChangeRecord.setChangeType(2); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | * 商户号 |
| | | */ |
| | | private static final String merchantNo = "888122600004175"; |
| | | /** |
| | | * 平台-报备商户号 |
| | | */ |
| | | public static final String sysTradeMerchantNo = "777168500885852"; |
| | | |
| | | private static final String format = "yyyy-MM-dd HH:mm:ss"; |
| | | /** |
| | |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | | //报备商户号 |
| | | body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | // body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | //产品类型 |
| | | body.put("productCode", "BANK_PAY_DAILY_ORDER"); |
| | | //交易请求时间 |
| | |
| | | */ |
| | | body.put("paidUse", singlePay.getPaidUse()); |
| | | //商户通知地址 |
| | | body.put("callbackUrl", singlePay.getCallbackUrl()); |
| | | body.put("callbackUrl", callbackUrl + singlePay.getCallbackUrl()); |
| | | 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()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (Map.Entry<String, Object> item : infoIds) { |
| | | for (Map.Entry<String, Object> item : entries) { |
| | | if (item.getKey() != null || item.getKey() != "") { |
| | | Object val = item.getValue(); |
| | | if (!(val == "" || val == null)) { |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | |
| | | * 202 处理中 批次正在处理中状态 |
| | | * 203 处理完成 批次中的每笔明细都明确了代付结果 |
| | | * 204 批次不存在 汇聚未受理该批次的请求,找不到该批次,明确失败 |
| | | * 205 交易成功 明确交易成功的状态码 |
| | | * 208 订单已取消 代付订单被商户审核为拒绝付款 |
| | | * 210 账务冻结中 确认出款后对商户的账户余额进行冻结处理 |
| | | * 211 账务解冻中 确认失败后对商户的账户余额进行解冻处理 |
| | | * 212 订单取消中 商户审核为拒绝付款的中间状态 |
| | | * 213 账务扣款中 确认成功后对商户的账户冻结款的扣款处理 |
| | | * 214 订单不存在 汇聚未受理该笔代付请求,找不到该笔订单,明确失败 |
| | | */ |
| | | private Integer status; |
| | | /** |
| | |
| | | package com.ruoyi.account.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | |
| | | private BigDecimal totalPartnerCommission; |
| | | |
| | | private List<CommissionDate> commissionDateList; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime startTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime endTime; |
| | | |
| | | } |
| | |
| | | private String vip; |
| | | @ApiModelProperty("距离(m)") |
| | | private BigDecimal distance; |
| | | @ApiModelProperty("手机号") |
| | | private String phone; |
| | | } |
| | |
| | | |
| | | @Data |
| | | public class WalletStatisticsDetail { |
| | | /** |
| | | * 门店名称 |
| | | */ |
| | | @ApiModelProperty(value = "门店名称") |
| | | @Excel(name = "门店名称") |
| | | private String shopName; |
| | | |
| | | /** |
| | | * 用户姓名 |
New file |
| | |
| | | package com.ruoyi.account.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/11 9:23 |
| | | */ |
| | | @Data |
| | | public class WithdrawalAuth { |
| | | /** |
| | | * 申请id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * 审核状态 |
| | | */ |
| | | private Integer auditStatus; |
| | | } |
| | |
| | | ST_Distance_Sphere( |
| | | point(#{nearbyReferrer.longitude},#{nearbyReferrer.latitude}), |
| | | point(longitude, latitude) |
| | | ) as distance |
| | | from t_app_user where city_code = #{cityCode} and del_flag = 0 and status = 1 |
| | | ) as distance, |
| | | phone |
| | | from t_app_user where city_code = #{cityCode} and del_flag = 0 and status = 1 and vip_id >= 4 |
| | | <if test="null != nearbyReferrer.name and '' != nearbyReferrer.name"> |
| | | and `name` like CONCAT('%', #{nearbyReferrer.name}, '%') |
| | | </if> |
| | |
| | | and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2} |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | <sql id="balanceChangeRecordList"> |
| | |
| | | <if test="changeRecord.startTime != null and changeRecord.endTime != null"> |
| | | and (tbcr.create_time between #{changeRecord.startTime} and #{changeRecord.endTime}) |
| | | </if> |
| | | <if test="changeRecord.changeType != null"> |
| | | and tbcr.change_type = #{changeRecord.changeType} |
| | | </if> |
| | | </where> |
| | | </sql> |
| | | |
| | |
| | | and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2} |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | t_user_point tup |
| | | LEFT JOIN t_app_user tau ON tup.app_user_id = tau.id |
| | | <where> |
| | | tup.type not in (8, 9, 14) |
| | | <if test="userPoint.userName != null and userPoint.userName != ''"> |
| | | AND tau.`name` LIKE concat('%',#{userPoint.userName},'%') |
| | | </if> |
| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | |
| | | 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.ruoyi.account.api.feignClient.UserAddressClient; |
| | | import com.ruoyi.account.api.model.UserAddress; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.RefundPassService; |
| | | import com.ruoyi.order.util.payment.model.RefundCallbackResult; |
| | | import com.ruoyi.order.util.vo.MapTrackKD100Vo; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.BaseSetting; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | |
| | | public R<Void> updateOrderStatus(@RequestBody Order order){ |
| | | Order order1 = orderService.getById(order.getId()); |
| | | order1.setOrderStatus(order.getOrderStatus()); |
| | | order1.setOldOrderStatus(order.getOldOrderStatus()); |
| | | orderService.updateById(order1); |
| | | return R.ok(); |
| | | } |
| | |
| | | |
| | | 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")))); |
| | | 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"))) |
| | | .orderByDesc(Order::getCreateTime)); |
| | | |
| | | |
| | | Map<String, List<Order>> map = orderList.stream().collect(Collectors.groupingBy(item -> item.getCreateTime() |
| | |
| | | Set<Long> collect = list.stream().map(Order::getAppUserId).collect(Collectors.toSet()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取订单快递明细 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/getOrderExpress/{id}") |
| | | @ApiOperation(value = "获取订单快递明细", tags = {"小程序-订单管理"}) |
| | | public R<MapTrackKD100Vo> getOrderExpress(@PathVariable("id") Long id){ |
| | | Order order = orderService.getById(id); |
| | | String expressResult = order.getExpressResult(); |
| | | if(StringUtils.isNotEmpty(expressResult)){ |
| | | MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(expressResult, MapTrackKD100Vo.class); |
| | | return R.ok(mapTrackKD100Vo); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取订单详情 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getOrderById") |
| | | public R<Order> getOrderById(@RequestParam("id") Long id){ |
| | | Order order = orderService.getById(id); |
| | | return R.ok(order); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改订单 |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @PostMapping("/editOrder") |
| | | public R editOrder(@RequestBody Order order){ |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private GoodsShopClient goodsShopClient; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | Integer getShopSaleNum(Integer shopId, Integer type); |
| | | |
| | | /** |
| | | * 定时查询快递信息 |
| | | */ |
| | | void taskExpress(); |
| | | } |
| | |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .eq(OrderGood::getOrderId, order.getId())); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | if(null == appUser){ |
| | | return; |
| | | } |
| | | //直推上级分佣金额 |
| | | BigDecimal ztsj_price = BigDecimal.ZERO; |
| | | //直帮上级分佣金额 |
| | |
| | | if(!inviteUser.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(inviteUser.getId()); |
| | | balanceChangeRecord.setVipId(inviteUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | if(!superiorLeader.getBalance().equals(balance)){ |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(superiorLeader.getId()); |
| | | balanceChangeRecord.setVipId(superiorLeader.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(4); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | |
| | | 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.account.api.feignClient.UserCouponClient; |
| | | import com.ruoyi.account.api.feignClient.UserPointClient; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | 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.service.*; |
| | | 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.MapTrackKD100Vo; |
| | | import com.ruoyi.order.util.vo.QueryKD100Vo; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.*; |
| | |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | private TechnicianSubscribeClient technicianSubscribeClient; |
| | | @Resource |
| | | private ShopBalanceStatementClient shopBalanceStatementClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private SystemConfigClient systemConfigClient; |
| | | |
| | | @Resource |
| | | private UserCouponClient userCouponClient; |
| | | |
| | | |
| | | |
| | |
| | | orderDetailVO.setAddressId(userAddress.getId()); |
| | | orderDetailVO.setRecieveName(userAddress.getRecieveName()); |
| | | orderDetailVO.setRecievePhone(userAddress.getRecievePhone()); |
| | | userAddress.setRecieveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); |
| | | orderDetailVO.setRecieveAddress(userAddress.getRecieveAddress()); |
| | | orderDetailVO.setOrderNumber(order.getOrderNumber()); |
| | | orderDetailVO.setCreateTime(order.getCreateTime()); |
| | |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(paymentAmount); |
| | |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //回退优惠券状态 |
| | | if(null != order.getUserCouponId()){ |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | userCoupon.setUseTime(null); |
| | | userCouponClient.editReturnUse(userCoupon); |
| | | } |
| | | } |
| | | if(3 == payMethod){ |
| | | //开始运费退款,积分支付,运费是单独进行支付的,所以需要单独退款 |
| | |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(expressAmount); |
| | |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //回退优惠券状态 |
| | | if(null != order.getUserCouponId()){ |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | userCoupon.setUseTime(null); |
| | | userCouponClient.editReturnUse(userCoupon); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | if(StringUtils.isNotEmpty(order.getAddressJson())){ |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | orderInfo.setRecipient(userAddress.getRecieveName() + "-" + userAddress.getRecievePhone()); |
| | | userAddress.setRecieveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); |
| | | orderInfo.setAddress(userAddress.getRecieveAddress()); |
| | | } |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | if(StringUtils.isNotEmpty(order.getExpressJson()) && !"NULL".equals(order.getExpressJson())){ |
| | | JSONObject jsonObject = JSON.parseObject(order.getExpressJson()); |
| | | String com = jsonObject.getString("com"); |
| | | String num = jsonObject.getString("num"); |
| | |
| | | public Integer getShopSaleNum(Integer shopId, Integer type) { |
| | | return this.baseMapper.getShopSaleNum(shopId, type); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时查询快递信息 |
| | | */ |
| | | @Override |
| | | public void taskExpress() { |
| | | Set<Long> order_express = redisTemplate.opsForZSet().rangeByScore("order_express", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(order_express.size() > 0){ |
| | | for (Long id : order_express) { |
| | | Order order = this.getById(id); |
| | | if(order.getOrderStatus() != 2){ |
| | | redisTemplate.opsForZSet().remove("order_express", id); |
| | | continue; |
| | | } |
| | | String expressJson = order.getExpressJson(); |
| | | if(StringUtils.isEmpty(expressJson)){ |
| | | redisTemplate.opsForZSet().remove("order_express", id); |
| | | continue; |
| | | } |
| | | //{"com":"jd","num":"JDV016336234367"} |
| | | JSONObject jsonObject = JSON.parseObject(expressJson); |
| | | String com = jsonObject.getString("com"); |
| | | String num = jsonObject.getString("num"); |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(), |
| | | userAddress.getProvince() + userAddress.getCity()); |
| | | order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); |
| | | this.updateById(order); |
| | | //延长时间x小时 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent()); |
| | | Integer waitTime = jsonObject1.getInteger("waitTime"); |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | //查询符合商品类型的商品数据 |
| | | List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid) |
| | | .in(ShoppingCart::getGoodsId, goodsIds).eq(ShoppingCart::getStatus, 1)); |
| | | //删除过期的秒杀活动商品 |
| | | List<ShoppingCart> list1 = new ArrayList<>(); |
| | | for (ShoppingCart shoppingCart : list) { |
| | | if(shoppingCart.getType() == 2){ |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |
| | | info.setGoodsId(shoppingCart.getGoodsId()); |
| | | info.setVip(appUser.getVipId()); |
| | | GoodsSeckill data1 = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); |
| | | if(null != data1){ |
| | | SeckillActivityInfo seckillActivityInfo = seckillActivityInfoClient.getSeckillActivityInfoById(data1.getSeckillActivityInfoId()).getData(); |
| | | if(null != seckillActivityInfo && (seckillActivityInfo.getIsShelves() == 1 && |
| | | seckillActivityInfo.getStartTime().isBefore(LocalDateTime.now()) && seckillActivityInfo.getEndTime().isAfter(LocalDateTime.now()))){ |
| | | |
| | | list1.add(shoppingCart); |
| | | continue; |
| | | } |
| | | } |
| | | this.removeById(shoppingCart.getId()); |
| | | }else{ |
| | | list1.add(shoppingCart); |
| | | } |
| | | } |
| | | |
| | | //构建返回数据 |
| | | List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null); |
| | | List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list1, null); |
| | | return page; |
| | | } |
| | | |
| | |
| | | //满XX才打折,只有现金才能优惠 |
| | | if((confirmOrderVo.getUseSimultaneously() || (!confirmOrderVo.getUseSimultaneously() && activityAmount.equals(BigDecimal.ZERO))) |
| | | && null != orderActivityInfo && confirmOrder.getPaymentType() == 1){ |
| | | BigDecimal zyh = BigDecimal.ZERO; |
| | | OrderActivityInfo activityInfo1 = null; |
| | | 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; |
| | | if(bigDecimal.compareTo(zyh) > 0){ |
| | | zyh = bigDecimal; |
| | | activityInfo1 = activityInfo; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != activityInfo1){ |
| | | confirmOrderVo.setActivityName(activityInfo1.getActivityName()); |
| | | paymentMoney = paymentMoney.subtract(zyh); |
| | | activityAmount = activityAmount.add(zyh); |
| | | } |
| | | } |
| | | confirmOrderVo.setDiscountAmount(activityAmount); |
| | | int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum(); |
| | | confirmOrderVo.setEarnPoint(earnPoint); |
| | | if(null != paymentMoney && BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | | |
| | | //支付金额,订单金额-订单优惠 |
| | | confirmOrderVo.setPayMoney(paymentMoney); |
| | | confirmOrderVo.setResidualPoint(appUser.getAvailablePoint().intValue()); |
| | |
| | | UserAddress userAddress = userAddressClient.getDefaultUserAddress(userid).getData(); |
| | | if(null != userAddress){ |
| | | userAddress.setIdStr(userAddress.getId().toString()); |
| | | userAddress.setRecieveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); |
| | | confirmOrderVo.setUserAddress(userAddress); |
| | | } |
| | | confirmOrderVo.setPaymentType(confirmOrder.getPaymentType()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(goods.getStatus() == 1){ |
| | | throw new RuntimeException(goods.getName() + "商品已被下架"); |
| | | } |
| | | if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(appUser.getVipId().toString())){ |
| | | throw new RuntimeException("无权限购买" + goods.getName()); |
| | | } |
| | | |
| | | ids.add(id); |
| | | } |
| | | |
| | |
| | | }else{ |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | orderPoint += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber()); |
| | | } |
| | | if(appUser.getLavePoint().intValue() < orderPoint){ |
| | | return R.fail("账户剩余积分不足"); |
| | | } |
| | | } |
| | | //现金的支付金额 |
| | |
| | | OrderActivityInfo orderActivityInfo1 = null; |
| | | if((1 == status || null == shoppingCartPayment.getUserCouponId()) && |
| | | null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3){ |
| | | //找出最优会的金额 |
| | | BigDecimal zyh = BigDecimal.ZERO; |
| | | 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; |
| | | if(bigDecimal.compareTo(zyh) > 0){ |
| | | zyh = bigDecimal; |
| | | orderActivityInfo1 = activityInfo; |
| | | } |
| | | } |
| | | } |
| | | |
| | | paymentMoney = paymentMoney.subtract(zyh); |
| | | activityAmount = activityAmount.add(zyh); |
| | | } |
| | | |
| | | //可获得的消费积分 |
| | |
| | | } |
| | | } |
| | | } |
| | | if(BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | | |
| | | //构建订单明细 |
| | | Order order = new Order(); |
| | | order.setAppUserId(userid); |
| | |
| | | } |
| | | if(3 != shoppingCartPayment.getPaymentType() && (fullReductionAmount.compareTo(BigDecimal.ZERO) > 0 ||moneyAmount.compareTo(BigDecimal.ZERO) > 0 || discountAmount.compareTo(BigDecimal.ZERO) > 0)){ |
| | | order.setCouponJson(JSON.toJSONString(couponInfoVo)); |
| | | order.setUserCouponId(shoppingCartPayment.getUserCouponId()); |
| | | } |
| | | if(activityAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | if(null != orderActivityInfo1){ |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo1)); |
| | | } |
| | | if(null != shoppingCartPayment.getUserAddressId()){ |
| | |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | | Integer availablePoint = appUser.getAvailablePoint(); |
| | | if(availablePoint < orderPoint){ |
| | | return R.fail("账户积分不足"); |
| | | return R.fail("账户可用积分不足"); |
| | | } |
| | | } |
| | | //判断运费支付是否足够 |
| | |
| | | //开始构建支付数据 |
| | | //现金支付 |
| | | paymentMoney = paymentMoney.add(expressFee).setScale(2, RoundingMode.HALF_EVEN); |
| | | if(BigDecimal.ZERO.compareTo(paymentMoney) > 0){ |
| | | paymentMoney = BigDecimal.ZERO; |
| | | } |
| | | if(1 == shoppingCartPayment.getPaymentType()){ |
| | | //调起微信支付 |
| | | 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(), null); |
| | | if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){ |
| | | return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg()); |
| | | if(BigDecimal.ZERO.compareTo(paymentMoney) < 0){ |
| | | //调起微信支付 |
| | | String goodsNames = goodsList.stream().map(MyShoppingCartVo::getName).collect(Collectors.joining("\n")); |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber(), paymentMoney.doubleValue(), order.getOrderType() == 1 ? "购买服务商品" : "购买单品商品", |
| | | goodsNames, "", "/order/shopping-cart/shoppingCartPaymentCallback", appUser.getWxOpenid(), 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(jsonObject.toJSONString()); |
| | | }else{ |
| | | |
| | | earnPoint = order.getGetPoint(); |
| | | appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | paymentMoney = order.getPaymentAmount(); |
| | | //构建积分流水记录 |
| | | if(earnPoint > 0){ |
| | | 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.setShopPoint(appUser.getShopPoint() + earnPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + earnPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + earnPoint1); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("shopPoint", earnPoint); |
| | | jsonObject.put("availablePoint", earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + earnPoint1); |
| | | jsonObject.put("transferablePoint", earnPoint1); |
| | | } |
| | | |
| | | UserPoint 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()); |
| | | userPoint.setExtention(jsonObject.toJSONString()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | //修改订支付状态 |
| | | order.setPayStatus(2); |
| | | //自提 |
| | | if(order.getOrderType() == 1 && StringUtils.isEmpty(order.getAddressJson())){ |
| | | order.setOrderStatus(2); |
| | | } |
| | | orderService.updateById(order); |
| | | |
| | | //处理优惠券 |
| | | if(null != order.getUserCouponId()){ |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | if(null != userCoupon && null == userCoupon.getUseTime()){ |
| | | userCoupon.setStatus(2); |
| | | userCoupon.setUseTime(LocalDateTime.now()); |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | //删除购物车数据 |
| | | userid = tokenService.getLoginUserApplet().getUserid(); |
| | | List<OrderGood> list1 = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, order.getId())); |
| | | List<Integer> goodsIds1 = list1.stream().map(OrderGood::getGoodsId).collect(Collectors.toList()); |
| | | this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds1)); |
| | | |
| | | } |
| | | 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(jsonObject.toJSONString()); |
| | | } |
| | | //账户余额 |
| | | BigDecimal redPacketAmount = BigDecimal.ZERO; |
| | |
| | | BigDecimal totalDistributionAmount = appUser.getTotalDistributionAmount(); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | //红包金额满足支付 |
| | | if(paymentMoney.compareTo(totalRedPacketAmount) <= 0){ |
| | | totalRedPacketAmount = totalRedPacketAmount.subtract(paymentMoney); |
| | | balance = balance.subtract(paymentMoney); |
| | | BigDecimal paymentMoney1 = paymentMoney; |
| | | if(paymentMoney1.compareTo(totalRedPacketAmount) <= 0){ |
| | | totalRedPacketAmount = totalRedPacketAmount.subtract(paymentMoney1); |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setBalance(balance); |
| | | redPacketAmount = paymentMoney; |
| | | redPacketAmount = paymentMoney1; |
| | | }else{ |
| | | paymentMoney = paymentMoney.subtract(totalRedPacketAmount); |
| | | paymentMoney1 = paymentMoney1.subtract(totalRedPacketAmount); |
| | | redPacketAmount = totalRedPacketAmount; |
| | | totalRedPacketAmount = BigDecimal.ZERO; |
| | | if(paymentMoney.compareTo(totalDistributionAmount) <= 0){ |
| | | totalDistributionAmount = totalDistributionAmount.subtract(paymentMoney); |
| | | balance = balance.subtract(paymentMoney); |
| | | if(paymentMoney1.compareTo(totalDistributionAmount) <= 0){ |
| | | totalDistributionAmount = totalDistributionAmount.subtract(paymentMoney1); |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = paymentMoney; |
| | | distributionAmount = paymentMoney1; |
| | | }else{ |
| | | paymentMoney = paymentMoney.subtract(totalDistributionAmount); |
| | | paymentMoney1 = paymentMoney1.subtract(totalDistributionAmount); |
| | | totalDistributionAmount = BigDecimal.ZERO; |
| | | balance = balance.subtract(paymentMoney); |
| | | balance = balance.subtract(paymentMoney1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | |
| | | //构建余额明细变动记录 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(5); |
| | | balanceChangeRecord.setBeforeAmount(balance.add(paymentMoney)); |
| | |
| | | orderService.updateById(order); |
| | | //删除购物车数据 |
| | | this.removeBatchByIds(ids); |
| | | //处理优惠券 |
| | | if(null != order.getUserCouponId()){ |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | if(null != userCoupon && null == userCoupon.getUseTime()){ |
| | | userCoupon.setUseTime(LocalDateTime.now()); |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | } |
| | | //积分支付 |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | |
| | | BigDecimal totalRedPacketAmount = appUser.getTotalRedPacketAmount(); |
| | | BigDecimal totalDistributionAmount = appUser.getTotalDistributionAmount(); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | if(expressFee.compareTo(totalRedPacketAmount) <= 0){ |
| | | totalRedPacketAmount = totalRedPacketAmount.subtract(expressFee); |
| | | balance = balance.subtract(expressFee); |
| | | BigDecimal expressFee1 = expressFee; |
| | | if(expressFee1.compareTo(totalRedPacketAmount) <= 0){ |
| | | totalRedPacketAmount = totalRedPacketAmount.subtract(expressFee1); |
| | | balance = balance.subtract(expressFee1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setBalance(balance); |
| | | redPacketAmount = expressFee; |
| | | redPacketAmount = expressFee1; |
| | | }else{ |
| | | expressFee = expressFee.subtract(totalRedPacketAmount); |
| | | expressFee1 = expressFee1.subtract(totalRedPacketAmount); |
| | | redPacketAmount = totalRedPacketAmount; |
| | | totalRedPacketAmount = BigDecimal.ZERO; |
| | | if(expressFee.compareTo(totalDistributionAmount) <= 0){ |
| | | totalDistributionAmount = totalDistributionAmount.subtract(expressFee); |
| | | balance = balance.subtract(expressFee); |
| | | if(expressFee1.compareTo(totalDistributionAmount) <= 0){ |
| | | totalDistributionAmount = totalDistributionAmount.subtract(expressFee1); |
| | | balance = balance.subtract(expressFee1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | | distributionAmount = expressFee; |
| | | distributionAmount = expressFee1; |
| | | }else{ |
| | | expressFee = expressFee.subtract(totalDistributionAmount); |
| | | expressFee1 = expressFee1.subtract(totalDistributionAmount); |
| | | totalDistributionAmount = BigDecimal.ZERO; |
| | | balance = balance.subtract(expressFee); |
| | | balance = balance.subtract(expressFee1); |
| | | appUser.setTotalRedPacketAmount(totalRedPacketAmount); |
| | | appUser.setTotalDistributionAmount(totalDistributionAmount); |
| | | appUser.setBalance(balance); |
| | |
| | | //构建余额明细变动记录 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setChangeType(5); |
| | | balanceChangeRecord.setBeforeAmount(balance.add(paymentMoney)); |
| | | balanceChangeRecord.setChangeAmount(paymentMoney); |
| | | balanceChangeRecord.setBeforeAmount(balance.add(expressFee)); |
| | | balanceChangeRecord.setChangeAmount(expressFee); |
| | | balanceChangeRecord.setAfterAmount(balance); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | |
| | | orderService.updateById(order); |
| | | //删除购物车数据 |
| | | this.removeBatchByIds(ids); |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Integer waitTime = jsonObject.getInteger("waitTime"); |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | } |
| | | |
| | |
| | | order.setOrderStatus(2); |
| | | } |
| | | orderService.updateById(order); |
| | | |
| | | //处理优惠券 |
| | | if(null != order.getUserCouponId()){ |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | if(null != userCoupon && null == userCoupon.getUseTime()){ |
| | | userCoupon.setStatus(2); |
| | | userCoupon.setUseTime(LocalDateTime.now()); |
| | | userCouponClient.editUserCoupon(userCoupon); |
| | | } |
| | | } |
| | | //添加查询快递信息队列 |
| | | if(StringUtils.isNotEmpty(order.getExpressJson())){ |
| | | //一小时后定时查询快递信息 |
| | | redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(1).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | //删除购物车数据 |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Long userid = order.getAppUserId(); |
| | | List<OrderGood> list = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, order.getId())); |
| | | List<Integer> goodsIds = list.stream().map(OrderGood::getGoodsId).collect(Collectors.toList()); |
| | | this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds)); |
| | | |
| | | //商品销量增加 |
| | | for (Integer goodsId : goodsIds) { |
| | | goodsClient.editGoodsNum(goodsId, 1); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | * 快递100查询带有地图轨迹数据的快递详情 |
| | | * @param com 快递公司代码 |
| | | * @param num 快递单号 |
| | | * @param from 触发城市名称 |
| | | * @param from 出发城市名称 |
| | | * @param to 到达城市名称 |
| | | * @return |
| | | */ |
| | |
| | | package com.ruoyi.order.util; |
| | | |
| | | import com.ruoyi.order.service.CommissionService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.ShoppingCartService; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Resource |
| | | private ShoppingCartService shoppingCartService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | public void taskMonth() { |
| | | commissionService.calculationCommission(); |
| | | shoppingCartService.closeOrder(); |
| | | orderService.taskExpress(); |
| | | } |
| | | |
| | | // 每天晚上23:59:59执行的定时任务 |
| | |
| | | * 商户号 |
| | | */ |
| | | private static final String merchantNo = "888122600004175"; |
| | | |
| | | /** |
| | | * 平台-报备商户号 |
| | | */ |
| | | public static final String sysTradeMerchantNo = "777168500885852"; |
| | | |
| | | private static final String format = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | |
| | | /** |
| | | * 支付回调地址 |
| | | */ |
| | | private static final String callbackUrl = "http://221.182.45.100:9000"; |
| | | |
| | | |
| | | /** |
| | | * 单笔代付 |
| | | * @param singlePay |
| | |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | | //报备商户号 |
| | | body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | // body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | //产品类型 |
| | | body.put("productCode", "BANK_PAY_DAILY_ORDER"); |
| | | //交易请求时间 |
| | |
| | | */ |
| | | body.put("paidUse", singlePay.getPaidUse()); |
| | | //商户通知地址 |
| | | body.put("callbackUrl", singlePay.getCallbackUrl()); |
| | | body.put("callbackUrl", callbackUrl + singlePay.getCallbackUrl()); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | SinglePayResult uniPayResult = jsonObject.getObject("data", SinglePayResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 单笔代付查询接口 |
| | | * @param merchantOrderNo 订单号 |
| | |
| | | SinglePayQueryResult uniPayResult = jsonObject.getObject("data", SinglePayQueryResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 可取余额查询 |
| | | * @return |
| | |
| | | AccountBalanceQueryResult uniPayResult = jsonObject.getObject("data", AccountBalanceQueryResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | 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()).compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (Map.Entry<String, Object> item : infoIds) { |
| | | for (Map.Entry<String, Object> item : entries) { |
| | | if (item.getKey() != null || item.getKey() != "") { |
| | | Object val = item.getValue(); |
| | | if (!(val == "" || val == null)) { |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | |
| | | private BigDecimal point; |
| | | @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") |
| | | private Integer status; |
| | | @ApiModelProperty("物流类型(1=自提,2=快递)") |
| | | private Integer expressType; |
| | | /** |
| | | * 用户id |
| | | */ |
| | |
| | | private BigDecimal paymentAmount; |
| | | @ApiModelProperty("获得积分") |
| | | private Integer point; |
| | | @ApiModelProperty("获得积分") |
| | | private Integer getPoint; |
| | | @ApiModelProperty("商品数量") |
| | | private Integer goodsNum; |
| | | @ApiModelProperty("商品信息") |
| | |
| | | pay_method as paymentType, |
| | | total_amount as orderMoney, |
| | | point, |
| | | order_status as status |
| | | order_status as status, |
| | | if(express_json is not null and express_json != 'NULL' and express_json != '', 2, 1) as expressType |
| | | from t_order where del_flag = 0 and pay_status = 2 |
| | | <if test="null != item.code and '' != item.code"> |
| | | and order_number like CONCAT('%', #{item.code}, '%') |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | 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.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.domain.Banner; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | | import com.ruoyi.other.api.domain.SeckillActivityInfo; |
| | | import com.ruoyi.other.service.BannerService; |
| | | import com.ruoyi.other.service.GoodsService; |
| | | import com.ruoyi.other.service.GoodsVipService; |
| | | import com.ruoyi.other.service.SeckillActivityInfoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | public class BannerController { |
| | | @Resource |
| | | private BannerService bannerService; |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | @Resource |
| | | private GoodsVipService goodsVipService; |
| | | @Resource |
| | | private SeckillActivityInfoService seckillActivityInfoService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "banner列表", tags = {"小程序-banner"}) |
| | | public R<List<Banner>> list(@ApiParam("名称") String name, |
| | |
| | | .eq(jumpType!=null,Banner::getJumpType, jumpType) |
| | | .eq(position!=null,Banner::getPosition, position) |
| | | .list(); |
| | | 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(); |
| | | } |
| | | for (Banner banner : list) { |
| | | Integer jumpType1 = banner.getJumpType(); |
| | | //商品详情 |
| | | if(null != jumpType1 && 3 == jumpType1){ |
| | | Goods goods = goodsService.getById(banner.getContent()); |
| | | if(null == goods || goods.getDelFlag() == 1){ |
| | | banner.setJumpType(1); |
| | | } |
| | | if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(vipId.toString())){ |
| | | banner.setJumpType(1); |
| | | } |
| | | } |
| | | //秒杀活动 |
| | | if(null != jumpType1 && 4 == jumpType1){ |
| | | SeckillActivityInfo activityInfo = seckillActivityInfoService.getById(banner.getContent()); |
| | | if(null == activityInfo || activityInfo.getDelFlag() == 1){ |
| | | banner.setJumpType(1); |
| | | } |
| | | if(!activityInfo.getVipIds().contains(vipId.toString())){ |
| | | banner.setJumpType(1); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | @PostMapping("/add") |
| | |
| | | //查出指定人员可领取优惠券 |
| | | List<CouponInfo> list1 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 2).apply("FIND_IN_SET('" + appUserById.getId() + "', person_ids)").list(); |
| | | //查出指定会员可领取优惠劵 |
| | | List<CouponInfo> list2 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 3).apply("FIND_IN_SET('" + appUserById.getVipId() + "', person_ids)").list(); |
| | | List<CouponInfo> list2 = couponInfoService.lambdaQuery().le(CouponInfo::getSendStartTime, now).ge(CouponInfo::getSendEndTime, now).eq(CouponInfo::getPersonType, 3).apply("FIND_IN_SET('" + appUserById.getVipId() + "', vip_ids)").list(); |
| | | List<CouponInfo> returnList = new ArrayList<>(); |
| | | count(userid, list, returnList); |
| | | count(userid, list1, returnList); |
| | | count(userid, list2, returnList); |
| | | |
| | | |
| | | return R.ok(returnList); |
| | | } |
| | | |
| | | private void count(Long userid, List<CouponInfo> list1, List<CouponInfo> returnList) { |
| | | for (CouponInfo couponInfo : list1) { |
| | | Long count = appUserClient.getCouponCount(userid, couponInfo.getId()).getData(); |
| | | Long count = appUserClient.getCouponCount(-1L, couponInfo.getId()).getData(); |
| | | if(couponInfo.getSendNum() <= count){ |
| | | couponInfo.setMaxNum(count.intValue() - couponInfo.getSendNum()); |
| | | for (int i = 0; i < couponInfo.getMaxNum(); i++) { |
| | | returnList.add(couponInfo); |
| | | } |
| | | continue; |
| | | } |
| | | count = appUserClient.getCouponCount(userid, couponInfo.getId()).getData(); |
| | | couponInfo.setMaxNum(couponInfo.getMaxNum() - count.intValue()); |
| | | for (int i = 0; i < couponInfo.getMaxNum(); i++) { |
| | | returnList.add(couponInfo); |
| | |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.redis.annotation.DistributedLock; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | |
| | | return R.ok(goods); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑商品 |
| | | * @param goods |
| | | * @return |
| | | */ |
| | | @PostMapping("/editGoodsList") |
| | | public R editGoodsList(@RequestBody List<Goods> goods){ |
| | | goodsService.updateBatchById(goods); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 商品销量增加 |
| | | */ |
| | | @PutMapping("/editGoodsNum") |
| | | @DistributedLock(lockNamePre = "#goods_lock", lockNamePost = "#goodsId") |
| | | public R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num){ |
| | | Goods goods = goodsService.getById(goodsId); |
| | | goods.setSaleNum(goods.getSaleNum() + num); |
| | | goodsService.updateById(goods); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有商品 |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAllGoods") |
| | | public R<List<Goods>> getAllGoods(){ |
| | | List<Goods> list = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getStatus, 2)); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Goods; |
| | | import com.ruoyi.other.api.domain.GoodsEvaluate; |
| | | import com.ruoyi.other.service.GoodsEvaluateService; |
| | |
| | | private GoodsService goodsService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/goodsList") |
| | | @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"}) |
| | | public R<List<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId){ |
| | | List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).list(); |
| | | List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).eq(GoodsEvaluate::getDelFlag, 0) |
| | | .eq(GoodsEvaluate::getStatus, 2).isNotNull(GoodsEvaluate::getComment).ne(GoodsEvaluate::getComment, "").orderByDesc(GoodsEvaluate::getCreateTime).list(); |
| | | for (GoodsEvaluate goodsEvaluate : list) { |
| | | AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); |
| | | if(null != appUserById){ |
| | |
| | | List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>() |
| | | .eq(GoodsEvaluate::getStatus, 2) |
| | | .eq(GoodsEvaluate::getAppUserId,loginUserApplet.getUserid()) |
| | | .eq(GoodsEvaluate::getDelFlag, 0) |
| | | .eq(GoodsEvaluate::getOrderId, orderId)); |
| | | for (GoodsEvaluate goodsEvaluate : list) { |
| | | Goods goods = goodsService.getById(goodsEvaluate.getGoodsId()); |
| | |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"}) |
| | | public R<Void> delete(@PathVariable("id") Long id){ |
| | | goodsEvaluateService.removeById(id); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); |
| | | goodsEvaluate.setDelFlag(1); |
| | | goodsEvaluateService.updateById(goodsEvaluate); |
| | | //修改订单为待评价 |
| | | Order data = orderClient.getOrderById(goodsEvaluate.getOrderId()).getData(); |
| | | data.setOrderStatus(data.getOldOrderStatus()); |
| | | orderClient.editOrder(data); |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | integers.add(3); |
| | | integers.add(4); |
| | | List<Integer> integers1 = new ArrayList<>(); |
| | | integers.retainAll(integers1); |
| | | System.err.println(integers); |
| | | System.err.println(integers1); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 评论列表 |
| | |
| | | .in(!goodsIds.isEmpty(), GoodsEvaluate::getGoodsId, goodsIds) |
| | | .in(!usersNameList.isEmpty(), GoodsEvaluate::getAppUserId, usersNameList) |
| | | .eq(goodsEvaluate.getStatus() != null, GoodsEvaluate::getStatus, goodsEvaluate.getStatus()) |
| | | .eq(GoodsEvaluate::getDelFlag, 0) |
| | | .orderByDesc(GoodsEvaluate::getCreateTime)); |
| | | |
| | | |
| | |
| | | item.setUserName(appUser.getName()); |
| | | } |
| | | Goods goods = goodsService.getById(item.getGoodsId()); |
| | | item.setGoodsName(goods.getName()); |
| | | if(null != goods){ |
| | | item.setGoodsName(goods.getName()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<Void> saveActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setIsShelf(0); |
| | | if (org.springframework.util.StringUtils.hasLength(orderActivityInfo.getVipIds())){ |
| | | List<String> vipIds = Arrays.asList(orderActivityInfo.getVipIds().split(",")); |
| | | List<String> vipIds = new ArrayList<>(Arrays.asList(orderActivityInfo.getVipIds().split(","))); |
| | | List<OrderActivityInfo> list = orderActivityInfoService.lambdaQuery() |
| | | .le(OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .or() |
| | |
| | | if (!list.isEmpty()){ |
| | | for (OrderActivityInfo activityInfo : list) { |
| | | List<String> vips = Arrays.asList(activityInfo.getVipIds().split(",")); |
| | | vipIds.retainAll(vips); |
| | | vipIds.addAll(vips); |
| | | if (!vipIds.isEmpty()){ |
| | | StringBuilder message = new StringBuilder(); |
| | | List<String> collect = vips.stream().sorted().collect(Collectors.toList()); |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @PostMapping("/addRedPackegeSet") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> addRedPackegeSet(@RequestBody RedPackegeSetDto redPackegeSets){ |
| | | redPackegeSetService.remove(null); |
| | | List<RedPackegeSet> redPackegeSetList = redPackegeSets.getRedPackegeSets(); |
| | | for (int i = 0; i < redPackegeSetList.size(); i++) { |
| | | RedPackegeSet redPackegeSet = redPackegeSetList.get(i); |
| | | LocalDateTime startTime = redPackegeSet.getStartTime(); |
| | | LocalDateTime endTime = redPackegeSet.getEndTime(); |
| | | for (int j = 0; j < redPackegeSetList.size(); j++) { |
| | | RedPackegeSet redPackegeSet1 = redPackegeSetList.get(j); |
| | | LocalDateTime startTime1 = redPackegeSet1.getStartTime(); |
| | | LocalDateTime endTime1 = redPackegeSet1.getEndTime(); |
| | | if(i != j && ((startTime.isAfter(startTime1) && endTime.isBefore(endTime1)) |
| | | || (startTime.isBefore(startTime1) && endTime.isAfter(startTime1) && endTime.isBefore(endTime1)) |
| | | || (startTime.isAfter(startTime1) && startTime.isBefore(endTime1) && endTime.isAfter(endTime1)))){ |
| | | return R.fail("时间有重叠,请重新配置"); |
| | | } |
| | | } |
| | | if (hasOverlap(redPackegeSetList)) { |
| | | return R.fail("时间段存在重叠,请重新配置"); |
| | | } |
| | | redPackegeSetService.remove(null); |
| | | redPackegeSetService.saveBatch(redPackegeSetList); |
| | | return R.ok(); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static boolean hasOverlap(List<RedPackegeSet> redPackegeSetList) { |
| | | // 首先根据startTime对列表进行排序 |
| | | Collections.sort(redPackegeSetList, Comparator.comparing(RedPackegeSet::getStartTime)); |
| | | |
| | | // 然后检查是否存在重叠 |
| | | for (int i = 0; i < redPackegeSetList.size() - 1; i++) { |
| | | RedPackegeSet current = redPackegeSetList.get(i); |
| | | RedPackegeSet next = redPackegeSetList.get(i + 1); |
| | | |
| | | // 如果当前时间段的结束时间晚于或等于下一个时间段的开始时间,则存在重叠 |
| | | if (current.getEndTime().isAfter(next.getStartTime()) || |
| | | current.getEndTime().isEqual(next.getStartTime())) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // 示例数据 |
| | | RedPackegeSet redPackegeSet = new RedPackegeSet(); |
| | | redPackegeSet.setStartTime(LocalDateTime.of(2025, 1, 13, 0, 0)); |
| | | redPackegeSet.setEndTime(LocalDateTime.of(2025, 1, 14, 0, 0)); |
| | | |
| | | RedPackegeSet redPackegeSet2 = new RedPackegeSet(); |
| | | redPackegeSet2.setStartTime(LocalDateTime.of(2025, 1, 13, 0, 0)); |
| | | redPackegeSet2.setEndTime(LocalDateTime.of(2025, 1, 14, 0, 0)); |
| | | List<RedPackegeSet> redPackegeSetList = Arrays.asList( |
| | | redPackegeSet,redPackegeSet2 |
| | | ); |
| | | |
| | | boolean overlapExists = hasOverlap(redPackegeSetList); |
| | | System.out.println("是否存在重叠: " + overlapExists); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | .set(SeckillActivityInfo::getIsShelves, seckillActivityVO.getShowStatus())); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | 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.feignClient.UserPointClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | 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.other.api.domain.PointSetting; |
| | | import com.ruoyi.other.api.domain.Share; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.enums.ShareAddType; |
| | | import com.ruoyi.other.enums.ShareAuditStatus; |
| | | import com.ruoyi.other.service.PointSettingService; |
| | | import com.ruoyi.other.service.ShareService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private UserPointClient userPointClient; |
| | | @Resource |
| | | private PointSettingService pointSettingService; |
| | | |
| | | |
| | | |
| | |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | if (sysUser.getRoleType()==1) { |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAuditStatus, 1).eq(Share::getDelFlag, 0).like(name != null, Share::getName, name) |
| | | .eq(Share::getAddType, 1).page(Page.of(pageNum, pageSize)); |
| | | .eq(addType != null , Share::getAddType, addType).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | }else { |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getDelFlag, 0).eq(Share::getObjectId, sysUser.getObjectId()) |
| | |
| | | @GetMapping("/auth/getAppletShare") |
| | | public R<Share> getAppletShare(){ |
| | | Share one = shareService.getOne(new LambdaQueryWrapper<Share>().eq(Share::getDelFlag, 0).eq(Share::getAppletShare, 1).eq(Share::getAuditStatus, 1).last(" limit 0, 1")); |
| | | //添加每日分享积分 |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Boolean data = userPointClient.judgmentDailyShare(userid).getData(); |
| | | if(!data){ |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | PointSetting pointSetting = pointSettingService.getOne(new LambdaQueryWrapper<PointSetting>().eq(PointSetting::getId, appUser.getVipId()).eq(PointSetting::getDelFlag, 0)); |
| | | if(null != pointSetting){ |
| | | Integer everySharePoint = pointSetting.getEverySharePoint(); |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | appUser.setTotalSharePoint(appUser.getTotalSharePoint() + everySharePoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + everySharePoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + everySharePoint); |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + everySharePoint); |
| | | appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + everySharePoint); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + everySharePoint); |
| | | appUserClient.editAppUserById(appUser); |
| | | //添加积分流水 |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setAppUserId(userid); |
| | | userPoint.setType(4); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(everySharePoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(appUser.getId()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return R.ok(one); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.other.service.ShopBalanceStatementService; |
| | | import com.ruoyi.other.service.ShopService; |
| | | import com.ruoyi.other.vo.ShopCommissionStatisticsVO; |
| | | 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 io.swagger.annotations.ApiParam; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.List; |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private ShopBalanceStatementMapper shopBalanceStatementMapper; |
| | | |
| | | @Resource |
| | | private ShopService shopService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | |
| | | public R<Page<ShopBalanceStatement>> shopCommissionStatisticslist(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | ShopBalanceStatement shopBalanceStatement){ |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | R<SysUser> sysUserR = sysUserClient.getSysUser(userid); |
| | | SysUser sysUser = sysUserR.getData(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | Page<ShopBalanceStatement> page = shopBalanceStatementService.lambdaQuery().eq(ShopBalanceStatement::getShopId, objectId).eq(shopBalanceStatement.getType() != null, ShopBalanceStatement::getType, shopBalanceStatement.getType()) |
| | | .orderByDesc(ShopBalanceStatement::getCreateTime) |
| | | .page(Page.of(pageNum, pageSize)); |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/getShopBalanceStatementList") |
| | | public R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestParam("types") Collection<Integer> types, @RequestParam("objectId") Long objectId){ |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.list(new LambdaQueryWrapper<ShopBalanceStatement>().eq(ShopBalanceStatement::getObjectId, objectId) |
| | | .in(ShopBalanceStatement::getType, types)); |
| | | public R<List<ShopBalanceStatement>> getShopBalanceStatementList(@RequestParam("types") Collection<Integer> types, @RequestParam(value = "objectId",required = false) Long objectId){ |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.list(new LambdaQueryWrapper<ShopBalanceStatement>() |
| | | .eq(objectId != null,ShopBalanceStatement::getObjectId, objectId) |
| | | .in(types !=null && !types.isEmpty(),ShopBalanceStatement::getType, types)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @PostMapping("/getShopBalanceStatementList2") |
| | | public R<List<ShopBalanceStatement>> getShopBalanceStatementList2(@RequestParam("type") Integer type, |
| | | @RequestParam(value = "date") LocalDateTime date){ |
| | | List<ShopBalanceStatement> list = shopBalanceStatementService.list(new LambdaQueryWrapper<ShopBalanceStatement>() |
| | | .eq(ShopBalanceStatement::getType, type) |
| | | .in(ShopBalanceStatement::getCreateTime, date)); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> add(@RequestBody Shop shop){ |
| | | String phone = shop.getPhone(); |
| | | if (!shopService.cheUserByPhone(phone)) { |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); |
| | | if (appUser == null){ |
| | | return R.fail("该手机号未注册"); |
| | | } |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(phone).getData(); |
| | | shop.setShopAllPoint(0); |
| | | shop.setLowerLevelSharePoint(0); |
| | | shop.setSharePoint(0); |
| | |
| | | shop.setDistrictCode(city); |
| | | shopService.save(shop); |
| | | |
| | | Integer shopId = shop.getId(); |
| | | |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(shop.getId()); |
| | | appUserShop.setShopId(shopId); |
| | | R<Void> r = appUserClient.addAppUserShop(appUserShop); |
| | | if (R.isError(r)){ |
| | | throw new RuntimeException("添加失败"); |
| | |
| | | if(null != sysUser){ |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(sysUser.getUserId()); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setNickName(sysUser.getNickName()); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | | if(null == data || data.size() == 0){ |
| | | userShop = new UserShop(); |
| | | userShop.setUserId(sysUser.getUserId()); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setRoleId(2L); |
| | | userShop.setCreateTime(LocalDateTime.now()); |
| | |
| | | user.setStatus("0"); |
| | | user.setDelFlag("0"); |
| | | user.setRoleType(2); |
| | | user.setObjectId(shop.getId()); |
| | | user.setObjectId(shopId); |
| | | user.setAppUserId(appUser.getId()); |
| | | user.setPassword(phone.substring(5)); |
| | | user.setCreateTime(new Date()); |
| | |
| | | |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setUserId(userId); |
| | | userShop.setShopId(shop.getId()); |
| | | userShop.setShopId(shopId); |
| | | userShop.setRoleType(1); |
| | | userShop.setRoleId(2L); |
| | | userShopClient.saveUserShop(userShop); |
| | | } |
| | | |
| | | // 更换下级会员绑定门店 |
| | | R<List<AppUser>> lowerShopR = appUserClient.setLowerUserShop(appUser.getId(), shopId); |
| | | if (R.isError(lowerShopR)){ |
| | | throw new RuntimeException("更换下级会员绑定门店失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | @DeleteMapping("/deleteShop") |
| | | @ApiOperation(value = "删除门店", tags = {"管理后台-门店管理"}) |
| | | public R<Void> deleteShop(@ApiParam("门店id") @RequestParam("id") Integer id){ |
| | | List<Goods> list1 = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag, 0).eq(Goods::getAppointStore, 1).eq(Goods::getStatus, 2)); |
| | | if(list1.size() > 0){ |
| | | Set<Integer> collect1 = list1.stream().map(Goods::getId).collect(Collectors.toSet()); |
| | | long count = goodsShopService.count(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getShopId, id).in(GoodsShop::getGoodsId, collect1)); |
| | | if(0 < count){ |
| | | return R.fail("门店已被商品使用,不能删除"); |
| | | } |
| | | } |
| | | Shop shop = shopService.getById(id); |
| | | shop.setDelFlag(1); |
| | | shopService.updateById(shop); |
| | |
| | | } |
| | | } |
| | | String city = TencentMapUtil.inverseGeographicalAnalysis(shop.getLongitude(), shop.getLatitude(), false); |
| | | if(!StringUtils.hasLength(city)){ |
| | | city = "510100"; |
| | | } |
| | | shop.setProvinceCode(city.substring(0, 2) + "0000"); |
| | | shop.setCityCode(city.substring(0, 4) + "00"); |
| | | shop.setDistrictCode(city); |
| | |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<Integer> shopIds = appUserShopList.stream().map(AppUserShop::getShopId).collect(Collectors.toList()); |
| | | List<Shop> shopList = shopService.list(new LambdaQueryWrapper<Shop>().in(Shop::getId, shopIds).eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<Shop> shopList = shopService.list(new LambdaQueryWrapper<Shop>().in(Shop::getId, shopIds).eq(Shop::getDelFlag, 0)); |
| | | long count = shopList.stream().filter(s -> s.getStatus() == 1).count(); |
| | | if(shopList.size() > 0 && count == 0){ |
| | | return R.fail("操作失败,当前门店已冻结"); |
| | | } |
| | | shopList = shopList.stream().filter(s -> s.getStatus() == 1).collect(Collectors.toList()); |
| | | if(null != appUser.getShopId()){ |
| | | Optional<Shop> first = shopList.stream().filter(s -> s.getId().equals(appUser.getShopId())).findFirst(); |
| | | if(first.isPresent()){ |
| | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/getShopIdByName") |
| | | R<Set<Integer>> getShopIdByName(@RequestParam String shopName){ |
| | | /** |
| | | * 根据名称查询门店id |
| | | * @param shopName |
| | | * @return |
| | | */ |
| | | @PostMapping("/getShopIdByName") |
| | | public R<Set<Integer>> getShopIdByName(@RequestParam("shopName") String shopName){ |
| | | List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>() |
| | | .like(Shop::getName, shopName)); |
| | | return R.ok(list.stream().map(Shop::getId).collect(Collectors.toSet())); |
| | |
| | | userShop.setUserId(userid); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | | List<Integer> collect = data.stream().map(UserShop::getShopId).collect(Collectors.toList()); |
| | | List<Shop> shops = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getId, collect).eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<Shop> shops = shopService.list(new LambdaQueryWrapper<Shop>() |
| | | .in(!CollectionUtils.isEmpty(collect),Shop::getId, collect) |
| | | .eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); |
| | | List<VerifiableShopVo> list = new ArrayList<>(); |
| | | for (Shop shop : shops) { |
| | | VerifiableShopVo vo = new VerifiableShopVo(); |
| | |
| | | import com.ruoyi.other.util.payment.model.SinglePayCallbackResult; |
| | | import com.ruoyi.other.util.payment.model.SinglePayResult; |
| | | 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.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | |
| | | public R<IPage<ShopWithdraw>> list(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | ShopWithdraw shopWithdraw) { |
| | | List<Shop> list = shopService.list(new LambdaUpdateWrapper<Shop>().like(StringUtils.isNotEmpty(shopWithdraw.getShopName()), Shop::getName, shopWithdraw.getShopName()).eq(Shop::getDelFlag, 0)); |
| | | List<Shop> list = shopService.list(new LambdaUpdateWrapper<Shop>() |
| | | .like(StringUtils.isNotEmpty(shopWithdraw.getShopName()), Shop::getName, shopWithdraw.getShopName()) |
| | | .eq(Shop::getDelFlag, 0)); |
| | | List<Integer> collect1 = list.stream().map(Shop::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(collect1)){ |
| | | return R.ok(Page.of(pageNum, pageSize)); |
| | | } |
| | | Page<ShopWithdraw> page = shopWithdrawService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<ShopWithdraw>() |
| | | .in(collect1.size() > 0, ShopWithdraw::getShopId, collect1)); |
| | | List<ShopWithdraw> records = page.getRecords(); |
| | |
| | | shops = shopService.listByIds(collect); |
| | | } |
| | | for(ShopWithdraw item : records){ |
| | | Optional<Shop> first = shops.stream().filter(s -> s.getId().equals(item.getId())).findFirst(); |
| | | Optional<Shop> first = shops.stream().filter(s -> s.getId().equals(item.getShopId())).findFirst(); |
| | | if(first.isPresent()){ |
| | | item.setShopName(first.get().getName()); |
| | | } |
| | | item.setIdStr(item.getId().toString()); |
| | | } |
| | | return R.ok(page); |
| | | } |
| | |
| | | .eq(shopWithdraw.getAuditStatus()!=null,ShopWithdraw::getAuditStatus,shopWithdraw.getAuditStatus()) |
| | | .orderByDesc(ShopWithdraw::getCreateTime) |
| | | ); |
| | | page.getRecords().forEach(s->s.setIdStr(s.getId().toString())); |
| | | return R.ok(page); |
| | | } |
| | | |
| | |
| | | @GetMapping("/shop/with") |
| | | @ApiOperation(value = "提现申请", notes = "提现申请列表", tags = {"门店后台"}) |
| | | public R shopwith(@RequestParam BigDecimal money){ |
| | | SysUser sysUser = tokenService.getLoginUser().getSysUser(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | Shop shop = shopService.getById(objectId); |
| | | if (money.compareTo(shop.getCanWithdrawMoney())>0){ |
| | |
| | | return R.fail("查询账户余额出错"); |
| | | } |
| | | Double useAbleSettAmount = accountBalanceQueryResult.getUseAbleSettAmount(); |
| | | if(useAbleSettAmount < shopWithdraw1.getMoney().doubleValue()){ |
| | | if(useAbleSettAmount < (shopWithdraw1.getMoney().doubleValue() + 1)){ |
| | | return R.fail("账户可用余额不足,请先补充账户余额"); |
| | | } |
| | | //银行卡转账 |
| | | SinglePay singlePay = new SinglePay(); |
| | | singlePay.setTradeMerchantNo(""); |
| | | singlePay.setTradeMerchantNo(TransferUtil.sysTradeMerchantNo); |
| | | singlePay.setMerchantOrderNo(shopWithdraw1.getId().toString()); |
| | | singlePay.setReceiverAccountNoEnc(shop.getReceiverAccountNoEnc()); |
| | | singlePay.setReceiverNameEnc(shop.getReceiverNameEnc()); |
| | |
| | | @PostMapping("/withdrawalCallback") |
| | | public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){ |
| | | Integer status = singlePayCallbackResult.getStatus(); |
| | | if(203 == status){ |
| | | if(203 == status || 205 == status){ |
| | | String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); |
| | | ShopWithdraw shopWithdraw = shopWithdrawService.getById(merchantOrderNo); |
| | | if(1 == shopWithdraw.getStatus()){ |
| | |
| | | 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.feignClient.AppUserShopClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private AppUserShopClient appUserShopClient; |
| | | |
| | | |
| | | |
| | |
| | | @GetMapping("/manage/list") |
| | | @ApiOperation(value = "技师列表", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> managelist(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@ApiParam("技师姓名") String name,@ApiParam("技师电话") String phone) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Long userid = tokenService.getLoginUser().getSysUser().getUserId(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Page<Technician> page = technicianService.lambdaQuery().like(name != null, Technician::getName, name) |
| | | .like(phone != null, Technician::getPhone, phone) |
| | | .eq(Technician::getShopId, objectId) |
| | | .eq(Technician::getShopId, sysUser.getObjectId()) |
| | | .page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | |
| | | @PostMapping("/manage/addorupdate") |
| | | @ApiOperation(value = "添加编辑", tags = {"门店-技师列表"}) |
| | | public R<Page<Technician>> add(@RequestBody Technician technician) { |
| | | |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | |
| | | |
| | | if (technician.getId()==null) { |
| | | technician.setSubscribeStatus(2); |
| | | List<Technician> list = technicianService.lambdaQuery().eq(Technician::getPhone, technician.getPhone()).eq(Technician::getShopId, sysUser.getObjectId()).list(); |
| | |
| | | return R.fail("当前号码已经添加"); |
| | | } |
| | | R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone()); |
| | | if (appUserByPhone1.getData()==null){ |
| | | AppUser appUser = appUserByPhone1.getData(); |
| | | if (appUser ==null){ |
| | | return R.fail("当前号码暂无注册用户"); |
| | | } |
| | | appUser.setUserType(2); |
| | | appUserClient.editAppUserById(appUser); |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setShopId(sysUser.getObjectId()); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShopClient.saveAppUserShop(appUserShop); |
| | | |
| | | }else { |
| | | Technician byId = technicianService.getById(technician.getId()); |
| | | if (byId.getPhone()!=technician.getPhone()){ |
| | |
| | | |
| | | /** |
| | | * 获取商品列表 |
| | | * @param pageInfo |
| | | * @param goodsCategoryId |
| | | * @param name |
| | | * @return |
| | | */ |
| | | List<GoodsVO> goodsList(PageInfo<GoodsVO> pageInfo, @Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name, @Param("vip") Integer vip); |
| | | List<GoodsVO> goodsList(@Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name, @Param("vip") Integer vip); |
| | | } |
| | |
| | | bargainPrice = new GoodsBargainPrice(); |
| | | bargainPrice.setShopId(sysUser.getObjectId()); |
| | | bargainPrice.setGoodsId(vo.getGoodsId()); |
| | | bargainPrice.setAuditStatus(1); |
| | | bargainPrice.setAuditStatus(0); |
| | | bargainPrice.setDelFlag(0); |
| | | bargainPrice.setCreateTime(LocalDateTime.now()); |
| | | bargainPrice.setCreateUserId(userid); |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | 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.mapper.GoodsEvaluateMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | }else { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | goodsEvaluate.setAppUserId(loginUserApplet.getUserid()); |
| | | goodsEvaluate.setCreateTime(LocalDateTime.now()); |
| | | save(goodsEvaluate); |
| | | } |
| | | } |
| | | if (CollectionUtil.isNotEmpty(evaluates)){ |
| | | Long orderId = goodsEvaluateVO.getEvaluates().get(0).getOrderId(); |
| | | Order data = orderClient.getOrderById(orderId).getData(); |
| | | Order order = new Order(); |
| | | order.setId(goodsEvaluateVO.getEvaluates().get(0).getOrderId()); |
| | | order.setId(data.getId()); |
| | | order.setOldOrderStatus(data.getOrderStatus()); |
| | | order.setOrderStatus(8); |
| | | R<Void> r = remoteOrderGoodsClient.updateOrderStatus(order); |
| | | if (R.isError(r)){ |
| | |
| | | package com.ruoyi.other.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | private GoodsBargainPriceDetailService goodsBargainPriceDetailService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<GoodsVO> goodsList(Goods search) { |
| | | PageInfo<GoodsVO> pageInfo = new PageInfo(search.getPageCurr(), search.getPageSize()); |
| | | Integer vipId = 0; |
| | | String provinceCode = null; |
| | | String cityCode = null; |
| | | String districtCode = null; |
| | | String provinceCode = "0"; |
| | | String cityCode = "0"; |
| | | String districtCode = "0"; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | |
| | | cityCode = appUser.getCityCode(); |
| | | districtCode = appUser.getDistrictCode(); |
| | | } |
| | | List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName(), vipId); |
| | | List<GoodsVO> list = this.baseMapper.goodsList(search.getGoodsCategoryId(), search.getName(), vipId); |
| | | for (GoodsVO goods : list) { |
| | | Price price = getPrice(vipId, goods.getGoodsId(), null, 1, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | |
| | | } |
| | | Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData(); |
| | | goods.setSaleNum(data); |
| | | } |
| | | |
| | | //手动排序 |
| | | if(StringUtils.isNotEmpty(search.getOrderByColumn())){ |
| | | if("selling_price".equals(search.getOrderByColumn())){ |
| | | list.sort(new Comparator<GoodsVO>() { |
| | | @Override |
| | | public int compare(GoodsVO o1, GoodsVO o2) { |
| | | if(null != o1.getSellingPrice() && null != o2.getSellingPrice()){ |
| | | return o1.getSellingPrice().compareTo(o2.getSellingPrice()) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | if(null == o1.getSellingPrice() && null != o2.getSellingPrice()){ |
| | | return BigDecimal.ZERO.compareTo(o2.getSellingPrice()) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | if(null != o1.getSellingPrice() && null == o2.getSellingPrice()){ |
| | | return o1.getSellingPrice().compareTo(BigDecimal.ZERO) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | return 0; |
| | | } |
| | | }); |
| | | } |
| | | if("integral".equals(search.getOrderByColumn())){ |
| | | list.sort(new Comparator<GoodsVO>() { |
| | | @Override |
| | | public int compare(GoodsVO o1, GoodsVO o2) { |
| | | if(null != o1.getIntegral() && null != o2.getIntegral()){ |
| | | return o1.getIntegral().compareTo(o2.getIntegral()) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | if(null == o1.getIntegral() && null != o2.getIntegral()){ |
| | | return Integer.valueOf(0).compareTo(o2.getIntegral()) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | if(null != o1.getIntegral() && null == o2.getIntegral()){ |
| | | return o1.getIntegral().compareTo(Integer.valueOf(0)) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | return 0; |
| | | } |
| | | }); |
| | | } |
| | | if("sale_num".equals(search.getOrderByColumn())){ |
| | | list.sort(new Comparator<GoodsVO>() { |
| | | @Override |
| | | public int compare(GoodsVO o1, GoodsVO o2) { |
| | | return o1.getSaleNum().compareTo(o2.getSaleNum()) * (StringUtils.isNotEmpty(search.getIsAsc()) ? -1 : 1); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | //手动处理分页 |
| | | PageInfo<GoodsVO> pageInfo = new PageInfo<>(); |
| | | pageInfo.setSize(search.getPageSize()); |
| | | pageInfo.setTotal(list.size()); |
| | | Integer pageSize = search.getPageSize(); |
| | | Integer pageNum = (search.getPageCurr() - 1) * pageSize; |
| | | |
| | | if(list.size() >= (pageNum + 1) * pageSize){ |
| | | list = list.subList(pageNum, pageNum + pageSize); |
| | | }else if(pageNum < list.size() && list.size() < (pageNum + 1) * pageSize){ |
| | | list = list.subList(pageNum, list.size()); |
| | | }else{ |
| | | list = new ArrayList<>(); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | |
| | | } |
| | | |
| | | Goods goods = this.getById(goodsId); |
| | | if(null == goods || goods.getDelFlag() == 1){ |
| | | throw new RuntimeException("商品不存在"); |
| | | } |
| | | if(goods.getStatus() == 1){ |
| | | throw new RuntimeException("商品已被下架"); |
| | | } |
| | | if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(vipId.toString())){ |
| | | throw new RuntimeException("权限不足"); |
| | | } |
| | | GoodsVO goodsVO = new GoodsVO(); |
| | | BeanUtils.copyBeanProp(goodsVO, goods); |
| | | goodsVO.setGoodsId(goods.getId()); |
| | |
| | | } |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); |
| | | goodsVO.setSaleNum(integer); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).ne(GoodsEvaluate::getComment, "") |
| | | .orderByDesc(GoodsEvaluate::getGrade).eq(GoodsEvaluate::getStatus, 2).isNotNull(GoodsEvaluate::getComment) |
| | | .eq(GoodsEvaluate::getDelFlag, 0).last(" limit 0, 1").one(); |
| | | if (null != goodsEvaluate) { |
| | | AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); |
| | | if(null != appUserById){ |
| | | goodsEvaluate.setUserName(appUserById.getName()); |
| | | goodsEvaluate.setAvatar(appUserById.getAvatar()); |
| | | goodsEvaluate.setIdStr(String.valueOf(goodsEvaluate.getId())); |
| | | } |
| | | } |
| | | goodsVO.setGoodsEvaluate(goodsEvaluate); |
| | | return goodsVO; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public IPage<Goods> getManageGoodsList(Page<Goods> page, Goods goods) { |
| | | return goodsMapper.selectManageGoodsList(page, goods); |
| | | IPage<Goods> goodsIPage = goodsMapper.selectManageGoodsList(page, goods); |
| | | goodsIPage.getRecords().forEach(goods1 -> { |
| | | Integer data = orderClient.getGoodsSaleNum(goods1.getId(), 1).getData(); |
| | | goods1.setSaleNum(data); |
| | | }); |
| | | return goodsIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void updateManageGoods(Goods goods) { |
| | | goodsMapper.updateById(goods); |
| | | this.updateById(goods); |
| | | //修改个别字段 |
| | | this.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getId, goods.getId()).set(Goods::getSellingPrice, goods.getSellingPrice()) |
| | | .set(Goods::getIntegral, goods.getIntegral())); |
| | | // 指定门店 |
| | | List<GoodsShop> goodsShopList = goods.getGoodsShopList(); |
| | | saveGoodsShopList(goodsShopList, goods.getId()); |
| | |
| | | saveGoodsAreaList(goodsAreaList, goods.getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private void saveGoodsAreaList(List<GoodsArea> goodsAreaList, Integer id) { |
| | | goodsAreaService.remove(new LambdaQueryWrapper<GoodsArea>() |
| | | .eq(GoodsArea::getGoodsId, id)); |
| | |
| | | area.setProvinceCode(goodsArea.getProvinceCode()); |
| | | area.setCityCode(goodsArea.getCityCode()); |
| | | area.setDistrictsCode(goodsArea.getDistrictsCode()); |
| | | if(null != area.getSellingPrice() && null != area.getIntegral()){ |
| | | if(null != area.getSellingPrice() || null != area.getIntegral()){ |
| | | goodsAreaList2.add(area); |
| | | } |
| | | } |
| | |
| | | .eq(GoodsAppUser::getGoodsId, id)); |
| | | if (!CollectionUtils.isEmpty(goodsAppUserList)){ |
| | | for (GoodsAppUser goodsAppUser : goodsAppUserList) { |
| | | goodsAppUser.setId(null ); |
| | | goodsAppUser.setId(null); |
| | | goodsAppUser.setGoodsId(id); |
| | | } |
| | | } |
| | |
| | | List<AppUser> appUsers = appUserClient.listByIds(userIds); |
| | | for (GoodsAppUser goodsAppUser : goodsAppUserList) { |
| | | appUsers.stream().filter(u -> u.getId().equals(goodsAppUser.getAppUserId())).findFirst().ifPresent( u -> { |
| | | goodsAppUser.setAppUserIdStr(goodsAppUser.getAppUserId().toString()); |
| | | goodsAppUser.setUserName(u.getName()); |
| | | goodsAppUser.setPhone(u.getPhone()); |
| | | VipSetting vipSetting = vipSettingService.getById(u.getVipId()); |
| | |
| | | import com.ruoyi.other.mapper.GoodsShopMapper; |
| | | import com.ruoyi.other.mapper.SeckillActivityInfoMapper; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | | import com.ruoyi.other.service.GoodsEvaluateService; |
| | | import com.ruoyi.other.service.GoodsSeckillService; |
| | | import com.ruoyi.other.service.GoodsService; |
| | | import com.ruoyi.other.service.SeckillActivityInfoService; |
| | |
| | | private GoodsService goodsService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | |
| | | @Override |
| | | public List<SeckillActivityVO> listSeckillActivity(Goods goods) { |
| | |
| | | AppUser appUser = appUserClient.getAppUserById(userid); |
| | | vipId = appUser.getVipId(); |
| | | } |
| | | SeckillActivityInfo activityInfo = this.getById(seckillActivityId); |
| | | if(null == activityInfo || activityInfo.getDelFlag() == 1){ |
| | | throw new RuntimeException("活动不存在"); |
| | | } |
| | | if(activityInfo.getIsShelves() == 0){ |
| | | throw new RuntimeException("活动已下架"); |
| | | } |
| | | if(!activityInfo.getVipIds().contains(vipId.toString())){ |
| | | throw new RuntimeException("权限不足"); |
| | | } |
| | | SeckillActivityDetailVO seckillActivityDetailVO = seckillActivityInfoMapper.selectDetail(seckillActivityId, vipId); |
| | | Integer goodsId = seckillActivityDetailVO.getGoodsId(); |
| | | |
| | |
| | | seckillActivityDetailVO.setShopList(shops); |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 2).getData(); |
| | | seckillActivityDetailVO.setSaleNum(integer); |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).isNotNull(GoodsEvaluate::getComment).ne(GoodsEvaluate::getComment, "") |
| | | .orderByDesc(GoodsEvaluate::getGrade).eq(GoodsEvaluate::getStatus, 2).eq(GoodsEvaluate::getDelFlag, 0).last(" limit 0, 1").one(); |
| | | if (null != goodsEvaluate) { |
| | | AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); |
| | | if(null != appUserById){ |
| | | goodsEvaluate.setUserName(appUserById.getName()); |
| | | goodsEvaluate.setAvatar(appUserById.getAvatar()); |
| | | goodsEvaluate.setIdStr(String.valueOf(goodsEvaluate.getId())); |
| | | } |
| | | } |
| | | seckillActivityDetailVO.setGoodsEvaluate(goodsEvaluate); |
| | | return seckillActivityDetailVO; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) { |
| | | Integer goodId = seckillActivityInfo.getGoodId(); |
| | | long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0) |
| | | .eq(SeckillActivityInfo::getIsShelves, 1).last(" and now() between start_time and end_time")); |
| | | if(0 < count){ |
| | | throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在"); |
| | | } |
| | | this.baseMapper.insert(seckillActivityInfo); |
| | | List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); |
| | | for (GoodsSeckill goodsSeckill : goodsSeckills) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) { |
| | | Integer goodId = seckillActivityInfo.getGoodId(); |
| | | long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0) |
| | | .eq(SeckillActivityInfo::getIsShelves, 1).last(" and now() between start_time and end_time")); |
| | | if(1 < count){ |
| | | throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在"); |
| | | } |
| | | this.baseMapper.updateById(seckillActivityInfo); |
| | | goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); |
| | | List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills(); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import com.ruoyi.other.api.enums.PointChangeType; |
| | | import com.ruoyi.other.mapper.ShopPointMapper; |
| | | 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 org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | |
| | | @Service |
| | | public class ShopPointServiceImpl extends ServiceImpl<ShopPointMapper, ShopPoint> implements ShopPointService { |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | List<ShopPoint> shopPoints = this.baseMapper.selectShopPointList(shopPoint); |
| | | Map<Integer, Integer> shopPointMap = shopPoints.stream() |
| | | .collect(Collectors.groupingBy( |
| | |
| | | LocalDateTime endTime = shopPoint.getEndTime(); |
| | | if(null != startTime){ |
| | | List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>() |
| | | // todo bug说应展示所有门店积分数据 |
| | | // .eq(ShopPoint::getShopId, shopPoint.getShopId()) |
| | | .eq(ShopPoint::getShopId, sysUser.getObjectId()) |
| | | .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'")); |
| | | List<String> date = new ArrayList<>(); |
| | | List<Map<String, Integer>> data = new ArrayList<>(); |
| | |
| | | List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(); |
| | | for (NearbyShopVO nearbyShopVO : nearbyShopVOS) { |
| | | Double wgs84 = GeodesyUtil.getDistance(nearbyShopVO.getLongitude() + "," + nearbyShopVO.getLatitude(), longitude + "," + latitude).get("WGS84"); |
| | | nearbyShopVO.setDistance(wgs84); |
| | | nearbyShopVO.setDistance(new BigDecimal(wgs84).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | } |
| | | nearbyShopVOS.sort(new Comparator<NearbyShopVO>() { |
| | | @Override |
| | |
| | | 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); |
| | | vo.setDistance(new BigDecimal(wgs84).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | nearbyShopVOS.add(0, vo); |
| | | } |
| | | } |
| | |
| | | Map<Long, List<ShopScore>> shopScoreMap = shopScores.stream().collect(Collectors.groupingBy(ShopScore::getShopId)); |
| | | AppUser finalAppUser1 = appUser; |
| | | nearbyShopVOS.forEach(nearbyShopVO -> { |
| | | nearbyShopVO.setScore("5"); |
| | | List<ShopScore> scores = shopScoreMap.get(nearbyShopVO.getId()); |
| | | if (scores != null && !scores.isEmpty()){ |
| | | BigDecimal score = scores.stream() |
| | |
| | | * 商户号 |
| | | */ |
| | | private static final String merchantNo = "888122600004175"; |
| | | |
| | | /** |
| | | * 平台-报备商户号 |
| | | */ |
| | | public static final String sysTradeMerchantNo = "777168500885852"; |
| | | |
| | | private static final String format = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | |
| | | /** |
| | | * 支付回调地址 |
| | | */ |
| | | private static final String callbackUrl = "http://221.182.45.100:9000"; |
| | | |
| | | |
| | | /** |
| | | * 单笔代付 |
| | | * @param singlePay |
| | |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | | //报备商户号 |
| | | body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | // body.put("tradeMerchantNo", singlePay.getTradeMerchantNo()); |
| | | //产品类型 |
| | | body.put("productCode", "BANK_PAY_DAILY_ORDER"); |
| | | //交易请求时间 |
| | |
| | | */ |
| | | body.put("paidUse", singlePay.getPaidUse()); |
| | | //商户通知地址 |
| | | body.put("callbackUrl", singlePay.getCallbackUrl()); |
| | | body.put("callbackUrl", callbackUrl + singlePay.getCallbackUrl()); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | SinglePayResult uniPayResult = jsonObject.getObject("data", SinglePayResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 单笔代付查询接口 |
| | | * @param merchantOrderNo 订单号 |
| | |
| | | SinglePayQueryResult uniPayResult = jsonObject.getObject("data", SinglePayQueryResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 可取余额查询 |
| | | * @return |
| | |
| | | AccountBalanceQueryResult uniPayResult = jsonObject.getObject("data", AccountBalanceQueryResult.class); |
| | | return uniPayResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | 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()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (Map.Entry<String, Object> item : infoIds) { |
| | | for (Map.Entry<String, Object> item : entries) { |
| | | if (item.getKey() != null || item.getKey() != "") { |
| | | Object val = item.getValue(); |
| | | if (!(val == "" || val == null)) { |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | TransferUtil.accountBalanceQuery(); |
| | | } |
| | | |
| | | } |
| | |
| | | public class SinglePayCallbackResult { |
| | | /** |
| | | * 交易状态 |
| | | * 201 批次已创建 汇聚受理并创建该批次的初始状态 |
| | | * 202 处理中 批次正在处理中状态 |
| | | * 203 处理完成 批次中的每笔明细都明确了代付结果 |
| | | * 204 批次不存在 汇聚未受理该批次的请求,找不到该批次,明确失败 |
| | | * 205 交易成功 明确交易成功的状态码 |
| | | * 208 订单已取消 代付订单被商户审核为拒绝付款 |
| | | * 210 账务冻结中 确认出款后对商户的账户余额进行冻结处理 |
| | | * 211 账务解冻中 确认失败后对商户的账户余额进行解冻处理 |
| | | * 212 订单取消中 商户审核为拒绝付款的中间状态 |
| | | * 213 账务扣款中 确认成功后对商户的账户冻结款的扣款处理 |
| | | * 214 订单不存在 汇聚未受理该笔代付请求,找不到该笔订单,明确失败 |
| | | */ |
| | | private Integer status; |
| | | /** |
| | |
| | | package com.ruoyi.other.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.other.api.domain.GoodsEvaluate; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @ApiModelProperty(value = "门店列表") |
| | | private List<Shop> shopList; |
| | | |
| | | @ApiModelProperty("评价") |
| | | private GoodsEvaluate goodsEvaluate; |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.vo; |
| | | |
| | | import com.ruoyi.other.api.domain.GoodsEvaluate; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | |
| | | @ApiModelProperty(value = "商品详情") |
| | | private String detail; |
| | | |
| | | @ApiModelProperty("评价") |
| | | private GoodsEvaluate goodsEvaluate; |
| | | } |
| | |
| | | <if test="gp.categoryId != null and gp.categoryId != ''"> |
| | | and tg.goods_category_id = #{gp.categoryId} |
| | | </if> |
| | | <if test="gp.auditStatus != null and gp.auditStatus != ''"> |
| | | <if test="gp.auditStatus != null"> |
| | | and tgbp.audit_status = #{gp.auditStatus} |
| | | </if> |
| | | </select> |
| | |
| | | tg.original_price as originalPrice, |
| | | tg.integral as integral, |
| | | tg.sale_num as saleNum, |
| | | tg.home_page_picture as homePagePicture |
| | | tg.home_page_picture as homePagePicture, |
| | | tg.sort |
| | | 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 (tg.commodity_authority like '%-1%' or tg.commodity_authority like CONCAT('%', #{vip}, '%')) |
| | | </if> |
| | | ORDER BY tg.sale_num DESC |
| | | ORDER BY ifnull(tg.sort, -1) DESC |
| | | </select> |
| | | <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods"> |
| | | SELECT |
| | |
| | | <if test="null != vip"> |
| | | and (FIND_IN_SET(#{vip}, commodity_authority) or commodity_authority like '%-1%') |
| | | </if> |
| | | order by sort desc |
| | | </select> |
| | | </mapper> |
| | |
| | | tgc.`name` goodsCategoryName, |
| | | tg.operating_cost, |
| | | tg.shop_cost, |
| | | tg.purchase_limit maxNum, |
| | | tsai.max_num maxNum, |
| | | tg.home_page_picture, |
| | | tg.original_price, |
| | | tg.sale_num, |
| | |
| | | SUM(ts.shop_all_point) totalPoint, |
| | | SUM(ts.share_point) commissionPoint, |
| | | SUM(ts.server_point) servicePoint, |
| | | SUM(ts.lower_level_giveaway_money) bindCommissionPoint, |
| | | SUM(ts.lower_level_share_point) bindCommissionPoint, |
| | | SUM(ts.giveaway_all_money) totalCommissionMoney, |
| | | SUM(ts.giveaway_money) commissionMoney, |
| | | SUM(ts.lower_level_giveaway_money) bindCommissionMoney, |
| | |
| | | <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 |
| | | </select> |