Browse Source

处理api接口错误

master
xyiege 3 years ago
parent
commit
c92123ef7f
  1. 7
      src/main/java/cn/chjyj/szwh/bean/Order.java
  2. 20
      src/main/java/cn/chjyj/szwh/bean/OrderGoodsDetail.java
  3. 34
      src/main/java/cn/chjyj/szwh/service/impl/OrderServiceImpl.java

7
src/main/java/cn/chjyj/szwh/bean/Order.java

@ -1,5 +1,7 @@
package cn.chjyj.szwh.bean; package cn.chjyj.szwh.bean;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -19,8 +21,10 @@ public class Order implements Serializable {
*/ */
private Integer id; private Integer id;
private Integer userId;//用户ID private Integer userId;//用户ID
@JSONField(name = "buy_islicode")
private String buyIslicode;//购买方isli标识码 private String buyIslicode;//购买方isli标识码
private String batchcode;//订单号 private String batchcode;//订单号
@JSONField(name = "account_ratio_id")
private Integer accountRatioId; // 分账比例ID private Integer accountRatioId; // 分账比例ID
private String historyBuyName; // 历史购买方名称 private String historyBuyName; // 历史购买方名称
private String historyBuyCode; // 历史购买方组织机构代码 private String historyBuyCode; // 历史购买方组织机构代码
@ -35,8 +39,11 @@ public class Order implements Serializable {
private String ticketimage;//发票图片url private String ticketimage;//发票图片url
private Integer ticketStatus;//开票状态(1:未开票,2:开票中,3:已开票;4:开票失败) private Integer ticketStatus;//开票状态(1:未开票,2:开票中,3:已开票;4:开票失败)
private Integer chargeChannel;//收费类型;1:微信;2:支付宝;3:银联 private Integer chargeChannel;//收费类型;1:微信;2:支付宝;3:银联
@JSONField(name = "pay_status")
private Integer payStatus;//支付状态;1:未支付;2:支付成功;3:支付失败 private Integer payStatus;//支付状态;1:未支付;2:支付成功;3:支付失败
@JSONField(name = "close_status")
private Integer closeStatus;//结算状态;1:无结算信息;2:结算中;3:用户名和收款人不一致;4:收款信息错误;5:结算成功 private Integer closeStatus;//结算状态;1:无结算信息;2:结算中;3:用户名和收款人不一致;4:收款信息错误;5:结算成功
@JSONField(name = "is_close")
private Integer isClose;//是否发送结算请求 private Integer isClose;//是否发送结算请求
private String closeSerialNumber;//结算流水号 private String closeSerialNumber;//结算流水号
private String payid; private String payid;

20
src/main/java/cn/chjyj/szwh/bean/OrderGoodsDetail.java

@ -35,7 +35,7 @@ public class OrderGoodsDetail implements Serializable {
private String goodsName;//商品名称 private String goodsName;//商品名称
private String goodsImage;//商品图片 private String goodsImage;//商品图片
private String contractCode;//合约关联编码(订单交易isli标识码) private String contractCode;//合约关联编码(订单交易isli标识码)
private String orderislicode; private String orderIslicode;
private String historyEntrustName;//历史委托方名称 private String historyEntrustName;//历史委托方名称
private String historyEntrustCode;//历史委托方组织机构代码 private String historyEntrustCode;//历史委托方组织机构代码
private String identifier;//资源isli private String identifier;//资源isli
@ -60,7 +60,7 @@ public class OrderGoodsDetail implements Serializable {
private Integer contractualPeriod;//委托周期;1:永久,2:单次,3:周期 private Integer contractualPeriod;//委托周期;1:永久,2:单次,3:周期
private Integer transactionClass;//交易种类;1:权属;2:商品 private Integer transactionClass;//交易种类;1:权属;2:商品
private String contract;//描述 private String contract;//描述
private String otheridentifiers;//权属自有标识符(商品自有标识符) private String otherIdentifiers;//权属自有标识符(商品自有标识符)
private String classification;//标的商品的分类(交易种类为商品时候用的) private String classification;//标的商品的分类(交易种类为商品时候用的)
private String sourceIslicode;//资源isli标识码 private String sourceIslicode;//资源isli标识码
private String sourceIslicodeName;//资源名称 private String sourceIslicodeName;//资源名称
@ -141,12 +141,12 @@ public class OrderGoodsDetail implements Serializable {
this.contractCode = contractCode; this.contractCode = contractCode;
} }
public String getOrderislicode() { public String getOrderIslicode() {
return orderislicode; return orderIslicode;
} }
public void setOrderislicode(String orderislicode) { public void setOrderIslicode(String orderIslicode) {
this.orderislicode = orderislicode; this.orderIslicode = orderIslicode;
} }
public String getHistoryEntrustName() { public String getHistoryEntrustName() {
@ -333,12 +333,12 @@ public class OrderGoodsDetail implements Serializable {
this.contract = contract; this.contract = contract;
} }
public String getOtheridentifiers() { public String getOtherIdentifiers() {
return otheridentifiers; return otherIdentifiers;
} }
public void setOtheridentifiers(String otheridentifiers) { public void setOtherIdentifiers(String otherIdentifiers) {
this.otheridentifiers = otheridentifiers; this.otherIdentifiers = otherIdentifiers;
} }
public String getClassification() { public String getClassification() {

34
src/main/java/cn/chjyj/szwh/service/impl/OrderServiceImpl.java

@ -580,10 +580,13 @@ public class OrderServiceImpl implements OrderService {
return bretMap; return bretMap;
} }
} }
// 判断当前订单是否存在问题
Order order = new Order();
//校验订单信息合法 //校验订单信息合法
SzOrderUtils.checkOrder(goods, goodsDetail, userIsli); String uretStr = SzOrderUtils.checkOrder(goods, goodsDetail, userIsli);
if(uretStr!=null){
bretMap.put("error",uretStr);
return bretMap;
}
// 计算服务费等 委托方总金额 // 计算服务费等 委托方总金额
BigDecimal serviceCharge = new BigDecimal("0"); BigDecimal serviceCharge = new BigDecimal("0");
BigDecimal totalMoney = new BigDecimal("0"); BigDecimal totalMoney = new BigDecimal("0");
@ -644,8 +647,15 @@ public class OrderServiceImpl implements OrderService {
} }
} }
} }
//设置用户信息
orderGoodsDetail.setUserId(userId);
// 暂存入订单号
orderGoodsDetail.setOrderIslicode(batchCode);
// 新增订单商品
orderGoodsDetailMapper.addOrderGoodsDetail(orderGoodsDetail);
// 订单实体 // 创建订单实体
Order order = new Order();
order.setBatchcode(batchCode); order.setBatchcode(batchCode);
order.setUserId(userId); order.setUserId(userId);
order.setBuyIslicode(userIsli); order.setBuyIslicode(userIsli);
@ -870,7 +880,7 @@ public class OrderServiceImpl implements OrderService {
/** /**
* 创建订单实现方法 * 创建订单实现方法
* * 用户信息来源于远程服务,仅仅记录购买用户
* @param userIsli * @param userIsli
* @param goodsJsonArray post过来的json参数 * @param goodsJsonArray post过来的json参数
* @return * @return
@ -878,12 +888,6 @@ public class OrderServiceImpl implements OrderService {
@Override @Override
public Map<String, Object> createOrder(String userIsli, JSONArray goodsJsonArray) { public Map<String, Object> createOrder(String userIsli, JSONArray goodsJsonArray) {
Map<String, Object> retmap = new HashMap<>(); Map<String, Object> retmap = new HashMap<>();
User user = userMapper.getUserByIsli(userIsli);
if (user == null) {
retmap.put("code", "error");
retmap.put("msg", "用户不存在");
return retmap;
}
Map bmap = new HashMap();// 执行返回map Map bmap = new HashMap();// 执行返回map
// 该用户的购物车 // 该用户的购物车
String rkey = "car_" + userIsli; String rkey = "car_" + userIsli;
@ -955,7 +959,13 @@ public class OrderServiceImpl implements OrderService {
otmap.put("buy_username", orderUser.getName()); otmap.put("buy_username", orderUser.getName());
// order goods // order goods
List<OrderGoodsDetail> orderGoodsDetailList = orderGoodsDetailMapper.getOrderGoodsDetailByBatchCode(batchcode); List<OrderGoodsDetail> orderGoodsDetailList = orderGoodsDetailMapper.getOrderGoodsDetailByBatchCode(batchcode);
otmap.put("order_detail", orderGoodsDetailList); //转化为前端要求格式
List noglist = new ArrayList();
for(OrderGoodsDetail nog:orderGoodsDetailList){
JSONObject nogjson = JSONObject.parseObject(JSON.toJSONString(nog));
noglist.add(nogjson);
}
otmap.put("order_detail", noglist);
// //
return otmap; return otmap;
} }

Loading…
Cancel
Save