!205 adding filter coupon logic

Merge pull request !205 from Admin/sit-Carl-V3
This commit is contained in:
Admin 2022-03-10 02:22:40 +00:00 committed by Gitee
commit 933bd475e1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 82 additions and 30 deletions

View File

@ -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()));
@ -40,8 +52,19 @@ public class CouponConfigService {
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")) {
afterFilterArrary.add(jsonResult);
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").toString().indexOf(productCode[g]) != -1&&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").toString().indexOf(productCode[g]) != -1 && couponConfigFindAllEntity.getStoreCode().equals(jsonResult.get("storeCodes")!=null ?jsonResult.get("storeCodes").toString():"")&&compareDate.compareTo(currentDate)>=0) {
afterFilterArrary.add(jsonResult);
}
}
}
}
}
@ -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);
}
}

View File

@ -39,7 +39,9 @@ public class CouponService {
}
public String couponGetAll(CouponGetAllEntity couponGetAllEntity) throws Exception{
String productCode = couponGetAllEntity.getProductCode();
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,14 @@ 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")) {
afterFilterArrary.add(jsonResult);
if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)) {
if (jsonResult.get("productCodes").toString().indexOf(productCode) != -1){
afterFilterArrary.add(jsonResult);
}
}else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)){
if (jsonResult.get("productCodes").toString().indexOf(productCode) != -1 && productCode.equals(jsonResult.get("storeCodes").toString())){
afterFilterArrary.add(jsonResult);
}
}
}
}

View File

@ -108,4 +108,8 @@ public class CouponGetAllEntity {
@ApiModelProperty(example = "1")
private int page;
private String productCode = "";
}

View File

@ -46,4 +46,8 @@ public class CouponConfigFindAllEntity {
@ApiModelProperty(example = "1")
private int page;
private String storeCode = "";
private String productCode = "";
}

View File

@ -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"));
}
}

View File

@ -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,