From 9308ec4dcadc96f4d93541148fa844cfcc70c762 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 18 五月 2023 16:44:54 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java | 87 +++++- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/UserToCouponServiceImpl.java | 33 ++ driver/guns-admin/src/main/resources/redis.properties | 18 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/CouponServiceImpl.java | 11 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml | 11 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java | 2 driver/guns-admin/src/main/resources/application.yml | 12 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/CouponMapper.java | 7 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/CouponMapper.xml | 23 + user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml | 2 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IUserToCouponService.java | 24 + driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Coupon.java | 95 +++++++ driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java | 2 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/UserToCouponMapper.xml | 44 +++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java | 96 ++++++- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java | 71 +++++ driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java | 19 + driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverRegisterWarpper.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java | 6 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java | 2 driver/guns-admin/src/test/java/com/supersavedriving/driver/GunsApplicationTest.java | 8 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java | 3 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/UserToCouponMapper.java | 27 ++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml | 2 user/guns-admin/src/main/resources/redis.properties | 13 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java | 4 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java | 6 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/UserToCoupon.java | 65 +++++ user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java | 14 + driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java | 14 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java | 8 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java | 2 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java | 4 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/ICouponService.java | 7 user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 4 driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml | 2 38 files changed, 675 insertions(+), 79 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java index ba6a17e..c1e2a4a 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/DriverController.java @@ -1,6 +1,7 @@ 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; @@ -161,8 +162,9 @@ @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")); } @@ -170,6 +172,21 @@ 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分钟有效期 diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java index 4a08e12..559ced8 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java @@ -26,6 +26,8 @@ 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; @@ -382,10 +384,11 @@ @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")); } @@ -397,7 +400,7 @@ 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(); @@ -447,8 +450,9 @@ @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; diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/CouponMapper.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/CouponMapper.java new file mode 100644 index 0000000..59ca740 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/CouponMapper.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/UserToCouponMapper.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/UserToCouponMapper.java new file mode 100644 index 0000000..595fb18 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/UserToCouponMapper.java @@ -0,0 +1,27 @@ +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); + + + +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml index 68accb2..711b5dc 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/AccountChangeDetailMapper.xml @@ -70,7 +70,7 @@ 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"> diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/CouponMapper.xml b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/CouponMapper.xml new file mode 100644 index 0000000..f880498 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/CouponMapper.xml @@ -0,0 +1,23 @@ +<?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> \ No newline at end of file diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml index e05ff23..fffe477 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/OrderMapper.xml @@ -70,8 +70,8 @@ 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, @@ -97,8 +97,8 @@ 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, @@ -109,6 +109,7 @@ a.endLng, a.estimatedPrice, a.estimatedMileage, + a.estimatedTime, a.startPrice, a.waitTime, a.actualMileage, @@ -190,7 +191,7 @@ 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} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/UserToCouponMapper.xml b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/UserToCouponMapper.xml new file mode 100644 index 0000000..505bbad --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/dao/mapping/UserToCouponMapper.xml @@ -0,0 +1,44 @@ +<?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> \ No newline at end of file diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Coupon.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Coupon.java new file mode 100644 index 0000000..5b2ada5 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/Coupon.java @@ -0,0 +1,95 @@ +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; +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/UserToCoupon.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/UserToCoupon.java new file mode 100644 index 0000000..07c78fd --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/model/UserToCoupon.java @@ -0,0 +1,65 @@ +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; +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/ICouponService.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/ICouponService.java new file mode 100644 index 0000000..f0fba9a --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/ICouponService.java @@ -0,0 +1,7 @@ +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> { +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java index e989838..5df2f51 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IOrderService.java @@ -153,7 +153,7 @@ * @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; /** diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IUserToCouponService.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IUserToCouponService.java new file mode 100644 index 0000000..f97f314 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/IUserToCouponService.java @@ -0,0 +1,24 @@ +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; + + +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/CouponServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/CouponServiceImpl.java new file mode 100644 index 0000000..c79d8d0 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/CouponServiceImpl.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java index 506c1d4..04833ee 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverServiceImpl.java @@ -179,6 +179,7 @@ driver.setApprovalTime(null); driver.setApprovalUserId(null); driver.setStatus(1); + driver.setSource(driverRegisterWarpper.getSource()); return driver; } @@ -545,7 +546,7 @@ 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){ diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java index 69279ab..8484b7d 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/DriverWorkServiceImpl.java @@ -66,7 +66,7 @@ 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) + "分钟后重试"); } } diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java index 0b943a8..797f285 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/OrderServiceImpl.java @@ -13,12 +13,8 @@ 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; @@ -93,6 +89,12 @@ @Autowired private IRevenueService revenueService; + + @Autowired + private ICouponService couponService; + + @Autowired + private IUserToCouponService userToCouponService; private Map<String, Timer> timerMap = new HashMap<>(); @@ -580,7 +582,7 @@ 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) { @@ -591,8 +593,10 @@ 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()); @@ -635,7 +639,7 @@ redisUtil.unlock(); return ResultUtil.error("订单已被取消"); } - if(state != 101){ + if(state != 101 && state != 201){ redisUtil.unlock(); return ResultUtil.error("手速慢了哦"); } @@ -650,6 +654,7 @@ if(null != order.getUserId()){ AppUser appUser = appUserService.selectById(order.getUserId()); appUser.setCancelCount(0); + appUser.setIsException(1); appUserService.updateById(appUser); } @@ -758,6 +763,10 @@ } if(order.getState() == 201){ return ResultUtil.error("订单正在转单中"); + } + if(order.getState() == 301){ + redisUtil.unlock(); + return ResultUtil.error("订单已被取消"); } order.setState(processOperationsWarpper.getState()); switch (processOperationsWarpper.getState()){ @@ -928,10 +937,16 @@ 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); @@ -1073,6 +1088,8 @@ driver.setServerStatus(1); driverService.updateById(driver); } + + pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getStatus()); return ResultUtil.success(); } @@ -1122,17 +1139,59 @@ * @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); @@ -1211,9 +1270,9 @@ //开始处理层级抽佣 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"); @@ -1505,9 +1564,9 @@ @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++) { diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/UserToCouponServiceImpl.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/UserToCouponServiceImpl.java new file mode 100644 index 0000000..62b0a12 --- /dev/null +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/service/impl/UserToCouponServiceImpl.java @@ -0,0 +1,33 @@ +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); + } + +} diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java index c0285b6..4ef0f94 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverInfoWarpper.java @@ -23,6 +23,8 @@ private Long youTuiEnd; @ApiModelProperty("账户余额") private Double balance; + @ApiModelProperty("可提现余额") + private Double withdrawBalance; @ApiModelProperty("佣金余额") private Double commission; @ApiModelProperty("积分") diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverRegisterWarpper.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverRegisterWarpper.java index 94dc1e9..ff93e22 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverRegisterWarpper.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/warpper/DriverRegisterWarpper.java @@ -32,4 +32,6 @@ private Integer inviterType; @ApiModelProperty(value = "邀约人Id", required = false, dataType = "int") private Integer inviterId; + @ApiModelProperty(value = "注册来源(1=司机端注册,2=其他端注册)", required = true, dataType = "int") + private Integer source; } diff --git a/driver/guns-admin/src/main/resources/application.yml b/driver/guns-admin/src/main/resources/application.yml index d4439eb..4e25aeb 100644 --- a/driver/guns-admin/src/main/resources/application.yml +++ b/driver/guns-admin/src/main/resources/application.yml @@ -13,8 +13,8 @@ application: name: driver-server profiles: - active: dev -# active: produce +# active: dev + active: produce mvc: static-path-pattern: /static/** view: @@ -55,8 +55,8 @@ 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 @@ -116,8 +116,8 @@ 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 --- diff --git a/driver/guns-admin/src/main/resources/redis.properties b/driver/guns-admin/src/main/resources/redis.properties index c3f1494..726be87 100644 --- a/driver/guns-admin/src/main/resources/redis.properties +++ b/driver/guns-admin/src/main/resources/redis.properties @@ -2,19 +2,19 @@ # 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 diff --git a/driver/guns-admin/src/test/java/com/supersavedriving/driver/GunsApplicationTest.java b/driver/guns-admin/src/test/java/com/supersavedriving/driver/GunsApplicationTest.java index 639e49a..56d50ff 100644 --- a/driver/guns-admin/src/test/java/com/supersavedriving/driver/GunsApplicationTest.java +++ b/driver/guns-admin/src/test/java/com/supersavedriving/driver/GunsApplicationTest.java @@ -2,7 +2,9 @@ // //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; @@ -18,11 +20,11 @@ //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); // } //} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java index 3fcf80f..77ec4cf 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java @@ -112,7 +112,7 @@ @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"), @@ -553,7 +553,7 @@ 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); diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java index 8e03a30..9436e1b 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/BroadcastController.java @@ -39,7 +39,9 @@ }) 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()); diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java index 5b37b5e..5f499ee 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/OrderController.java @@ -241,8 +241,8 @@ @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.....") @@ -611,4 +611,8 @@ return new ResponseWarpper(500, e.getMessage()); } } + + + + } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml index b164791..14b1f47 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/CommercialMapper.xml @@ -30,7 +30,7 @@ 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> diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml index 5885545..be52de2 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/dao/mapping/OrderMapper.xml @@ -80,7 +80,7 @@ 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, diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java index 0320c9d..50486e7 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IOrderService.java @@ -149,4 +149,6 @@ * @throws Exception */ List<OrderListWarpper> queryNotInvoiceOrder(Integer uid, NotInvoiceOrder notInvoiceOrder) throws Exception; + + } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java index cd6adaf..4e071cf 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/IUserToCouponService.java @@ -52,4 +52,10 @@ * @return */ Integer queryUsedCouponNum(Integer uid); + + + /** + * 删除优惠券数据 + */ + void delUserCoupon(); } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java index 7264bc4..9db79f1 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java @@ -128,6 +128,7 @@ 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; @@ -204,7 +205,8 @@ * @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(); diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java index 9301de9..2432a2f 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/ComplaintServiceImpl.java @@ -43,6 +43,6 @@ complaint.setState(1); complaint.setStatus(1); complaint.setCreateTime(new Date()); - this.updateById(complaint); + this.insert(complaint); } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java index c2f51f8..cb78e30 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/DriverServiceImpl.java @@ -1,5 +1,6 @@ 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; @@ -64,6 +65,7 @@ // 构造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) { diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java index fd6c398..af5bc2e 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java @@ -431,6 +431,9 @@ 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()); @@ -439,6 +442,7 @@ driverService.updateById(driver); appUser.setCancelCount(0); + appUser.setIsException(1); appUserService.updateById(appUser); } @@ -631,6 +635,9 @@ 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){ @@ -710,6 +717,14 @@ 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(); } @@ -725,20 +740,24 @@ 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; } @@ -758,6 +777,8 @@ 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); @@ -766,7 +787,6 @@ //先算优惠券 Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney); if(null != coupon && null == couponId){ - orderMoney = orderMoney - coupon.getCouponPreferentialAmount(); orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount()); orderPriceWarpper.setCouponId(coupon.getId()); } @@ -777,10 +797,10 @@ 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); @@ -859,10 +879,12 @@ 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); @@ -924,10 +946,27 @@ 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); } } @@ -987,6 +1026,7 @@ 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()); @@ -1054,6 +1094,7 @@ this.updateById(order); return ResultUtil.success(payCode); + // TODO: 2023/5/18 取消支付后需要处理优惠券数据回退 // // // new Thread(new Runnable() { @@ -1237,6 +1278,25 @@ 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; @@ -1661,4 +1721,6 @@ notInvoiceOrder.setPageNum((notInvoiceOrder.getPageNum() - 1) * notInvoiceOrder.getPageSize());; return this.baseMapper.queryNotInvoiceOrder(uid, notInvoiceOrder); } + + } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java index 1665047..c3b7696 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/UserToCouponServiceImpl.java @@ -1,5 +1,6 @@ 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; @@ -62,4 +63,17 @@ 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); + } + } } diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java new file mode 100644 index 0000000..00e6ee1 --- /dev/null +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/TaskUtil.java @@ -0,0 +1,71 @@ +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(); + } + } +} diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java index ccff87c..dc76e72 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/warpper/PushOrderInfoWarpper.java @@ -19,6 +19,12 @@ 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; } diff --git a/user/guns-admin/src/main/resources/redis.properties b/user/guns-admin/src/main/resources/redis.properties index 8e63a9f..8386340 100644 --- a/user/guns-admin/src/main/resources/redis.properties +++ b/user/guns-admin/src/main/resources/redis.properties @@ -1,14 +1,15 @@ #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 -- Gitblit v1.7.1