提交 f110ace0 作者: 张小凤

RequirementsDao(update)

上级 fbe9b7bd
package com.mmc.csf.infomation.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/8/28 14:47
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FlyHandAgreeVO {
@ApiModelProperty(value = "需求id", example = "1")
@NotNull(message = "需求id不能为空")
private Integer requirementsInfoId;
@ApiModelProperty(value = "用户ID", hidden = true)
private Integer userAccountId;
}
......@@ -6,6 +6,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
......@@ -26,15 +27,21 @@ public class RequirementsAmountVO {
@ApiModelProperty(value = "修改任务佣金", example = "900")
private BigDecimal updateOrderAmount;
@ApiModelProperty(value = "需求id", example = "需求id")
@ApiModelProperty(value = "需求id", example = "1")
@NotNull(message = "需求id不能为空")
private Integer requirementsInfoId;
@ApiModelProperty(value = "用户id", example = "用户id")
@ApiModelProperty(value = "用户id", example = "用户id", hidden = true)
private Integer userAccountId;
@ApiModelProperty(value = "原因", example = "原因")
private String reason;
@ApiModelProperty(value = "图片地址", example = "http://")
private String url;
@ApiModelProperty(value = "支付方式,云享金:1,佣金:2,微信支付:3", example = "1,2,3", required = true)
private String paymentType;
@ApiModelProperty(value = "修改后微信支付订单编号")
private String wechatPayOrderNumber;
}
/*
package com.mmc.csf.release.config;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
*/
/**
* @Author small
* @Date 2023/8/22 10:56
* @Version 1.0
* <p>
* 倒计时
* @param arg
* @throws ParseException
*//*
public class CountDownConfig {
public static int time = 60 * 60 * 60;
public static Calendar c;
public static long endTime;
public static Date date;
public static long startTime;
public static long midTime;
*/
/**
* 倒计时
*
* @param arg
* @throws ParseException
*//*
public static void main(String[] arg) throws ParseException {
Long beforTime = System.currentTimeMillis();
Long afterTime = beforTime + 3600 * 1000;
midTime = (afterTime - beforTime) / 1000;
time2();
}
*/
/*
* 方法二:设定时间戳,倒计时
*//*
private static void time2() {
while (midTime > 0) {
midTime--;
long h = midTime / 60 / 60 % 60;
long m = midTime / 60 % 60;
long s = midTime % 60;
System.out.println("还剩" + h + "小时" + m + "分钟" + s + "秒");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
*/
......@@ -279,6 +279,15 @@ public class RequirementsController extends BaseController {
return requirementsService.updatePublisherCancel(amountVO, request);
}
@ApiOperation(value = "new——小程序-—修改佣金后飞手确认结算")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("flyHandAgree")
public ResultBody flyHandAgree(HttpServletRequest request, @RequestBody FlyHandAgreeVO agreeVO) {
Integer userAccountId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
agreeVO.setUserAccountId(userAccountId);
return requirementsService.flyHandAgree(agreeVO, request);
}
@ApiOperation(value = "new--小程序——结算时修改任务佣金获取订单编号")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
......
package com.mmc.csf.release.controller.test;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* @Author small
* @Date 2023/8/28 16:32
* @Version 1.0
*/
@Slf4j
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory factory;
@Bean
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
return container;
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
}
package com.mmc.csf.release.controller.test;
import com.alibaba.fastjson.JSONObject;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.common.util.web.ResultEnum;
import com.mmc.csf.config.IsNullConvertZeroUtil;
import com.mmc.csf.infomation.vo.*;
import com.mmc.csf.release.dao.RequirementsDao;
import com.mmc.csf.release.entity.requirements.RequirementsInfoDO;
import com.mmc.csf.release.entity.requirements.RequirementsServiceDO;
import com.mmc.csf.release.entity.requirements.ServiceSettleAccountsDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
/**
* @Author small
* @Date 2023/8/28 16:31
* @Version 1.0
*/
@Transactional
@Component
@Slf4j
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {
@Autowired
private RestTemplate restTemplate;
@Value("${iuav.payment.url}")
private String paymentApp;
@Value("${iuav.userapp.url}")
private String userApp;
@Autowired
private RequirementsDao requirementsDao;
@Autowired
private StringRedisTemplate stringRedisTemplate;
public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
@Override
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
String prefix = "";
if (expiredKey.indexOf("_") != -1) {
prefix = expiredKey.substring(0, expiredKey.indexOf("_"));
}
//根据key的前缀判断是不是属于订单过期
if ("order".equals(prefix)) {
String orderId = expiredKey.substring(expiredKey.indexOf("_") + 1);
log.info("订单编号:{}已过期,开始处理==========", orderId);
RequirementsInfoDO requirementsInfoDO = requirementsDao.publisherOrderNumber(orderId);
System.out.println(requirementsInfoDO);
ResultBody resultBody = getResultBody(requirementsInfoDO);
}
}
private ResultBody getResultBody(RequirementsInfoDO infoDO) {
ServiceSettleAccountsVO settleAccountsVO = new ServiceSettleAccountsVO();
settleAccountsVO.setRequirementsInfoId(infoDO.getId());
// RequirementsInfoDO infoDO = requirementsDao.selectSettleAccounts(settleAccountsVO);
RequirementsServiceDO requirementsServiceDO = requirementsDao.serviceSettleAccounts(settleAccountsVO);
IsNullConvertZeroUtil.checkIsNull(infoDO);
IsNullConvertZeroUtil.checkIsNull(requirementsServiceDO);
ServiceSettleAccountsDO settleAccountsDO = new ServiceSettleAccountsDO(settleAccountsVO);
requirementsDao.settleAccounts(settleAccountsDO);
requirementsDao.updateScene(settleAccountsVO.getRequirementsInfoId(), 5);
requirementsDao.updateInfo(settleAccountsVO.getRequirementsInfoId(), 5);
//正常结算
WalletFlowVO walletFlowVO = new WalletFlowVO();
PublisherWalletFlowVO publisherWalletFlowVO = new PublisherWalletFlowVO();
FlyerWalletFlowVO flyerWalletFlowVO = new FlyerWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(publisherWalletFlowVO);
IsNullConvertZeroUtil.checkIsNull(flyerWalletFlowVO);
//给发布者发送
BigDecimal orderAmount = infoDO.getOrderAmount();
BigDecimal bigDecimal = new BigDecimal(0.9);
BigDecimal bigDecimal1 = orderAmount.multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
publisherWalletFlowVO.setModeOfPayment(700);
publisherWalletFlowVO.setFlyerSalaryAmount(bigDecimal1);
publisherWalletFlowVO.setCashAmount(infoDO.getCashAmount().negate());
publisherWalletFlowVO.setSalaryAmount(infoDO.getSalaryAmount().negate());
publisherWalletFlowVO.setUserAccountId(infoDO.getUserAccountId());
publisherWalletFlowVO.setOperateUserAccountId(0);
if ("TOP_ORDER".equals(infoDO.getOrderLevel())) {
publisherWalletFlowVO.setTopYxjAmount(infoDO.getLevelCashAmount().negate());
publisherWalletFlowVO.setTopSalaryAmount(infoDO.getLevelSalaryAmount().negate());
} else if ("RUSH_ORDER".equals(infoDO.getOrderLevel())) {
publisherWalletFlowVO.setUrgentYxjAmount(infoDO.getLevelCashAmount().negate());
publisherWalletFlowVO.setUrgentSalaryAmount(infoDO.getLevelSalaryAmount().negate());
}
//退飞手钱
flyerWalletFlowVO.setModeOfPayment(700);
flyerWalletFlowVO.setCashAmount(requirementsServiceDO.getCashAmount());
flyerWalletFlowVO.setSalaryAmount(requirementsServiceDO.getSalaryAmount());
flyerWalletFlowVO.setUserAccountId(requirementsServiceDO.getPilotCertificationUserId());
flyerWalletFlowVO.setOperateUserAccountId(0);
ApplyRefundVO applyRefundVO = new ApplyRefundVO();
if (requirementsServiceDO.getWeChat().compareTo(BigDecimal.ZERO) != 0) {
applyRefundVO.setReason("原路退回");
applyRefundVO.setOutTradeNo(requirementsServiceDO.getWechatPayOrderNumber());
BigDecimal weChat = requirementsServiceDO.getWeChat();
BigDecimal decimal = new BigDecimal(100);
long longValueWeChat = weChat.multiply(new BigDecimal(100)).longValue();
applyRefundVO.setRefund(longValueWeChat);
applyRefund(applyRefundVO, "");
}
walletFlowVO.setPublisherWalletFlowVO(publisherWalletFlowVO);
walletFlowVO.setFlyerWalletFlowVO(flyerWalletFlowVO);
flyerCancel(walletFlowVO, "");
return ResultBody.success();
}
/**
* 公共调用
*
* @param walletFlowVO
* @param token
* @return
*/
public ResultBody flyerCancel(WalletFlowVO walletFlowVO, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(walletFlowVO), headers);
ResponseEntity<Object> exchange = null;
try {
exchange = restTemplate.exchange(userApp + "/userapp/pay/feignWalletFlow", HttpMethod.POST, entity, Object.class);
} catch (RestClientException e) {
return ResultBody.error(ResultEnum.THE_THIRD_PARTY_INTERFACE_IS_BEING_UPDATED);
}
return ResultBody.success();
}
/**
* 退款
*/
public ResultBody applyRefund(ApplyRefundVO applyRefundVO, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(applyRefundVO), headers);
ResponseEntity<Object> exchange = null;
try {
exchange = restTemplate.exchange(paymentApp + "/payment/wechat/feignApplyRefund", HttpMethod.POST, entity, Object.class);
} catch (RestClientException e) {
return ResultBody.error(ResultEnum.THE_THIRD_PARTY_INTERFACE_IS_BEING_UPDATED);
}
return ResultBody.success();
}
}
package com.mmc.csf.release.controller.test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* @Author small
* @Date 2023/8/28 16:35
* @Version 1.0
*/
@Component
public class RedisUtil {
private RedisTemplate<String, String> redisTemplate;
@Autowired
public RedisUtil(RedisTemplate<String, String> redisTemplate) {
this.redisTemplate = redisTemplate;
}
/**
* 读取缓存
*
* @param key
* @return
*/
public String get(final String key) {
return redisTemplate.opsForValue().get(key);
}
/**
* 写入缓存
*/
public boolean ins(final String key, String value, int time, TimeUnit unit) {
boolean result = false;
try {
redisTemplate.opsForValue().set(key, value, time, unit);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public boolean expire(String key, long time) {
try {
if (time > 0L) {
this.redisTemplate.expire(key, time, TimeUnit.SECONDS);
}
return true;
} catch (Exception var5) {
var5.printStackTrace();
return false;
}
}
/**
* 删除缓存
*/
public boolean delete(final String key) {
boolean result = false;
try {
redisTemplate.delete(key);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
......@@ -117,6 +117,8 @@ public interface RequirementsDao {
RequirementsInfoDO publisherCancel(Integer requirementsInfoId, Integer userAccountId);
RequirementsInfoDO publisherOrderNumber(String publisherNumber);
List<FlowDictionaryDO> flowDictionary();
void addAmount(RequirementsAmountDO requirementsAmountDO);
......@@ -152,6 +154,8 @@ public interface RequirementsDao {
RequirementsInfoDO selectSettleAccounts(ServiceSettleAccountsVO settleAccountsVO);
RequirementsInfoDO flyHandAgree(Integer requirementsInfoId);
RequirementsServiceDO serviceSettleAccounts(ServiceSettleAccountsVO settleAccountsVO);
void deletePublishService(Integer requirementsInfoId);
......@@ -160,4 +164,8 @@ public interface RequirementsDao {
void deletePreempt(Integer requirementsInfoId);
void requirementsAmountUpdate(RequirementsAmountUpdateDO amountUpdateDO);
RequirementsAmountUpdateDO selectAmountUpdate(Integer requirementsInfoId);
}
package com.mmc.csf.release.entity.requirements;
import com.mmc.csf.config.IsNullConvertZero;
import com.mmc.csf.infomation.vo.RequirementsAmountVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -17,14 +18,19 @@ import java.math.BigDecimal;
@AllArgsConstructor
@NoArgsConstructor
public class RequirementsAmountUpdateDO {
private Integer id;
@ApiModelProperty(value = "服务需求id", example = "1")
private Integer requirementTypeId;
private Integer requirementsInfoId;
@ApiModelProperty(value = "发布者修改后的订单金额", example = "100")
@ApiModelProperty(value = "发布者订单金额", example = "100")
@IsNullConvertZero
private BigDecimal orderAmount;
@ApiModelProperty(value = "发布者修改订单金额", example = "100")
@IsNullConvertZero
private BigDecimal updateOrderAmount;
@ApiModelProperty(value = "需要支付的云享金", example = "100")
@IsNullConvertZero
private BigDecimal cashAmount;
......@@ -38,8 +44,7 @@ public class RequirementsAmountUpdateDO {
private BigDecimal salaryAmount;
@ApiModelProperty(value = "微信支付的订单编号", example = "100")
@IsNullConvertZero
private BigDecimal wechatPayOrderNumber;
private String wechatPayOrderNumber;
@ApiModelProperty(value = "修改原因", example = "未按时完成任务")
private String reason;
......@@ -50,5 +55,27 @@ public class RequirementsAmountUpdateDO {
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "需要退回金额", example = "100")
@IsNullConvertZero
private BigDecimal returnCashAmount;
@ApiModelProperty(value = "需要退回微信金额")
@IsNullConvertZero
private BigDecimal returnWeChat;
@ApiModelProperty(value = "需要退回佣金")
@IsNullConvertZero
private BigDecimal returnSalaryAmount;
public RequirementsAmountUpdateDO(RequirementsAmountVO amountVO, RequirementsInfoDO requirementsInfoDO) {
this.updateOrderAmount = amountVO.getUpdateOrderAmount();
this.reason = amountVO.getReason();
this.url = amountVO.getUrl();
this.userAccountId = amountVO.getUserAccountId();
this.orderAmount = requirementsInfoDO.getOrderAmount();
this.requirementsInfoId = requirementsInfoDO.getId();
}
}
......@@ -121,4 +121,6 @@ public interface RequirementsService {
ResultBody deletePublishService(Integer requirementsInfoId, Integer userAccountId);
ResultBody deletePreempt(Integer requirementsInfoId, Integer userAccountId);
ResultBody flyHandAgree(FlyHandAgreeVO agreeVO, HttpServletRequest request);
}
......@@ -44,6 +44,41 @@
#{levelSalaryAmount});
</insert>
<insert id="requirementsAmountUpdate"
parameterType="com.mmc.csf.release.entity.requirements.RequirementsAmountUpdateDO"
keyProperty="id" useGeneratedKeys="true">
INSERT INTO requirements_amount_update(requirements_info_id, order_amount, cash_amount, we_chat, salary_amount,
wechat_pay_order_number, create_time, update_time, reason, url,
user_account_id, update_order_amount, return_cash_amount, return_we_chat,
return_salary_amount)
values (#{requirementsInfoId}, #{orderAmount}, #{cashAmount}, #{weChat}, #{salaryAmount},
#{wechatPayOrderNumber}, NOW(), NOW(), #{reason}, #{url},
#{userAccountId}, #{updateOrderAmount}, #{returnCashAmount}, #{returnWeChat},
#{returnSalaryAmount})
</insert>
<select id="selectAmountUpdate" resultType="com.mmc.csf.release.entity.requirements.RequirementsAmountUpdateDO">
SELECT id,
requirements_info_id,
order_amount,
cash_amount,
we_chat,
salary_amount,
wechat_pay_order_number,
create_time,
update_time,
reason,
url,
user_account_id,
service_flow_id,
update_order_amount,
return_cash_amount,
return_we_chat,
return_salary_amount
FROM requirements_amount_update
WHERE requirements_info_id = #{requirementsInfoId}
</select>
<update id="solveRequire">
update requirements_info
set is_solved = 1
......@@ -755,6 +790,56 @@
WHERE ri.user_account_id = #{userAccountId}
AND ri.id = #{requirementsInfoId}
</select>
<select id="publisherOrderNumber" resultType="com.mmc.csf.release.entity.requirements.RequirementsInfoDO">
SELECT ri.id,
ri.task_title,
ri.task_start_time,
ri.task_end_time,
ri.task_address,
ri.longitude,
ri.latitude,
ri.require_url,
ri.require_description,
ri.requirement_type_id,
ri.user_account_id,
rt.type_name AS requirementTypeName,
ri.publish_phone,
ri.publisher_number,
ri.service_id,
ra.total_amount,
ri.insurance,
ra.order_level,
ra.order_amount,
sf.doing,
sf.waiting,
sf.user_port,
sf.flyer_port,
sf.order_status,
ri.publish,
ra.order_amount,
ra.we_chat,
ra.salary_amount,
ra.cash_amount,
ra.level_cash_amount,
ra.level_salary_amount,
ra.level_we_chat_amount,
ra.wechat_pay_order_number,
ri.service_flow_id,
rs.pilot_certification_user_id,
rs.openid as flyerOpenid,
ri.create_time,
ra.order_level_amount
FROM requirements_info ri
LEFT JOIN requirements_type rt
ON rt.id = ri.requirement_type_id
LEFT JOIN service_flow sf ON sf.id = ri.service_flow_id
LEFT JOIN requirements_amount ra ON ra.requirements_info_id = ri.id
LEFT JOIN requirements_service rs ON rs.requirements_info_id = ri.id
WHERE ri.publisher_number = #{publisherNumber}
</select>
<select id="flowDictionary" resultType="com.mmc.csf.release.entity.requirements.FlowDictionaryDO">
SELECT id,
waiting,
......@@ -937,6 +1022,52 @@
WHERE ri.id = #{requirementsInfoId}
</select>
<select id="flyHandAgree" resultType="com.mmc.csf.release.entity.requirements.RequirementsInfoDO">
SELECT ri.id,
ri.task_title,
ri.task_start_time,
ri.task_end_time,
ri.task_address,
ri.longitude,
ri.latitude,
ri.require_url,
ri.require_description,
ri.requirement_type_id,
ri.user_account_id,
rt.type_name AS requirementTypeName,
ri.publish_phone,
ri.publisher_number,
ri.service_id,
ra.total_amount,
ri.insurance,
ra.order_level,
ra.order_amount,
sf.doing,
sf.waiting,
sf.user_port,
sf.flyer_port,
sf.order_status,
ri.publish,
ra.order_amount,
ra.we_chat,
ra.salary_amount,
ra.cash_amount,
ra.level_cash_amount,
ra.level_salary_amount,
ra.level_we_chat_amount,
ra.wechat_pay_order_number,
ri.service_flow_id,
ri.create_time,
ra.order_level_amount,
ra.update_order_amount
FROM requirements_info ri
LEFT JOIN requirements_type rt
ON rt.id = ri.requirement_type_id
LEFT JOIN service_flow sf ON sf.id = ri.service_flow_id
LEFT JOIN requirements_amount ra ON ra.requirements_info_id = ri.id
WHERE ri.id = #{requirementsInfoId}
</select>
<select id="serviceSettleAccounts" resultType="com.mmc.csf.release.entity.requirements.RequirementsServiceDO">
SELECT ri.id,
ri.task_title,
......@@ -964,7 +1095,8 @@
rs.salary_amount,
rs.we_chat,
rs.wechat_pay_order_number,
rs.preempt_total_amount
rs.preempt_total_amount,
rs.pilot_certification_user_id
FROM requirements_info ri
LEFT JOIN requirements_type rt ON rt.id = ri.requirement_type_id
LEFT JOIN service_flow sf ON sf.id = ri.service_flow_id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论