|
@@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
|
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.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
@@ -127,7 +128,7 @@ public class OrderController {
|
|
/**
|
|
/**
|
|
* 提交订单接口
|
|
* 提交订单接口
|
|
*
|
|
*
|
|
- * @return code:1000=用户账户异常,1001=数据异常
|
|
|
|
|
|
+ * @return code:-1=(用户账户异常,数据异常,操作异常等),1提交成功(msg=1支付完成,2未完成支付)
|
|
* @Param params参数格式:
|
|
* @Param params参数格式:
|
|
* 参数1=userId用户ID
|
|
* 参数1=userId用户ID
|
|
* 参数2=organizeID组织ID,
|
|
* 参数2=organizeID组织ID,
|
|
@@ -143,9 +144,10 @@ public class OrderController {
|
|
* 参数6=balanceDeductionFlag是否使用余额抵扣(1使用,2不使用)
|
|
* 参数6=balanceDeductionFlag是否使用余额抵扣(1使用,2不使用)
|
|
* 参数7=orderShouldPayFee订单应付金额(商品总金额 - 余额抵扣 - 经理折扣默认为0)
|
|
* 参数7=orderShouldPayFee订单应付金额(商品总金额 - 余额抵扣 - 经理折扣默认为0)
|
|
*/
|
|
*/
|
|
|
|
+ @Transactional
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping("/submitOrder")
|
|
@RequestMapping("/submitOrder")
|
|
- public WxJsonModel submitOrder(String params, HttpServletRequest request) {
|
|
|
|
|
|
+ public synchronized WxJsonModel submitOrder(String params, HttpServletRequest request) {
|
|
WxJsonModel wxJsonModel = WxJsonModel.newInstance();
|
|
WxJsonModel wxJsonModel = WxJsonModel.newInstance();
|
|
logger.info(">>>>>>订单信息params:" + params);
|
|
logger.info(">>>>>>订单信息params:" + params);
|
|
//检查用户是否登入
|
|
//检查用户是否登入
|
|
@@ -153,55 +155,56 @@ public class OrderController {
|
|
HttpSession session = request.getSession();
|
|
HttpSession session = request.getSession();
|
|
String openid = (String) session.getAttribute("openid");
|
|
String openid = (String) session.getAttribute("openid");
|
|
Integer organizeID1 = (Integer) session.getAttribute("organizeID");
|
|
Integer organizeID1 = (Integer) session.getAttribute("organizeID");
|
|
|
|
+// CmOperationUser currentUser = loginService.doLogin("oEjHd4gCC7SO5Eo3ogt5g4pj2mNU", 1);
|
|
CmOperationUser currentUser = loginService.doLogin(openid, organizeID1);
|
|
CmOperationUser currentUser = loginService.doLogin(openid, organizeID1);
|
|
if (null == currentUser) {
|
|
if (null == currentUser) {
|
|
- return wxJsonModel.error("1000", "用户账户异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "用户账户异常");
|
|
}
|
|
}
|
|
Integer cmOperationID = currentUser.getId();//当前操作者ID
|
|
Integer cmOperationID = currentUser.getId();//当前操作者ID
|
|
if (StringUtils.isBlank(params)) {
|
|
if (StringUtils.isBlank(params)) {
|
|
- return wxJsonModel.error("1001", "数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "数据异常");
|
|
}
|
|
}
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
try {
|
|
try {
|
|
map = (Map<String, Object>) JsonMapper.getInstance().fromJsonString(params, Map.class);
|
|
map = (Map<String, Object>) JsonMapper.getInstance().fromJsonString(params, Map.class);
|
|
if (null == map) {
|
|
if (null == map) {
|
|
logger.info(">>>>>数据异常,参数不能为空");
|
|
logger.info(">>>>>数据异常,参数不能为空");
|
|
- return wxJsonModel.error("1001", "数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "数据异常");
|
|
}
|
|
}
|
|
Integer userId = (Integer) map.get("userId");
|
|
Integer userId = (Integer) map.get("userId");
|
|
Integer organizeID = (Integer) map.get("organizeID");
|
|
Integer organizeID = (Integer) map.get("organizeID");
|
|
- String cartType = (String) map.get("cartType");
|
|
|
|
|
|
+ String cartType = String.valueOf(map.get("cartType")) ;
|
|
Integer addressID = (Integer) map.get("addressID");
|
|
Integer addressID = (Integer) map.get("addressID");
|
|
Object orderInfo = map.get("orderInfo");
|
|
Object orderInfo = map.get("orderInfo");
|
|
- String balanceDeductionFlag = (String) map.get("balanceDeductionFlag");
|
|
|
|
- Double orderShouldPayFee = (Double) map.get("orderShouldPayFee");//此金额为前端计算,适用于后端计算金额复查
|
|
|
|
|
|
+ String balanceDeductionFlag = String.valueOf(map.get("balanceDeductionFlag"));
|
|
|
|
+ Double orderShouldPayFee = Double.parseDouble(String.valueOf(map.get("orderShouldPayFee")));//此金额为前端计算,适用于后端计算金额复查
|
|
//校验传入参数的正确性
|
|
//校验传入参数的正确性
|
|
if (null == userId) {
|
|
if (null == userId) {
|
|
- return wxJsonModel.error("1001", "用户数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "用户数据异常");
|
|
}
|
|
}
|
|
if (null == organizeID) {
|
|
if (null == organizeID) {
|
|
- return wxJsonModel.error("1001", "组织数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "组织数据异常");
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(cartType)) {
|
|
if (StringUtils.isEmpty(cartType)) {
|
|
- return wxJsonModel.error("1001", "购买类型数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "购买类型数据异常");
|
|
}
|
|
}
|
|
if (null == addressID) {
|
|
if (null == addressID) {
|
|
- return wxJsonModel.error("1001", "地址数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "地址数据异常");
|
|
}
|
|
}
|
|
if (null == orderInfo) {
|
|
if (null == orderInfo) {
|
|
- return wxJsonModel.error("1001", "订单数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "订单数据异常");
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(balanceDeductionFlag)) {
|
|
if (StringUtils.isEmpty(balanceDeductionFlag)) {
|
|
- return wxJsonModel.error("1001", "余额抵扣数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "余额抵扣数据异常");
|
|
}
|
|
}
|
|
if (null == orderShouldPayFee) {
|
|
if (null == orderShouldPayFee) {
|
|
- return wxJsonModel.error("1001", "订单应付金额数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "订单应付金额数据异常");
|
|
}
|
|
}
|
|
//保存订单信息
|
|
//保存订单信息
|
|
return orderService.saveOrderInfo(wxJsonModel, userId, organizeID, cartType, addressID, orderInfo, balanceDeductionFlag, orderShouldPayFee, cmOperationID);
|
|
return orderService.saveOrderInfo(wxJsonModel, userId, organizeID, cartType, addressID, orderInfo, balanceDeductionFlag, orderShouldPayFee, cmOperationID);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.info(">>>>>系统异常" + e.getMessage());
|
|
logger.info(">>>>>系统异常" + e.getMessage());
|
|
- return wxJsonModel.error("1001", "数据异常");
|
|
|
|
|
|
+ return wxJsonModel.error("-1", "数据异常");
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|