diff --git a/rc-busness/pages/personal/settlement.vue b/rc-busness/pages/personal/settlement.vue index 7bda8af0..5ea680de 100644 --- a/rc-busness/pages/personal/settlement.vue +++ b/rc-busness/pages/personal/settlement.vue @@ -306,9 +306,17 @@ export default { let total = 0; let couponUsed = false; let tmpShoppingCartList = this.arrSort(this.goldmedal); - + let qualifiedProductAmount = 0; + let skipQualifiedProductAmountCalculating = false; + for(let itemInCart of tmpShoppingCartList) { - if((!this.curCoupon.productCodes || this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) && !couponUsed) { + if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) { + qualifiedProductAmount += (itemInCart.productPrice * itemInCart.buyCount); + } + } + + for(let itemInCart of tmpShoppingCartList) { + if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed) { if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) { //Check minQuantity total+=(itemInCart.buyCount * itemInCart.productPrice); @@ -318,7 +326,8 @@ export default { } else { //Into coupon discount calculation switch(this.curCoupon.couponTypeId) { - case 1: //Amount deduct + case 1: //Amount deduct + /* if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) { total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount); this.discountAmount = this.curCoupon.couponAmount; @@ -330,14 +339,16 @@ export default { this.curCoupon = {couponName:'未能使用该优惠券'}; } break; + */ case 2: //Amount deduct with minPrice restriction case 6: - if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) { - total = total + (itemInCart.productPrice * itemInCart.buyCount) - this.curCoupon.couponAmount; + if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= qualifiedProductAmount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) { + total = total + qualifiedProductAmount - this.curCoupon.couponAmount; this.discountAmount = this.curCoupon.couponAmount; - this.discountedProductCode = itemInCart.productCode; + this.discountedProductCode = itemInCart.productCode; + skipQualifiedProductAmountCalculating = true; couponUsed=true; - } else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > (itemInCart.productPrice * itemInCart.buyCount)) { + } else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) { total = total + itemInCart.productPrice * itemInCart.buyCount; this.discountAmount = 0; this.curCoupon = {couponName:'未能使用该优惠券'}; @@ -357,7 +368,11 @@ export default { //Into coupon discount calculation end } } else { - total += itemInCart.productPrice * itemInCart.buyCount; + if(skipQualifiedProductAmountCalculating && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) { + + } else { + total += itemInCart.productPrice * itemInCart.buyCount; + } } } return total; @@ -408,6 +423,7 @@ export default { let paramsToAPI = { mobile : mobile, useStartDate : curDate.getFullYear()+'-'+(curDate.getMonth()+1)+'-'+curDate.getDate(), + status:0 }; if(productCodes) paramsToAPI.productCodes = productCodes.join(','); @@ -464,6 +480,7 @@ export default { if(dateChecked && myCoupon.activityId != 10 && myCoupon.status == 0 && (!myCoupon.productCodes || myCoupon.productCodes.indexOf(itemInCart.productCode)>-1)) { //if(dateChecked) { //data.data.splice(tmpIndex,1); + data.data[tmpIndex]={}; _self.drawlist.push(myCoupon); avaliableCouponNum++; } diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/CouponService.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/CouponService.java index 9fda9f7b..90c24567 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/CouponService.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/CouponService.java @@ -45,7 +45,7 @@ public class CouponService { Map paramMap = MapRemoveNullUtil.setConditionMap(couponGetAllEntity); Date currentDate = SmartDateUtil.parseYMD(paramMap.get("useStartDate") == null ? "1990-01-01":paramMap.get("useStartDate")); paramMap.remove("productCodes"); - paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getStatus())); + paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("")?null:StringUtil.toString(couponGetAllEntity.getStatus())); paramMap.put("page",StringUtil.toString(couponGetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getPage())); paramMap.put("rows",StringUtil.toString(couponGetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getRows())); paramMap.put("usestartDate",paramMap.get("useStartDate")); diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/TransitionController.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/TransitionController.java index 900e2127..9dfd20fc 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/TransitionController.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/TransitionController.java @@ -6,6 +6,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import net.lab1024.smartadmin.common.anno.OperateLog; import net.lab1024.smartadmin.common.domain.ResponseDTO; +import net.lab1024.smartadmin.common.heartbeat.IpUtil; import net.lab1024.smartadmin.common.heartbeat.StringUtil; import net.lab1024.smartadmin.constant.SwaggerTagConst; import net.lab1024.smartadmin.module.system.royalcanin.coupon.*; @@ -283,6 +284,8 @@ public class TransitionController { royalcaninOperateLogEntity.setMsg(jsonObject.getString("msg")== null ?"":jsonObject.getString("msg")); royalcaninOperateLogEntity.setParams(params); royalcaninOperateLogEntity.setAcceptTime(dateformat.format(acceptTime)); + royalcaninOperateLogEntity.setData(jsonObject.getString("data") == null?"" : jsonObject.getString("data")); + royalcaninOperateLogEntity.setAccountIp(IpUtil.getLocalIP() == null ?"":IpUtil.getLocalIP()); royalcaninOperateLogService.add(royalcaninOperateLogEntity); return ResponseDTO.succ(); } diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/coupon/CouponGetAllEntity.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/coupon/CouponGetAllEntity.java index 2391c848..f9e05a7c 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/coupon/CouponGetAllEntity.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/coupon/CouponGetAllEntity.java @@ -47,7 +47,7 @@ public class CouponGetAllEntity { * 0:未使用,1已使用,2已作废 */ @ApiModelProperty(example = "1") - private int status; + private String status = ""; /** * 是否已经使用 diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/domain/RoyalcaninOperateLogEntity.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/domain/RoyalcaninOperateLogEntity.java index 814a4320..fc4a1e1b 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/domain/RoyalcaninOperateLogEntity.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/domain/RoyalcaninOperateLogEntity.java @@ -31,4 +31,8 @@ public class RoyalcaninOperateLogEntity { private String code; private String msg; + + private String accountIp; + + private String data; } diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/GoodController.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/GoodController.java index a788496a..c1a4a12e 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/GoodController.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/GoodController.java @@ -2,11 +2,15 @@ package net.lab1024.smartadmin.module.system.royalcanin.good; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import net.lab1024.smartadmin.common.anno.OperateLog; import net.lab1024.smartadmin.common.constant.ResponseCodeConst; import net.lab1024.smartadmin.common.domain.ResponseDTO; +import net.lab1024.smartadmin.common.heartbeat.IpUtil; import net.lab1024.smartadmin.common.heartbeat.StringUtil; import net.lab1024.smartadmin.constant.SwaggerTagConst; import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogEntity; @@ -20,6 +24,7 @@ import net.lab1024.smartadmin.module.system.royalcanin.productSearchTag.service. import net.lab1024.smartadmin.util.MapRemoveNullUtil; import net.lab1024.smartadmin.util.SmartHttpUtil; import net.lab1024.smartadmin.util.SmartJWTUtil; +import net.lab1024.smartadmin.util.SmartStringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -124,7 +129,7 @@ public class GoodController { long acceptTime = System.currentTimeMillis() ; long elapsedTime = acceptTime - startTime; //记录服务响应时间 - addOperatreFullData("royalcanin/h5/product/query",result.length()+"", startTime,elapsedTime,acceptTime,result.length() >0 ?"1":"0",result.length() >0 ?"SUCCESS":"FAIL"); + addOperatreFullData("royalcanin/h5/product/query",result.length()+"", startTime,elapsedTime,acceptTime,result.length() >0 ?"1":"0",result.length() >0 ?"SUCCESS":"FAIL",result); return result; }catch (Exception e){ System.out.println(e.getMessage()); @@ -143,7 +148,7 @@ public class GoodController { long acceptTime = System.currentTimeMillis() ; long elapsedTime = acceptTime - startTime; //记录服务响应时间 - addOperatreFullData("royalcanin/h5/productMaster/query",result.length()+"", startTime,elapsedTime,acceptTime,result.length() >0 ?"1":"0",result.length() >0 ?"SUCCESS":"FAIL"); + addOperatreFullData("royalcanin/h5/productMaster/query",result.length()+"", startTime,elapsedTime,acceptTime,result.length() >0 ?"1":"0",result.length() >0 ?"SUCCESS":"FAIL",result); return result; } @@ -158,7 +163,7 @@ public class GoodController { goodService.remoteGetProductSearchTagData(); } - public ResponseDTO addOperatreFullData(String type, String params, Long startTime, Long elapsedTime, Long acceptTime,String code,String msg)throws Exception{ + public ResponseDTO addOperatreFullData(String type, String params, Long startTime, Long elapsedTime, Long acceptTime,String code,String msg,String result)throws Exception{ SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); RoyalcaninOperateLogEntity royalcaninOperateLogEntity = new RoyalcaninOperateLogEntity(); royalcaninOperateLogEntity.setElapsedTime(StringUtil.toString(elapsedTime)); @@ -168,6 +173,14 @@ public class GoodController { royalcaninOperateLogEntity.setMsg(msg); royalcaninOperateLogEntity.setParams(params); royalcaninOperateLogEntity.setAcceptTime(dateformat.format(acceptTime)); + String data = ""; + if(SmartStringUtil.isNotBlank(result)){ + JSONObject jsonObj = JSONObject.parseArray(result).getJSONObject(0); + jsonObj.remove("productAttachmentList"); + data = jsonObj.toString(); + } + royalcaninOperateLogEntity.setData(data); + royalcaninOperateLogEntity.setAccountIp(IpUtil.getLocalIP() == null ?"":IpUtil.getLocalIP()); royalcaninOperateLogService.add(royalcaninOperateLogEntity); return ResponseDTO.succ(); } diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/OrderController.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/OrderController.java index 20a2d17a..444ee293 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/OrderController.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/OrderController.java @@ -66,9 +66,7 @@ public class OrderController { public ResponseDTO> generateOrderWX(@RequestBody List ordersEntityList){ StringBuffer productId = new StringBuffer(); StringBuffer productName = new StringBuffer(); - StringBuffer remark = new StringBuffer(); Map resultMsg = new HashMap<>(); - String memberId = ""; String mobile = ""; int buyCount = 0; double total_fee = 0 ; @@ -77,8 +75,12 @@ public class OrderController { JSONArray orderDatilListJson = new JSONArray(); OrdersEntity ordersEntity = new OrdersEntity(); OrderAddress orderAddress = new OrderAddress(); + + String memberId = ""; + String couponCode = ""; try { for (OrdersEntity ordersEntitys : ordersEntityList) { + //删除购物车信息 cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode()); //存储orderDetailList @@ -94,31 +96,9 @@ public class OrderController { orderDatilListEntity.setProductCode(goodsObject.getString("productCode")); orderDatilListEntity.setEcPrice(goodsObject.getString("ecPrice")); orderDatilListJson.add(orderDatilListEntity); - if (ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) { - CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity(); - couponGetAllEntity.setMemberId(ordersEntitys.getMemberId()); - couponGetAllEntity.setCouponCode(ordersEntitys.getCouponCode()); - String couponInfo = couponService.couponGetAll(couponGetAllEntity); - JSONObject jsonObject = JSONObject.parseObject(couponInfo); - 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); - 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.setCouponCode(jsonObjectData.getString("couponCode")); - ordersEntity.setCouponName(jsonObjectData.getString("couponName")); - ordersEntity.setCouponId(jsonObjectData.getString("couponId")); - ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); - total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); - } else { - total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); - } + + total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); + basePoint = basePoint + ordersEntitys.getBasePoint(); orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName()); orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName()); @@ -126,16 +106,42 @@ public class OrderController { orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber()); orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName()); orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName()); - productId.append(ordersEntitys.getProductCode() + ","); - productName.append(ordersEntitys.getProductName() + ","); - remark.append(ordersEntitys.getBuyCount() + ","); + productId.append(ordersEntitys.getProductCode()+","); + productName.append(ordersEntitys.getProductName()+","); memberId = ordersEntitys.getMemberId(); + if (ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) { + couponCode = ordersEntitys.getCouponCode(); + } mobile = ordersEntitys.getPhoneNumber(); buyCount = buyCount + ordersEntitys.getBuyCount(); } + //验证优惠卷 + if (couponCode != "" && couponCode != null) { + CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity(); + couponGetAllEntity.setMemberId(memberId); + couponGetAllEntity.setCouponCode(couponCode); + String couponInfo = couponService.couponGetAll(couponGetAllEntity); + JSONObject jsonObject = JSONObject.parseObject(couponInfo); + 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); + 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.setCouponCode(jsonObjectData.getString("couponCode")); + ordersEntity.setCouponName(jsonObjectData.getString("couponName")); + ordersEntity.setCouponId(jsonObjectData.getString("couponId")); + ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); + total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee); + } ordersEntity.setOrderAddress(orderAddress); - ordersEntity.setProductCode(productId.substring(0, productId.length() - 1)); - ordersEntity.setProductName(productName.substring(0, productName.length() - 1)); + ordersEntity.setProductCode(productId.substring(0,productId.length()-1)); + ordersEntity.setProductName(productName.substring(0,productName.length()-1)); ordersEntity.setOrderAmount(StringUtil.toString(total_fee)); ordersEntity.setMemberId(memberId); ordersEntity.setPhoneNumber(mobile); @@ -143,7 +149,7 @@ public class OrderController { ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo()); ordersEntity.setOrderStatus("0"); ordersEntity.setBasePoint(basePoint); - ordersEntity.setRemark(remark.substring(0,remark.length() - 1)); + ordersEntity.setPayType("3"); resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson); if (resultMsg.get("code").equals("1")) { wxPayEntity.setProduct_id(ordersEntity.getProductCode()); @@ -173,7 +179,6 @@ public class OrderController { StringBuffer productId = new StringBuffer(); StringBuffer productName = new StringBuffer(); Map resultMsg = new HashMap<>(); - String memberId = ""; String mobile = ""; int buyCount = 0; double total_fee = 0 ; @@ -182,8 +187,12 @@ public class OrderController { JSONArray orderDatilListJson = new JSONArray(); OrdersEntity ordersEntity = new OrdersEntity(); OrderAddress orderAddress = new OrderAddress(); + + String memberId = ""; + String couponCode = ""; try { for (OrdersEntity ordersEntitys : ordersEntityList) { + //删除购物车信息 cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode()); //存储orderDetailList @@ -199,10 +208,28 @@ public class OrderController { orderDatilListEntity.setProductCode(goodsObject.getString("productCode")); orderDatilListEntity.setEcPrice(goodsObject.getString("ecPrice")); orderDatilListJson.add(orderDatilListEntity); - if (ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) { + + total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); + + basePoint = basePoint + ordersEntitys.getBasePoint(); + orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName()); + orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName()); + orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo()); + orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber()); + orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName()); + orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName()); + productId.append(ordersEntitys.getProductCode()+","); + productName.append(ordersEntitys.getProductName()+","); + memberId = ordersEntitys.getMemberId(); + couponCode = ordersEntitys.getCouponCode(); + mobile = ordersEntitys.getPhoneNumber(); + buyCount = buyCount + ordersEntitys.getBuyCount(); + } + //验证优惠卷 + if (couponCode != "" && couponCode != null) { CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity(); - couponGetAllEntity.setMemberId(ordersEntitys.getMemberId()); - couponGetAllEntity.setCouponCode(ordersEntitys.getCouponCode()); + couponGetAllEntity.setMemberId(memberId); + couponGetAllEntity.setCouponCode(couponCode); String couponInfo = couponService.couponGetAll(couponGetAllEntity); JSONObject jsonObject = JSONObject.parseObject(couponInfo); com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data")); @@ -220,23 +247,8 @@ public class OrderController { ordersEntity.setCouponName(jsonObjectData.getString("couponName")); ordersEntity.setCouponId(jsonObjectData.getString("couponId")); ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); - total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); - } else { - total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); + total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee); } - basePoint = basePoint + ordersEntitys.getBasePoint(); - orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName()); - orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName()); - orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo()); - orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber()); - orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName()); - orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName()); - productId.append(ordersEntitys.getProductCode()+","); - productName.append(ordersEntitys.getProductName()+","); - memberId = ordersEntitys.getMemberId(); - mobile = ordersEntitys.getPhoneNumber(); - buyCount = buyCount + ordersEntitys.getBuyCount(); - } ordersEntity.setOrderAddress(orderAddress); ordersEntity.setProductCode(productId.substring(0,productId.length()-1)); ordersEntity.setProductName(productName.substring(0,productName.length()-1)); @@ -276,7 +288,6 @@ public class OrderController { StringBuffer productId = new StringBuffer(); StringBuffer productName = new StringBuffer(); Map resultMsg = new HashMap<>(); - String memberId = ""; String mobile = ""; int buyCount = 0; double total_fee = 0 ; @@ -285,27 +296,49 @@ public class OrderController { JSONArray orderDatilListJson = new JSONArray(); OrdersEntity ordersEntity = new OrdersEntity(); OrderAddress orderAddress = new OrderAddress(); - try { - for (OrdersEntity ordersEntitys : ordersEntityList) { - //删除购物车信息 - cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode()); - //存储orderDetailList - ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity(); - productMasterQueryEntity.setProductCode(ordersEntitys.getProductCode()); - String goodsStr = goodService.productQuery(productMasterQueryEntity); - com.alibaba.fastjson.JSONArray jsonGoodsArray = JSONObject.parseArray(goodsStr); - JSONObject goodsObject = (JSONObject)jsonGoodsArray.get(0); - OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity(); - orderDatilListEntity.setProductName(goodsObject.getString("productName")); - orderDatilListEntity.setPcs(ordersEntitys.getBuyCount()); - orderDatilListEntity.setProductCode(goodsObject.getString("productCode")); - orderDatilListEntity.setEcPrice(goodsObject.getString("ecPrice")); - orderDatilListJson.add(orderDatilListEntity); - if (ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) { + String memberId = ""; + String couponCode = ""; + try { + for (OrdersEntity ordersEntitys : ordersEntityList) { + + //删除购物车信息 + cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode()); + //存储orderDetailList + ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity(); + productMasterQueryEntity.setProductCode(ordersEntitys.getProductCode()); + String goodsStr = goodService.productQuery(productMasterQueryEntity); + + com.alibaba.fastjson.JSONArray jsonGoodsArray = JSONObject.parseArray(goodsStr); + JSONObject goodsObject = (JSONObject)jsonGoodsArray.get(0); + OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity(); + orderDatilListEntity.setProductName(goodsObject.getString("productName")); + orderDatilListEntity.setPcs(ordersEntitys.getBuyCount()); + orderDatilListEntity.setProductCode(goodsObject.getString("productCode")); + orderDatilListEntity.setEcPrice(goodsObject.getString("ecPrice")); + orderDatilListJson.add(orderDatilListEntity); + + total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); + + basePoint = basePoint + ordersEntitys.getBasePoint(); + orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName()); + orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName()); + orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo()); + orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber()); + orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName()); + orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName()); + productId.append(ordersEntitys.getProductCode()+","); + productName.append(ordersEntitys.getProductName()+","); + memberId = ordersEntitys.getMemberId(); + couponCode = ordersEntitys.getCouponCode(); + mobile = ordersEntitys.getPhoneNumber(); + buyCount = buyCount + ordersEntitys.getBuyCount(); + } + //验证优惠卷 + if (couponCode != "" && couponCode != null) { CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity(); - couponGetAllEntity.setMemberId(ordersEntitys.getMemberId()); - couponGetAllEntity.setCouponCode(ordersEntitys.getCouponCode()); + couponGetAllEntity.setMemberId(memberId); + couponGetAllEntity.setCouponCode(couponCode); String couponInfo = couponService.couponGetAll(couponGetAllEntity); JSONObject jsonObject = JSONObject.parseObject(couponInfo); com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data")); @@ -323,34 +356,19 @@ public class OrderController { ordersEntity.setCouponName(jsonObjectData.getString("couponName")); ordersEntity.setCouponId(jsonObjectData.getString("couponId")); ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); - total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); - } else { - total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); + total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee); } - basePoint = basePoint + ordersEntitys.getBasePoint(); - orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName()); - orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName()); - orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo()); - orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber()); - orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName()); - orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName()); - productId.append(ordersEntitys.getProductCode()+","); - productName.append(ordersEntitys.getProductName()+","); - memberId = ordersEntitys.getMemberId(); - mobile = ordersEntitys.getPhoneNumber(); - buyCount = buyCount + ordersEntitys.getBuyCount(); - } - ordersEntity.setOrderAddress(orderAddress); - ordersEntity.setProductCode(productId.substring(0,productId.length()-1)); - ordersEntity.setProductName(productName.substring(0,productName.length()-1)); - ordersEntity.setOrderAmount(StringUtil.toString(total_fee)); - ordersEntity.setMemberId(memberId); - ordersEntity.setPhoneNumber(mobile); - ordersEntity.setBuyCount(buyCount); - ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo()); - ordersEntity.setOrderStatus("0"); - ordersEntity.setBasePoint(basePoint); - ordersEntity.setPayType("3"); + ordersEntity.setOrderAddress(orderAddress); + ordersEntity.setProductCode(productId.substring(0,productId.length()-1)); + ordersEntity.setProductName(productName.substring(0,productName.length()-1)); + ordersEntity.setOrderAmount(StringUtil.toString(total_fee)); + ordersEntity.setMemberId(memberId); + ordersEntity.setPhoneNumber(mobile); + ordersEntity.setBuyCount(buyCount); + ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo()); + ordersEntity.setOrderStatus("0"); + ordersEntity.setBasePoint(basePoint); + ordersEntity.setPayType("3"); resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson); //判断订单生成状况 if (resultMsg.get("code").equals("1")) { diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java index be8f95a9..5d09ca89 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/royalcanin/good/service/OrderService.java @@ -3,6 +3,7 @@ package net.lab1024.smartadmin.module.system.royalcanin.good.service; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import net.lab1024.smartadmin.common.domain.ResponseDTO; +import net.lab1024.smartadmin.common.heartbeat.IpUtil; import net.lab1024.smartadmin.common.heartbeat.StringUtil; import net.lab1024.smartadmin.module.system.royalcanin.CouponService; import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCancelEntity; @@ -293,12 +294,14 @@ public class OrderService { royalcaninOperateLogEntity.setMsg(jsonObject.getString("msg")== null ?"":jsonObject.getString("msg")); royalcaninOperateLogEntity.setParams(params); royalcaninOperateLogEntity.setAcceptTime(dateformat.format(acceptTime)); + royalcaninOperateLogEntity.setData(jsonObject.getString("data") == null?"" : jsonObject.getString("data")); + royalcaninOperateLogEntity.setAccountIp(IpUtil.getLocalIP() == null ?"":IpUtil.getLocalIP()); royalcaninOperateLogService.add(royalcaninOperateLogEntity); return ResponseDTO.succ(); } - public double couponTotal(String couponTypeId,double discount,double total,int buyCount){ + public double couponTotal(String couponTypeId,double discount,double total){ double endTotal = 0; switch (couponTypeId) { @@ -306,22 +309,19 @@ public class OrderService { // endTotal = (total * (buyCount-1)) + (total * discount); // break; case "2": - endTotal = total * buyCount - discount; + endTotal = total - discount; break; case "3": - endTotal = (total * buyCount) * (1-discount); + endTotal = total * (1-discount); break; case "1" : - endTotal = total * buyCount - discount; + endTotal = total - discount; break; case "4" : - endTotal = (total * buyCount) * (1-discount); + endTotal = total * (1-discount); break; case "6" : - endTotal = total * buyCount - discount; - break; - case "0": - endTotal = total * buyCount; + endTotal = total - discount; break; } return endTotal; diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/wxpay/WxpayService.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/wxpay/WxpayService.java index 95f03fdb..c9ad2a92 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/wxpay/WxpayService.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/module/system/wxpay/WxpayService.java @@ -15,6 +15,7 @@ import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity; import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPay; import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPayUtil; import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity; +import net.lab1024.smartadmin.util.AESUtil; import net.lab1024.smartadmin.util.MapRemoveNullUtil; import net.lab1024.smartadmin.util.SmartHttpUtil; import net.lab1024.smartadmin.util.SmartIPUtil; @@ -111,7 +112,8 @@ public class WxpayService { paramMap.put("channelId","15"); String sb = SmartHttpUtil.sendPostForm(url+"productMaster/query",paramMap,null); JSONObject jsonObject = JSONObject.parseObject(sb); - com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data")); + String result = AESUtil.decryptLinux(jsonObject.getString("data"), AESUtil.KEY); + com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(result); JSONObject jsonObjectData = (JSONObject)jsonArray.get(0); basePoint = basePoint + Double.parseDouble(jsonObjectData.getString("basePoint")); } diff --git a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/util/SmartJWTUtil.java b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/util/SmartJWTUtil.java index f06863f0..0e2e8d47 100644 --- a/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/util/SmartJWTUtil.java +++ b/smart-admin-service/smart-admin-api/src/main/java/net/lab1024/smartadmin/util/SmartJWTUtil.java @@ -80,7 +80,7 @@ public class SmartJWTUtil { public static void main(String[] args) { String token = SmartJWTUtil.generateToken("884159"); System.out.println(token); - System.out.println(SmartJWTUtil.decodeToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg4NDIzNCIsImV4cCI6MTY0ODI4MjAxNX0.itFA3bb0XNk2LSD3ey3_o33GYK3Rt0v9MXiRerhu-6A")); + System.out.println(SmartJWTUtil.decodeToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg4NDEyNyIsImV4cCI6MTY0NTA5MTc5Nn0.UHEYiTkHtwQjTNjiAKg8CTP-Ab_KSfFzBiIip49gLUk")); } }