提交 5d414318 作者: 张小凤

Demand(update)

上级 65a7a9a2
...@@ -406,6 +406,7 @@ public enum ResultEnum implements BaseErrorInfoInterface { ...@@ -406,6 +406,7 @@ public enum ResultEnum implements BaseErrorInfoInterface {
THE_TOKEN_CANNOT_BE_NULL("2018", "token不能为null"), THE_TOKEN_CANNOT_BE_NULL("2018", "token不能为null"),
THE_CURRENT_ACCOUNT_CANNOT_PLACE_ORDERS("2019", "后台管理账号不能下单"), THE_CURRENT_ACCOUNT_CANNOT_PLACE_ORDERS("2019", "后台管理账号不能下单"),
NO_PAYMENT_REQUIRED("20021","自己发布的需求无需支付"), NO_PAYMENT_REQUIRED("20021","自己发布的需求无需支付"),
THE_CURRENT_DEMAND_IS_PAID("200022","当前需求已支付,无需重复支付"),
THIRD_PARTY_ERRORS("2020","第三方接口错误或者第三接口正在更新"); THIRD_PARTY_ERRORS("2020","第三方接口错误或者第三接口正在更新");
/** /**
......
...@@ -60,4 +60,17 @@ public class DemandReleaseOrderController extends BaseController { ...@@ -60,4 +60,17 @@ public class DemandReleaseOrderController extends BaseController {
} }
@ApiOperation(value = "获取发布者的电话")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/getPublishPhone")
public ResultBody getPublishPhone(@RequestBody @Validated CommonPaymentVO commonPaymentVO, HttpServletRequest request) {
return releaseOrderService.getPublishPhone(commonPaymentVO, request,this.getCurrentAccount(request).getUserAccountId());
}
} }
package com.mmc.oms.dao.demand; package com.mmc.oms.dao.demand;
import com.mmc.oms.entity.demand.DemandReleaseOrderDO; import com.mmc.oms.entity.demand.DemandReleaseOrderDO;
import com.mmc.oms.model.vo.demand.UserPayInfoVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
...@@ -15,4 +16,8 @@ public interface DemandReleaseOrderDao { ...@@ -15,4 +16,8 @@ public interface DemandReleaseOrderDao {
void addRequirementsInfo(DemandReleaseOrderDO requirementsInfoDO); void addRequirementsInfo(DemandReleaseOrderDO requirementsInfoDO);
DemandReleaseOrderDO orderPayment(String orderNumber); DemandReleaseOrderDO orderPayment(String orderNumber);
void updateOrderDemand(DemandReleaseOrderDO releaseOrderDO);
DemandReleaseOrderDO selectPhone(String orderNumber);
} }
...@@ -5,6 +5,7 @@ import com.mmc.oms.common.publicinterface.Insert; ...@@ -5,6 +5,7 @@ import com.mmc.oms.common.publicinterface.Insert;
import com.mmc.oms.common.publicinterface.Update; import com.mmc.oms.common.publicinterface.Update;
import com.mmc.oms.model.vo.demand.DemandReleaseOrderVO; import com.mmc.oms.model.vo.demand.DemandReleaseOrderVO;
import com.mmc.oms.model.vo.demand.OrderRequestParamsVO; import com.mmc.oms.model.vo.demand.OrderRequestParamsVO;
import com.mmc.oms.model.vo.demand.UserPayInfoVO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -84,9 +85,16 @@ public class DemandReleaseOrderDO implements Serializable { ...@@ -84,9 +85,16 @@ public class DemandReleaseOrderDO implements Serializable {
@ApiModelProperty(value = "应支付金额 单位元", example = "1.00") @ApiModelProperty(value = "应支付金额 单位元", example = "1.00")
private BigDecimal paramMoney; private BigDecimal paramMoney;
@ApiModelProperty(value = "实际支付金额 单位元", example = "1.00")
private BigDecimal practicalMoney;
@ApiModelProperty(value = "发布者id", example = "1", required = true) @ApiModelProperty(value = "发布者id", example = "1", required = true)
private Integer publishAccountId; private Integer publishAccountId;
@ApiModelProperty(value = "需求发布id",required = true)
private Integer requirementsInfoId;
public DemandReleaseOrderDO(DemandReleaseOrderVO requirementsInfoVO) { public DemandReleaseOrderDO(DemandReleaseOrderVO requirementsInfoVO) {
this.requirementTypeId = requirementsInfoVO.getRequirementTypeId(); this.requirementTypeId = requirementsInfoVO.getRequirementTypeId();
this.requirementTypeName=requirementsInfoVO.getRequirementTypeName(); this.requirementTypeName=requirementsInfoVO.getRequirementTypeName();
...@@ -104,8 +112,17 @@ public class DemandReleaseOrderDO implements Serializable { ...@@ -104,8 +112,17 @@ public class DemandReleaseOrderDO implements Serializable {
this.orderNumber=requirementsInfoVO.getOrderNumber(); this.orderNumber=requirementsInfoVO.getOrderNumber();
this.paramMoney=requirementsInfoVO.getParamMoney(); this.paramMoney=requirementsInfoVO.getParamMoney();
this.publishAccountId=requirementsInfoVO.getPublishAccountId(); this.publishAccountId=requirementsInfoVO.getPublishAccountId();
this.requirementsInfoId=requirementsInfoVO.getRequirementsInfoId();
} }
public DemandReleaseOrderDO(UserPayInfoVO userPayInfoVO,BigDecimal divide) {
this.orderNumber = userPayInfoVO.getOutTradeNo();
this.practicalMoney=divide;
this.userAccountId=userPayInfoVO.getUserAccountId();
}
public OrderRequestParamsVO buildOrderRequestParamsVO() { public OrderRequestParamsVO buildOrderRequestParamsVO() {
return OrderRequestParamsVO.builder().orderNo(this.orderNumber).description(this.requireDescription). return OrderRequestParamsVO.builder().orderNo(this.orderNumber).description(this.requireDescription).
orderPort(3) orderPort(3)
......
...@@ -21,6 +21,8 @@ import java.util.Date; ...@@ -21,6 +21,8 @@ import java.util.Date;
public class DemandReleaseOrderVO { public class DemandReleaseOrderVO {
private static final long serialVersionUID = -447951390213113317L; private static final long serialVersionUID = -447951390213113317L;
@ApiModelProperty(value = "需求发布id",required = true)
private Integer requirementsInfoId;
@ApiModelProperty(value = "需求类型id", example = "1", required = true) @ApiModelProperty(value = "需求类型id", example = "1", required = true)
private Integer requirementTypeId; private Integer requirementTypeId;
......
package com.mmc.oms.model.vo.demand;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author small
* @Date 2023/7/26 17:34
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PublisherPhoneVO {
@ApiModelProperty(value = "发布者电话", example = "1892994543", required = true)
private String publishPhone;
}
package com.mmc.oms.model.vo.demand;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Author small
* @Date 2023/7/26 17:49
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserPayInfoVO {
@ApiModelProperty("订单号")
private String outTradeNo;
@ApiModelProperty("支付成功时间")
private String successTime;
@ApiModelProperty("用户支付金额")
private Integer wxNotifyPayerTotal;
@ApiModelProperty("交易状态")
private String tradeState;
@ApiModelProperty("用户id")
private Integer userAccountId;
}
...@@ -17,4 +17,6 @@ public interface DemandReleaseOrderService { ...@@ -17,4 +17,6 @@ public interface DemandReleaseOrderService {
ResultBody orderPayment(CommonPaymentVO commonPaymentVO, HttpServletRequest request, Integer userAccountId); ResultBody orderPayment(CommonPaymentVO commonPaymentVO, HttpServletRequest request, Integer userAccountId);
ResultBody getPublishPhone(CommonPaymentVO commonPaymentVO, HttpServletRequest request, Integer userAccountId);
} }
package com.mmc.oms.service.demand.Impl; package com.mmc.oms.service.demand.Impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mmc.oms.common.RedisConstant;
import com.mmc.oms.common.ResultEnum; import com.mmc.oms.common.ResultEnum;
import com.mmc.oms.common.json.JsonUtil;
import com.mmc.oms.common.result.ResultBody; import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.dao.demand.DemandReleaseOrderDao; import com.mmc.oms.dao.demand.DemandReleaseOrderDao;
import com.mmc.oms.entity.demand.DemandReleaseOrderDO; import com.mmc.oms.entity.demand.DemandReleaseOrderDO;
import com.mmc.oms.model.dto.mall.ProductSpecPriceDTO;
import com.mmc.oms.model.dto.order.OrderInfoDTO;
import com.mmc.oms.model.vo.demand.CommonPaymentVO; import com.mmc.oms.model.vo.demand.CommonPaymentVO;
import com.mmc.oms.model.vo.demand.DemandReleaseOrderVO; import com.mmc.oms.model.vo.demand.DemandReleaseOrderVO;
import com.mmc.oms.model.vo.demand.OrderRequestParamsVO; import com.mmc.oms.model.vo.demand.OrderRequestParamsVO;
import com.mmc.oms.model.vo.demand.UserPayInfoVO;
import com.mmc.oms.service.demand.DemandReleaseOrderService; import com.mmc.oms.service.demand.DemandReleaseOrderService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -38,6 +47,9 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService ...@@ -38,6 +47,9 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
@Value("${payment.url}") @Value("${payment.url}")
private String paymentUrl; private String paymentUrl;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override @Override
public ResultBody publish(DemandReleaseOrderVO demandReleaseOrderVO, HttpServletRequest request) { public ResultBody publish(DemandReleaseOrderVO demandReleaseOrderVO, HttpServletRequest request) {
DemandReleaseOrderDO requirementsInfoDO = new DemandReleaseOrderDO(demandReleaseOrderVO); DemandReleaseOrderDO requirementsInfoDO = new DemandReleaseOrderDO(demandReleaseOrderVO);
...@@ -56,6 +68,10 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService ...@@ -56,6 +68,10 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
int i = multiply.intValue(); int i = multiply.intValue();
OrderRequestParamsVO orderRequestParamsVO = demandReleaseOrderDO.buildOrderRequestParamsVO(); OrderRequestParamsVO orderRequestParamsVO = demandReleaseOrderDO.buildOrderRequestParamsVO();
orderRequestParamsVO.setAmount(i); orderRequestParamsVO.setAmount(i);
BigDecimal practicalMoney = demandReleaseOrderDO.getPracticalMoney();
if (practicalMoney!=null){
return ResultBody.error(ResultEnum.THE_CURRENT_DEMAND_IS_PAID);
}
if (i!=0){ if (i!=0){
return releaseOrder(orderRequestParamsVO, token); return releaseOrder(orderRequestParamsVO, token);
}else if(i==0){ }else if(i==0){
...@@ -65,6 +81,28 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService ...@@ -65,6 +81,28 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
return ResultBody.success(); return ResultBody.success();
} }
@Override
public ResultBody getPublishPhone(CommonPaymentVO commonPaymentVO, HttpServletRequest request, Integer userAccountId) {
String token = request.getHeader("token");
HttpHeaders headers = new HttpHeaders();
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(null, headers);
ResponseEntity<UserPayInfoVO> exchange = restTemplate.exchange(paymentUrl + "/wechat/queryUserPayInfo" + "?orderNo=" + commonPaymentVO.getOrderNumber(), HttpMethod.GET, entity, UserPayInfoVO.class);
UserPayInfoVO body = exchange.getBody();
if ( body.getWxNotifyPayerTotal()!=null){
BigDecimal divide = BigDecimal.valueOf(Long.valueOf(body.getWxNotifyPayerTotal())).divide(new BigDecimal(100));
DemandReleaseOrderDO requirementsInfoDO = new DemandReleaseOrderDO(body,divide);
releaseOrderDao.updateOrderDemand(requirementsInfoDO);
DemandReleaseOrderDO demandReleaseOrderDO = releaseOrderDao.selectPhone(requirementsInfoDO.getOrderNumber());
stringRedisTemplate.opsForValue().set(demandReleaseOrderDO.getRequirementsInfoId().toString(), JsonUtil.parseObjToJson(demandReleaseOrderDO));
return ResultBody.success(demandReleaseOrderDO.getPublishPhone());
}
return ResultBody.success();
}
public ResultBody releaseOrder(OrderRequestParamsVO orderRequestParamsVO, String token) { public ResultBody releaseOrder(OrderRequestParamsVO orderRequestParamsVO, String token) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
......
...@@ -10,14 +10,31 @@ ...@@ -10,14 +10,31 @@
INSERT INTO demand_release_order(requirement_type_id, user_account_id, publish_name, publish_phone,publish_account_id, INSERT INTO demand_release_order(requirement_type_id, user_account_id, publish_name, publish_phone,publish_account_id,
require_description, create_time, require_description, create_time,
update_time, task_title, task_start_time, task_end_time, task_address, longitude, update_time, task_title, task_start_time, task_end_time, task_address, longitude,
latitude, require_url,order_number,param_money,requirement_type_name) latitude, require_url,order_number,param_money,requirement_type_name,requirements_info_id)
VALUES (#{requirementTypeId}, #{userAccountId}, #{publishName}, #{publishPhone},#{publishAccountId}, VALUES (#{requirementTypeId}, #{userAccountId}, #{publishName}, #{publishPhone},#{publishAccountId},
#{requireDescription}, NOW(), #{requireDescription}, NOW(),
NOW(), #{taskTitle}, #{taskStartTime}, #{taskEndTime}, #{taskAddress}, #{longitude}, NOW(), #{taskTitle}, #{taskStartTime}, #{taskEndTime}, #{taskAddress}, #{longitude},
#{latitude}, #{requireUrl},#{orderNumber},#{paramMoney},#{requirementTypeName}); #{latitude}, #{requireUrl},#{orderNumber},#{paramMoney},#{requirementTypeName},#{requirementsInfoId});
</insert> </insert>
<select id="orderPayment" resultType="com.mmc.oms.entity.demand.DemandReleaseOrderDO"> <select id="orderPayment" resultType="com.mmc.oms.entity.demand.DemandReleaseOrderDO">
select * from demand_release_order where order_number=#{orderNumber} select * from demand_release_order where order_number=#{orderNumber}
</select> </select>
<update id="updateOrderDemand" parameterType="com.mmc.oms.entity.demand.DemandReleaseOrderDO">
UPDATE demand_release_order
<set>
<if test="userAccountId != null">
user_account_id = #{userAccountId},
</if>
<if test="practicalMoney != null">
practical_money = #{practicalMoney},
</if>
</set>
WHERE order_number = #{orderNumber}
</update>
<select id="selectPhone" resultType="com.mmc.oms.entity.demand.DemandReleaseOrderDO">
select publish_phone,requirements_info_id,user_account_id,order_number from demand_release_order where order_number = #{orderNumber}
</select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论