mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
!212 adding filter coupon logic
Merge pull request !212 from Admin/sit-Carl
This commit is contained in:
commit
835a389654
@ -473,32 +473,27 @@ export const goodsmessage = (productCode) => {
|
||||
}
|
||||
|
||||
|
||||
//优惠券的查询
|
||||
export const getdiscount = (memberId,channelSecurity,mobile) => {
|
||||
//优惠券的查询
|
||||
export const getdiscount = (memberId,channelSecurity,mobile) => {
|
||||
var data = {
|
||||
memberId:memberId,
|
||||
mobile:mobile
|
||||
}
|
||||
return fetch('memberAddress?type=getAll', data, 'POST' )
|
||||
}
|
||||
}
|
||||
|
||||
//可用的优惠券
|
||||
export const alldiscount = (memberId,channelSecurity,mobile) => {
|
||||
var data = {
|
||||
memberId:memberId,
|
||||
}
|
||||
//可用的优惠券
|
||||
export const alldiscount = (paramsObj) => {
|
||||
var data = paramsObj;
|
||||
return fetch('couponConfig?type=getAll', data, 'POST' )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//用户领取的优惠券
|
||||
export const getdraw = (mobile,states) => {
|
||||
var data = {
|
||||
mobile:mobile,
|
||||
status:states
|
||||
}
|
||||
//用户领取的优惠券
|
||||
export const getdraw = (paramsObj) => {
|
||||
var data = paramsObj;
|
||||
return fetch('coupon?type=getAll', data, 'POST' )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//微信支付
|
||||
|
@ -35,7 +35,7 @@
|
||||
</picture>
|
||||
</a>
|
||||
</swiper-slide>
|
||||
|
||||
<!--
|
||||
<swiper-slide>
|
||||
<a href="#">
|
||||
<picture>
|
||||
@ -45,6 +45,7 @@
|
||||
</picture>
|
||||
</a>
|
||||
</swiper-slide>
|
||||
-->
|
||||
</swiper>
|
||||
<div
|
||||
id="homeBannerSwiperPagnation"
|
||||
|
@ -141,8 +141,14 @@ export default {
|
||||
methods: {
|
||||
...mapMutations(["changemessage","checkIsLogin"]),
|
||||
//获取用户领取的优惠券
|
||||
async userdraw(mobile,states) {
|
||||
let data = await getdraw(mobile,states);
|
||||
async userdraw(mobile) {
|
||||
//let curDate = new Date();
|
||||
let paramsToAPI = {
|
||||
mobile : mobile,
|
||||
//useStartDate : curDate.getYear()+'-'+curDate.getMonth()+'-'+curDate.getDate(),
|
||||
//productCodes : ''
|
||||
};
|
||||
let data = await getdraw(paramsToAPI);
|
||||
let _self = this;
|
||||
if(data){
|
||||
let list = [];
|
||||
@ -211,9 +217,15 @@ export default {
|
||||
if(coupon.fValidTo) {
|
||||
valDateToTime = new Date(coupon.fValidTo).getTime();
|
||||
}
|
||||
/*
|
||||
if(valDateFromTime && valDateToTime && curTime >= valDateFromTime && curTime <= valDateToTime && coupon.status == 0) {
|
||||
coupon.canUse=true;
|
||||
this.newlist.push(coupon);
|
||||
}
|
||||
*/
|
||||
if(valDateToTime && curTime <= valDateToTime && coupon.status == 0) {
|
||||
coupon.canUse=true;
|
||||
this.newlist.push(coupon);
|
||||
}
|
||||
break;
|
||||
case USED:
|
||||
|
@ -388,7 +388,18 @@ export default {
|
||||
},
|
||||
//获取用户领取的优惠券
|
||||
async userdraw(mobile) {
|
||||
let data = await getdraw(mobile);
|
||||
let curDate = new Date();
|
||||
let productCodes = [];
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
productCodes.push(itemInCart.productCode);
|
||||
}
|
||||
let paramsToAPI = {
|
||||
mobile : mobile,
|
||||
useStartDate : curDate.getFullYear()+'-'+(curDate.getMonth()+1)+'-'+curDate.getDate(),
|
||||
};
|
||||
if(productCodes)
|
||||
paramsToAPI.productCodes = productCodes.join(',');
|
||||
let data = await getdraw(paramsToAPI);
|
||||
let _self = this;
|
||||
let curTime = new Date().getTime();
|
||||
let valDateFromTime=0;
|
||||
@ -397,18 +408,27 @@ export default {
|
||||
let avaliableCouponNum = 0;
|
||||
if (data) {
|
||||
this.drawlist=[];
|
||||
avaliableCouponNum = data.length;
|
||||
this.drawlist = data.data;
|
||||
/*
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
let tmpIndex=0;
|
||||
for(let myCoupon of data.data) {
|
||||
valDateFromTime=0;
|
||||
valDateToTime=0;
|
||||
dateChecked=true;
|
||||
|
||||
if(myCoupon.fValidFrom) {
|
||||
//Fix ios date issue
|
||||
myCoupon.fValidFrom = myCoupon.fValidFrom.replace(/-/g, '/');
|
||||
valDateFromTime = new Date(myCoupon.fValidFrom).getTime();
|
||||
}
|
||||
if(myCoupon.fValidTo) {
|
||||
//Fix ios date issue
|
||||
myCoupon.fValidTo = myCoupon.fValidTo.replace(/-/g, '/');
|
||||
valDateToTime = new Date(myCoupon.fValidTo).getTime();
|
||||
}
|
||||
|
||||
if(valDateFromTime && curTime < valDateFromTime) {
|
||||
dateChecked=false;
|
||||
}
|
||||
@ -433,6 +453,7 @@ export default {
|
||||
tmpIndex++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if(avaliableCouponNum > 0) {
|
||||
this.curCoupon.couponName = '有 '+avaliableCouponNum+' 张优惠券可以使用';
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ export default {
|
||||
this.curItem.curGoodUrl = this.curItem.goodUrl.pc;
|
||||
}
|
||||
this.usermessage = this.$store.state.userInfo;
|
||||
if (this.usermessage !== "" || this.usermessage.data !== undefined) {
|
||||
//if (this.usermessage !== "" || this.usermessage.data !== undefined) {
|
||||
this.productCode = this.$route.query.productCode;
|
||||
_hmt.push([
|
||||
"_trackCustomEvent",
|
||||
@ -483,7 +483,7 @@ export default {
|
||||
"product_name": this.curItem.productName,
|
||||
}
|
||||
])
|
||||
}
|
||||
//}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["changemessage","checkIsLogin"]),
|
||||
@ -562,8 +562,19 @@ export default {
|
||||
},
|
||||
|
||||
//获取所有的优惠券
|
||||
async alldrawlist(memberId) {
|
||||
let data = await alldiscount(memberId);
|
||||
async alldrawlist() {
|
||||
this.checkIsLogin();
|
||||
this.usermessage = this.$store.state.userInfo;
|
||||
let storeCode = '';
|
||||
if(this.usermessage && this.usermessage.data && this.usermessage.data.storeCode) {
|
||||
storeCode = this.usermessage.data.storeCode
|
||||
}
|
||||
let paramsToAPI={
|
||||
productCode:this.curItem.productCode,
|
||||
};
|
||||
if(storeCode)
|
||||
paramsToAPI.stroeCode = stroeCode;
|
||||
let data = await alldiscount(paramsToAPI);
|
||||
let userlist = [];
|
||||
let menulsit = [];
|
||||
if (data) {
|
||||
@ -574,9 +585,6 @@ export default {
|
||||
this.userlist.forEach((element, index) => {
|
||||
if (typeof element.productCodes == "string" || !element.productCodes) {
|
||||
userlist.push(element);
|
||||
// let s=element.productCodes.split(',');
|
||||
// console.log(s.indexOf(this.productCode) != -1 )
|
||||
// console.log('这是字符串')
|
||||
}
|
||||
});
|
||||
let menualist = [];
|
||||
@ -585,21 +593,37 @@ export default {
|
||||
let valDateToTime=0;
|
||||
let curTime = new Date().getTime();
|
||||
let dateChecked=true;
|
||||
/*
|
||||
if(item.publishFrom && curTime < item.publishFrom) {
|
||||
dateChecked=false;
|
||||
}
|
||||
if(item.publishTo && curTime > item.publishTo) {
|
||||
dateChecked=false;
|
||||
}
|
||||
|
||||
if(item.fValidFrom) {
|
||||
//Fix ios date issue
|
||||
item.fValidFrom = item.fValidFrom.replace(/-/g, '/');
|
||||
valDateFromTime = new Date(item.fValidFrom).getTime();
|
||||
}
|
||||
if(item.fValidTo) {
|
||||
//Fix ios date issue
|
||||
item.fValidTo = item.fValidTo.replace(/-/g, '/');
|
||||
valDateToTime = new Date(item.fValidTo).getTime();
|
||||
}
|
||||
|
||||
if(valDateFromTime && curTime < valDateFromTime) {
|
||||
dateChecked=false;
|
||||
}
|
||||
if(valDateToTime && curTime > valDateToTime) {
|
||||
dateChecked=false;
|
||||
}
|
||||
|
||||
if(item.packageTypeIds!='1') {
|
||||
dateChecked=false;
|
||||
}
|
||||
*/
|
||||
|
||||
if(this.mainProduct && this.mainProduct.petType && item.petCategoryIds) {
|
||||
if(this.mainProduct.petType===0 && item.petCategoryIds!='1')
|
||||
dateChecked=false;
|
||||
@ -611,7 +635,7 @@ export default {
|
||||
if(item.petAgeTypeIds!=productToCouponAgeId)
|
||||
dateChecked=false;
|
||||
}
|
||||
|
||||
/*
|
||||
if(dateChecked && item.activityId!=10) {
|
||||
if(!item.productCodes) {
|
||||
menualist.push(item);
|
||||
@ -626,6 +650,12 @@ export default {
|
||||
} else {
|
||||
//Expired coupons
|
||||
}
|
||||
*/
|
||||
if(dateChecked) {
|
||||
menualist.push(item);
|
||||
} else {
|
||||
//Expired coupons
|
||||
}
|
||||
});
|
||||
this.usernewlist = menualist;
|
||||
}
|
||||
@ -741,7 +771,7 @@ export default {
|
||||
return;
|
||||
} else {
|
||||
//this.userdraw(this.usermessage.data.mobile);
|
||||
this.alldrawlist(this.usermessage.data.id);
|
||||
this.alldrawlist();
|
||||
this.dialogInfo1 = true;
|
||||
}
|
||||
},
|
||||
|
@ -6,10 +6,15 @@ import net.lab1024.smartadmin.common.heartbeat.StringUtil;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.couponConfig.CouponConfigFindAllEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.couponConfig.CouponConfigGetEntity;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartDateUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@ -24,8 +29,15 @@ public class CouponConfigService {
|
||||
return SmartHttpUtil.sendPostForm(url+"get",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponConfigFindAll(CouponConfigFindAllEntity couponConfigFindAllEntity) throws Exception{
|
||||
public String couponConfigFindAll(CouponConfigFindAllEntity couponConfigFindAllEntity){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date currentDate = SmartDateUtil.parseYMD(sdf.format(new Date()));
|
||||
|
||||
String storeCode = couponConfigFindAllEntity.getStoreCode();
|
||||
String[] productCode = couponConfigFindAllEntity.getProductCode().split(",");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponConfigFindAllEntity);
|
||||
paramMap.remove("storeCode");
|
||||
paramMap.remove("productCode");
|
||||
paramMap.put("memberTagId",StringUtil.toString(couponConfigFindAllEntity.getMemberTagId()).equals("0")?null:StringUtil.toString(couponConfigFindAllEntity.getMemberTagId()));
|
||||
paramMap.put("memberId",StringUtil.toString(couponConfigFindAllEntity.getMemberId()).equals("0")?null:StringUtil.toString(couponConfigFindAllEntity.getMemberId()));
|
||||
paramMap.put("rows",StringUtil.toString(couponConfigFindAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponConfigFindAllEntity.getRows()));
|
||||
@ -39,11 +51,22 @@ public class CouponConfigService {
|
||||
com.alibaba.fastjson.JSONArray afterFilterArrary = new JSONArray();
|
||||
for(int i = 0;i < jsonArray.size();i ++){
|
||||
JSONObject jsonResult = (JSONObject)jsonArray.get(i);
|
||||
if(jsonResult.getString("udf2") != null) {
|
||||
if (jsonResult.getString("udf2").equals("H5")) {
|
||||
if(jsonResult.getString("udf2") != null&& !"0".equals(jsonResult.getString("leftAllotment"))) {
|
||||
Date compareDate = SmartDateUtil.parseYMD(jsonResult.get("fPublishTo").toString());
|
||||
if ("H5".equals(jsonResult.getString("udf2"))&&"".equals(storeCode)&&!"".equals(productCode)) {
|
||||
for(int g = 0 ;g<productCode.length;g++) {
|
||||
if (((jsonResult.get("productCodes")!=null?jsonResult.get("productCodes").toString().indexOf(productCode[g]):"".indexOf(productCode[g])) != -1||jsonResult.get("productCodes")==null)&&compareDate.compareTo(currentDate)>=0) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
}
|
||||
}
|
||||
}else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(storeCode)&&!"".equals(productCode)){
|
||||
for(int g = 0 ;g<productCode.length;g++) {
|
||||
if (((jsonResult.get("productCodes")!=null?jsonResult.get("productCodes").toString().indexOf(productCode[g]):"".indexOf(productCode[g])) != -1 ||jsonResult.get("productCodes")==null)&& couponConfigFindAllEntity.getStoreCode().equals(jsonResult.get("storeCodes")!=null ?jsonResult.get("storeCodes").toString():"")&&compareDate.compareTo(currentDate)>=0) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject JSONResult = new JSONObject();
|
||||
JSONResult.put("code",jsonObjectResult.getString("code"));
|
||||
@ -52,4 +75,16 @@ public class CouponConfigService {
|
||||
return JSONResult.toJSONString();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String spStr = "8110000807,811000080123";
|
||||
// String str = "8110000807,81100008012,81100008024,8111000807,81110008012,81110008024,8112001007,8112001012,8112001024,8113001007,8113001012,8113001024,80230008F07,80240008F07,80250008F07,8023450008F07,8023450008F12,8026780008F07,8026780008F12,8023450008F24,8026780008F24,81220020F03,80210020F03,81220020F06,80210020F06,81220020F12,81220020F24,80210020F12,80260008F07,80270008F07,80280008F07,80290008F07,80230008F12,80240008F12,80250008F12,80230008F24,80240008F24,80250008F24,80260008F12,80270008F12,80280008F12,80290008F12,80260008F24,80270008F24,80280008F24,80290008F24,81350008F07,80330008F07,80310008F07,81350008F12,80330008F12,80310008F12";
|
||||
// String[] splitStr =spStr.split(",");
|
||||
// for(int i = 0 ;i < splitStr.length;i++){
|
||||
// System.out.println(str.indexOf(splitStr[i]));>SmartDateUtil.formatYMD(date)
|
||||
// }
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date currentDate = SmartDateUtil.parseYMD(sdf.format(new Date()));
|
||||
System.out.println(SmartDateUtil.parseYMD("2022-03-9").compareTo(currentDate)>=0);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ public class CouponService {
|
||||
}
|
||||
|
||||
public String couponGetAll(CouponGetAllEntity couponGetAllEntity) throws Exception{
|
||||
String productCode = couponGetAllEntity.getProductCodes();
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetAllEntity);
|
||||
paramMap.remove("productCode");
|
||||
paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("0")?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()));
|
||||
@ -52,8 +54,12 @@ public class CouponService {
|
||||
for(int i = 0;i < jsonArray.size();i ++){
|
||||
JSONObject jsonResult = (JSONObject)jsonArray.get(i);
|
||||
if(jsonResult.getString("udf2") != null) {
|
||||
if (jsonResult.getString("udf2").equals("H5")) {
|
||||
if ("H5".equals(jsonResult.getString("udf2"))&&"".equals(productCode)) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
}else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)){
|
||||
if ((jsonResult.get("productCodes")!=null?jsonResult.get("productCodes").toString().indexOf(productCode):"".indexOf(productCode)) != -1 ||jsonResult.get("productCodes")==null){
|
||||
afterFilterArrary.add(jsonResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,4 +108,8 @@ public class CouponGetAllEntity {
|
||||
|
||||
@ApiModelProperty(example = "1")
|
||||
private int page;
|
||||
|
||||
|
||||
private String productCodes = "";
|
||||
|
||||
}
|
||||
|
@ -46,4 +46,8 @@ public class CouponConfigFindAllEntity {
|
||||
@ApiModelProperty(example = "1")
|
||||
private int page;
|
||||
|
||||
private String storeCode = "";
|
||||
|
||||
private String productCode = "";
|
||||
|
||||
}
|
||||
|
@ -58,10 +58,11 @@ public class OrderController {
|
||||
|
||||
@ApiOperation(value = "微信支付订单", notes = "生成订单")
|
||||
@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 productName = new StringBuffer();
|
||||
StringBuffer remark = new StringBuffer();
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
String memberId = "";
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
@ -73,7 +74,7 @@ public class OrderController {
|
||||
OrderAddress orderAddress = new OrderAddress();
|
||||
try {
|
||||
for (OrdersEntity ordersEntitys : ordersEntityList) {
|
||||
// System.out.println("ordersEntityList.size()"+ordersEntityList.size());
|
||||
//删除购物车信息
|
||||
cartService.cancelProduct(ordersEntitys.getMemberId(), ordersEntity.getProductCode());
|
||||
//存储orderDetailList
|
||||
OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity();
|
||||
@ -89,6 +90,9 @@ public class OrderController {
|
||||
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")){
|
||||
@ -104,7 +108,6 @@ public class OrderController {
|
||||
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount();
|
||||
}
|
||||
basePoint = basePoint + ordersEntitys.getBasePoint();
|
||||
// System.out.println("basePoint"+basePoint);
|
||||
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
|
||||
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
|
||||
orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo());
|
||||
@ -129,9 +132,8 @@ public class OrderController {
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setBasePoint(basePoint);
|
||||
ordersEntity.setRemark(remark.substring(0,remark.length() - 1));
|
||||
int result = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||
if (result == 1) {
|
||||
System.out.println("orderService.generateOrder(ordersEntity, orderDatilListJson) == 1");
|
||||
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||
if (resultMsg.get("code").equals("1")) {
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
@ -139,21 +141,26 @@ public class OrderController {
|
||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
|
||||
}else if (result == 3){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED);
|
||||
}else if (resultMsg.get("code").equals("0")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("3")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("4")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
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订单")
|
||||
@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 productName = new StringBuffer();
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
String memberId = "";
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
@ -163,6 +170,7 @@ 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
|
||||
@ -179,7 +187,15 @@ public class OrderController {
|
||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
JSONObject jsonObjectData = (JSONObject)jsonArray.get(0);
|
||||
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"));
|
||||
@ -213,18 +229,26 @@ public class OrderController {
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setBasePoint(basePoint);
|
||||
ordersEntity.setPayType("3");
|
||||
|
||||
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
|
||||
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||
if (resultMsg.get("code").equals("1")) {
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
|
||||
Map<String, String> returnMap = new HashMap<>();
|
||||
returnMap.put("orderNumber",ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount",ordersEntity.getOrderAmount());
|
||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrder(wxPayEntity));
|
||||
}else if (resultMsg.get("code").equals("0")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("3")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("4")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL,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订单")
|
||||
@ -232,6 +256,7 @@ public class OrderController {
|
||||
public ResponseDTO<Map<String, String>> generateOrderWXJSAPI(@RequestBody List<OrdersEntity> ordersEntityList,String resp) throws Exception {
|
||||
StringBuffer productId = new StringBuffer();
|
||||
StringBuffer productName = new StringBuffer();
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
String memberId = "";
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
@ -241,6 +266,7 @@ 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
|
||||
@ -257,7 +283,15 @@ public class OrderController {
|
||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
JSONObject jsonObjectData = (JSONObject)jsonArray.get(0);
|
||||
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"));
|
||||
@ -291,18 +325,27 @@ public class OrderController {
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setBasePoint(basePoint);
|
||||
ordersEntity.setPayType("3");
|
||||
|
||||
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
|
||||
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||
//判断订单生成状况
|
||||
if (resultMsg.get("code").equals("1")) {
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
|
||||
Map<String, String> returnMap = new HashMap<>();
|
||||
returnMap.put("orderNumber",ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount",ordersEntity.getOrderAmount());
|
||||
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrderJSAPI(wxPayEntity,resp));
|
||||
returnMap.put("orderNumber", ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount", ordersEntity.getOrderAmount());
|
||||
return ResponseDTO.succData(returnMap, wxpayService.generateQRCode(wxPayEntity));
|
||||
}else if (resultMsg.get("code").equals("0")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("3")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("4")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL,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 ;
|
||||
|
||||
@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();
|
||||
Map<String, String>resultMap = new HashMap<>();
|
||||
try {
|
||||
if (ordersEntity.getCouponCode() != "" && null != ordersEntity.getCouponCode()) {
|
||||
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
|
||||
@ -64,7 +65,9 @@ public class OrderService {
|
||||
couponCosumeEntity.setRealCouponAmount(realCouponAmount);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponService.couponCosume(couponCosumeEntity));
|
||||
if (!jsonObject.getString("code").equals("0")) {
|
||||
return 3;
|
||||
resultMap.put("code","4");
|
||||
resultMap.put("msg",jsonObject.getString("msg"));
|
||||
return resultMap;
|
||||
}
|
||||
//coupon json化
|
||||
OrderCouponEntity orderCouponEntity = new OrderCouponEntity();
|
||||
@ -99,35 +102,45 @@ public class OrderService {
|
||||
addOrSaveEntity.setAddressUserName(orderAddress.getAddressUserName());
|
||||
JSONObject jsonObject = JSONObject.parseObject(addOrSave(addOrSaveEntity));
|
||||
|
||||
if (jsonObject.getString("code").equals("1"))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
if (jsonObject.getString("code").equals("1")){
|
||||
resultMap.put("code",jsonObject.getString("code"));
|
||||
resultMap.put("msg",jsonObject.getString("msg"));
|
||||
return resultMap;
|
||||
}else{
|
||||
resultMap.put("code",jsonObject.getString("code"));
|
||||
resultMap.put("msg",jsonObject.getString("msg"));
|
||||
return resultMap;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
resultMap.put("code","0");
|
||||
resultMap.put("msg","订单生成有误,请联系管理员!");
|
||||
return resultMap;
|
||||
}
|
||||
}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){
|
||||
if(notifyService.findNotifyByOrderNumber(orderNumber) != null)
|
||||
if(notifyService.findNotifyByOrderNumber(orderNumber) != null) {
|
||||
return 1;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Boolean afterPaySucceedUpdateOrderStatus(String outTradeNo,String totalFee){
|
||||
int result = ordersDao.updateOrderStatus(outTradeNo,totalFee);
|
||||
if(result == 1)
|
||||
if(result == 1) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ResponseDTO<String> cancelOrder(String addOrSaveJson) throws Exception {
|
||||
|
@ -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.eyJpZCI6Ijg4NDE1OSIsImV4cCI6MTY0NjM4Mzk1NH0.-ilK-e-49c88IxdkSW1QMNZQ3P2LG7iIsQRXYlrXjjo"));
|
||||
System.out.println(SmartJWTUtil.decodeToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg4NDIzNCIsImV4cCI6MTY0ODI4MjAxNX0.itFA3bb0XNk2LSD3ey3_o33GYK3Rt0v9MXiRerhu-6A"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1604,30 +1604,31 @@ CREATE TABLE IF NOT EXISTS `t_royalcanin_operate_log` (
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
|
||||
DROP TABLE IF EXISTS `t_good_orders`;
|
||||
CREATE TABLE `t_good_orders` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_no` varchar(20) DEFAULT NULL COMMENT '订单号',
|
||||
`order_status` varchar(20) DEFAULT NULL COMMENT '0:待付款,1:待收货,2:已完成,3:已取消,4:异常订单',
|
||||
`order_amount` varchar(11) DEFAULT NULL COMMENT '订单金额',
|
||||
`pay_amount` varchar(11) DEFAULT NULL COMMENT '实际支付金额',
|
||||
`product_code` varchar(20) DEFAULT NULL COMMENT '产品表外键ID',
|
||||
`coupon_code` varchar(20) DEFAULT NULL COMMENT '优惠券code',
|
||||
`coupon_id` varchar(20) DEFAULT NULL COMMENT '优惠券ID',
|
||||
`coupon_name` varchar(20) DEFAULT NULL COMMENT '优惠券名字',
|
||||
`coupon_amount` varchar(20) DEFAULT NULL COMMENT '优惠券金额',
|
||||
`product_name` varchar(50) DEFAULT NULL COMMENT '产品名字',
|
||||
`member_id` varchar(20) DEFAULT NULL COMMENT '用户member',
|
||||
`phone_number` varchar(20) DEFAULT NULL COMMENT '用户手机',
|
||||
`buy_count` int(11) DEFAULT NULL COMMENT '产品购买的个数',
|
||||
`base_point` int(11) DEFAULT NULL COMMENT '产品积分',
|
||||
`pay_type` int(11) DEFAULT NULL COMMENT '支付方式 1:支付宝 2:微信',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '订单创建时间',
|
||||
`pay_time` datetime DEFAULT NULL COMMENT '支付时间',
|
||||
`remark` varchar(20) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
|
||||
|
||||
CREATE TABLE `t_good_orders` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_no` varchar(20) DEFAULT NULL COMMENT '订单号',
|
||||
`order_status` varchar(20) DEFAULT NULL COMMENT '0:待付款,1:待收货,2:已完成,3:已取消,4:异常订单',
|
||||
`order_amount` varchar(11) DEFAULT NULL COMMENT '订单金额',
|
||||
`pay_amount` varchar(11) DEFAULT NULL COMMENT '实际支付金额',
|
||||
`product_code` varchar(20) DEFAULT NULL COMMENT '产品表外键ID',
|
||||
`coupon_code` varchar(20) DEFAULT NULL COMMENT '优惠券code',
|
||||
`coupon_id` varchar(20) DEFAULT NULL COMMENT '优惠券ID',
|
||||
`coupon_name` varchar(20) DEFAULT NULL COMMENT '优惠券名字',
|
||||
`coupon_amount` varchar(20) DEFAULT NULL COMMENT '优惠券金额',
|
||||
`product_name` varchar(50) DEFAULT NULL COMMENT '产品名字',
|
||||
`member_id` varchar(20) DEFAULT NULL COMMENT '用户member',
|
||||
`phone_number` varchar(20) DEFAULT NULL COMMENT '用户手机',
|
||||
`buy_count` int(11) DEFAULT NULL COMMENT '产品购买的个数',
|
||||
`base_point` int(11) DEFAULT NULL COMMENT '产品积分',
|
||||
`pay_type` int(11) DEFAULT NULL COMMENT '支付方式 1:支付宝 2:微信',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '订单创建时间',
|
||||
`pay_time` datetime DEFAULT NULL COMMENT '支付时间',
|
||||
`remark` varchar(20) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
|
||||
|
||||
DROP TABLE IF EXISTS `t_good_goods`;
|
||||
CREATE TABLE `t_good_goods` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`product_code` VARCHAR(20) NOT NULL COMMENT '标品编码',
|
||||
@ -1688,7 +1689,7 @@ CREATE TABLE IF NOT EXISTS `t_royalcanin_notify_operate_log` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `t_royalcanin_productsearchtag`;
|
||||
CREATE TABLE `t_royalcanin_productsearchtag` (
|
||||
`id` int(50) NOT NULL,
|
||||
`brand_code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user