mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
!203 modify generate order error logic statement
Merge pull request !203 from Admin/sit-Carl-V3
This commit is contained in:
commit
d853bede3f
@ -58,10 +58,11 @@ public class OrderController {
|
|||||||
|
|
||||||
@ApiOperation(value = "微信支付订单", notes = "生成订单")
|
@ApiOperation(value = "微信支付订单", notes = "生成订单")
|
||||||
@PostMapping("royalcanin/generateOrderWX")
|
@PostMapping("royalcanin/generateOrderWX")
|
||||||
public ResponseDTO<Map<String, String>> generateOrderWX(@RequestBody List<OrdersEntity> ordersEntityList) throws Exception {
|
public ResponseDTO<Map<String, String>> generateOrderWX(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||||
StringBuffer productId = new StringBuffer();
|
StringBuffer productId = new StringBuffer();
|
||||||
StringBuffer productName = new StringBuffer();
|
StringBuffer productName = new StringBuffer();
|
||||||
StringBuffer remark = new StringBuffer();
|
StringBuffer remark = new StringBuffer();
|
||||||
|
Map<String, String> resultMsg = new HashMap<>();
|
||||||
String memberId = "";
|
String memberId = "";
|
||||||
String mobile = "";
|
String mobile = "";
|
||||||
int buyCount = 0;
|
int buyCount = 0;
|
||||||
@ -73,7 +74,7 @@ public class OrderController {
|
|||||||
OrderAddress orderAddress = new OrderAddress();
|
OrderAddress orderAddress = new OrderAddress();
|
||||||
try {
|
try {
|
||||||
for (OrdersEntity ordersEntitys : ordersEntityList) {
|
for (OrdersEntity ordersEntitys : ordersEntityList) {
|
||||||
// System.out.println("ordersEntityList.size()"+ordersEntityList.size());
|
//删除购物车信息
|
||||||
cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode());
|
cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode());
|
||||||
//存储orderDetailList
|
//存储orderDetailList
|
||||||
OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity();
|
OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity();
|
||||||
@ -89,6 +90,9 @@ public class OrderController {
|
|||||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||||
|
if(jsonArray.size() == 0){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||||
|
}
|
||||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||||
if (jsonObjectData.getString("udf2") != null){
|
if (jsonObjectData.getString("udf2") != null){
|
||||||
if (!jsonObjectData.getString("udf2").equals("H5")){
|
if (!jsonObjectData.getString("udf2").equals("H5")){
|
||||||
@ -104,7 +108,6 @@ public class OrderController {
|
|||||||
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount();
|
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount();
|
||||||
}
|
}
|
||||||
basePoint = basePoint + ordersEntitys.getBasePoint();
|
basePoint = basePoint + ordersEntitys.getBasePoint();
|
||||||
// System.out.println("basePoint"+basePoint);
|
|
||||||
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
|
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
|
||||||
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
|
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
|
||||||
orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo());
|
orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo());
|
||||||
@ -129,9 +132,8 @@ public class OrderController {
|
|||||||
ordersEntity.setOrderStatus("0");
|
ordersEntity.setOrderStatus("0");
|
||||||
ordersEntity.setBasePoint(basePoint);
|
ordersEntity.setBasePoint(basePoint);
|
||||||
ordersEntity.setRemark(remark.substring(0,remark.length() - 1));
|
ordersEntity.setRemark(remark.substring(0,remark.length() - 1));
|
||||||
int result = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||||
if (result == 1) {
|
if (resultMsg.get("code").equals("1")) {
|
||||||
System.out.println("orderService.generateOrder(ordersEntity, orderDatilListJson) == 1");
|
|
||||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||||
@ -139,21 +141,22 @@ public class OrderController {
|
|||||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||||
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
|
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
|
||||||
}else if (result == 3){
|
}else if (resultMsg.get("code").equals("3")){
|
||||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED);
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
@ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
||||||
@PostMapping("royalcanin/generateOrderWXH5")
|
@PostMapping("royalcanin/generateOrderWXH5")
|
||||||
public ResponseDTO<Map<String, String>> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList) throws Exception {
|
public ResponseDTO<Map<String, String>> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||||
StringBuffer productId = new StringBuffer();
|
StringBuffer productId = new StringBuffer();
|
||||||
StringBuffer productName = new StringBuffer();
|
StringBuffer productName = new StringBuffer();
|
||||||
|
Map<String, String> resultMsg = new HashMap<>();
|
||||||
String memberId = "";
|
String memberId = "";
|
||||||
String mobile = "";
|
String mobile = "";
|
||||||
int buyCount = 0;
|
int buyCount = 0;
|
||||||
@ -163,6 +166,7 @@ public class OrderController {
|
|||||||
JSONArray orderDatilListJson = new JSONArray();
|
JSONArray orderDatilListJson = new JSONArray();
|
||||||
OrdersEntity ordersEntity = new OrdersEntity();
|
OrdersEntity ordersEntity = new OrdersEntity();
|
||||||
OrderAddress orderAddress = new OrderAddress();
|
OrderAddress orderAddress = new OrderAddress();
|
||||||
|
try{
|
||||||
for (OrdersEntity ordersEntitys:ordersEntityList) {
|
for (OrdersEntity ordersEntitys:ordersEntityList) {
|
||||||
cartService.cancelProduct(ordersEntitys.getMemberId(),ordersEntity.getProductCode());
|
cartService.cancelProduct(ordersEntitys.getMemberId(),ordersEntity.getProductCode());
|
||||||
//存储orderDetailList
|
//存储orderDetailList
|
||||||
@ -179,7 +183,15 @@ public class OrderController {
|
|||||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||||
|
if(jsonArray.size() == 0){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||||
|
}
|
||||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||||
|
if (jsonObjectData.getString("udf2") != null){
|
||||||
|
if (!jsonObjectData.getString("udf2").equals("H5")){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
|
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
|
||||||
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
|
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
|
||||||
@ -213,18 +225,22 @@ public class OrderController {
|
|||||||
ordersEntity.setOrderStatus("0");
|
ordersEntity.setOrderStatus("0");
|
||||||
ordersEntity.setBasePoint(basePoint);
|
ordersEntity.setBasePoint(basePoint);
|
||||||
ordersEntity.setPayType("3");
|
ordersEntity.setPayType("3");
|
||||||
|
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||||
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
|
if (resultMsg.get("code").equals("1")) {
|
||||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||||
|
|
||||||
Map<String, String> returnMap = new HashMap<>();
|
Map<String, String> returnMap = new HashMap<>();
|
||||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||||
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrder(wxPayEntity));
|
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrder(wxPayEntity));
|
||||||
|
}else if (resultMsg.get("code").equals("3")){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
|
}catch (Exception e){
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "微信支付JSAPI订单", notes = "生成JSAPI订单")
|
@ApiOperation(value = "微信支付JSAPI订单", notes = "生成JSAPI订单")
|
||||||
@ -232,6 +248,7 @@ public class OrderController {
|
|||||||
public ResponseDTO<Map<String, String>> generateOrderWXJSAPI(@RequestBody List<OrdersEntity> ordersEntityList,String resp) throws Exception {
|
public ResponseDTO<Map<String, String>> generateOrderWXJSAPI(@RequestBody List<OrdersEntity> ordersEntityList,String resp) throws Exception {
|
||||||
StringBuffer productId = new StringBuffer();
|
StringBuffer productId = new StringBuffer();
|
||||||
StringBuffer productName = new StringBuffer();
|
StringBuffer productName = new StringBuffer();
|
||||||
|
Map<String, String> resultMsg = new HashMap<>();
|
||||||
String memberId = "";
|
String memberId = "";
|
||||||
String mobile = "";
|
String mobile = "";
|
||||||
int buyCount = 0;
|
int buyCount = 0;
|
||||||
@ -241,6 +258,7 @@ public class OrderController {
|
|||||||
JSONArray orderDatilListJson = new JSONArray();
|
JSONArray orderDatilListJson = new JSONArray();
|
||||||
OrdersEntity ordersEntity = new OrdersEntity();
|
OrdersEntity ordersEntity = new OrdersEntity();
|
||||||
OrderAddress orderAddress = new OrderAddress();
|
OrderAddress orderAddress = new OrderAddress();
|
||||||
|
try{
|
||||||
for (OrdersEntity ordersEntitys:ordersEntityList) {
|
for (OrdersEntity ordersEntitys:ordersEntityList) {
|
||||||
cartService.cancelProduct(ordersEntitys.getMemberId(),ordersEntity.getProductCode());
|
cartService.cancelProduct(ordersEntitys.getMemberId(),ordersEntity.getProductCode());
|
||||||
//存储orderDetailList
|
//存储orderDetailList
|
||||||
@ -257,7 +275,15 @@ public class OrderController {
|
|||||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||||
|
if(jsonArray.size() == 0){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||||
|
}
|
||||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||||
|
if (jsonObjectData.getString("udf2") != null){
|
||||||
|
if (!jsonObjectData.getString("udf2").equals("H5")){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
|
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
|
||||||
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
|
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
|
||||||
@ -291,18 +317,22 @@ public class OrderController {
|
|||||||
ordersEntity.setOrderStatus("0");
|
ordersEntity.setOrderStatus("0");
|
||||||
ordersEntity.setBasePoint(basePoint);
|
ordersEntity.setBasePoint(basePoint);
|
||||||
ordersEntity.setPayType("3");
|
ordersEntity.setPayType("3");
|
||||||
|
//判断订单生成状况
|
||||||
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
|
if (resultMsg.get("code").equals("1")) {
|
||||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||||
|
|
||||||
Map<String, String> returnMap = new HashMap<>();
|
Map<String, String> returnMap = new HashMap<>();
|
||||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||||
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrderJSAPI(wxPayEntity,resp));
|
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
|
||||||
|
}else if (resultMsg.get("code").equals("3")){
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
|
}catch (Exception e){
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,9 @@ public class OrderService {
|
|||||||
private String url ;
|
private String url ;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int generateOrder(OrdersEntity ordersEntity, JSONArray listJson) throws Exception {
|
public Map<String,String> generateOrder(OrdersEntity ordersEntity, JSONArray listJson) throws Exception {
|
||||||
AddOrSaveEntity addOrSaveEntity = new AddOrSaveEntity();
|
AddOrSaveEntity addOrSaveEntity = new AddOrSaveEntity();
|
||||||
|
Map<String, String>resultMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
if (ordersEntity.getCouponCode() != "" && null != ordersEntity.getCouponCode()) {
|
if (ordersEntity.getCouponCode() != "" && null != ordersEntity.getCouponCode()) {
|
||||||
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
|
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
|
||||||
@ -64,7 +65,9 @@ public class OrderService {
|
|||||||
couponCosumeEntity.setRealCouponAmount(realCouponAmount);
|
couponCosumeEntity.setRealCouponAmount(realCouponAmount);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(couponService.couponCosume(couponCosumeEntity));
|
JSONObject jsonObject = JSONObject.parseObject(couponService.couponCosume(couponCosumeEntity));
|
||||||
if (!jsonObject.getString("code").equals("0")) {
|
if (!jsonObject.getString("code").equals("0")) {
|
||||||
return 3;
|
resultMap.put("code",jsonObject.getString("code"));
|
||||||
|
resultMap.put("msg",jsonObject.getString("msg"));
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
//coupon json化
|
//coupon json化
|
||||||
OrderCouponEntity orderCouponEntity = new OrderCouponEntity();
|
OrderCouponEntity orderCouponEntity = new OrderCouponEntity();
|
||||||
@ -99,18 +102,26 @@ public class OrderService {
|
|||||||
addOrSaveEntity.setAddressUserName(orderAddress.getAddressUserName());
|
addOrSaveEntity.setAddressUserName(orderAddress.getAddressUserName());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(addOrSave(addOrSaveEntity));
|
JSONObject jsonObject = JSONObject.parseObject(addOrSave(addOrSaveEntity));
|
||||||
|
|
||||||
if (jsonObject.getString("code").equals("1"))
|
if (jsonObject.getString("code").equals("1")){
|
||||||
return 1;
|
resultMap.put("code",jsonObject.getString("code"));
|
||||||
else
|
resultMap.put("msg",jsonObject.getString("msg"));
|
||||||
return 0;
|
return resultMap;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
resultMap.put("code",jsonObject.getString("code"));
|
||||||
|
resultMap.put("msg",jsonObject.getString("msg"));
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultMap.put("code","0");
|
||||||
|
resultMap.put("msg","订单生成有误,请联系管理员!");
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
System.out.println(e.getMessage()
|
System.out.println(e.getMessage());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return 0;
|
resultMap.put("code","0");
|
||||||
|
resultMap.put("msg","数据操作有误,请联系管理员!");
|
||||||
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkNotify(String orderNumber){
|
public int checkNotify(String orderNumber){
|
||||||
|
Loading…
Reference in New Issue
Block a user