New file |
| | |
| | | package com.ruoyi.account.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:25 |
| | | */ |
| | | @Data |
| | | @TableName("t_balance_payment") |
| | | public class BalancePayment { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.NONE) |
| | | private Long id; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | | /** |
| | | * 支付金额 |
| | | */ |
| | | @TableField("money") |
| | | private BigDecimal money; |
| | | /** |
| | | * 微信支付流水 |
| | | */ |
| | | @TableField("serial_number") |
| | | private String serialNumber; |
| | | /** |
| | | * 微信支付状态(1=待支付,2=已支付) |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | /** |
| | | * 完成支付时间 |
| | | */ |
| | | @TableField("payment_time") |
| | | private LocalDateTime paymentTime; |
| | | /** |
| | | * 余额变更记录id |
| | | */ |
| | | @TableField("balance_change_record_id") |
| | | private Long balanceChangeRecordId; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("create_time") |
| | | private LocalDateTime createTime; |
| | | } |
| | |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/7 14:38 |
| | |
| | | public R<Integer> getShopSaleNum(Integer shopId, Integer type) { |
| | | return R.fail("获取门店销售订单数量失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Set<Long>> getAppUserByShoppingShop(Integer shopId) { |
| | | return R.fail("获取所有在指定门店消费的用户id失败:" + cause); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.order.feignClient; |
| | | |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.factory.OrderClientFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | /** |
| | | * 获取商品销售数量 |
| | | * @param goodsId |
| | | * @param type 购买类型(1=普通商品,2=秒杀商品) |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getGoodsSaleNum") |
| | |
| | | */ |
| | | @PostMapping("/order/getShopSaleNum") |
| | | R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type); |
| | | |
| | | |
| | | /** |
| | | * 获取所有在指定门店消费的用户id |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | @PostMapping("/order/getAppUserByShoppingShop") |
| | | R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId); |
| | | } |
| | |
| | | @TableField("pass_status") |
| | | private Integer passStatus; |
| | | |
| | | @ApiModelProperty(value = "审核时间") |
| | | @TableField("auth_time") |
| | | private LocalDateTime authTime; |
| | | |
| | | @ApiModelProperty(value = "后台审核备注") |
| | | @TableField("pass_remark") |
| | | private String passRemark; |
| | |
| | | @ApiModelProperty(value = "实际支付价格") |
| | | private BigDecimal paymentAmount; |
| | | |
| | | @ApiModelProperty(value = "快递费") |
| | | private BigDecimal expressAmount; |
| | | |
| | | |
| | | } |
| | |
| | | @TableField("district_code") |
| | | private String districtCode; |
| | | |
| | | |
| | | @TableField(exist = false) |
| | | private Double distance; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "主键") |
| | | @TableId("id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | |
| | | @ApiModelProperty("跳转内容2") |
| | | private String content2; |
| | | @ApiModelProperty("跳转类型2 - 1无2外部链接3商品详情4秒杀商品详情5领卷中心") |
| | | private String direct2; |
| | | private Integer direct2; |
| | | @ApiModelProperty("公司简介") |
| | | private String companyInfo; |
| | | |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | public class OrderActivityInfoClientFallbackFactory implements FallbackFactory<OrderActivityInfoClient> { |
| | | @Override |
| | | public OrderActivityInfoClient create(Throwable cause) { |
| | | return new OrderActivityInfoClient(){ |
| | | @Override |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(Integer vip) { |
| | | public R<List<OrderActivityInfo>> getNowOrderActivityInfo(Integer vip) { |
| | | return R.fail("获取当前生效的活动失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/29 10:55 |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/order-activity-info/getNowOrderActivityInfo") |
| | | R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip); |
| | | R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip); |
| | | } |
| | |
| | | * @param roleType |
| | | * @return |
| | | */ |
| | | @PostMapping("/user/delShopUser") |
| | | @PostMapping("/user/user/delShopUser") |
| | | R delShopUser(@RequestParam("objectId") Integer objectId, @RequestParam("roleType") Integer roleType); |
| | | |
| | | |
| | |
| | | SysUser sysUser = sysUserService.getById(userid); |
| | | if(sysUser.getRoleType() == 2){ |
| | | wrapper.eq(SysRole::getShopId, sysUser.getObjectId()); |
| | | }else{ |
| | | wrapper.isNull(SysRole::getShopId); |
| | | } |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, wrapper.orderByDesc(SysRole::getCreateTime)); |
| | | for (SysRole record : page.getRecords()) { |
| | |
| | | <if test="shopId != null"> |
| | | AND shop_id = #{shopId} |
| | | </if> |
| | | <if test="shopId == null"> |
| | | AND shop_id is null |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | order by d.parent_id, d.order_num |
| | |
| | | ) |
| | | </when> |
| | | <otherwise> |
| | | and role_type = 1 |
| | | <if test="null != req.deptId"> |
| | | and dept_id = #{req.deptId} |
| | | </if> |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.other.api.domain.Shop; |
| | |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.StoreClient; |
| | | import com.ruoyi.other.api.feignClient.VipSettingClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private RemoteOrderGoodsClient remoteOrderGoodsClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | AppUser appUser) { |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); |
| | | for (AppUser record : appuserPage.getRecords()) { |
| | | if (record.getInviteUserId() != null) { |
| | | AppUser byId1 = appUserService.getById(record.getInviteUserId()); |
| | |
| | | @GetMapping("/statistics") |
| | | @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) |
| | | public R<UserStatistics> statistics() { |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userId = null; |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | userId = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | } |
| | | UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId); |
| | | return R.ok(userStatistics); |
| | | } |
| | | |
| | |
| | | @GetMapping("/statistics/detail") |
| | | @ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"}) |
| | | public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | Integer shopId = null; |
| | | Set<Long> userIds = null; |
| | | if(null != userId){ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | if(data.getRoleType() == 2){ |
| | | shopId = data.getObjectId(); |
| | | if(null == userId){ |
| | | userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); |
| | | }else{ |
| | | userIds = new HashSet<>(); |
| | | userIds.add(userId); |
| | | } |
| | | } |
| | | UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds); |
| | | return R.ok(userStatisticsDetail); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/commissionDetail") |
| | | @ApiOperation(value = "分佣统计", tags = "管理后台-首页统计") |
| | | public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) { |
| | | List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList()); |
| | | |
| | | public R<CommissionDetail> commissionDetail() { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0); |
| | | if(sysUser.getRoleType() == 2){ |
| | | queryWrapper.eq(AppUser::getShopId, sysUser.getObjectId()); |
| | | } |
| | | List<AppUser> appUserList = appUserService.list(queryWrapper); |
| | | if (appUserList.isEmpty()) { |
| | | return R.ok(new CommissionDetail()); |
| | | } |
| | | |
| | | BigDecimal totalCommission = BigDecimal.ZERO; |
| | | BigDecimal totalServiceFee = BigDecimal.ZERO; |
| | | BigDecimal totalUserCommission = BigDecimal.ZERO; |
| | | Map<Integer, BigDecimal> vipCommissions = new HashMap<>(); |
| | | Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>(); |
| | | |
| | | for (AppUser appUser : appUserList) { |
| | | BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO); |
| | | totalCommission = totalCommission.add(distributionAmount); |
| | |
| | | } |
| | | } |
| | | List<Shop> data = shopClient.getAllShop().getData(); |
| | | if(sysUser.getRoleType() == 2){ |
| | | data = Arrays.asList(shopClient.getShopById(sysUser.getObjectId()).getData()); |
| | | } |
| | | for (Shop shop : data) { |
| | | totalServiceFee = totalServiceFee.add(shop.getServerGiveawayMoney()); |
| | | totalUserCommission = totalUserCommission.add(shop.getGiveawayMoney()); |
| | |
| | | BigDecimal add = commissionDate.getNormalCommission().add(commissionDate.getGoldCommission()).add(commissionDate.getDiamondCommission()).add(commissionDate.getAgentCommission()) |
| | | .add(commissionDate.getSuperAgentCommission()).add(commissionDate.getTopAgentCommission()).add(commissionDate.getPartnerCommission()); |
| | | commissionDate.setTotalCommission(add); |
| | | |
| | | // commissionDate.setServiceChargeCommission(); |
| | | // commissionDate.setAssociatedUserCommission(); |
| | | // commissionDate.setBindLowerLevelStoresCommission(); |
| | | return commissionDate; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | commissionDetail.setCommissionDateList(commissionDateList); |
| | | |
| | | return R.ok(commissionDetail); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/mine/list1") |
| | | @ApiOperation(value = "已领取列表", tags = {"管理后台-优惠劵"}) |
| | | public R<Page<UserCoupon>> list1(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status, Integer id) { |
| | | Page<UserCoupon> page = userCouponService.lambdaQuery() |
| | | .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime) |
| | | .isNotNull(status!=null&&status==2,UserCoupon::getUseTime) |
| | | .eq(UserCoupon::getCouponId, id) |
| | | .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()).page(Page.of(pageNum-1, pageSize)); |
| | | for (UserCoupon record : page.getRecords()) { |
| | | record.setIdStr(record.getId().toString()); |
| | | CouponInfo data = couponClient.detail(record.getCouponId()).getData(); |
| | | CouponInfoVo vo = new CouponInfoVo(); |
| | | BeanUtils.copyProperties(data,vo); |
| | | //如果是商品券,将商品名称返回 |
| | | if (vo.getCouponType()==4){ |
| | | List<String> goodNames = new ArrayList<>(); |
| | | if (vo.getForGoodIds().equals("-1")){ |
| | | goodNames.add("全部商品"); |
| | | }else{ |
| | | String[] split = vo.getForGoodIds().split(","); |
| | | R<List<Goods>> goodsById = goodsClient.getGoodsById(split); |
| | | if (goodsById.getData()!=null){ |
| | | for (Goods datum : goodsById.getData()) { |
| | | goodNames.add(datum.getName()); |
| | | } |
| | | } |
| | | vo.setGoodNames(goodNames); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | record.setCouponInfoVo(vo); |
| | | if (record.getUseTime()==null){ |
| | | record.setStatus(1); |
| | | if (record.getEndTime().isBefore(LocalDateTime.now())){ |
| | | record.setStatus(3); |
| | | } |
| | | }else { |
| | | record.setStatus(2); |
| | | } |
| | | |
| | | |
| | | AppUser appUser = appUserService.getById(record.getAppUserId()); |
| | | record.setUserName(appUser.getName()); |
| | | record.setPhone(appUser.getPhone()); |
| | | } |
| | | return R.ok(page); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/get") |
| | | @ApiOperation(value = "领取或者兑换优惠券", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<Page<UserCoupon>> get(@RequestParam Integer couponId) { |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecord; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.service.WalletService; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.payment.PaymentUtil; |
| | | import com.ruoyi.account.util.payment.model.UniPayCallbackResult; |
| | | import com.ruoyi.account.util.payment.model.UniPayResult; |
| | | import com.ruoyi.account.vo.WalletVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.YearMonth; |
| | | import java.time.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private BalancePaymentService balancePaymentService; |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 钱包详情 |
| | |
| | | */ |
| | | @GetMapping("recharge") |
| | | @ApiOperation(value = "充值", notes = "钱包充值") |
| | | public R<Void> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) { |
| | | public R<String> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); |
| | | String wxOpenid = appUser.getWxOpenid(); |
| | | // 商户号 |
| | | String partnerTradeNo; |
| | | // TODO 充值 |
| | | return R.ok(); |
| | | BalancePayment balancePayment = new BalancePayment(); |
| | | balancePayment.setAppUserId(appUser.getId()); |
| | | balancePayment.setMoney(amount); |
| | | balancePayment.setStatus(1); |
| | | balancePayment.setCreateTime(LocalDateTime.now()); |
| | | balancePaymentService.save(balancePayment); |
| | | //调起支付 |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(balancePayment.getId().toString(), amount.doubleValue(), "余额充值", "余额充值", "", |
| | | "/account/wallet/rechargeCallback", appUser.getWxOpenid(), null); |
| | | if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){ |
| | | return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg()); |
| | | } |
| | | String rc_result = uniPayResult.getRc_Result(); |
| | | JSONObject jsonObject = JSON.parseObject(rc_result); |
| | | //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。 |
| | | long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC); |
| | | redisTemplate.opsForZSet().add("BalanceRecharge", balancePayment.getId(), second); |
| | | return R.ok(jsonObject.toJSONString()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充值支付回调 |
| | | * @param callback |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/rechargeCallback") |
| | | public void rechargeCallback(UniPayCallbackResult callback, HttpServletResponse response){ |
| | | String r2_orderNo = callback.getR2_OrderNo(); |
| | | BalancePayment balancePayment = balancePaymentService.getById(r2_orderNo); |
| | | if(null == balancePayment || balancePayment.getStatus() != 1){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | return; |
| | | } |
| | | if("100".equals(callback.getR6_Status())){ |
| | | //添加账户变动流水 |
| | | BigDecimal money = balancePayment.getMoney(); |
| | | AppUser appUser = appUserService.getById(balancePayment.getAppUserId()); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | appUser.setBalance(appUser.getBalance().add(money)); |
| | | appUser.setWithdrawableAmount(appUser.getWithdrawableAmount().add(money)); |
| | | appUser.setTotalRechargeAmount(appUser.getTotalRechargeAmount().add(money)); |
| | | appUserService.updateById(appUser); |
| | | //流水 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setOrderId(balanceChangeRecord.getId()); |
| | | balanceChangeRecord.setChangeType(1); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(money); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | |
| | | balancePayment.setStatus(2); |
| | | balancePayment.setPaymentTime(LocalDateTime.now()); |
| | | balancePayment.setSerialNumber(callback.getR8_BankOrderNo()); |
| | | balancePayment.setBalanceChangeRecordId(balanceChangeRecord.getId()); |
| | | balancePaymentService.updateById(balancePayment); |
| | | |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping("/auth") |
| | | @ApiOperation(value = "提现申请审批", tags = {"后台"}) |
| | | public R auth(@RequestParam Long id,@ApiParam("2'审核通过',3'审核拒绝'") Integer auditStatus){ |
| | | public R auth(@RequestParam("id") Long id,@ApiParam("2'审核通过',3'审核拒绝'") @RequestParam("auditStatus") Integer auditStatus){ |
| | | WithdrawalRequests withdrawal = withdrawalRequestsService.getById(id); |
| | | BigDecimal withdrawalAmount = withdrawal.getWithdrawalAmount(); |
| | | if(withdrawal.getAuditStatus() != 1){ |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | List<NearbyReferrerVo> getNearbyReferrer(@Param("cityCode") String cityCode, @Param("nearbyReferrer") NearbyReferrer nearbyReferrer); |
| | | |
| | | IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser); |
| | | IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser, @Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds); |
| | | IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,@Param("objectId")Integer objectId,@Param("userIds")List<Long> userIds); |
| | | |
| | | UserStatistics getUserStatistics(); |
| | | UserStatistics getUserStatistics(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userId); |
| | | |
| | | UserStatisticsDetail getUserStatisticsDetail(Long userId); |
| | | UserStatisticsDetail getUserStatisticsDetail(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds); |
| | | |
| | | |
| | | |
New file |
| | |
| | | package com.ruoyi.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | public interface BalancePaymentMapper extends BaseMapper<BalancePayment> { |
| | | } |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | void onlineRecord(); |
| | | |
| | | IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser); |
| | | IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId); |
| | | IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds); |
| | | |
| | | /** |
| | |
| | | * 降级检测 |
| | | */ |
| | | void demotionDetection(); |
| | | |
| | | |
| | | /** |
| | | * 定时任务关闭订单 |
| | | */ |
| | | void closeOrder(); |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | public interface BalancePaymentService extends IService<BalancePayment> { |
| | | } |
| | |
| | | import com.ruoyi.account.mapper.AppUserMapper; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.SMSUtil; |
| | | import com.ruoyi.account.util.payment.PaymentUtil; |
| | | import com.ruoyi.account.util.payment.model.CloseOrderResult; |
| | | import com.ruoyi.account.util.tencentMap.TencentMapUtil; |
| | | import com.ruoyi.account.util.weChat.EnvVersion; |
| | | import com.ruoyi.account.util.weChat.WXCore; |
| | |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @author luodangjia |
| | | * @since 2024-11-21 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService { |
| | | |
| | |
| | | |
| | | @Resource |
| | | private UserCouponService userCouponService; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | @Resource |
| | | private BalancePaymentService balancePaymentService; |
| | | |
| | | |
| | | /** |
| | |
| | | appUser.setProvinceCode(region.getCode()); |
| | | } |
| | | this.save(appUser); |
| | | //添加定时任务队列 |
| | | VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData(); |
| | | Integer vipCancelDay = vipSetting.getVipCancelDay(); |
| | | Integer vipChangeDay = vipSetting.getVipChangeDay(); |
| | | //解绑推广人 |
| | | redisTemplate.opsForZSet().add("unbind_promoter", appUser.getId().toString(), LocalDateTime.now().plusDays(vipCancelDay).toEpochSecond(ZoneOffset.UTC)); |
| | | //可更换推广人 |
| | | redisTemplate.opsForZSet().add("replaceable", appUser.getId().toString(), LocalDateTime.now().plusDays(vipChangeDay).toEpochSecond(ZoneOffset.UTC)); |
| | | |
| | | //增加积分变动记录 |
| | | if(0 == old && regisPoint > 0){ |
| | | //构建积分流水记录 |
| | |
| | | @Override |
| | | public void unbindThePromoter() { |
| | | //注册X天后没有升级成黄金会员则自动解绑推广人 |
| | | VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData(); |
| | | Integer vipCancelDay = vipSetting.getVipCancelDay(); |
| | | Integer vipChangeDay = vipSetting.getVipChangeDay(); |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) |
| | | .eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(create_time) + (" + vipCancelDay + " * 86400)) <= UNIX_TIMESTAMP()")); |
| | | for (AppUser appUser : list) { |
| | | UpdateWrapper<AppUser> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("invite_user_id", null).set("shop_id", null).eq("id", appUser.getId()); |
| | | this.update(updateWrapper); |
| | | |
| | | //解绑推广人 |
| | | Set<Long> unbind_promoter = redisTemplate.opsForZSet().range("unbind_promoter", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(unbind_promoter.size() > 0){ |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) |
| | | .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter)); |
| | | for (AppUser appUser : list) { |
| | | UpdateWrapper<AppUser> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("invite_user_id", null).set("shop_id", null).eq("id", appUser.getId()); |
| | | this.update(updateWrapper); |
| | | } |
| | | } |
| | | |
| | | //可更换推广人 |
| | | list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(ifnull(last_shop_time, create_time)) + (" + vipChangeDay + " * 86400)) <= UNIX_TIMESTAMP()")); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | | Set<Long> replaceable = redisTemplate.opsForZSet().range("replaceable", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(replaceable.size() > 0){ |
| | | List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) |
| | | .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter)); |
| | | for (AppUser appUser : list) { |
| | | appUser.setChangePromoter(1); |
| | | this.updateById(appUser); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser) { |
| | | public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId) { |
| | | if (StringUtils.isNotEmpty(appUser.getShopName())){ |
| | | R<Set<Integer>> shopR = shopClient.getShopIdByName(appUser.getShopName()); |
| | | if (R.isSuccess(shopR)){ |
| | |
| | | } |
| | | } |
| | | } |
| | | return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser); |
| | | return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser, shopId, userId); |
| | | } |
| | | @Override |
| | | public IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds) { |
| | |
| | | this.updateBatchById(appUserList); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 定时任务关闭订单 |
| | | */ |
| | | @Override |
| | | public void closeOrder() { |
| | | //订单支付数据 |
| | | long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); |
| | | Set<String> orderPayment = redisTemplate.opsForZSet().range("BalanceRecharge", 0, second); |
| | | if(orderPayment.size() > 0){ |
| | | List<BalancePayment> list = balancePaymentService.list(new LambdaQueryWrapper<BalancePayment>().in(BalancePayment::getId, orderPayment)); |
| | | for (BalancePayment order : list) { |
| | | if(null == order || order.getStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getId().toString()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("BalanceRecharge", order.getId(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getId(), com.alibaba.fastjson2.JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.BalancePayment; |
| | | import com.ruoyi.account.mapper.BalancePaymentMapper; |
| | | import com.ruoyi.account.service.BalancePaymentService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2025/1/8 17:47 |
| | | */ |
| | | @Service |
| | | public class BalancePaymentServiceImpl extends ServiceImpl<BalancePaymentMapper, BalancePayment> implements BalancePaymentService { |
| | | } |
| | |
| | | public void sendVipCoupon(){ |
| | | //解绑推广人 |
| | | appUserService.unbindThePromoter(); |
| | | //关闭充值订单 |
| | | appUserService.closeOrder(); |
| | | } |
| | | |
| | | /** |
| | |
| | | #{shopId} |
| | | </foreach> |
| | | </if> |
| | | <if test="null != shopId"> |
| | | and ta.shop_id = #{shopId} or ta.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | order by ta.is_danger desc |
| | | |
| | |
| | | SUM(CASE WHEN tau.vip_id = 7 THEN 1 ELSE 0 END) AS partnerUser |
| | | FROM |
| | | t_app_user tau |
| | | <where> |
| | | <if test="null != shopId"> |
| | | tau.shop_id = #{shopId} or tau.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail"> |
| | | SELECT |
| | |
| | | FROM |
| | | t_app_user tau |
| | | <where> |
| | | <if test="null != userName and '' != userName"> |
| | | and tau.id = #{userId} |
| | | <if test="null != shopId"> |
| | | tau.shop_id = #{shopId} or |
| | | </if> |
| | | <if test="null != userId and userId.size() > 0"> |
| | | tau.id in |
| | | <foreach collection="userId" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.BaseSetting; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | private BaseSettingClient baseSettingClient; |
| | | @Resource |
| | | private OrderMapper orderMapper; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation(value = "订单核销", tags = {"小程序-个人中心-门店管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单号", name = "code", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "String"), |
| | | }) |
| | | @GetMapping("/writeOff/{code}/{shopId}") |
| | | public R<Void> writeOff(@PathVariable("code") String code, @PathVariable("shopId") Integer shopId){ |
| | | orderService.writeOff(code, shopId); |
| | | @GetMapping("/writeOff/{id}/{shopId}") |
| | | public R<Void> writeOff(@PathVariable("id") String id, @PathVariable("shopId") Integer shopId){ |
| | | orderService.writeOff(id, shopId); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | public R<OrderStatistics> getOrderStatistics(@RequestParam("startTime") String startTime, |
| | | @RequestParam("endTime") String endTime){ |
| | | |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>() |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>().eq(sysUser.getRoleType() == 2, Order::getShopId, sysUser.getObjectId()) |
| | | .between(Order::getCreateTime, LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))); |
| | | |
| | | |
| | |
| | | orderStatisticsDetail.setTotal(total); |
| | | orderStatisticsDetails.add(orderStatisticsDetail); |
| | | }); |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime); |
| | | Integer shopId = null; |
| | | if(sysUser.getRoleType() == 2){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime, shopId); |
| | | if(null != orderStatistics){ |
| | | orderStatistics.setOrderStatisticsDetailList(orderStatisticsDetails); |
| | | } |
| | |
| | | return R.ok(shopSaleNum); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有在指定门店消费的用户id |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAppUserByShoppingShop") |
| | | public R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId){ |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getShopId, shopId).eq(Order::getDelFlag, 0).eq(Order::getPayStatus, 2).in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8))); |
| | | Set<Long> collect = list.stream().map(Order::getAppUserId).collect(Collectors.toSet()); |
| | | return R.ok(collect); |
| | | } |
| | | } |
| | | |
| | |
| | | List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList); |
| | | |
| | | OrderStatistics getOrderStatistics(@Param("startTime")String startTime, |
| | | @Param("endTime") String endTime); |
| | | @Param("endTime") String endTime, @Param("shopId") Integer shopId); |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | boolean check(Order order, Integer shopId, Long userId); |
| | | |
| | | void writeOff(String code,Integer shopId); |
| | | void writeOff(String id,Integer shopId); |
| | | |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void calculationCommission() { |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getIsCommission, 0).isNotNull(Order::getAfterSaleTime) |
| | | .eq(Order::getDelFlag, 0).last(" and after_sale_time <= now()")); |
| | | .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()")); |
| | | List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | |
| | | for (Order order : list) { |
| | | if(order.getPayMethod() == 3){ |
| | | continue; |
| | | } |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .eq(OrderGood::getOrderId, order.getId())); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | |
| | | } |
| | | |
| | | //上级门店分佣 |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | if(null != shop1){ |
| | | Integer pid = shop1.getPid(); |
| | | Shop shop2 = shopClient.getShopById(pid).getData(); |
| | | if(null != shop2){ |
| | | AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId()); |
| | | if(null != sjShopAppUser){ |
| | | BigDecimal shopBalance = shop2.getBalance(); |
| | | Integer lavePoint = sjShopAppUser.getLavePoint(); |
| | | Integer shopLavePoint = shop2.getLavePoint(); |
| | | if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){ |
| | | //门店返佣 |
| | | shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | if(bdmdsj_point > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){ |
| | | earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point); |
| | | sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1); |
| | | sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){ |
| | | sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point); |
| | | sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point); |
| | | //门店返佣 |
| | | shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point); |
| | | shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point); |
| | | shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point); |
| | | } |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | appUserClient.editAppUserById(sjShopAppUser); |
| | | shopClient.updateShop(shop2); |
| | | //添加明细记录 |
| | | if(!shop2.getBalance().equals(shopBalance)){ |
| | | ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); |
| | | shopBalanceStatement.setShopId(shop2.getId()); |
| | | shopBalanceStatement.setType(2); |
| | | shopBalanceStatement.setHistoricalBalance(shopBalance); |
| | | shopBalanceStatement.setVariableAmount(bdmdsj_price); |
| | | shopBalanceStatement.setBalance(shop2.getBalance()); |
| | | shopBalanceStatement.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatement.setCreateUserId(order.getAppUserId()); |
| | | shopBalanceStatement.setObjectId(order.getId()); |
| | | shopBalanceStatement.setExtension(order.getOrderNumber()); |
| | | shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); |
| | | } |
| | | //添加积分明细 |
| | | if(!sjShopAppUser.getLavePoint().equals(lavePoint)){ |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(14); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(bdmdsj_point); |
| | | userPoint.setBalance(sjShopAppUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(sjShopAppUser.getId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setExtention(order.getOrderNumber()); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(sjShopAppUser.getId()); |
| | | } |
| | | |
| | | if(!shop2.getLavePoint().equals(shopLavePoint)){ |
| | | ShopPoint shopPoint = new ShopPoint(); |
| | | shopPoint.setShopId(shop2.getId()); |
| | | shopPoint.setType(3); |
| | | shopPoint.setHistoricalPoint(shopLavePoint); |
| | | shopPoint.setVariablePoint(bdmdsj_point); |
| | | shopPoint.setBalance(shop2.getLavePoint()); |
| | | shopPoint.setCreateTime(LocalDateTime.now()); |
| | | shopPoint.setCreateUserId(order.getAppUserId()); |
| | | shopPoint.setObjectId(order.getId()); |
| | | shopPoint.setOrderNum(order.getOrderNumber()); |
| | | shopPointClient.saveShopPoint(shopPoint); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | order.setIsCommission(1); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void writeOff(String code,Integer shopId) { |
| | | public void writeOff(String id,Integer shopId) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getId, code)); |
| | | Order order = orderMapper.selectById(id); |
| | | boolean check = check(order, shopId, loginUserApplet.getUserid()); |
| | | if (!check){ |
| | | throw new ServiceException("订单不存在"); |
| | |
| | | for (OrderPageListVo orderPageListVo : list) { |
| | | Long appUserId = orderPageListVo.getAppUserId(); |
| | | AppUser appUser = appUserClient.getAppUserById(appUserId); |
| | | orderPageListVo.setUserName(appUser.getName()); |
| | | orderPageListVo.setPhone(appUser.getPhone()); |
| | | if(null != appUser){ |
| | | orderPageListVo.setUserName(appUser.getName()); |
| | | orderPageListVo.setPhone(appUser.getPhone()); |
| | | } |
| | | RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0, 1")); |
| | | orderPageListVo.setRefundPassId(null != one ? one.getId().toString() : null); |
| | | } |
| | |
| | | if(!Arrays.asList(1, 2, 3).contains(order.getOrderStatus())){ |
| | | return R.fail("订单取消失败"); |
| | | } |
| | | if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){ |
| | | if(null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())){ |
| | | return R.fail("订单取消失败"); |
| | | } |
| | | order.setOrderStatus(5); |
| | |
| | | //余额退款 |
| | | OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderBalancePayment){ |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //构建账户余额流水明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | |
| | | orderInfo.setOrderStatus(order.getOrderStatus()); |
| | | orderInfo.setCreateTime(order.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | orderInfo.setUserName(appUser.getName()); |
| | | orderInfo.setPhone(appUser.getPhone()); |
| | | if(null != appUser){ |
| | | orderInfo.setUserName(appUser.getName()); |
| | | orderInfo.setPhone(appUser.getPhone()); |
| | | } |
| | | orderInfo.setOrderType(order.getOrderType() == 1 ? "服务" : (StringUtils.isNotEmpty(order.getExpressJson()) ? "单品-快递配送" : "单品-自提")); |
| | | Shop shop = shopClient.getShopById(order.getShopId()).getData(); |
| | | if(null != shop){ |
| | |
| | | return R.fail("不能重复操作"); |
| | | } |
| | | refundPass.setPassStatus(status); |
| | | refundPass.setAuthTime(LocalDateTime.now()); |
| | | //退货退款 |
| | | if(refundPass.getRefundMethod() == 1 && 2 == status){ |
| | | refundPass.setStatus(4); |
| | |
| | | area.setProvinceCode(appUser.getProvinceCode()); |
| | | area.setVip(appUser.getVipId()); |
| | | GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); |
| | | price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsArea.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsArea.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); |
| | | if(null != goodsArea){ |
| | | price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsArea.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsArea.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); |
| | | }else{ |
| | | GoodsVip goodsVip = goodsVipClient.getGoodsVip(goodsId, appUser.getVipId()).getData(); |
| | | price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsVip.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsVip.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsVip.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsVip.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsVip.getTechnicianPoints()); |
| | | price.setBoundShopCharges(goodsVip.getBoundShopCharges()); |
| | | price.setBoundShopPoints(goodsVip.getBoundShopPoints()); |
| | | price.setBoundShopSuperiorsCharges(goodsVip.getBoundShopSuperiorsCharges()); |
| | | price.setBoundShopSuperiorsPoints(goodsVip.getBoundShopSuperiorsPoints()); |
| | | } |
| | | } |
| | | }else{ |
| | | //构建价格数据 |
| | |
| | | } |
| | | |
| | | //查询当前是否有订单活动 |
| | | OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | //满XX才打折,只有现金才能优惠 |
| | | if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1 && orderActivityInfo.getConditionAmount().compareTo(orderMoney) <= 0){ |
| | | confirmOrderVo.setActivityName(orderActivityInfo.getActivityName()); |
| | | BigDecimal multiply = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN); |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1){ |
| | | for (OrderActivityInfo activityInfo : orderActivityInfo) { |
| | | if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | confirmOrderVo.setActivityName(activityInfo.getActivityName()); |
| | | //优惠后的支付金额 |
| | | BigDecimal multiply = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | //优惠金额 |
| | | BigDecimal bigDecimal = paymentMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN); |
| | | paymentMoney = multiply; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | confirmOrderVo.setDiscountAmount(activityAmount); |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | |
| | | } |
| | | |
| | | //查询当前是否有订单活动 |
| | | OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | | //系统活动设置(优惠券和活动能否同时使用) |
| | | boolean useSimultaneously = baseSetting.getContent().equals("1"); |
| | | Integer status = JSON.parseObject(baseSetting.getContent()).getInteger("status"); |
| | | //满XX才打折,只有现金才能优惠 |
| | | //如果使用优惠券,则需要判断是否可以和同时使用,且活动满足使用条件。 |
| | | //没有使用优惠券,只需要判断是都满足使用条件 |
| | | if((useSimultaneously || null == shoppingCartPayment.getUserCouponId()) && |
| | | null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3 && orderActivityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | BigDecimal paymentMoney1 = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | discount = orderActivityInfo.getDiscount(); |
| | | paymentMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | OrderActivityInfo orderActivityInfo1 = null; |
| | | if((1 == status || null == shoppingCartPayment.getUserCouponId()) && |
| | | null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3){ |
| | | for (OrderActivityInfo activityInfo : orderActivityInfo) { |
| | | if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | BigDecimal paymentMoney1 = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); |
| | | BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); |
| | | discount = activityInfo.getDiscount(); |
| | | paymentMoney = paymentMoney1; |
| | | activityAmount = activityAmount.add(bigDecimal); |
| | | orderActivityInfo1 = activityInfo; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //可获得的消费积分 |
| | |
| | | order.setCouponJson(JSON.toJSONString(couponInfoVo)); |
| | | } |
| | | if(activityAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo)); |
| | | order.setActivityJson(JSON.toJSONString(orderActivityInfo1)); |
| | | } |
| | | if(null != shoppingCartPayment.getUserAddressId()){ |
| | | UserAddress address = userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData(); |
| | |
| | | if(expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | if(shoppingCartPayment.getFreightPaymentType() == 1){ |
| | | //调起微信支付 |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber() + appUser.getId(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费", |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay("K" + order.getOrderNumber(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费", |
| | | "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), null); |
| | | if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){ |
| | | return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg()); |
| | |
| | | jsonObject.put("orderId", order.getId().toString()); |
| | | //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。 |
| | | long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC); |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber() + appUser.getId(), second); |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", "K" + order.getOrderNumber(), second); |
| | | return R.ok(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult) { |
| | | String r2_orderNo = uniPayCallbackResult.getR2_OrderNo(); |
| | | r2_orderNo = r2_orderNo.substring(0, 23); |
| | | r2_orderNo = r2_orderNo.substring(1); |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, r2_orderNo)); |
| | | if(null == order || order.getPayStatus() == 2){ |
| | | return R.ok(); |
| | |
| | | //订单支付数据 |
| | | long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); |
| | | Set<String> orderPayment = redisTemplate.opsForZSet().range("OrderPayment", 0, second); |
| | | for (String code : orderPayment) { |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("OrderPayment", code); |
| | | continue; |
| | | if(orderPayment.size() > 0){ |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, orderPayment)); |
| | | for (Order order : list) { |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getOrderNumber()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("OrderPayment", order.getOrderNumber(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber()); |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("OrderPayment", code, 0); |
| | | log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("OrderPayment", code); |
| | | } |
| | | |
| | | //快递支付 |
| | | Set<String> materialFlowPayment = redisTemplate.opsForZSet().range("MaterialFlowPayment", 0, second); |
| | | for (String code : materialFlowPayment) { |
| | | code = code.substring(0, 23); |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code)); |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", code); |
| | | continue; |
| | | if(materialFlowPayment.size() > 0){ |
| | | materialFlowPayment.forEach(s->s.substring(1)); |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, materialFlowPayment)); |
| | | for (Order order : list) { |
| | | if(null == order || order.getPayStatus() != 1){ |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber()); |
| | | continue; |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder("K" + order.getOrderNumber()); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber(), 0); |
| | | log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber()); |
| | | } |
| | | //开始执行关闭订单操作 |
| | | CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code); |
| | | if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) && |
| | | Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){ |
| | | redisTemplate.opsForZSet().add("MaterialFlowPayment", code, 0); |
| | | log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult)); |
| | | } |
| | | redisTemplate.opsForZSet().remove("MaterialFlowPayment", code); |
| | | } |
| | | } |
| | | } |
| | |
| | | o.num, |
| | | o.point, |
| | | o.payment_amount, |
| | | o.express_amount, |
| | | COUNT(o.id) AS order_count |
| | | FROM |
| | | t_order o |
| | | <where> |
| | | <if test="status != null"> |
| | | o.order_status = #{status} |
| | | <choose> |
| | | <when test="status == 4"> |
| | | o.order_status in (4, 8) |
| | | </when> |
| | | <otherwise> |
| | | o.order_status = #{status} |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | <if test="userId != null"> |
| | | AND o.app_user_id = #{userId} |
| | |
| | | o.num, |
| | | o.point, |
| | | o.payment_amount, |
| | | o.create_time |
| | | o.create_time, |
| | | o.express_amount |
| | | ORDER BY |
| | | o.create_time DESC |
| | | </select> |
| | |
| | | <if test="startTime != null and '' != startTime and endTime != null and '' != endTime"> |
| | | and tor.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | <if test="null != shopId"> |
| | | and tor.shop_id = #{shopId} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | |
| | | */ |
| | | @GetMapping("/goodsDetail/{goodsId}") |
| | | @ApiOperation(value = "商品详情", tags = {"小程序-商城-首页"}) |
| | | public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId){ |
| | | return R.ok(goodsService.goodsDetail(goodsId)); |
| | | public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId, String longitude, String latitude){ |
| | | return R.ok(goodsService.goodsDetail(goodsId, longitude, latitude)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getNowOrderActivityInfo") |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .eq(OrderActivityInfo::getIsShelf, 1).eq(OrderActivityInfo::getStatus, 1) |
| | | .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1")); |
| | | public R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | List<OrderActivityInfo> one = orderActivityInfoService.list(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .eq(OrderActivityInfo::getIsShelf, 1).last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids)")); |
| | | return R.ok(one); |
| | | } |
| | | |
| | |
| | | Page<OrderActivityInfo> page = orderActivityInfoService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<OrderActivityInfo>() |
| | | .eq(orderActivityInfo.getId() != null, OrderActivityInfo::getId, orderActivityInfo.getId()) |
| | | .eq(StringUtils.isNotEmpty(orderActivityInfo.getActivityName()), OrderActivityInfo::getActivityName, orderActivityInfo.getActivityName()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, orderActivityInfo.getStartTime()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf())); |
| | | .gt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, LocalDateTime.now()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()).orderByDesc(OrderActivityInfo::getCreateTime)); |
| | | page.getRecords().forEach(item -> { |
| | | LocalDateTime startTime = item.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | */ |
| | | @GetMapping("/detail/{id}") |
| | | @ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页"}) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id) |
| | | public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id, String latitude, String longitude) |
| | | { |
| | | return R.ok(seckillActivityInfoService.detail(id)); |
| | | return R.ok(seckillActivityInfoService.detail(id, latitude, longitude)); |
| | | } |
| | | |
| | | |
| | |
| | | import com.ruoyi.other.enums.ShareAddType; |
| | | import com.ruoyi.other.enums.ShareAuditStatus; |
| | | import com.ruoyi.other.service.ShareService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | |
| | | public R<List<Share>> recommandlist() { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | return R.ok(shareService.list(new LambdaQueryWrapper<Share>().eq(Share::getAddType, 2) |
| | | .eq(Share::getObjectId, userid))); |
| | | .eq(Share::getObjectId, userid).or().eq(Share::getAddType, 1).eq(Share::getAuditStatus, 1).eq(Share::getDelFlag, 0))); |
| | | } |
| | | |
| | | |
| | |
| | | public R<Void> manage(@RequestBody Share share) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Long userid = loginUser.getSysUser().getUserId(); |
| | | share.setAddType(1); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | share.setAddType(sysUser.getRoleType() == 1 ? 1 : 3); |
| | | share.setAppletShare(0); |
| | | share.setAuditStatus(ShareAuditStatus.SUCCESS.getCode()); |
| | | share.setObjectId(userid.toString()); |
| | | if(sysUser.getRoleType() == 2){ |
| | | share.setObjectId(sysUser.getObjectId().toString()); |
| | | } |
| | | share.setDelFlag(0); |
| | | shareService.save(share); |
| | | return R.ok(); |
| | |
| | | @ApiOperation(value = "广告管理-分享管理-编辑", tags = {"管理后台"}) |
| | | @PostMapping("/manage/edit") |
| | | public R<Void> manageedit(@RequestBody Share share) { |
| | | |
| | | shareService.updateById(share); |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiOperation(value = "广告管理-分享管理-删除", tags = {"管理后台"}) |
| | | @GetMapping("/manage/delete") |
| | | public R<Void> managedelete(@RequestParam Integer id) { |
| | | |
| | | shareService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | |
| | | public R<Page<Share>> managelist(String name, Integer addType, @RequestParam Integer pageNum, Integer pageSize) { |
| | | //判断当前登陆人是平台还是门店 |
| | | if (tokenService.getLoginUser().getSysUser().getRoleType()==1) { |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize)); |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAuditStatus, 1).like(name != null, Share::getName, name) |
| | | .eq(Share::getAddType, 1).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | }else { |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, tokenService.getLoginUser().getSysUser().getObjectId()).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize)); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, sysUser.getObjectId()) |
| | | .like(name != null, Share::getName, name).page(Page.of(pageNum, pageSize)); |
| | | return R.ok(page); |
| | | } |
| | | } |
| | |
| | | Shop shop = shopService.getById(id); |
| | | shop.setDelFlag(1); |
| | | shopService.updateById(shop); |
| | | //获取门店的员工数据 |
| | | UserShop userShop = new UserShop(); |
| | | userShop.setShopId(shop.getId()); |
| | | List<UserShop> data = userShopClient.getUserShop(userShop).getData(); |
| | |
| | | sysUserClient.delShopUser(shop.getId(), 2); |
| | | //修改小程序用户类型和门店数据 |
| | | for (SysUser sysUser : sysUserList) { |
| | | String userName = sysUser.getUserName(); |
| | | //通过电话号码查询小程序用户和门店关系数据 |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(userName).getData(); |
| | | AppUser appUser = appUserClient.getAppUserByPhone1(sysUser.getUserName()).getData(); |
| | | //需要先判断用户是否没有关联任何门店 |
| | | List<AppUserShop> userShops = appUserShopClient.getAppUserShop(appUser.getId()).getData(); |
| | | if(userShops.size() == 1 && userShops.get(0).getShopId().equals(shop.getId())){ |
| | | appUser.setUserType(1); |
| | | appUserClient.editAppUserById(appUser); |
| | | } |
| | | |
| | | //删除用户门店关系表数据 |
| | | AppUserShop appUserShop = new AppUserShop(); |
| | | appUserShop.setAppUserId(appUser.getId()); |
| | | appUserShop.setShopId(shop.getId()); |
| | | appUserShopClient.delAppUserShop(appUserShop); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiOperation(value = "绑定门店", tags = {"小程序-个人中心"}) |
| | | public R<Void> bindShop(@ApiParam("门店id") @RequestParam Integer shopId) { |
| | | AppUser appUser = appUserClient.getAppUserById(SecurityUtils.getUserId()); |
| | | if(null != appUser.getShopId()){ |
| | | return R.fail("不能重复绑定门店"); |
| | | } |
| | | appUser.setShopId(shopId); |
| | | return appUserClient.editAppUserById(appUser); |
| | | } |
| | |
| | | import com.ruoyi.other.api.domain.ShopPoint; |
| | | import com.ruoyi.other.service.ShopPointService; |
| | | import com.ruoyi.other.vo.ShopPointStatistics; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private ShopPointService shopPointService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | /** |
| | |
| | | @GetMapping("/shop/statistics") |
| | | @ApiOperation(value = "门店积分统计", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<ShopPointStatistics> shopstatistics(ShopPoint shopPoint) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | shopPoint.setShopId(objectId); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | shopPoint.setShopId(sysUser.getObjectId()); |
| | | ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint); |
| | | return R.ok(statistics); |
| | | } |
| | | @GetMapping("/shop/statistics/list") |
| | | @ApiOperation(value = "门店积分统计列表", notes = "门店积分统计", tags = {"门店后台"}) |
| | | public R<Page<ShopPoint>> shopstatisticslist(ShopPoint shopPoint,Integer pageNum,Integer pageSize) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, objectId).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, sysUser.getObjectId()).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType()) |
| | | .like(shopPoint.getOrderNum()!=null,ShopPoint::getOrderNum, shopPoint.getOrderNum()) |
| | | .orderByDesc(ShopPoint::getCreateTime) |
| | | .page(Page.of(pageNum, pageSize)); |
| | |
| | | import com.ruoyi.other.api.domain.TechnicianSubscribe; |
| | | import com.ruoyi.other.service.TechnicianSubscribeService; |
| | | import com.ruoyi.other.vo.TechnicianSubscribeVO; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private TechnicianSubscribeService technicianSubscribeService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/shop/list") |
| | |
| | | @ApiParam("电话")String phone, |
| | | @ApiParam("姓名")String name, |
| | | @ApiParam("服务方式:1=上门服务,2=到店服务")Integer serviceMode, Integer pageCurr, Integer pageSize) { |
| | | Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId(); |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(objectId), status, phone, name, serviceMode, pageCurr, pageSize); |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userid).getData(); |
| | | PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(sysUser.getObjectId()), status, phone, name, serviceMode, pageCurr, pageSize); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | |
| | | |
| | | List<NearbyShopVO> selectNearbyShopList(@Param("longitude") BigDecimal longitude,@Param("latitude") BigDecimal latitude); |
| | | |
| | | ShopDetailVO selectShopDetail(Integer shopId); |
| | | ShopDetailVO selectShopDetail(@Param("shopId") Integer shopId); |
| | | |
| | | ShopStatistics getShopStatistics(@Param("shopId") Integer shopId); |
| | | |
| | |
| | | |
| | | PageInfo<GoodsVO> goodsList(Goods goods); |
| | | |
| | | GoodsVO goodsDetail(Long goodsId); |
| | | GoodsVO goodsDetail(Long goodsId, String longitude, String latitude); |
| | | |
| | | List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId); |
| | | |
| | |
| | | |
| | | List<SeckillActivityVO> listSeckillActivity(Goods goods); |
| | | |
| | | SeckillActivityDetailVO detail(Integer seckillActivityId); |
| | | SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude); |
| | | |
| | | void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo); |
| | | |
| | |
| | | import com.ruoyi.other.mapper.GoodsShopMapper; |
| | | import com.ruoyi.other.mapper.ShopMapper; |
| | | import com.ruoyi.other.service.*; |
| | | import com.ruoyi.other.util.GeodesyUtil; |
| | | import com.ruoyi.other.vo.GoodsVO; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import org.jetbrains.annotations.NotNull; |
| | |
| | | goods.setSellingPrice(price.getCash()); |
| | | goods.setIntegral(price.getPoint()); |
| | | } |
| | | Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData(); |
| | | goods.setSaleNum(data); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | @Override |
| | | public GoodsVO goodsDetail(Long goodsId) { |
| | | public GoodsVO goodsDetail(Long goodsId, String longitude, String latitude) { |
| | | if (goodsId == null || goodsId <= 0) { |
| | | throw new NullPointerException("商品ID不能为空"); |
| | | } |
| | |
| | | BeanUtils.copyBeanProp(goodsVO, goods); |
| | | goodsVO.setGoodsId(goods.getId()); |
| | | goodsVO.setGoodsName(goods.getName()); |
| | | Price price = getPrice(vipId, goods.getId(), 1, null, provinceCode, cityCode, districtCode); |
| | | Price price = getPrice(vipId, goods.getId(), null, 1, provinceCode, cityCode, districtCode); |
| | | if(null != price){ |
| | | goodsVO.setPointPayment(price.getPointPayment() ? 1 : 0); |
| | | goodsVO.setCashPayment(price.getCashPayment() ? 1 : 0); |
| | |
| | | .in(Shop::getDelFlag, 0)); |
| | | goodsVO.setShopList(shopList); |
| | | } |
| | | List<Shop> shopList = goodsVO.getShopList(); |
| | | for (Shop shop : shopList) { |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | shop.setDistance(wgs84); |
| | | } |
| | | shopList.sort(new Comparator<Shop>() { |
| | | @Override |
| | | public int compare(Shop o1, Shop o2) { |
| | | return o1.getDistance().compareTo(o2.getDistance()); |
| | | } |
| | | }); |
| | | goodsVO.setShopList(shopList); |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); |
| | | goodsVO.setSaleNum(integer); |
| | | return goodsVO; |
| | |
| | | good.setSellingPrice(price.getCash()); |
| | | good.setIntegral(price.getPoint()); |
| | | } |
| | | Integer data = orderClient.getGoodsSaleNum(good.getId(), 1).getData(); |
| | | good.setSaleNum(data); |
| | | } |
| | | return goods; |
| | | } |
| | |
| | | if (!CollectionUtils.isEmpty(goodsAreaList)){ |
| | | for (GoodsArea goodsArea : goodsAreaList) { |
| | | List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList(); |
| | | List<GoodsArea> goodsAreaList2 = new ArrayList<>(); |
| | | for (GoodsArea area : goodsAreaList1) { |
| | | area.setId(null); |
| | | area.setGoodsId(id); |
| | |
| | | area.setProvinceCode(goodsArea.getProvinceCode()); |
| | | area.setCityCode(goodsArea.getCityCode()); |
| | | area.setDistrictsCode(goodsArea.getDistrictsCode()); |
| | | if(null != area.getSellingPrice() && null != area.getIntegral()){ |
| | | goodsAreaList2.add(area); |
| | | } |
| | | } |
| | | goodsAreaService.saveBatch(goodsAreaList1); |
| | | goodsAreaService.saveBatch(goodsAreaList2); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.other.service.GoodsSeckillService; |
| | | import com.ruoyi.other.service.GoodsService; |
| | | import com.ruoyi.other.service.SeckillActivityInfoService; |
| | | import com.ruoyi.other.util.GeodesyUtil; |
| | | import com.ruoyi.other.vo.SeckillActivityDetailVO; |
| | | import com.ruoyi.other.vo.SeckillActivityVO; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); |
| | | goods.setVipId(appUser.getVipId()); |
| | | List<SeckillActivityVO> seckillActivityVOS = seckillActivityInfoMapper.listSeckillActivity(goods); |
| | | for (SeckillActivityVO seckillActivityVO : seckillActivityVOS) { |
| | | Integer data = orderClient.getGoodsSaleNum(seckillActivityVO.getGoodsId(), 2).getData(); |
| | | seckillActivityVO.setSaleNum(data); |
| | | LocalDateTime startTime = seckillActivityVO.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime endTime = seckillActivityVO.getEndTime(); |
| | | if (endTime.isBefore(now)){ |
| | | seckillActivityVO.setStatus(3); //已结束 |
| | | }else if (startTime.isBefore(now)){ |
| | | seckillActivityVO.setStatus(2); // 已开始 |
| | | }else { |
| | | seckillActivityVO.setStatus(1); // 未开始 |
| | | } |
| | | } |
| | | return seckillActivityVOS; |
| | | } |
| | | |
| | | @Override |
| | | public SeckillActivityDetailVO detail(Integer seckillActivityId) { |
| | | public SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude) { |
| | | Integer vipId = 0; |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(StringUtils.isNotEmpty(token)){ |
| | |
| | | }else{ |
| | | shops = shopMapper.selectList(new LambdaUpdateWrapper<Shop>().eq(Shop::getDelFlag, 0)); |
| | | } |
| | | |
| | | for (Shop shop : shops) { |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | shop.setDistance(wgs84); |
| | | } |
| | | shops.sort(new Comparator<Shop>() { |
| | | @Override |
| | | public int compare(Shop o1, Shop o2) { |
| | | return o1.getDistance().compareTo(o2.getDistance()); |
| | | } |
| | | }); |
| | | seckillActivityDetailVO.setShopList(shops); |
| | | Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 2).getData(); |
| | | seckillActivityDetailVO.setSaleNum(integer); |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude); |
| | | if(null != appUser && null != appUser.getShopId()){ |
| | | AppUser finalAppUser = appUser; |
| | | NearbyShopVO nearbyShopVO = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst().get(); |
| | | if(null != nearbyShopVO){ |
| | | nearbyShopVOS.remove(nearbyShopVO); |
| | | Optional<NearbyShopVO> first = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst(); |
| | | if(first.isPresent()){ |
| | | NearbyShopVO nearbyShopVO = first.get(); |
| | | if(null != nearbyShopVO){ |
| | | nearbyShopVOS.remove(nearbyShopVO); |
| | | } |
| | | } |
| | | |
| | | Shop shop = shopMapper.selectById(appUser.getShopId()); |
| | | NearbyShopVO vo = new NearbyShopVO(); |
| | | vo.setId(appUser.getShopId().longValue()); |
| | | vo.setName(shop.getName()); |
| | | vo.setAddress(shop.getAddress()); |
| | | vo.setHomePicture(shop.getHomePicture()); |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | vo.setDistance(wgs84.toString()); |
| | | nearbyShopVOS.add(0, vo); |
| | | if(null != shop){ |
| | | NearbyShopVO vo = new NearbyShopVO(); |
| | | vo.setId(appUser.getShopId().longValue()); |
| | | vo.setName(shop.getName()); |
| | | vo.setAddress(shop.getAddress()); |
| | | vo.setHomePicture(shop.getHomePicture()); |
| | | Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84"); |
| | | vo.setDistance(wgs84.toString()); |
| | | nearbyShopVOS.add(0, vo); |
| | | } |
| | | } |
| | | if (nearbyShopVOS == null || nearbyShopVOS.isEmpty()) { |
| | | return Collections.emptyList(); |
| | |
| | | |
| | | @Override |
| | | public ShopDetailVO getShopDetail(Integer shopId, BigDecimal longitude, BigDecimal latitude) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | // 查询店铺详情 |
| | | ShopDetailVO shopDetailVO = shopMapper.selectShopDetail(shopId); |
| | | if (shopDetailVO == null) { |
| | | throw new ServiceException("查询店铺不存在"); |
| | | } |
| | | |
| | | ShopScore one = shopScoreService.getOne(new LambdaQueryWrapper<ShopScore>().eq(ShopScore::getAppUserId, userid).eq(ShopScore::getShopId, shopId).last(" order by create_time desc limit 0, 1")); |
| | | shopDetailVO.setScore(null == one ? BigDecimal.ZERO : one.getScore()); |
| | | // 计算距离 |
| | | if (shopDetailVO.getLongitude() != null && shopDetailVO.getLatitude() != null){ |
| | | String shopLocation = String.format("%s,%s", shopDetailVO.getLongitude(), shopDetailVO.getLatitude()); |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | if (subscribe.getOrderId() != null){ |
| | | orderGoodsClient.subscribe(subscribe.getOrderId(), subscribe.getTechnicianId()); |
| | | } |
| | | LocalDateTime subscribeTime = subscribe.getSubscribeTime(); |
| | | long deadlineTimestamp = subscribeTime.atZone(ZoneId.systemDefault()).toEpochSecond(); |
| | | redisTemplate.opsForZSet().add("delay_queue:subscribe", subscribe.getId().toString(), deadlineTimestamp); |
| | | //添加到redis有序队列中用于定时处理状态 |
| | | redisTemplate.opsForZSet().add("technician_subscribe", subscribe.getId().toString(), subscribe.getSubscribeTime().toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void taskEditStstus() { |
| | | List<TechnicianSubscribe> list = this.list(new LambdaQueryWrapper<TechnicianSubscribe>().eq(TechnicianSubscribe::getStatus, 0).eq(TechnicianSubscribe::getDelFlag, 0) |
| | | .lt(TechnicianSubscribe::getSubscribeTime, LocalDateTime.now())); |
| | | list.forEach(s->s.setStatus(3)); |
| | | if(list.size() > 0){ |
| | | Set<String> technician_subscribe = redisTemplate.opsForZSet().range("technician_subscribe", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(technician_subscribe.size() > 0){ |
| | | List<TechnicianSubscribe> list = this.listByIds(technician_subscribe); |
| | | list.forEach(s->s.setStatus(3)); |
| | | this.updateBatchById(list); |
| | | redisTemplate.opsForZSet().remove("technician_subscribe", technician_subscribe.toArray()); |
| | | } |
| | | } |
| | | } |
| | |
| | | ts.start_time, |
| | | ts.end_time, |
| | | ts.longitude, |
| | | ts.latitude, |
| | | AVG( tss.score ) score |
| | | ts.latitude |
| | | FROM |
| | | t_shop ts |
| | | LEFT JOIN t_shop_score tss ON ts.id = tss.shop_id |
| | | WHERE |
| | | ts.del_flag = 0 |
| | | AND ts.`status` = 1 |
| | | AND ts.id = #{id} |
| | | GROUP BY |
| | | ts.id, |
| | | ts.details_picture, |
| | | ts.certification, |
| | | ts.`name`, |
| | | ts.address, |
| | | ts.business_date, |
| | | ts.start_time, |
| | | ts.end_time, |
| | | ts.longitude, |
| | | ts.latitude |
| | | WHERE ts.del_flag = 0 AND ts.`status` = 1 AND ts.id = #{shopId} |
| | | </select> |
| | | <select id="selectShopList" resultType="com.ruoyi.other.api.domain.Shop"> |
| | | SELECT |