Merge remote-tracking branch 'origin/master'
| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.model.DriverBank; |
| | | import com.supersavedriving.driver.modular.system.model.Edition; |
| | | import com.supersavedriving.driver.modular.system.model.JoiningRequirements; |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "1=登录,2=注册", name = "type", required = true, dataType = "int"), |
| | | }) |
| | | public ResponseWarpper getVerificationCode(String receiver, String phone){ |
| | | public ResponseWarpper getVerificationCode(String receiver, String phone, Integer type){ |
| | | if(ToolUtil.isEmpty(receiver)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("receiver")); |
| | | } |
| | |
| | | return ResponseWarpper.success(ResultUtil.paranErr("phone")); |
| | | } |
| | | try { |
| | | if(type == 1){ |
| | | Driver driver = driverService.selectOne(new EntityWrapper<Driver>().eq("phone", phone).ne("status", 3)); |
| | | if(null == driver){ |
| | | return ResponseWarpper.success(ResultUtil.error("账号未注册")); |
| | | } |
| | | if(driver.getApprovalStatus() == 1){ |
| | | return ResponseWarpper.success(ResultUtil.error("账号正在审核中")); |
| | | } |
| | | if(driver.getApprovalStatus() == 3){ |
| | | return ResponseWarpper.success(ResultUtil.error("账号审核未通过")); |
| | | } |
| | | if(driver.getStatus() == 2){ |
| | | return ResponseWarpper.success(ResultUtil.error("账号已冻结")); |
| | | } |
| | | } |
| | | String numberRandom = UUIDUtil.getNumberRandom(5); |
| | | SMSUtil.send(phone, "1d0f0cbe5b214b0d8efa891730eb532a", "[\"" + numberRandom + "\"]"); |
| | | redisUtil.setStrValue(receiver + phone, numberRandom, 300);//5分钟有效期 |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @ApiOperation(value = "服务完成后修改订单状态", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(value = "107(线上支付),108(完成线下支付)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "支付方式(1=线上,2=线下)", name = "payType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "107(待支付),108(已完成)", name = "state", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResponseWarpper setOrderStatus(Long orderId, Integer state){ |
| | | public ResponseWarpper setOrderStatus(Long orderId, Integer payType, Integer state){ |
| | | if(ToolUtil.isEmpty(orderId)){ |
| | | return ResponseWarpper.success(ResultUtil.paranErr("orderId")); |
| | | } |
| | |
| | | if(null == uid){ |
| | | return ResponseWarpper.tokenErr(); |
| | | } |
| | | ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, state); |
| | | ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, payType, state); |
| | | return ResponseWarpper.success(resultUtil); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | @PostMapping("/base/order/cloudRecordingCallback") |
| | | public void cloudRecordingCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | CloudRecordingCallback cloudRecordingCallback = RongYunUtil.cloudRecordingCallback(request); |
| | | // System.err.println("-------------------云端录制状态回调!-------------------"); |
| | | // System.err.println(JSON.toJSONString(cloudRecordingCallback)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | System.err.println(sdf.format(new Date()) + "-------------------云端录制状态回调!-------------------"); |
| | | System.err.println(JSON.toJSONString(cloudRecordingCallback)); |
| | | if(null == cloudRecordingCallback){ |
| | | System.err.println("云端录制状态回调解析出错!"); |
| | | return; |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | |
| | | public interface CouponMapper extends BaseMapper<Coupon> { |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.dao; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | import com.supersavedriving.driver.modular.system.model.UserToCoupon; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | |
| | | /** |
| | | * 用户优惠券 |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 11:44 |
| | | */ |
| | | public interface UserToCouponMapper extends BaseMapper<UserToCoupon> { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | */ |
| | | Coupon queryCoupon(@Param("uid") Integer uid, @Param("price") Double price); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | code, |
| | | changeType as `type`, |
| | | UNIX_TIMESTAMP(createTime) * 1000 as createTime, |
| | | (newData - oldData) as money, |
| | | (newData - oldData) as amount, |
| | | newData as balance |
| | | from t_account_change_detail where userType = 2 and userId = #{driverId} and changeType in (1, 3, 4, 7, 8) |
| | | <if test="null != time and '' != time"> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.CouponMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.Coupon"> |
| | | <id column="id" property="id"/> |
| | | <result column="agent_id" property="agentId"/> |
| | | <result column="branch_office_id" property="branchOfficeId"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="coupon_name" property="couponName"/> |
| | | <result column="coupon_type" property="couponType"/> |
| | | <result column="coupon_code" property="couponCode"/> |
| | | <result column="coupon_service_type" property="couponServiceType"/> |
| | | <result column="coupon_conditional_amount" property="couponConditionalAmount"/> |
| | | <result column="coupon_preferential_amount" property="couponPreferentialAmount"/> |
| | | <result column="coupon_validity" property="couponValidity"/> |
| | | <result column="coupon_send_quantity" property="couponSendQuantity"/> |
| | | <result column="coupon_state" property="couponState"/> |
| | | <result column="coupon_count" property="couponCount"/> |
| | | <result column="remaining_quantity" property="remainingQuantity"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | b.avatar, |
| | | a.userName, |
| | | a.userPhone, |
| | | (select count(1) from t_order where userPhone = a.userPhone and state in (107, 108)) as orderTimes, |
| | | (select count(1) from t_order where userPhone = a.userPhone and state in (301)) as cancelTimes, |
| | | (select count(1) from t_order where userId = a.userId and state in (107, 108, 109)) as orderTimes, |
| | | (select count(1) from t_order where userId = a.userId and state in (301)) as cancelTimes, |
| | | a.source, |
| | | UNIX_TIMESTAMP(a.createTime) * 1000 as createTime, |
| | | a.startAddress, |
| | |
| | | b.avatar, |
| | | a.userName, |
| | | a.userPhone, |
| | | (select count(1) from t_order where userPhone = a.userPhone and state in (107, 108)) as orderTimes, |
| | | (select count(1) from t_order where userPhone = a.userPhone and state in (301)) as cancelTimes, |
| | | (select count(1) from t_order where userId = a.userId and state in (107, 108, 109)) as orderTimes, |
| | | (select count(1) from t_order where userId = a.userId and state in (301)) as cancelTimes, |
| | | a.source, |
| | | UNIX_TIMESTAMP(a.createTime) * 1000 as createTime, |
| | | a.startAddress, |
| | |
| | | a.endLng, |
| | | a.estimatedPrice, |
| | | a.estimatedMileage, |
| | | a.estimatedTime, |
| | | a.startPrice, |
| | | a.waitTime, |
| | | a.actualMileage, |
| | |
| | | count(1) as number |
| | | from t_order a |
| | | left join t_driver b on (a.driverId = b.id) |
| | | where a.state in (107, 108, 108) and a.`status` = 1 |
| | | where a.state in (107, 108, 109) and a.`status` = 1 |
| | | <if test="null != dayType and 1 == dayType"><!--天--> |
| | | <if test="null != time and '' != time"> |
| | | and DATE_FORMAT(a.createTime, '%Y年%m月%d日') = #{time} |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.supersavedriving.driver.modular.system.dao.UserToCouponMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.supersavedriving.driver.modular.system.model.UserToCoupon"> |
| | | <id column="id" property="id" /> |
| | | <result column="userId" property="userId" /> |
| | | <result column="couponId" property="couponId" /> |
| | | <result column="couponTotal" property="couponTotal" /> |
| | | <result column="validCount" property="validCount" /> |
| | | <result column="expireCount" property="expireCount" /> |
| | | <result column="expireTime" property="expireTime" /> |
| | | <result column="createTime" property="createTime" /> |
| | | <result column="status" property="status" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="queryCoupon" resultType="com.supersavedriving.driver.modular.system.model.Coupon"> |
| | | select |
| | | b.id, |
| | | a.agent_id as agentId, |
| | | a.branch_office_id as branchOfficeId, |
| | | a.create_time as createTime, |
| | | a.coupon_name as couponName, |
| | | a.coupon_type as couponType, |
| | | a.coupon_code as couponCode, |
| | | a.coupon_service_type as couponServiceType, |
| | | a.coupon_conditional_amount as couponConditionalAmount, |
| | | a.coupon_preferential_amount as couponPreferentialAmount, |
| | | a.coupon_validity as couponValidity, |
| | | a.coupon_send_quantity as couponSendQuantity, |
| | | a.coupon_state as couponState, |
| | | a.coupon_count as couponCount, |
| | | a.remaining_quantity as remainingQuantity |
| | | from t_coupon a |
| | | left join t_user_to_coupon b on (a.id = b.couponId) |
| | | where b.status = 1 and b.expireTime > now() and b.validCount > 0 |
| | | and b.userId = #{uid} and a.coupon_conditional_amount <= #{price} and a.coupon_preferential_amount < #{price} |
| | | order by a.coupon_preferential_amount desc limit 0, 1 |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 优惠券 |
| | | * @author pzb |
| | | * @Date 2023/2/28 11:57 |
| | | */ |
| | | @Data |
| | | @TableName("t_coupon") |
| | | public class Coupon { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 代理商id |
| | | */ |
| | | @TableField("agent_id") |
| | | private Integer agentId; |
| | | /** |
| | | * 分公司id |
| | | */ |
| | | @TableField("branch_office_id") |
| | | private Integer branchOfficeId; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | /** |
| | | * 优惠券名称 |
| | | */ |
| | | @TableField("coupon_name") |
| | | private String couponName; |
| | | /** |
| | | * 优惠券类型 1活动券 2新人券 |
| | | */ |
| | | @TableField("coupon_type") |
| | | private Integer couponType; |
| | | /** |
| | | * 优惠券码 |
| | | */ |
| | | @TableField("coupon_code") |
| | | private String couponCode; |
| | | /** |
| | | * 服务类型 1通用券 |
| | | */ |
| | | @TableField("coupon_service_type") |
| | | private Integer couponServiceType; |
| | | /** |
| | | * 条件金额 |
| | | */ |
| | | @TableField("coupon_conditional_amount") |
| | | private Double couponConditionalAmount; |
| | | /** |
| | | * 优惠金额 |
| | | */ |
| | | @TableField("coupon_preferential_amount") |
| | | private Double couponPreferentialAmount; |
| | | /** |
| | | * 有效期 |
| | | */ |
| | | @TableField("coupon_validity") |
| | | private Integer couponValidity; |
| | | /** |
| | | * 赠送数量 |
| | | */ |
| | | @TableField("coupon_send_quantity") |
| | | private Integer couponSendQuantity; |
| | | /** |
| | | * 是否冻结 1正常 2冻结 |
| | | */ |
| | | @TableField("coupon_state") |
| | | private Integer couponState; |
| | | /** |
| | | * 优惠券数量 |
| | | */ |
| | | @TableField("coupon_count") |
| | | private Integer couponCount; |
| | | /** |
| | | * 剩余数量 |
| | | */ |
| | | @TableField("remaining_quantity") |
| | | private Integer remainingQuantity; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户优惠券关系 |
| | | * @author pzb |
| | | * @Date 2023/3/2 11:04 |
| | | */ |
| | | @Data |
| | | @TableName("t_user_to_coupon") |
| | | public class UserToCoupon { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableField("id") |
| | | private Integer id; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | /** |
| | | * 优惠券id |
| | | */ |
| | | @TableField("couponId") |
| | | private Integer couponId; |
| | | /** |
| | | * 领取总数 |
| | | */ |
| | | @TableField("couponTotal") |
| | | private Integer couponTotal; |
| | | /** |
| | | * 有效数据 |
| | | */ |
| | | @TableField("validCount") |
| | | private Integer validCount; |
| | | /** |
| | | * 过期数量 |
| | | */ |
| | | @TableField("expireCount") |
| | | private Integer expireCount; |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @TableField("expireTime") |
| | | private Date expireTime; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | /** |
| | | * 状态 1正常 2冻结 3删除 |
| | | */ |
| | | @TableField("status") |
| | | private Integer status; |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | |
| | | public interface ICouponService extends IService<Coupon> { |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil setOrderStatus(Integer uid, Long orderId, Integer state) throws Exception; |
| | | ResultUtil setOrderStatus(Integer uid, Long orderId, Integer payType, Integer state) throws Exception; |
| | | |
| | | |
| | | /** |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | import com.supersavedriving.driver.modular.system.model.UserToCoupon; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 14:21 |
| | | */ |
| | | public interface IUserToCouponService extends IService<UserToCoupon> { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Coupon queryCoupon(Integer uid, Double price) throws Exception; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.CouponMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | import com.supersavedriving.driver.modular.system.service.ICouponService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService { |
| | | } |
| | |
| | | driver.setApprovalTime(null); |
| | | driver.setApprovalUserId(null); |
| | | driver.setStatus(1); |
| | | driver.setSource(driverRegisterWarpper.getSource()); |
| | | return driver; |
| | | } |
| | | |
| | |
| | | DriverInfoWarpper driverInfo = new DriverInfoWarpper(); |
| | | BeanUtils.copyProperties(driver, driverInfo); |
| | | driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission()); |
| | | |
| | | driverInfo.setWithdrawBalance(driver.getBalance()); |
| | | YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid) |
| | | .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1")); |
| | | if(null != youTuiDriver){ |
| | |
| | | if(null != orderTransfer){ |
| | | int i = Double.valueOf((System.currentTimeMillis() - orderTransfer.getSuccessTime().getTime()) / 60000).intValue(); |
| | | if(num5 > i){ |
| | | return ResultUtil.error("暂时还无法上班,请稍后重试"); |
| | | return ResultUtil.error("暂时还无法上班,请" + (num5 - i) + "分钟后重试"); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | import com.supersavedriving.driver.modular.system.util.GaoDe.model.District; |
| | | import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import com.supersavedriving.driver.modular.system.model.*; |
| | | import com.supersavedriving.driver.modular.system.service.*; |
| | | import com.supersavedriving.driver.modular.system.util.PushUtil; |
| | | import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper; |
| | | import com.supersavedriving.driver.modular.system.warpper.HallOrderList; |
| | |
| | | |
| | | @Autowired |
| | | private IRevenueService revenueService; |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | @Autowired |
| | | private IUserToCouponService userToCouponService; |
| | | |
| | | private Map<String, Timer> timerMap = new HashMap<>(); |
| | | |
| | |
| | | orderRefusal.setOrderId(orderId); |
| | | orderRefusalService.insert(orderRefusal); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | Driver driver = driverService.selectById(uid); |
| | | //扣除积分 |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null != systemConfig) { |
| | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setUserId(uid); |
| | | accountChangeDetail.setType(2); |
| | | accountChangeDetail.setChangeType(2); |
| | | accountChangeDetail.setOrderId(orderId); |
| | | accountChangeDetail.setOldData(null == driver.getIntegral() ? 0 : driver.getIntegral().doubleValue()); |
| | | driver.setIntegral((null == driver.getIntegral() ? 0 : driver.getIntegral()) - num10); |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("订单已被取消"); |
| | | } |
| | | if(state != 101){ |
| | | if(state != 101 && state != 201){ |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("手速慢了哦"); |
| | | } |
| | |
| | | if(null != order.getUserId()){ |
| | | AppUser appUser = appUserService.selectById(order.getUserId()); |
| | | appUser.setCancelCount(0); |
| | | appUser.setIsException(1); |
| | | appUserService.updateById(appUser); |
| | | } |
| | | |
| | |
| | | } |
| | | if(order.getState() == 201){ |
| | | return ResultUtil.error("订单正在转单中"); |
| | | } |
| | | if(order.getState() == 301){ |
| | | redisUtil.unlock(); |
| | | return ResultUtil.error("订单已被取消"); |
| | | } |
| | | order.setState(processOperationsWarpper.getState()); |
| | | switch (processOperationsWarpper.getState()){ |
| | |
| | | int travelTime = Double.valueOf((System.currentTimeMillis() - order.getStartTime().getTime()) / 60000).intValue(); |
| | | pushOrderInfoWarpper.setTravelTime(travelTime); |
| | | } |
| | | pushUtil.pushOrderInfo(uid, 2, pushOrderInfoWarpper); |
| | | if(null != order.getUserId()){ |
| | | pushUtil.pushOrderInfo(order.getUserId(), 1, pushOrderInfoWarpper); |
| | | } |
| | | if(order.getState() == 301){//司机取消不推送给司机 |
| | | CancelOrder cancelOrder = cancelOrderService.selectOne(new EntityWrapper<CancelOrder>().eq("orderId", order.getId()).eq("status", 1)); |
| | | if(null != cancelOrder && cancelOrder.getUserType() == 2){ |
| | | return; |
| | | } |
| | | } |
| | | pushUtil.pushOrderInfo(uid, 2, pushOrderInfoWarpper); |
| | | } |
| | | },0, 10000); |
| | | timerMap.put(orderId.toString(), timer); |
| | |
| | | driver.setServerStatus(1); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getStatus()); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer state) throws Exception { |
| | | public ResultUtil setOrderStatus(Integer uid, Long orderId, Integer payType, Integer state) throws Exception { |
| | | List<Integer> s = Arrays.asList(107, 108); |
| | | if(!s.contains(state)){ |
| | | return ResultUtil.error("操作失败"); |
| | | } |
| | | Order order = this.selectById(orderId); |
| | | order.setState(state); |
| | | |
| | | // TODO: 2023/5/18 临时 |
| | | payType = 1; |
| | | if(state == 108){ |
| | | payType = 2; |
| | | } |
| | | |
| | | if(payType == 2 && state == 107){ |
| | | Coupon coupon = userToCouponService.queryCoupon(order.getUserId(), order.getOrderMoney()); |
| | | if(null != coupon){ |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountAmount(coupon.getCouponPreferentialAmount()); |
| | | order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount()); |
| | | } |
| | | } |
| | | |
| | | if(payType == 2 && state == 108){ |
| | | order.setPayType(3); |
| | | order.setPayTime(new Date()); |
| | | order.setPayMoney(order.getOrderMoney() - order.getDiscountAmount()); |
| | | if(null != order.getCouponId()){ |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId()); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | order.setPayMoney(order.getPayMoney() - coupon.getCouponPreferentialAmount()); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(driver.getCouponBalance()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(7); |
| | | accountChangeDetail.setOrderId(order.getId()); |
| | | accountChangeDetail.setExplain("优惠券收入"); |
| | | driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount()); |
| | | accountChangeDetail.setNewData(driver.getCouponBalance()); |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | } |
| | | } |
| | | } |
| | | this.updateById(order); |
| | | |
| | |
| | | //开始处理层级抽佣 |
| | | if(null != driver.getInviterType() && driver.getInviterType() == 2){ |
| | | Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机 |
| | | if(null != driver1.getInviterType() && driver1.getInviterType() == 2){ |
| | | if(null != driver1 && null != driver1.getInviterType() && driver1.getInviterType() == 2){ |
| | | Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机 |
| | | if(null != driver2.getInviterType() && driver2.getInviterType() == 2){ |
| | | if(null != driver2 && null != driver2.getInviterType() && driver2.getInviterType() == 2){ |
| | | Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机 |
| | | Double num5 = jsonObject1.getDouble("num5"); |
| | | Double num6 = jsonObject1.getDouble("num6"); |
| | |
| | | @Override |
| | | public List<MyAchievementWarpper> queryMyAchievement(Integer driverId, String time) throws Exception { |
| | | List<MyAchievementWarpper> list = new ArrayList<>(); |
| | | time = time.replaceAll("-", "年") + "月"; |
| | | // time = time.replaceAll("-", "年"); |
| | | //订单量 |
| | | List<PerformanceRankingWarpper> performanceRankingWarppers = performanceRankingWarppers = this.baseMapper.queryDriverRank(time, 2); |
| | | List<PerformanceRankingWarpper> performanceRankingWarppers = this.baseMapper.queryDriverRank(time, 2); |
| | | int position = 0; |
| | | Double d = 0D; |
| | | for (int i = 0; i < performanceRankingWarppers.size(); i++) { |
New file |
| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.modular.system.dao.UserToCouponMapper; |
| | | import com.supersavedriving.driver.modular.system.model.Coupon; |
| | | import com.supersavedriving.driver.modular.system.model.UserToCoupon; |
| | | import com.supersavedriving.driver.modular.system.service.IUserToCouponService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/3/2 14:22 |
| | | */ |
| | | @Service |
| | | public class UserToCouponServiceImpl extends ServiceImpl<UserToCouponMapper, UserToCoupon> implements IUserToCouponService { |
| | | |
| | | |
| | | /** |
| | | * 获取可用优惠券 |
| | | * @param uid |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Coupon queryCoupon(Integer uid, Double price) throws Exception { |
| | | return this.baseMapper.queryCoupon(uid, price); |
| | | } |
| | | |
| | | } |
| | |
| | | private Long youTuiEnd; |
| | | @ApiModelProperty("账户余额") |
| | | private Double balance; |
| | | @ApiModelProperty("可提现余额") |
| | | private Double withdrawBalance; |
| | | @ApiModelProperty("佣金余额") |
| | | private Double commission; |
| | | @ApiModelProperty("积分") |
| | |
| | | private Integer inviterType; |
| | | @ApiModelProperty(value = "邀约人Id", required = false, dataType = "int") |
| | | private Integer inviterId; |
| | | @ApiModelProperty(value = "注册来源(1=司机端注册,2=其他端注册)", required = true, dataType = "int") |
| | | private Integer source; |
| | | } |
| | |
| | | application: |
| | | name: driver-server |
| | | profiles: |
| | | active: dev |
| | | # active: produce |
| | | # active: dev |
| | | active: produce |
| | | mvc: |
| | | static-path-pattern: /static/** |
| | | view: |
| | |
| | | datasource: |
| | | url: jdbc:mysql://127.0.0.1:3306/super_save_driving?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | # password: f4OfRjqoN3jSiNGiUoiNsQdOBtCOKYRj |
| | | password: 123456 |
| | | password: f4OfRjqoN3jSiNGiUoiNsQdOBtCOKYRj |
| | | # password: 123456 |
| | | db-name: guns #用来搜集数据库的所有表 |
| | | filters: wall,mergeStat |
| | | |
| | |
| | | spring: |
| | | data: |
| | | mongodb: |
| | | # uri: mongodb://root:CEtyLdKjPk0yeHNo@127.0.0.1:27017/admin |
| | | uri: mongodb://127.0.0.1:27017/admin |
| | | uri: mongodb://root:CEtyLdKjPk0yeHNo@127.0.0.1:27017/admin |
| | | # uri: mongodb://127.0.0.1:27017/admin |
| | | |
| | | --- |
| | | |
| | |
| | | # RedisÊý¾Ý¿âË÷Òý£¨Ä¬ÈÏΪ0£© |
| | | spring.redis.database=0 |
| | | |
| | | # Redis·þÎñÆ÷µØÖ· |
| | | spring.redis.host=127.0.0.1 |
| | | # Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | spring.redis.port=16379 |
| | | # Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ |
| | | |
| | | ## Redis·þÎñÆ÷µØÖ· |
| | | #spring.redis.host=127.0.0.1 |
| | | ## Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | #spring.redis.port=16379 |
| | | #spring.redis.port=6379 |
| | | ## Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | #spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ |
| | | |
| | | ## Redis·þÎñÆ÷µØÖ· |
| | | spring.redis.host=127.0.0.1 |
| | | ## Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | spring.redis.port=6379 |
| | | ## Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | spring.redis.password=123456 |
| | | #spring.redis.password=123456 |
| | | |
| | | # Á¬½Ó³Ø×î´óÁ¬½ÓÊý£¨Ê¹ÓøºÖµ±íʾûÓÐÏÞÖÆ£© |
| | | spring.redis.jedis.pool.max-active=1024 |
| | |
| | | // |
| | | //import com.supersavedriving.driver.modular.system.model.WeatherCity; |
| | | //import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; |
| | | //import com.supersavedriving.driver.modular.system.service.IOrderService; |
| | | //import com.supersavedriving.driver.modular.system.service.IWeatherCityService; |
| | | //import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | //import com.supersavedriving.driver.modular.system.util.juhe.WeatherCityInfo; |
| | | //import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil; |
| | | //import org.junit.Test; |
| | |
| | | //public class GunsApplicationTest { |
| | | // |
| | | // @Autowired |
| | | // private IAccountChangeDetailService accountChangeDetailService; |
| | | // private IOrderService orderService; |
| | | // |
| | | // |
| | | // @Test |
| | | // public void test(){ |
| | | // accountChangeDetailService.deductionInsurance(); |
| | | // public void test() throws Exception { |
| | | // ResultUtil resultUtil = orderService.rejectionOrder(1, 1L); |
| | | // } |
| | | //} |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryNearbyDrivers") |
| | | // @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") |
| | | @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") |
| | | @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), |
| | |
| | | phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone; |
| | | String value = redisUtil.getValue(phone); |
| | | if(ToolUtil.isEmpty(value) || !value.equals(code)){ |
| | | resultUtil = ResultUtil.error("验证码无效"); |
| | | return ResponseWarpper.success(ResultUtil.error("验证码无效")); |
| | | } |
| | | redisUtil.remove(phone); |
| | | return ResponseWarpper.success(resultUtil); |
| | |
| | | }) |
| | | public ResponseWarpper<List<String>> queryBroadcast(){ |
| | | try { |
| | | List<Broadcast> broadcasts = broadcastService.selectList(new EntityWrapper<Broadcast>().eq("status", 1).orderBy("sort desc limit 0, 5")); |
| | | List<Broadcast> broadcasts = broadcastService.selectList(new EntityWrapper<Broadcast>() |
| | | .eq("`status`", 1).eq("`show`", 1) |
| | | .eq("`upDown`", 1).orderBy("`sort` desc limit 0, 5")); |
| | | List<String> list = new ArrayList<>(); |
| | | for (Broadcast broadcast : broadcasts) { |
| | | list.add(broadcast.getContent()); |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/order/queryOrderPrice") |
| | | // @ServiceLog(name = "获取待支付页面订单费用明细", url = "/api/order/queryOrderPrice") |
| | | @ApiOperation(value = "获取待支付页面订单费用明细", tags = {"用户端-首页"}, notes = "") |
| | | // @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice") |
| | | @ApiOperation(value = "获取订单费用明细", tags = {"用户端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | jumpType, |
| | | jumpUrl, |
| | | html |
| | | from t_commercial where status = 1 |
| | | from t_commercial where status = 1 and onOffLine = 1 |
| | | <if test="null != type"> |
| | | and `type` = #{type} |
| | | </if> |
| | |
| | | b.`name` as driverName, |
| | | b.phone as driverPhone, |
| | | b.`code` as driverCode, |
| | | (DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y')) as driverAge, |
| | | ifnull(DATE_FORMAT(now(), '%Y') - DATE_FORMAT(b.firstCertificateTime, '%Y'), 0) as driverAge, |
| | | (select count(1) from t_order where driverId = b.id and `status` = 1 and state in (107, 108, 109)) as driverNumber, |
| | | b.score as driverScore, |
| | | a.state, |
| | |
| | | * @throws Exception |
| | | */ |
| | | List<OrderListWarpper> queryNotInvoiceOrder(Integer uid, NotInvoiceOrder notInvoiceOrder) throws Exception; |
| | | |
| | | |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | Integer queryUsedCouponNum(Integer uid); |
| | | |
| | | |
| | | /** |
| | | * 删除优惠券数据 |
| | | */ |
| | | void delUserCoupon(); |
| | | } |
| | |
| | | key = token.substring(token.length() - 16); |
| | | } |
| | | redisUtil.setStrValue(key, appUser.getId().toString(), 7 * 24 * 60 * 60); |
| | | redisUtil.setStrValue("USER_" + appUser.getPhone(), key, 7 * 24 * 60 * 60); |
| | | return token; |
| | | } |
| | | return null; |
| | |
| | | * @param userId |
| | | */ |
| | | public List<CouponWarpper> pushCoupon(Integer userId){ |
| | | List<Coupon> coupons = couponService.selectList(new EntityWrapper<Coupon>().eq("coupon_type", 2).eq("coupon_state", 1).gt("remaining_quantity", 0)); |
| | | List<Coupon> coupons = couponService.selectList(new EntityWrapper<Coupon>().eq("coupon_type", 2) |
| | | .eq("coupon_state", 1).eq("status", 1).gt("remaining_quantity", 0)); |
| | | List<CouponWarpper> list = new ArrayList<>(); |
| | | for (Coupon coupon : coupons) { |
| | | UserToCoupon userToCoupon = new UserToCoupon(); |
| | |
| | | complaint.setState(1); |
| | | complaint.setStatus(1); |
| | | complaint.setCreateTime(new Date()); |
| | | this.updateById(complaint); |
| | | this.insert(complaint); |
| | | } |
| | | } |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.core.util.ToolUtil; |
| | |
| | | // 构造query对象 |
| | | Query query = Query.query(Criteria.where("location").withinSphere(circle)); |
| | | List<Location> locations = mongoTemplate.find(query, Location.class); |
| | | // System.err.println("附近空闲司机" + JSON.toJSONString(locations)); |
| | | List<Integer> collect = locations.stream().map(Location::getDriverId).collect(Collectors.toList()); |
| | | List<DriverWork> driverWorks = driverWorkService.selectList(new EntityWrapper<DriverWork>().in("driverId", collect).eq("status", 1)); |
| | | for (DriverWork driverWork : driverWorks) { |
| | |
| | | return ResultUtil.error("司机还未上班"); |
| | | } |
| | | Driver driver = driverService.selectById(travelOrder.getDriverId()); |
| | | if(driver.getServerStatus() == 2){ |
| | | return ResultUtil.error("司机正在服务中"); |
| | | } |
| | | order.setAgentId(driver.getAgentId()); |
| | | order.setBranchOfficeId(driver.getBranchOfficeId()); |
| | | order.setOrderTakingTime(new Date()); |
| | |
| | | driverService.updateById(driver); |
| | | |
| | | appUser.setCancelCount(0); |
| | | appUser.setIsException(1); |
| | | appUserService.updateById(appUser); |
| | | } |
| | | |
| | |
| | | this.updateById(order); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | appUser.setCancelCount(appUser.getCancelCount() + 1); |
| | | if(appUser.getCancelCount() >= 3){ |
| | | appUser.setIsException(2); |
| | | } |
| | | appUserService.updateById(appUser); |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | if(null != driver){ |
| | |
| | | Order orderPrice = getOrderPrice(1, d, 0, order1, city); |
| | | order.setEstimatedPrice(orderPrice.getEstimatedPrice()); |
| | | this.updateById(order); |
| | | |
| | | PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper(); |
| | | pushOrderInfoWarpper.setId(order.getId()); |
| | | pushOrderInfoWarpper.setState(order.getState()); |
| | | pushOrderInfoWarpper.setEndAddress(order.getEndAddress()); |
| | | pushOrderInfoWarpper.setEndLat(order.getEndLat()); |
| | | pushOrderInfoWarpper.setEndLng(order.getEndLng()); |
| | | pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | Order order = this.selectById(orderId); |
| | | OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper(); |
| | | BeanUtils.copyProperties(order, orderPriceWarpper); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | orderPriceWarpper.setBalance(appUser.getAccountBalance()); |
| | | Double orderMoney = order.getOrderMoney(); |
| | | //先算优惠券 |
| | | Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney); |
| | | if(null != coupon){ |
| | | orderMoney = orderMoney - coupon.getCouponPreferentialAmount(); |
| | | orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | orderPriceWarpper.setCouponId(coupon.getId()); |
| | | orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue()); |
| | | if(null == order.getPayTime()){ |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | orderPriceWarpper.setBalance(appUser.getAccountBalance()); |
| | | Double orderMoney = order.getOrderMoney(); |
| | | //先算优惠券 |
| | | Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney); |
| | | if(null != coupon){ |
| | | orderMoney = orderMoney - coupon.getCouponPreferentialAmount(); |
| | | orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | orderPriceWarpper.setCouponId(coupon.getId()); |
| | | } |
| | | orderPriceWarpper.setDiscount(0D); |
| | | orderPriceWarpper.setDiscountAmount(0D); |
| | | orderPriceWarpper.setPayType(1);//微信支付 |
| | | orderPriceWarpper.setPayMoney(orderMoney); |
| | | } |
| | | orderPriceWarpper.setDiscount(0D); |
| | | orderPriceWarpper.setDiscountAmount(0D); |
| | | orderPriceWarpper.setPayType(1);//微信支付 |
| | | orderPriceWarpper.setPayMoney(orderMoney); |
| | | return orderPriceWarpper; |
| | | } |
| | | |
| | |
| | | OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper(); |
| | | BeanUtils.copyProperties(order, orderPriceWarpper); |
| | | AppUser appUser = appUserService.selectById(uid); |
| | | orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue()); |
| | | orderPriceWarpper.setBalance(appUser.getAccountBalance()); |
| | | orderPriceWarpper.setDiscount(0D); |
| | | orderPriceWarpper.setDiscountAmount(0D); |
| | |
| | | //先算优惠券 |
| | | Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney); |
| | | if(null != coupon && null == couponId){ |
| | | orderMoney = orderMoney - coupon.getCouponPreferentialAmount(); |
| | | orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | orderPriceWarpper.setCouponId(coupon.getId()); |
| | | } |
| | |
| | | orderPriceWarpper.setDiscountedPrice(coupon1.getCouponPreferentialAmount()); |
| | | orderPriceWarpper.setCouponId(couponId); |
| | | } |
| | | if(payType == 1 && appUser.getHavDiscount() == 1){//使用余额抵扣 |
| | | if(payType == 1 && appUser.getHavDiscount() == 1 && balance >= orderMoney){//使用余额抵扣 |
| | | orderPriceWarpper.setDiscount(9D); |
| | | orderPriceWarpper.setDiscountAmount(orderMoney * 0.1); |
| | | orderMoney = orderMoney * 0.9; |
| | | orderPriceWarpper.setDiscountAmount(new BigDecimal(orderMoney * 0.1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | orderMoney = new BigDecimal(orderMoney * 0.9).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | if(payType == 0){//不使用余额抵扣 |
| | | orderPriceWarpper.setPayType(1); |
| | |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | userToCouponService.updateById(userToCoupon); |
| | | } |
| | | } |
| | | order.setPayType(1); |
| | |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | | order.setDiscountedPrice(coupon.getCouponPreferentialAmount()); |
| | | |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(driver.getCouponBalance()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(7); |
| | | accountChangeDetail.setOrderId(order.getId()); |
| | | accountChangeDetail.setExplain("优惠券收入"); |
| | | driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount()); |
| | | accountChangeDetail.setNewData(driver.getCouponBalance()); |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | } |
| | | } |
| | | |
| | |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(couponId); |
| | | if(userToCoupon.getValidCount() > 0){ |
| | | userToCoupon.setValidCount(userToCoupon.getValidCount() - 1); |
| | | userToCouponService.updateById(userToCoupon); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | payMoney = payMoney - coupon.getCouponPreferentialAmount(); |
| | | order.setCouponId(coupon.getId()); |
| | |
| | | this.updateById(order); |
| | | return ResultUtil.success(payCode); |
| | | |
| | | // TODO: 2023/5/18 取消支付后需要处理优惠券数据回退 |
| | | // |
| | | // |
| | | // new Thread(new Runnable() { |
| | |
| | | List<PlatformRechargeRecord> platformRechargeRecords = platformRechargeRecordService.selectList(new EntityWrapper<PlatformRechargeRecord>().eq("state", 2).last(" and balance > 0 order by payTime")); |
| | | Double discountedPrice = order.getDiscountedPrice(); |
| | | Driver driver = driverService.selectById(order.getDriverId()); |
| | | |
| | | UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId()); |
| | | Coupon coupon = couponService.selectById(userToCoupon.getCouponId()); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(order.getDriverId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setOldData(driver.getCouponBalance()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(7); |
| | | accountChangeDetail.setOrderId(order.getId()); |
| | | accountChangeDetail.setExplain("优惠券收入"); |
| | | driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount()); |
| | | accountChangeDetail.setNewData(driver.getCouponBalance()); |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.insert(accountChangeDetail); |
| | | |
| | | |
| | | for (PlatformRechargeRecord platformRechargeRecord : platformRechargeRecords) { |
| | | if(discountedPrice == 0){ |
| | | break; |
| | |
| | | notInvoiceOrder.setPageNum((notInvoiceOrder.getPageNum() - 1) * notInvoiceOrder.getPageSize());; |
| | | return this.baseMapper.queryNotInvoiceOrder(uid, notInvoiceOrder); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.UserToCouponMapper; |
| | | import com.supersavedriving.user.modular.system.model.Coupon; |
| | |
| | | public Integer queryUsedCouponNum(Integer uid) { |
| | | return this.baseMapper.queryUsedCouponNum(uid); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除优惠券 |
| | | */ |
| | | @Override |
| | | public void delUserCoupon() { |
| | | List<UserToCoupon> userToCoupons = this.selectList(new EntityWrapper<UserToCoupon>().eq("status", 1).last(" and UNIX_TIMESTAMP(expireTime) + 1296000 <= UNIX_TIMESTAMP(now())")); |
| | | for (UserToCoupon userToCoupon : userToCoupons) { |
| | | userToCoupon.setStatus(3); |
| | | this.updateById(userToCoupon); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.supersavedriving.user.modular.system.util; |
| | | |
| | | |
| | | import com.supersavedriving.user.modular.system.service.IUserToCouponService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | /** |
| | | * 定时任务工具类 |
| | | */ |
| | | @Component |
| | | public class TaskUtil { |
| | | |
| | | @Autowired |
| | | private IUserToCouponService userToCouponService; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 |
| | | */ |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void taskMinute(){ |
| | | try { |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 每天的凌晨执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void taskDay(){ |
| | | try { |
| | | userToCouponService.delUserCoupon(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 每月1日凌晨执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 1 * *") |
| | | public void taskMonth1(){ |
| | | try { |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 每月16日凌晨执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 16 * *") |
| | | public void taskMonth16(){ |
| | | try { |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | private Double actualMileage; |
| | | @ApiModelProperty("行驶时间(分钟)") |
| | | private Integer travelTime; |
| | | @ApiModelProperty("终点地址") |
| | | private String endAddress; |
| | | @ApiModelProperty("终点纬度") |
| | | private String endLat; |
| | | @ApiModelProperty("终点经度") |
| | | private String endLng; |
| | | @ApiModelProperty("101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中") |
| | | private Integer state; |
| | | } |
| | |
| | | #redisÅäÖÿªÊ¼ |
| | | # RedisÊý¾Ý¿âË÷Òý£¨Ä¬ÈÏΪ0£© |
| | | spring.redis.database=0 |
| | | ## Redis·þÎñÆ÷µØÖ· |
| | | #spring.redis.host=127.0.0.1 |
| | | ### Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | #spring.redis.port=16379 |
| | | ### Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | #spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ |
| | | |
| | | ## Redis·þÎñÆ÷µØÖ· |
| | | #spring.redis.host=127.0.0.1 |
| | | ## Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | #spring.redis.port=16379 |
| | | ## Redis·þÎñÆ÷Á¬½ÓÃÜÂ루ĬÈÏΪ¿Õ£© |
| | | #spring.redis.password=cKsEeyffDXG5PzNg8CIbrWxFluXrCprZ |
| | | |
| | | # Redis·þÎñÆ÷µØÖ· |
| | | spring.redis.host=127.0.0.1 |
| | | # Redis·þÎñÆ÷Á¬½Ó¶Ë¿Ú |
| | | spring.redis.port=6379 |