Skip to content

Commit

Permalink
订单支付
Browse files Browse the repository at this point in the history
  • Loading branch information
tendy committed Sep 26, 2017
1 parent 77fd2d0 commit cfbe41f
Show file tree
Hide file tree
Showing 31 changed files with 102 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/eroom/web/constants/PayConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public static class OrderState{
*/
public static final String FAIL = "04";
}

public static class Type{
public static final String ALIPAY = "alipay";
public static final String WECHAT = "wechat";
}
}

public static class RentOrder{
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/AccountBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public AccountBook(long custId, String bookItemId, BigDecimal totalAmount,

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "book_id", unique = true, nullable = false)
public Long getBookId() {
return this.bookId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public AccountBookDetail(long custId, long bookId, String inOutFlag, BigDecimal

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "book_detail_id", unique = true, nullable = false)
public Long getBookDetailId() {
return this.bookDetailId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class BaseCityBussiness {
private String bussinessName;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class BaseCityDistrict {
private String districtName;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/BaseCitySubway.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BaseCitySubway {
private Integer sortId;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "subway_id")
public long getSubwayId() {
return subwayId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class BaseProvinceCity {
private Byte cityLevel;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/BaseSubway.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class BaseSubway {
private int sysMuser;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class BaseSubwayStation {
private int sysMuser;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class BaseSubwayStationRel {
private int sysMuser;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
public long getId() {
return id;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/BedroomInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public BedroomInfo(long roomId, String space, String decorate, String imageUrl,

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "bedroom_id", unique = true, nullable = false)
public Long getBedroomId() {
return this.bedroomId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CmCust.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public CmCust(String address, String assetLevel, String assignSaleFlag, Date ass

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "cust_id", unique = true, nullable = false)
public Long getCustId() {
return this.custId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CmCustWx.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public CmCustWx(Long agentCustId, String agentFlag, String agentGroupNo, String

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "cust_id", unique = true, nullable = false)
public Long getCustId() {
return this.custId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CmCustWxExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public CmCustWxExt(long custId, String assetLevel, Date birthday, String cityCod
}

@Id

@Column(name = "cust_id", unique = true, nullable = false)
public long getCustId() {
return this.custId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CmImportLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public CmImportLog(String createStaffNo, Date createTime, String importFileName,

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "log_id", unique = true, nullable = false)
public Long getLogId() {
return this.logId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CustInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public CustInfo(String name, String phone, String qq, String wechat, String nick

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "cust_id", unique = true, nullable = false)
public Long getCustId() {
return this.custId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/CustRoomCollect.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public CustRoomCollect(long custId, long rentId, String state, Date createTime,

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "collect_id", unique = true, nullable = false)
public Long getCollectId() {
return this.collectId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/PayDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public PayDetail(long roomId, long custId, String type, BigDecimal amount, Date

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "pay_detail_id", unique = true, nullable = false)
public Long getPayDetailId() {
return this.payDetailId;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/PayOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class PayOrder {
private long rentId;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pay_order_id")
public long getPayOrderId() {
return payOrderId;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/eroom/web/entity/po/RentOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RentOrder {
private long rentOrderId;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@javax.persistence.Column(name = "rent_order_id")
public long getRentOrderId() {
return rentOrderId;
Expand Down Expand Up @@ -298,6 +299,18 @@ public void setPaidAmount(BigDecimal paidAmount) {
this.paidAmount = paidAmount;
}

private Date paidEndTime;

@Basic
@javax.persistence.Column(name = "paid_end_time")
public Date getPaidEndTime() {
return paidEndTime;
}

public void setPaidEndTime(Date paidEndTime) {
this.paidEndTime = paidEndTime;
}

@Override
public String toString() {
return "RentOrder{" +
Expand Down Expand Up @@ -325,6 +338,7 @@ public String toString() {
", payPhase=" + payPhase +
", totlePhase=" + totlePhase +
", paidAmount=" + paidAmount +
", paidEndTime=" + paidEndTime +
'}';
}
}
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/RentParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public RentParam(String paramCode, String paramSubType, String paramTitle, Strin

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "id", unique = true, nullable = false)
public Long getId() {
return this.id;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/RoomAssess.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class RoomAssess {
private String type;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "assess_id")
public long getAssessId() {
return assessId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/RoomBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public RoomBook(long rentId, long custRenterId, long custOwnerId, long roomId, L

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "book_id", unique = true, nullable = false)
public Long getBookId() {
return this.bookId;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/RoomInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class RoomInfo {
private long roomId;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@javax.persistence.Column(name = "room_id")
public long getRoomId() {
return roomId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/RoomMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public RoomMessage(long roomId, long custId, String content, Date createTime, Da

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "message_id", unique = true, nullable = false)
public Long getMessageId() {
return this.messageId;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/eroom/web/entity/po/RoomRent.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public RoomRent(long roomId, long custOwnerId, String rentType, BigDecimal price

@Id
@GeneratedValue(strategy = IDENTITY)

@Column(name = "rent_id", unique = true, nullable = false)
public Long getRentId() {
return this.rentId;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eroom/web/entity/po/RoomRentSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class RoomRentSet {
private BigDecimal lateAmount;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "rent_set_id")
public long getRentSetId() {
return rentSetId;
Expand Down
29 changes: 28 additions & 1 deletion src/main/java/com/eroom/web/service/pay/PayOrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.eroom.web.constants.RoomConstants;
import com.eroom.web.constants.SystemConstants;
import com.eroom.web.dao.pay.PayOrderDao;
import com.eroom.web.dao.pay.RentOrderDao;
import com.eroom.web.entity.po.PayOrder;
import com.eroom.web.entity.po.RentOrder;
import com.eroom.web.service.BaseService;
Expand All @@ -24,6 +25,9 @@ public class PayOrderService extends BaseService {
@Resource
private PayOrderDao payOrderDao;

@Resource
private RentOrderDao rentOrderDao;

@Resource
private RoomRentService roomRentService;

Expand All @@ -35,7 +39,30 @@ public class PayOrderService extends BaseService {
*/
public void payRentOrder(Long custRenterId, Long payOrderId) throws Exception {
PayOrder payOrder = payOrderDao.get(PayOrder.class, payOrderId);
//支付修改数据
//判断是否为此用户的支付订单
if(custRenterId != payOrder.getCustRenterId()){
throw new BusinessException(SystemConstants.ExceptionMsg.PARAM_NULL_EXCEPTION_MSG);
}
//支付修改数据 type:alipay wechat pay_order_state
payOrder.setPayOrderState(PayConstants.PayOrder.OrderState.FINISH);
payOrder.setType(PayConstants.PayOrder.Type.ALIPAY);
payOrderDao.update(payOrder);

//修改租住订单数据 paidEndTime payPhase paidAmount
RentOrder rentOrder = rentOrderDao.get(RentOrder.class, payOrder.getRentOrderId());
rentOrder.setPaidEndTime(payOrder.getEndTime());
//支付期数加一
int payPhase = rentOrder.getPayPhase()+1;
rentOrder.setPayPhase(payPhase);
//添加支付的总金额
BigDecimal paidAmount = rentOrder.getPaidAmount();
paidAmount.add(payOrder.getAmount());
rentOrder.setPaidAmount(paidAmount);
//修改订单状态,如果为未支付则修改为履行中
if(PayConstants.RentOrder.RentOrderState.WAIT_PAY.equals(rentOrder.getRentOrderState())){
rentOrder.setRentOrderState(PayConstants.RentOrder.RentOrderState.PAID);
}
rentOrderDao.update(rentOrder);

//下架房源信息
roomRentService.updateRoomRentPaid(payOrder.getRentId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public RentOrder saveRentOrder(Long custId, Long rentId, String rentTimeType) th
rentOrder.setBedroomId(roomRent.getBedroomId());
rentOrder.setRentType(roomRent.getRentType());
rentOrder.setPayType(roomRent.getPayType());
rentOrder.setPaidEndTime(startTime);

//设置订单状态为待支付状态
rentOrder.setRentOrderState(PayConstants.RentOrder.RentOrderState.WAIT_PAY);
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/eroom/web/service/PayOrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ public void getPayOrderTest() throws Exception {
logger.info("\n获取空数据");
}
}

@Test
public void payOrderTest() throws Exception {
payOrderService.payRentOrder(1L, 3L);
}
}
38 changes: 38 additions & 0 deletions src/test/java/com/eroom/web/service/RentOrderServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.eroom.web.service;

import com.eroom.web.BaseTest;
import com.eroom.web.constants.PayConstants;
import com.eroom.web.entity.po.PayOrder;
import com.eroom.web.entity.po.RentOrder;
import com.eroom.web.service.pay.PayOrderService;
import com.eroom.web.service.pay.RentOrderService;
import com.eroom.web.utils.util.CollectionUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

/**
* Created by tendy on 2017/8/3.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml"})
public class RentOrderServiceTest extends BaseTest {

@Resource
private PayOrderService payOrderService;

@Resource
private RentOrderService rentOrderService;

@Test
public void getRentOrderTest() throws Exception {
RentOrder rentOrder = rentOrderService.saveRentOrder(1L, 8L, "01");
//生成第一期订单 rentOrder没有获取到
payOrderService.addPayRentOrder(rentOrder);
logger.info("\n测试数据:"+rentOrder.toString());
}
}

0 comments on commit cfbe41f

Please sign in to comment.