圣诞快乐
# v1.3 更新列表
1. 【新增】砍价
2. 【新增】拼团
3. 【新增】一号通
4. 【修复】商品sku 编辑时出现商品属性对应错误的问题
5. 【修复】商品推广海报生成二维码可能会出错的问题【小程序调试中】
6. 【修复】微信公众号和小程序头像可能获取不到的问题
7. 【修复】下单时可能会出错的问题
8. 【修复】pc管理端用户访问量
9. 【修复】微信退款
10. 【修复】管理端订单状态可能出现不正确的情况
11. 【修复】WEB管理端-菜单色调,短信API更新,首页用户访问量,系统设置tab是自动选择下一及表单
12. 【修复】系统设置出现更新不正确的问题
This commit is contained in:
@@ -57,4 +57,7 @@ public class CheckAdminToken {
|
||||
}
|
||||
return request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
||||
}
|
||||
|
||||
public static String st = "ags0o175LNCnToaXF9EaLdQ";
|
||||
public static String sk = "p&va7ylslUKwgx1vm8)L";
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ public class CheckFrontToken {
|
||||
String[] routerList = {
|
||||
"api/front/product/detail",
|
||||
"api/front/coupons",
|
||||
"api/front/index"
|
||||
"api/front/index",
|
||||
"api/front/bargain/list",
|
||||
"api/front/combination/list"
|
||||
};
|
||||
|
||||
return ArrayUtils.contains(routerList, uri);
|
||||
|
||||
@@ -9,6 +9,18 @@ import com.github.pagehelper.PageInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公共分页对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class CommonPage<T> {
|
||||
private Integer page = Constants.DEFAULT_PAGE;
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.common;
|
||||
import com.exception.ExceptionCodeEnum;
|
||||
import com.exception.ExceptionHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 公共返回对象
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -52,6 +56,28 @@ public class CommonResult<T> {
|
||||
return new CommonResult<T>(ExceptionCodeEnum.SUCCESS.getCode(), ExceptionCodeEnum.SUCCESS.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @param record 获取的数据
|
||||
*/
|
||||
public static CommonResult<Map<String, Object>> success(MyRecord record) {
|
||||
return new CommonResult<>(ExceptionCodeEnum.SUCCESS.getCode(), ExceptionCodeEnum.SUCCESS.getMessage(), record.getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @param recordList 获取的数据
|
||||
*/
|
||||
public static CommonResult<List<Map<String, Object>>> success(List<MyRecord> recordList) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
recordList.forEach(i -> {
|
||||
list.add(i.getColumns());
|
||||
});
|
||||
return new CommonResult<>(ExceptionCodeEnum.SUCCESS.getCode(), ExceptionCodeEnum.SUCCESS.getMessage(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
|
||||
458
crmeb/src/main/java/com/common/MyRecord.java
Normal file
458
crmeb/src/main/java/com/common/MyRecord.java
Normal file
@@ -0,0 +1,458 @@
|
||||
package com.common;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 公共对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public class MyRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 905784513600884082L;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MyRecord.class);
|
||||
|
||||
private Map<String, Object> columns;
|
||||
|
||||
void setColumnsMap(Map<String, Object> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return columns map.
|
||||
*/
|
||||
public Map<String, Object> getColumns() {
|
||||
if (null == columns) {
|
||||
columns = new HashMap<String, Object>();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns value with map.
|
||||
*
|
||||
* @param columns the columns map
|
||||
*/
|
||||
public MyRecord setColums(Map<String, Object> columns) {
|
||||
this.getColumns().putAll(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns value with MyRecord.
|
||||
*
|
||||
* @param record the MyRecord object
|
||||
*/
|
||||
public MyRecord setColums(MyRecord record) {
|
||||
this.getColumns().putAll(record.getColumns());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns value with JSONObject.
|
||||
*
|
||||
* @param jsonObject the MyRecord object
|
||||
*/
|
||||
public MyRecord setColums(JSONObject jsonObject) {
|
||||
Map<String, Object> columns = this.getColumns();
|
||||
jsonObject.forEach(columns::put);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set columns value with Model object.
|
||||
* @param t
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public <T> MyRecord setColums(T t) {
|
||||
Map<String, Object> columns = this.getColumns();
|
||||
|
||||
String[] fieldNames = getFiledName(t);
|
||||
|
||||
for (int i = 0; i < fieldNames.length; i++) {
|
||||
String name = fieldNames[i];
|
||||
if (!StringUtils.isEmpty(name) &&"serialVersionUID".equals(name)) {
|
||||
continue ;
|
||||
}
|
||||
Object value = getFieldValueByName(name, t);
|
||||
if (null != value) {
|
||||
// if (getFiledType(name, t).equals(Date.class)) {
|
||||
// value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date)value);
|
||||
// }
|
||||
columns.put(name, value);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove attribute of this myRecord.
|
||||
*
|
||||
* @param column the column name of the myRecord
|
||||
*/
|
||||
public MyRecord remove(String column) {
|
||||
getColumns().remove(column);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove columns of this myRecord.
|
||||
*
|
||||
* @param columns the column names of the myRecord
|
||||
*/
|
||||
public MyRecord remove(String... columns) {
|
||||
if (columns != null)
|
||||
for (String c : columns)
|
||||
this.getColumns().remove(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove columns if it is null.
|
||||
*/
|
||||
public MyRecord removeNullValueColumns() {
|
||||
for (java.util.Iterator<Map.Entry<String, Object>> it = getColumns().entrySet().iterator(); it.hasNext(); ) {
|
||||
Map.Entry<String, Object> e = it.next();
|
||||
if (e.getValue() == null) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep columns of this record and remove other columns.
|
||||
*
|
||||
* @param columns the column names of the record
|
||||
*/
|
||||
public MyRecord keep(String... columns) {
|
||||
if (columns != null && columns.length > 0) {
|
||||
Map<String, Object> newColumns = new HashMap<String, Object>(columns.length); // getConfig().containerFactory.getColumnsMap();
|
||||
for (String c : columns)
|
||||
if (this.getColumns().containsKey(c)) // prevent put null value to the newColumns
|
||||
newColumns.put(c, this.getColumns().get(c));
|
||||
|
||||
this.getColumns().clear();
|
||||
this.getColumns().putAll(newColumns);
|
||||
} else
|
||||
this.getColumns().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep column of this record and remove other columns.
|
||||
*
|
||||
* @param column the column names of the record
|
||||
*/
|
||||
public MyRecord keep(String column) {
|
||||
if (getColumns().containsKey(column)) { // prevent put null value to the newColumns
|
||||
Object keepIt = getColumns().get(column);
|
||||
getColumns().clear();
|
||||
getColumns().put(column, keepIt);
|
||||
} else
|
||||
getColumns().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all columns of this record.
|
||||
*/
|
||||
public MyRecord clear() {
|
||||
getColumns().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set column to record.
|
||||
*
|
||||
* @param column the column name
|
||||
* @param value the value of the column
|
||||
*/
|
||||
public MyRecord set(String column, Object value) {
|
||||
getColumns().put(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set column to record.
|
||||
*
|
||||
* @param column the column name
|
||||
* @param valueList the value of the column
|
||||
*/
|
||||
public MyRecord set(String column, List<MyRecord> valueList) {
|
||||
List<HashMap<String, Object>> value = new ArrayList<>();
|
||||
valueList.forEach(o -> {
|
||||
HashMap<String, Object> va = new HashMap<>(o.getColumns());
|
||||
value.add(va);
|
||||
});
|
||||
getColumns().put(column, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of any mysql type
|
||||
*/
|
||||
public <T> T get(String column) {
|
||||
return (T) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of any mysql type. Returns defaultValue if null.
|
||||
*/
|
||||
public <T> T get(String column, Object defaultValue) {
|
||||
Object result = getColumns().get(column);
|
||||
return (T) (result != null ? result : defaultValue);
|
||||
}
|
||||
|
||||
public Object getObject(String column) {
|
||||
return getColumns().get(column);
|
||||
}
|
||||
|
||||
public Object getObject(String column, Object defaultValue) {
|
||||
Object result = getColumns().get(column);
|
||||
return result != null ? result : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: varchar, char, enum, set, text, tinytext, mediumtext, longtext
|
||||
*/
|
||||
public String getStr(String column) {
|
||||
// return (String)getColumns().get(column);
|
||||
Object s = getColumns().get(column);
|
||||
return s != null ? s.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: int, integer, tinyint(n) n > 1, smallint, mediumint
|
||||
*/
|
||||
public Integer getInt(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.intValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: bigint
|
||||
*/
|
||||
public Long getLong(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.longValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: unsigned bigint
|
||||
*/
|
||||
public java.math.BigInteger getBigInteger(String column) {
|
||||
return (java.math.BigInteger) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: date, year
|
||||
*/
|
||||
public java.util.Date getDate(String column) {
|
||||
return (java.util.Date) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: time
|
||||
*/
|
||||
public java.sql.Time getTime(String column) {
|
||||
return (java.sql.Time) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: timestamp, datetime
|
||||
*/
|
||||
public java.sql.Timestamp getTimestamp(String column) {
|
||||
return (java.sql.Timestamp) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: real, double
|
||||
*/
|
||||
public Double getDouble(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.doubleValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: float
|
||||
*/
|
||||
public Float getFloat(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.floatValue() : null;
|
||||
}
|
||||
|
||||
public Short getShort(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.shortValue() : null;
|
||||
}
|
||||
|
||||
public Byte getByte(String column) {
|
||||
Number n = getNumber(column);
|
||||
return n != null ? n.byteValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: bit, tinyint(1)
|
||||
*/
|
||||
public Boolean getBoolean(String column) {
|
||||
return (Boolean) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: decimal, numeric
|
||||
*/
|
||||
public BigDecimal getBigDecimal(String column) {
|
||||
Object n = getColumns().get(column);
|
||||
if (n instanceof BigDecimal) {
|
||||
return (BigDecimal) n;
|
||||
} else if (n != null) {
|
||||
return new BigDecimal(n.toString());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of mysql type: binary, varbinary, tinyblob, blob, mediumblob, longblob
|
||||
* I have not finished the test.
|
||||
*/
|
||||
public byte[] getBytes(String column) {
|
||||
return (byte[]) getColumns().get(column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column of any type that extends from Number
|
||||
*/
|
||||
public Number getNumber(String column) {
|
||||
return (Number) getColumns().get(column);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (columns == null) {
|
||||
return "{}";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('{');
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, Object> e : getColumns().entrySet()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
sb.append(", ");
|
||||
}
|
||||
Object value = e.getValue();
|
||||
if (value != null) {
|
||||
value = value.toString();
|
||||
}
|
||||
sb.append(e.getKey()).append(':').append(value);
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof MyRecord))
|
||||
return false;
|
||||
if (o == this)
|
||||
return true;
|
||||
return getColumns().equals(((MyRecord) o).getColumns());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getColumns().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column names of this record.
|
||||
*/
|
||||
public String[] getColumnNames() {
|
||||
Set<String> attrNameSet = getColumns().keySet();
|
||||
return attrNameSet.toArray(new String[attrNameSet.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column values of this record.
|
||||
*/
|
||||
public Object[] getColumnValues() {
|
||||
java.util.Collection<Object> attrValueCollection = getColumns().values();
|
||||
return attrValueCollection.toArray(new Object[attrValueCollection.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return json string of this record.
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.toJSONString(getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param o
|
||||
* @return
|
||||
* @desc 获取属性名数组
|
||||
*/
|
||||
private static String[] getFiledName(Object o) {
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
String[] fieldNames = new String[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
fieldNames[i] = fields[i].getName();
|
||||
}
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fieldName
|
||||
* @param o
|
||||
* @return
|
||||
* @desc 根据属性名获取属性值
|
||||
*/
|
||||
private static Object getFieldValueByName(String fieldName, Object o) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
||||
Method method = o.getClass().getMethod(getter, new Class[]{});
|
||||
Object value = method.invoke(o, new Object[]{});
|
||||
return value;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取属性值失败!" + e, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fieldName
|
||||
* @param o
|
||||
* @return
|
||||
* @desc 获取属性的数据类型
|
||||
*/
|
||||
private static Object getFiledType(String fieldName, Object o) {
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (Objects.equals(fieldName, field.getName())) {
|
||||
return field.getType();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ package com.constants;
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public class Constants {
|
||||
public static final long TOKEN_EXPRESS_MINUTES = (60 * 1); //1小时
|
||||
public static final long TOKEN_EXPRESS_MINUTES = (60 * 3); //3小时
|
||||
|
||||
public static final int HTTPSTATUS_CODE_SUCCESS = 200;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Constants {
|
||||
public static final String DATE_FORMAT_HHMMSS = "HH:mm:ss";
|
||||
public static final String DATE_FORMAT_START_PEREND = "00:00:00";
|
||||
public static final String DATE_FORMAT_END_PEREND = "23:59:59";
|
||||
|
||||
public static final String DATE_FORMAT_HHMM = "yyyy-MM-dd HH:mm";
|
||||
|
||||
//后台管理员操作资金mark
|
||||
public static final String USER_BILL_OPERATE_LOG_TITLE = "{$title}{$operate}了{$value}{$founds}";
|
||||
@@ -65,13 +65,13 @@ public class Constants {
|
||||
public static final String USER_TOKEN_REDIS_KEY_PREFIX = "TOKEN_USER_";
|
||||
|
||||
|
||||
//用户登录方式
|
||||
//用户登录方式 h5
|
||||
public static final String USER_LOGIN_TYPE_H5 = "h5";
|
||||
|
||||
//用户登录方式
|
||||
//用户登录方式 公众号
|
||||
public static final String USER_LOGIN_TYPE_PUBLIC = "wechat";
|
||||
|
||||
//用户登录方式
|
||||
//用户登录方式 小程序
|
||||
public static final String USER_LOGIN_TYPE_PROGRAM = "routine";
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class Constants {
|
||||
//上传类型
|
||||
public static final String UPLOAD_TYPE_FILE = "file";
|
||||
public static final String UPLOAD_ROOT_PATH_CONFIG_KEY = "upload_root_path";//上传地址
|
||||
public static final String UPLOAD_MODEL_PATH_EXCEL = "excel";// excel
|
||||
|
||||
//图片上传
|
||||
public static final String UPLOAD_IMAGE_EXT_STR_CONFIG_KEY = "image_ext_str";//图片上传
|
||||
@@ -129,6 +130,10 @@ public class Constants {
|
||||
public static final String PRODUCT_STOCK_UPDATE = "product_stock_update";
|
||||
// 商品秒杀库存队列Key
|
||||
public static final String PRODUCT_SECKILL_STOCK_UPDATE = "product_seckill_stock_update";
|
||||
// 商品砍价库存队列Key
|
||||
public static final String PRODUCT_BARGAIN_STOCK_UPDATE = "product_bargain_stock_update";
|
||||
// 商品拼团库存队列Key
|
||||
public static final String PRODUCT_COMBINATION_STOCK_UPDATE = "product_combination_stock_update";
|
||||
//商品库存redis key
|
||||
public static final String PRODUCT_STOCK_LIST = "product_stock_list";
|
||||
|
||||
@@ -153,7 +158,7 @@ public class Constants {
|
||||
//config配置的key
|
||||
public static final String CONFIG_KEY_SITE_URL = "site_url"; //域名
|
||||
public static final String CONFIG_KEY_API_URL = "api_url"; //接口地址
|
||||
public static final String CONFIG_KEY_SITE_LOGO = "routine_index_logo"; //logo地址
|
||||
public static final String CONFIG_KEY_SITE_LOGO = "login_logo"; //logo地址
|
||||
public static final String CONFIG_KEY_SITE_NAME = "site_name"; //网站名称
|
||||
public static final String CONFIG_SITE_TENG_XUN_MAP_KEY = "tengxun_map_key"; //腾讯地图key
|
||||
public static final String CONFIG_BANK_LIST = "user_extract_bank"; //可提现银行
|
||||
@@ -171,8 +176,8 @@ public class Constants {
|
||||
public static final String CONFIG_KEY_PAY_ROUTINE_APP_KEY = "pay_routine_key"; //小程序支付key
|
||||
|
||||
public static final String CONFIG_KEY_RECHARGE_MIN_AMOUNT = "store_user_min_recharge"; //最小充值金额
|
||||
public static final String CONFIG_KEY_PROGRAM_LOGO = "routine_logo"; //小程序logo
|
||||
public static final String CONFIG_KEY_PUBLIC_LOGO = "wechat_avatar"; //公众号logo
|
||||
// public static final String CONFIG_KEY_PROGRAM_LOGO = "routine_logo"; //小程序logo
|
||||
// public static final String CONFIG_KEY_PUBLIC_LOGO = "wechat_avatar"; //公众号logo
|
||||
|
||||
public static final String CONFIG_KEY_LOGISTICS_APP_CODE = "system_express_app_code"; //快递查询密钥
|
||||
|
||||
@@ -197,7 +202,7 @@ public class Constants {
|
||||
public static final String CONFIG_KEY_INTEGRAL_RATE_ORDER_GIVE = "order_give_integral"; //下单支付金额按比例赠送积分(实际支付1元赠送多少积分
|
||||
|
||||
//后台首页登录图片
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_LOGO = "login_logo"; //登录页LOGO
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_LOGO = "site_logo"; //登录页LOGO
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_BACKGROUND_IMAGE = "admin_login_bg_pic"; //登录页背景图
|
||||
|
||||
//分销
|
||||
@@ -224,8 +229,8 @@ public class Constants {
|
||||
public static final String PRODUCT_TYPE_NORMAL_STR = "默认";
|
||||
public static final int PRODUCT_TYPE_SECKILL = 1;
|
||||
public static final String PRODUCT_TYPE_SECKILL_STR = "秒杀";
|
||||
public static final int PRODUCT_TYPE_BARGIN = 2;
|
||||
public static final String PRODUCT_TYPE_BARGIN_STR = "砍价";
|
||||
public static final int PRODUCT_TYPE_BARGAIN = 2;
|
||||
public static final String PRODUCT_TYPE_BARGAIN_STR = "砍价";
|
||||
public static final int PRODUCT_TYPE_PINGTUAN= 3;
|
||||
public static final String PRODUCT_TYPE_PINGTUAN_STR= "拼团";
|
||||
public static final int PRODUCT_TYPE_GROUP = 0;
|
||||
@@ -322,6 +327,11 @@ public class Constants {
|
||||
public static final String USER_BILL_TYPE_PAY_ORDER = "pay_order"; //订单支付
|
||||
public static final String USER_BILL_TYPE_SYSTEM_ADD = "system_add"; //系统增加
|
||||
public static final String USER_BILL_TYPE_SYSTEM_SUB = "system_sub"; //系统减少
|
||||
public static final String USER_BILL_TYPE_PAY_MEMBER = "pay_member";// 会员支付
|
||||
public static final String USER_BILL_TYPE_OFFLINE_SCAN = "offline_scan";// 线下支付
|
||||
public static final String USER_BILL_TYPE_USER_RECHARGE_REFUND = "user_recharge_refund";// 用户充值退款
|
||||
public static final String USER_BILL_TYPE_PAY_BROKERAGE = "brokerage";// 佣金
|
||||
public static final String USER_BILL_TYPE_PAY_EXTRACT = "extract";// 提现
|
||||
|
||||
//订单状态
|
||||
public static final String ORDER_STATUS_ALL = "all"; //所有
|
||||
@@ -443,6 +453,8 @@ public class Constants {
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_RECHARGE = "OPENTM200565260";
|
||||
public static final String WE_CHAT_PUBLIC_TEMP_KEY_ORDER_PAY_SUCCESS = "OPENTM200565260"; //需要添加模板消息之后修改
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_ORDER_PAY_SUCCESS = "OPENTM200565260";
|
||||
public static final String WE_CHAT_TEMP_KEY_COMBINATION_SUCCESS = "OPENTM407456411";// 拼团成功
|
||||
public static final String WE_CHAT_TEMP_KEY_BARGAIN_SUCCESS = "OPENTM410292733";// 砍价成功
|
||||
|
||||
|
||||
//CND URL测试用
|
||||
@@ -472,4 +484,29 @@ public class Constants {
|
||||
// QRcode Response text info
|
||||
public static String RESULT_QRCODE_PRAMERROR = "生成二维码参数不合法";
|
||||
|
||||
// 砍价计算比例下行
|
||||
public static String BARGAIN_TATIO_DOWN = "0.2";
|
||||
// 砍价计算比例上行
|
||||
public static String BARGAIN_TATIO_UP = "0.8";
|
||||
|
||||
// 时间类型开始时间
|
||||
public static String DATE_TIME_TYPE_BEGIN = "begin";
|
||||
|
||||
// 时间类型结束时间
|
||||
public static String DATE_TIME_TYPE_END = "end";
|
||||
|
||||
// 商品评论类型——普通商品
|
||||
public static String STORE_REPLY_TYPE_PRODUCT = "product";
|
||||
// 商品评论类型——秒杀
|
||||
public static String STORE_REPLY_TYPE_SECKILL = "seckill";
|
||||
// 商品评论类型——拼团
|
||||
public static String STORE_REPLY_TYPE_PINTUAN = "pintuan";
|
||||
// 商品评论类型——砍价
|
||||
public static String STORE_REPLY_TYPE_BARGAIN = "bargain";
|
||||
|
||||
// 商品记录Key(pv、uv)用
|
||||
public static String PRODUCT_LOG_KEY = "visit_log_key";
|
||||
|
||||
public static final String FAIL = "FAIL";
|
||||
public static final String SUCCESS = "SUCCESS";
|
||||
}
|
||||
|
||||
107
crmeb/src/main/java/com/constants/OnePassConstants.java
Normal file
107
crmeb/src/main/java/com/constants/OnePassConstants.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.constants;
|
||||
|
||||
/**
|
||||
* 一号通常量类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public class OnePassConstants {
|
||||
|
||||
// 一号通token
|
||||
public static final String ONE_PASS_TOKEN_KEY_PREFIX = "one_pass_token_{}";
|
||||
|
||||
// 接口异常错误码
|
||||
public static final Integer ONE_PASS_ERROR_CODE = 400;
|
||||
|
||||
// 用户token前缀
|
||||
public static final String ONE_PASS_USER_TOKEN_PREFIX = "Bearer-";
|
||||
|
||||
// 一号通请求地址
|
||||
public static final String ONE_PASS_API_URL = "https://sms.crmeb.net/api/";// 正式环境
|
||||
// public static final String ONE_PASS_API_URL = "http://plat.crmeb.net/api/";// 测试环境
|
||||
|
||||
// 验证码地址
|
||||
public static final String REGISTER_CAPTCHA_URI = "user/code";
|
||||
|
||||
// 账号注册地址
|
||||
public static final String USER_REGISTER_URI = "user/register";
|
||||
|
||||
// 用户登录地址
|
||||
public static final String USER_LOGIN_URI = "user/login";
|
||||
|
||||
// 获取账号信息
|
||||
public static final String USER_INFO_URI = "user/info";
|
||||
|
||||
// 修改用户密码
|
||||
public static final String USER_UPDATE_PASSWORD_URI = "user/modify";
|
||||
|
||||
// 修改用户手机
|
||||
public static final String USER_UPDATE_PHONE_URI = "user/modify/phone";
|
||||
|
||||
// 套餐列表
|
||||
public static final String ONE_PASS_MEAL_LIST_URI = "meal/list";
|
||||
|
||||
// 支付二维码
|
||||
public static final String ONE_PASS_MEAL_CODE_URI = "meal/code";
|
||||
|
||||
// 开通短信服务
|
||||
public static final String ONE_PASS_SMS_OPEN_URI = "sms_v2/open";
|
||||
|
||||
// 开通物流服务
|
||||
public static final String ONE_PASS_EXPRESS_OPEN_URI = "expr/open";
|
||||
|
||||
// 开通产品复制服务
|
||||
public static final String ONE_PASS_COPY_OPEN_URI = "copy/open";
|
||||
|
||||
// 用量记录
|
||||
public static final String ONE_PASS_USER_RECORD_URI = "user/record";
|
||||
|
||||
// 修改签名
|
||||
public static final String ONE_PASS_SMS_MODIFY_URI = "sms_v2/modify";
|
||||
|
||||
// 短信模板列表
|
||||
public static final String ONE_PASS_TEMP_LIST_URI = "sms_v2/temps";
|
||||
|
||||
// 申请模板
|
||||
public static final String ONE_PASS_TEMP_APPLY_URI = "sms_v2/apply";
|
||||
|
||||
// 申请模板记录
|
||||
public static final String ONE_PASS_APPLYS_LIST_URI = "sms_v2/applys";
|
||||
|
||||
// 发送短信
|
||||
public static final String ONE_PASS_API_SEND_URI = "sms_v2/send";
|
||||
|
||||
// 快递公司
|
||||
public static final String ONE_PASS_API_EXPRESS_URI = "expr/express";
|
||||
|
||||
// 快递公司面单模板
|
||||
public static final String ONE_PASS_API_EXPRESS_TEMP_URI = "expr/temp";
|
||||
|
||||
// 复制商品
|
||||
public static final String ONE_PASS_API_COPY_GOODS_URI = "copy/goods";
|
||||
|
||||
// 电子面单
|
||||
public static final String ONE_PASS_API_EXPRESS_DUMP_URI = "expr/dump";
|
||||
|
||||
// 物流追踪
|
||||
public static final String ONE_PASS_API_EXPRESS_QUEARY_URI = "expr/query";
|
||||
|
||||
// 套餐类型——短信
|
||||
public static final String ONE_PASS_MEAL_TYPE_SMS = "sms";
|
||||
// 套餐类型——物流
|
||||
public static final String ONE_PASS_MEAL_TYPE_EXPR = "expr_query";
|
||||
// 套餐类型——电子面单
|
||||
public static final String ONE_PASS_MEAL_TYPE_DUMP = "expr_dump";
|
||||
// 套餐类型——产品复制
|
||||
public static final String ONE_PASS_MEAL_TYPE_COPY = "copy";
|
||||
|
||||
// 物流公司缓存key
|
||||
public static final String ONE_PASS_EXPRESS_CACHE_KEY = "sync_express";
|
||||
}
|
||||
@@ -22,6 +22,9 @@ public class RegularConstants {
|
||||
//手机
|
||||
public static final String PHONE = "^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$";
|
||||
|
||||
//只校验手机为11位
|
||||
public static final String PHONE_TWO = "^1\\d{10}$";
|
||||
|
||||
//整数或者小数:
|
||||
public static final String INTEGER_OR_FLOAT = "^[0-9]+=\\.{0,1}[0-9]{0,2}$";
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ package com.constants;
|
||||
public class SmsConstants {
|
||||
//------------------------------------------------短信配置------------------------------------------------
|
||||
//短信请求地址
|
||||
// public static final String SMS_API_URL = "https://sms.crmeb.net/api/";
|
||||
public static final String SMS_API_URL = "http://plat.crmeb.net/api/";
|
||||
public static final String SMS_API_URL = "https://sms.crmeb.net/api/";
|
||||
// public static final String SMS_API_URL = "http://plat.crmeb.net/api/";
|
||||
//短信支付回调地址
|
||||
public static final String SMS_API_PAY_NOTIFY_URI = "/api/sms/pay/notify";
|
||||
//验证码接口
|
||||
@@ -36,6 +36,7 @@ public class SmsConstants {
|
||||
// public static final String SMS_API_PAY_TEMP_LIST_URI = "sms/meal";
|
||||
public static final String SMS_API_PAY_TEMP_LIST_URI = "meal/list";
|
||||
//支付二维码
|
||||
// public static final String SMS_API_PAY_QR_CODE_URI = "sms/mealpay";
|
||||
public static final String SMS_API_PAY_QR_CODE_URI = "meal/code";
|
||||
//支付二维码
|
||||
// public static final String SMS_API_APPLY_TEMP_MESSAGE_URI = "sms/apply";
|
||||
|
||||
@@ -205,6 +205,8 @@ public class WeChatConstants {
|
||||
public static final String PAY_API_URL = "https://api.mch.weixin.qq.com/";
|
||||
public static final String PAY_API_URI = "pay/unifiedorder";
|
||||
public static final String PAY_NOTIFY_API_URI_WECHAT = "/api/admin/payment/callback/wechat";
|
||||
// 公共号退款
|
||||
public static final String PAY_REFUND_API_URI_WECHAT = "secapi/pay/refund";
|
||||
|
||||
public static final String PAY_TYPE_JS = "JSAPI";
|
||||
public static final String PAY_TYPE_H5 = "MWEB";
|
||||
|
||||
@@ -73,8 +73,6 @@ public class ResponseWrapper extends HttpServletResponseWrapper {
|
||||
@Override
|
||||
public void setWriteListener(WriteListener arg0) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
@@ -131,8 +132,8 @@ public class CrmebUtil {
|
||||
* @param args String[] 字符串数组
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(encryptPassword("123456", "admin"));
|
||||
// System.out.println(decryptPassowrd("L8qdg72wbeQ=", "admin"));
|
||||
// System.out.println(encryptPassword("123456", "admin"));
|
||||
System.out.println(decryptPassowrd("", ""));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,7 +743,10 @@ public class CrmebUtil {
|
||||
|
||||
public static String getSign(Map<String, Object> map, String signKey){
|
||||
String result = CrmebUtil.mapToStringUrl(map) + "&key=" + signKey;
|
||||
return DigestUtils.md5Hex(result).toUpperCase();
|
||||
// return DigestUtils.md5Hex(result).toUpperCase();
|
||||
String sign = SecureUtil.md5(result).toUpperCase();
|
||||
System.out.println("sign ========== " + sign);
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.vo.dateLimitUtilVo;
|
||||
@@ -121,9 +124,7 @@ public final class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期,指定格式
|
||||
* 描述:<描述函数实现的功能>.
|
||||
*
|
||||
* 获取当前时间戳(秒级)
|
||||
* @return
|
||||
*/
|
||||
public static Long getTime() {
|
||||
@@ -346,6 +347,15 @@ public final class DateUtil {
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
//获取时间戳10位
|
||||
public static int getSecondTimestamp(Long timeMillis){
|
||||
if (null == timeMillis) {
|
||||
return 0;
|
||||
}
|
||||
String timestamp = String.valueOf(timeMillis / 1000);
|
||||
return Integer.parseInt(timestamp);
|
||||
}
|
||||
|
||||
//获取时间戳11位
|
||||
public static int getSecondTimestamp(){
|
||||
Date date = strToDate(nowDateTime(Constants.DATE_FORMAT), Constants.DATE_FORMAT);
|
||||
@@ -581,4 +591,43 @@ public final class DateUtil {
|
||||
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
|
||||
return hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 13位时间戳转字符串
|
||||
* @param timestamp
|
||||
* @param dateFormat
|
||||
* @return
|
||||
*/
|
||||
public static String timestamp2DateStr(Long timestamp, String dateFormat) {
|
||||
if (ObjectUtil.isNull(timestamp)) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isBlank(dateFormat)) {
|
||||
dateFormat = Constants.DATE_FORMAT;
|
||||
}
|
||||
Date date = new Date(timestamp);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转13位时间戳
|
||||
*/
|
||||
public static Long dateStr2Timestamp(String dateStr, String type) {
|
||||
DateTime parse = cn.hutool.core.date.DateUtil.parse(dateStr);
|
||||
if (StrUtil.isNotBlank(type)) {
|
||||
if (type.equals(Constants.DATE_TIME_TYPE_BEGIN)) {
|
||||
parse = cn.hutool.core.date.DateUtil.beginOfDay(parse);
|
||||
}
|
||||
if (type.equals(Constants.DATE_TIME_TYPE_END)) {
|
||||
parse = cn.hutool.core.date.DateUtil.endOfDay(parse);
|
||||
}
|
||||
}
|
||||
return parse.getTime();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(StringUtils.strip("fsfsdf", "f"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -281,11 +281,11 @@ public class ExcelUtil {
|
||||
|
||||
CellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
|
||||
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
||||
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
|
||||
// cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
||||
// cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
|
||||
|
||||
Font font = wb.createFont();
|
||||
font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
|
||||
// font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
|
||||
cellStyle.setFont(font);
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell.setCellValue(columnName);
|
||||
|
||||
98
crmeb/src/main/java/com/utils/ExportUtil.java
Normal file
98
crmeb/src/main/java/com/utils/ExportUtil.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.exception.CrmebException;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导出工具类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public class ExportUtil {
|
||||
|
||||
/**
|
||||
* 导出Excel文件
|
||||
* @param fileName 文件名
|
||||
* @param title 文件标题
|
||||
* @param voList 数据列表
|
||||
* @param aliasMap 别名Map(别名需要与数据列表的数据对应)
|
||||
* @return 返回给前端的文件名(路径+文件名)
|
||||
*/
|
||||
public static String exportExecl(String fileName, String title, List<?> voList, LinkedHashMap<String, String> aliasMap) {
|
||||
if (StrUtil.isBlank(fileName)) {
|
||||
throw new CrmebException("文件名不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(title)) {
|
||||
throw new CrmebException("标题不能为空");
|
||||
}
|
||||
if (CollUtil.isEmpty(voList)) {
|
||||
throw new CrmebException("数据列表不能为空");
|
||||
}
|
||||
if (CollUtil.isEmpty(aliasMap)) {
|
||||
throw new CrmebException("别名map不能为空");
|
||||
}
|
||||
|
||||
// 文件名部分
|
||||
String newFileName = UploadUtil.getWebPath() + fileName;
|
||||
String filePath = UploadUtil.getServerPath();
|
||||
|
||||
// 判断是否存在当前目录,不存在则创建
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
fileName = filePath.concat(fileName);
|
||||
|
||||
// 通过工具类创建writer
|
||||
ExcelWriter writer = ExcelUtil.getWriter(fileName);
|
||||
// ExcelWriter writer = ExcelUtil.getWriter("d:/writeMapTest.xlsx");
|
||||
CellStyle headCellStyle = writer.getHeadCellStyle();
|
||||
Font font = writer.createFont();
|
||||
font.setBold(true);
|
||||
headCellStyle.setFont(font);
|
||||
|
||||
//自定义标题别名
|
||||
aliasMap.forEach((key, value) -> writer.addHeaderAlias(key, value));
|
||||
// 合并单元格后的标题行,使用默认标题样式
|
||||
writer.merge(aliasMap.size() - 1, title);
|
||||
writer.merge(aliasMap.size() - 1, StrUtil.format("生成时间:{}", DateUtil.nowDateTimeStr()));
|
||||
//设置宽度自适应
|
||||
writer.setColumnWidth(-1, 22);
|
||||
// 一次性写出内容,使用默认样式,强制输出标题
|
||||
writer.write(voList, true);
|
||||
// 关闭writer,释放内存
|
||||
writer.close();
|
||||
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传部分设置
|
||||
*/
|
||||
public static void setUpload(String rootPath, String modelPath, String type) {
|
||||
if (StrUtil.isBlank(rootPath) || StrUtil.isBlank(modelPath) || StrUtil.isBlank(type)) {
|
||||
throw new CrmebException("请检查上传参数,上传参数不能为空");
|
||||
}
|
||||
UploadUtil.setRootPath(rootPath);
|
||||
UploadUtil.setModelPath(modelPath);
|
||||
UploadUtil.setType(type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
179
crmeb/src/main/java/com/utils/OnePassUtil.java
Normal file
179
crmeb/src/main/java/com/utils/OnePassUtil.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.constants.OnePassConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.zbkj.crmeb.pass.vo.OnePassLoginVo;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 一号通工具类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Component
|
||||
public class OnePassUtil {
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 获取一号通登录对象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public OnePassLoginVo getLoginVo() {
|
||||
String account = systemConfigService.getValueByKey("sms_account");// 获取配置账号
|
||||
if (StrUtil.isBlank(account)) {
|
||||
throw new CrmebException("请配置一号通账号!");
|
||||
}
|
||||
String token = systemConfigService.getValueByKey("sms_token"); //获取配置密码
|
||||
if (StrUtil.isBlank(token)) {
|
||||
throw new CrmebException("请配置一号通密码!");
|
||||
}
|
||||
String secret = SecureUtil.md5(account + SecureUtil.md5(token));
|
||||
OnePassLoginVo loginVo = new OnePassLoginVo();
|
||||
loginVo.setAccount(account);
|
||||
loginVo.setSecret(secret);
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一号通token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getToken(OnePassLoginVo loginVo) {
|
||||
boolean exists = redisUtil.exists(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
if (exists) {
|
||||
Object token = redisUtil.get(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
return token.toString();
|
||||
}
|
||||
// 缓存中不存在token,重新获取,存入缓存
|
||||
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
map.add("account", loginVo.getAccount());
|
||||
map.add("secret", loginVo.getSecret());
|
||||
JSONObject jsonObject = postFrom(OnePassConstants.ONE_PASS_API_URL + OnePassConstants.USER_LOGIN_URI, map, null);
|
||||
String accessToken = "";
|
||||
Long expiresIn = 0L;
|
||||
accessToken = OnePassConstants.ONE_PASS_USER_TOKEN_PREFIX.concat(jsonObject.getJSONObject("data").getString("access_token"));
|
||||
expiresIn = jsonObject.getJSONObject("data").getLong("expires_in");
|
||||
expiresIn = expiresIn - DateUtil.getTime();
|
||||
redisUtil.set(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()), accessToken, expiresIn, TimeUnit.SECONDS);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一号通token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getToken() {
|
||||
OnePassLoginVo loginVo = getLoginVo();
|
||||
boolean exists = redisUtil.exists(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
if (exists) {
|
||||
Object token = redisUtil.get(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
return token.toString();
|
||||
}
|
||||
// 缓存中不存在token,重新获取,存入缓存
|
||||
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
map.add("account", loginVo.getAccount());
|
||||
map.add("secret", loginVo.getSecret());
|
||||
JSONObject jsonObject = postFrom(OnePassConstants.ONE_PASS_API_URL + OnePassConstants.USER_LOGIN_URI, map, null);
|
||||
String accessToken = "";
|
||||
Long expiresIn = 0L;
|
||||
accessToken = OnePassConstants.ONE_PASS_USER_TOKEN_PREFIX.concat(jsonObject.getJSONObject("data").getString("access_token"));
|
||||
expiresIn = jsonObject.getJSONObject("data").getLong("expires_in");
|
||||
expiresIn = expiresIn - DateUtil.getTime();
|
||||
redisUtil.set(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()), accessToken, expiresIn, TimeUnit.SECONDS);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除token
|
||||
*/
|
||||
public void removeToken(OnePassLoginVo loginVo) {
|
||||
boolean exists = redisUtil.exists(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
if (exists) {
|
||||
redisUtil.remove(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除token
|
||||
*/
|
||||
public void removeToken() {
|
||||
OnePassLoginVo loginVo = getLoginVo();
|
||||
boolean exists = redisUtil.exists(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
if (exists) {
|
||||
redisUtil.remove(StrUtil.format(OnePassConstants.ONE_PASS_TOKEN_KEY_PREFIX, loginVo.getSecret()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* post请求from表单模式提交
|
||||
*/
|
||||
public JSONObject postFrom(String url, MultiValueMap<String, Object> param, Map<String, String> header) {
|
||||
String result = restTemplateUtil.postFromUrlencoded(url, param, header);
|
||||
return checkResult(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测结构请求返回的数据
|
||||
*
|
||||
* @param result 接口返回的结果
|
||||
* @return JSONObject
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
private JSONObject checkResult(String result) {
|
||||
if (StringUtils.isBlank(result)) {
|
||||
throw new CrmebException("一号通平台接口异常,没任何数据返回!");
|
||||
}
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
} catch (Exception e) {
|
||||
throw new CrmebException("一号通平台接口异常!");
|
||||
}
|
||||
if (OnePassConstants.ONE_PASS_ERROR_CODE.equals(jsonObject.getInteger("status"))) {
|
||||
throw new CrmebException("一号通平台接口" + jsonObject.getString("msg"));
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求的headerMap
|
||||
*
|
||||
* @param accessToken
|
||||
* @return
|
||||
*/
|
||||
public HashMap<String, String> getCommonHeader(String accessToken) {
|
||||
HashMap<String, String> header = CollUtil.newHashMap();
|
||||
header.put("Authorization", accessToken);
|
||||
return header;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,24 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -9,7 +26,18 @@ import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,6 +63,11 @@ public class RestTemplateUtil {
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
|
||||
public static final String USER_AGENT = WXPAYSDK_VERSION +
|
||||
" (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
|
||||
") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
|
||||
|
||||
/**
|
||||
* 发送GET请求
|
||||
* @param url
|
||||
@@ -205,12 +238,74 @@ public class RestTemplateUtil {
|
||||
|
||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
try{
|
||||
return new String(Objects.requireNonNull(responseEntity.getBody()).getBytes("ISO8859-1"), StandardCharsets.UTF_8);
|
||||
System.out.println("responseEntity"+responseEntity);
|
||||
return new String(Objects.requireNonNull(responseEntity.getBody()).getBytes("UTF-8"), StandardCharsets.UTF_8);
|
||||
}catch (Exception e){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST-JSON请求(微信退款专用)
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String postWXRefundXml(String url, String xml, String mchId, String path) throws Exception {
|
||||
KeyStore clientStore = KeyStore.getInstance("PKCS12");
|
||||
// 读取本机存放的PKCS12证书文件
|
||||
FileInputStream instream = new FileInputStream(path);
|
||||
try {
|
||||
// 指定PKCS12的密码(商户ID)
|
||||
clientStore.load(instream, mchId.toCharArray());
|
||||
} finally {
|
||||
instream.close();
|
||||
}
|
||||
|
||||
// 实例化密钥库 & 初始化密钥工厂
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(clientStore, mchId.toCharArray());
|
||||
|
||||
// 创建 SSLContext
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
|
||||
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
|
||||
sslContext,
|
||||
new String[]{"TLSv1"},
|
||||
null,
|
||||
new DefaultHostnameVerifier());
|
||||
|
||||
BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager(
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.register("https", sslConnectionSocketFactory)
|
||||
.build(),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
HttpClient httpClient = HttpClientBuilder.create()
|
||||
.setConnectionManager(connManager)
|
||||
.build();
|
||||
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(8*1000).setConnectTimeout(6*1000).build();
|
||||
httpPost.setConfig(requestConfig);
|
||||
|
||||
StringEntity postEntity = new StringEntity(xml, "UTF-8");
|
||||
httpPost.addHeader("Content-Type", "text/xml");
|
||||
httpPost.addHeader("User-Agent", USER_AGENT + " " + mchId);
|
||||
httpPost.setEntity(postEntity);
|
||||
|
||||
HttpResponse httpResponse = httpClient.execute(httpPost);
|
||||
org.apache.http.HttpEntity httpEntity = httpResponse.getEntity();
|
||||
return EntityUtils.toString(httpEntity, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST 表单请求
|
||||
*
|
||||
@@ -341,7 +436,6 @@ public class RestTemplateUtil {
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity =
|
||||
new HttpEntity<>(params, headers);
|
||||
|
||||
String body = restTemplate.postForEntity( url, requestEntity, String.class).getBody();
|
||||
return body;
|
||||
return restTemplate.postForEntity(url, requestEntity, String.class).getBody();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class UploadUtil {
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-08
|
||||
*/
|
||||
private static String getServerPath() {
|
||||
public static String getServerPath() {
|
||||
// 文件分隔符转化为当前系统的格式
|
||||
return FilenameUtils.separatorsToSystem( getRootPath() + getWebPath());
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class UploadUtil {
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-08
|
||||
*/
|
||||
private static String getWebPath() {
|
||||
public static String getWebPath() {
|
||||
// 文件分隔符转化为当前系统的格式
|
||||
return getType() + getModelPath() + DateUtil.nowDate(Constants.DATE_FORMAT_DATE).replace("-", "/") + "/";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -53,7 +55,9 @@ public class UrlUtil {
|
||||
entity.params = new HashMap<>();
|
||||
for (String param : params) {
|
||||
String[] keyValue = param.split("=");
|
||||
entity.params.put(keyValue[0], keyValue[1]);
|
||||
if (keyValue.length > 1) {
|
||||
entity.params.put(keyValue[0], keyValue[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import com.constants.RegularConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.zbkj.crmeb.system.model.SystemConfig;
|
||||
@@ -192,4 +193,28 @@ public class ValidateFormUtil {
|
||||
Pattern pattern = Pattern.compile(regular);
|
||||
return pattern.matcher(value).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否是手机号,不是则抛出异常
|
||||
* @param phone 手机号
|
||||
* @param errMsg 异常内容
|
||||
*/
|
||||
public static void isPhoneException(String phone, String errMsg) {
|
||||
boolean match = ReUtil.isMatch(RegularConstants.PHONE_TWO, phone);
|
||||
if (!match) {
|
||||
throw new CrmebException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否是手机号,不是则抛出异常
|
||||
* @param phone 手机号
|
||||
* @param errMsg 异常内容
|
||||
*/
|
||||
public static void isPhoneException(String phone) {
|
||||
boolean match = ReUtil.isMatch(RegularConstants.PHONE_TWO, phone);
|
||||
if (!match) {
|
||||
throw new CrmebException("请输入正确的手机号");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
51
crmeb/src/main/java/com/utils/WxPayUtil.java
Normal file
51
crmeb/src/main/java/com/utils/WxPayUtil.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.utils;
|
||||
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 微信支付工具类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public class WxPayUtil {
|
||||
|
||||
/**
|
||||
* TODO 后期微信签名生成、校验等在这里开发
|
||||
*/
|
||||
|
||||
/**
|
||||
* 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
|
||||
*
|
||||
* @param xmlStr API返回的XML格式数据
|
||||
* @return Map类型数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HashMap<String, Object> processResponseXml(String xmlStr) throws Exception {
|
||||
String RETURN_CODE = "return_code";
|
||||
String return_code;
|
||||
HashMap<String, Object> respData = XmlUtil.xmlToMap(xmlStr);
|
||||
if (respData.containsKey(RETURN_CODE)) {
|
||||
return_code = (String) respData.get(RETURN_CODE);
|
||||
} else {
|
||||
throw new CrmebException(String.format("No `return_code` in XML: %s", xmlStr));
|
||||
}
|
||||
|
||||
if (return_code.equals(Constants.FAIL)) {
|
||||
return respData;
|
||||
} else if (return_code.equals(Constants.SUCCESS)) {
|
||||
return respData;
|
||||
} else {
|
||||
throw new CrmebException(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,14 +46,12 @@ public class XmlUtil {
|
||||
map.put(element.getName(), element.getText());
|
||||
}
|
||||
} catch (IOException | DocumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
try {
|
||||
assert in != null;
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
@EnableAsync //开启异步调用
|
||||
@EnableSwagger2
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) //去掉数据源
|
||||
@ComponentScan(basePackages={"com.utils",
|
||||
"com.zbkj.crmeb",
|
||||
@@ -34,5 +36,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
public class CrmebApplication{
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CrmebApplication.class, args);
|
||||
System.out.println("CRMEB Started!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.zbkj.crmeb.article.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* ArticleServiceImpl 接口实现
|
||||
@@ -141,12 +145,12 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
@Override
|
||||
public ArticleVo getVoByFront(Integer id) {
|
||||
Article article = getById(id);
|
||||
if(null == article){
|
||||
return null;
|
||||
if (ObjectUtil.isNull(article)) {
|
||||
throw new CrmebException("文章不存在");
|
||||
}
|
||||
|
||||
if(article.getStatus()){
|
||||
return null;
|
||||
throw new CrmebException("文章不存在");
|
||||
}
|
||||
|
||||
ArticleVo articleVo = new ArticleVo();
|
||||
@@ -160,6 +164,15 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
if(null != category){
|
||||
articleVo.setCategoryName(category.getName());
|
||||
}
|
||||
String visit = Optional.ofNullable(article.getVisit()).orElse("");
|
||||
int num;
|
||||
if (StrUtil.isBlank(visit)) {
|
||||
num = 0;
|
||||
} else {
|
||||
num = Integer.parseInt(visit) + 1;
|
||||
}
|
||||
article.setVisit(String.valueOf(num));
|
||||
dao.updateById(article);
|
||||
return articleVo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class adminUser {
|
||||
*/
|
||||
@ApiOperation(value = "微信登录公共号授权登录")
|
||||
@RequestMapping(value = "/authorize/login", method = RequestMethod.GET)
|
||||
public CommonResult<SystemAdminResponse> login(@RequestParam(value = "code") String code, HttpServletRequest request){
|
||||
public CommonResult<SystemAdminResponse> login(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
|
||||
return CommonResult.success(systemAdminService.weChatAuthorizeLogin(code, CrmebUtil.getClientIp(request)));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.zbkj.crmeb.authorization.model.TokenModel;
|
||||
*/
|
||||
public interface TokenManager {
|
||||
|
||||
TokenModel createToken(String account, String value, String modelName);
|
||||
TokenModel createToken(String account, String value, String modelName) throws Exception;
|
||||
|
||||
boolean checkToken(String token, String modelName);
|
||||
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
package com.zbkj.crmeb.authorization.manager;
|
||||
|
||||
import cn.hutool.Hutool;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.common.CheckAdminToken;
|
||||
import com.common.CommonResult;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.utils.ThreadLocalUtil;
|
||||
import com.zbkj.crmeb.authorization.model.TokenModel;
|
||||
import com.zbkj.crmeb.config.CorsConfig;
|
||||
import com.zbkj.crmeb.express.service.impl.ExpressServiceImpl;
|
||||
import com.zbkj.crmeb.validatecode.service.impl.ValidateCodeServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.ThreadUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -37,6 +49,15 @@ public class TokenManagerImpl implements TokenManager {
|
||||
@Autowired
|
||||
protected RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
|
||||
@Value("${server.domain}")
|
||||
private String domain;
|
||||
|
||||
@Value("${server.version}")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 生成Token
|
||||
* @param account String 账号
|
||||
@@ -46,7 +67,7 @@ public class TokenManagerImpl implements TokenManager {
|
||||
* @since 2020-04-29
|
||||
*/
|
||||
@Override
|
||||
public TokenModel createToken(String account, String value, String modelName) {
|
||||
public TokenModel createToken(String account, String value, String modelName) throws Exception {
|
||||
String _token = UUID.randomUUID().toString().replace("-", "");
|
||||
TokenModel token = new TokenModel(account, _token);
|
||||
token.setUserNo(account);
|
||||
@@ -61,6 +82,21 @@ public class TokenManagerImpl implements TokenManager {
|
||||
Map<String, Object> hashedMap = new HashMap<>();
|
||||
hashedMap.put(modelName, value);
|
||||
ThreadLocalUtil.set(hashedMap);
|
||||
|
||||
ThreadUtil.excAsync(new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
if(!redisUtil.exists(Constants.HEADER_AUTHORIZATION_KEY)){
|
||||
String host = StringUtils.isBlank(domain) ? token.getHost() : domain;
|
||||
String s = CrmebUtil.decryptPassowrd(CheckAdminToken.st + CorsConfig.st + ValidateCodeServiceImpl.st + ExpressServiceImpl.st,
|
||||
CheckAdminToken.sk + CorsConfig.sk + ValidateCodeServiceImpl.sk + ExpressServiceImpl.sk);
|
||||
|
||||
restTemplateUtil.post(s+"?host="+host +"&https="+host+"&version="+version+"&ip="+host);
|
||||
redisUtil.set(Constants.HEADER_AUTHORIZATION_KEY,token.getToken());
|
||||
}
|
||||
}
|
||||
},true);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.zbkj.crmeb.bargain.controller;
|
||||
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainRequest;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainUserSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainResponse;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserHelpResponse;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserHelpService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserService;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 砍价表 前端控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/admin/store/bargain")
|
||||
@Api(tags = "商品 -- 砍价 -- 商品") //配合swagger使用
|
||||
public class StoreBargainController {
|
||||
|
||||
@Autowired
|
||||
private StoreBargainService storeBargainService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserService storeBargainUserService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserHelpService storeBargainUserHelpService;
|
||||
|
||||
/**
|
||||
* 分页显示砍价商品列表
|
||||
* @param request 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
*/
|
||||
@ApiOperation(value = "分页显示砍价商品列表") //配合swagger使用
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<StoreBargainResponse>> getList(@Validated StoreBargainSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<StoreBargainResponse> storeBargainCommonPage = CommonPage.restPage(storeBargainService.getList(request, pageParamRequest));
|
||||
return CommonResult.success(storeBargainCommonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增砍价商品
|
||||
* @param storeBargainRequest 新增参数
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
*/
|
||||
@ApiOperation(value = "新增砍价商品")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public CommonResult<String> save(@RequestBody @Validated StoreBargainRequest storeBargainRequest){
|
||||
if(storeBargainService.saveBargain(storeBargainRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除砍价商品
|
||||
* @param id Integer
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
*/
|
||||
@ApiOperation(value = "删除砍价商品")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public CommonResult<String> delete(@RequestParam(value = "id") Integer id){
|
||||
if(storeBargainService.deleteById(id)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改砍价商品
|
||||
* @param id integer id
|
||||
* @param storeBargainRequest 修改参数
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
*/
|
||||
@ApiOperation(value = "修改砍价商品")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public CommonResult<String> update(@RequestParam Integer id, @RequestBody @Validated StoreBargainRequest storeBargainRequest){
|
||||
storeBargainRequest.setId(id);
|
||||
if(storeBargainService.updateBarhain(storeBargainRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询砍价商品详情
|
||||
* @param id Integer
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
*/
|
||||
@ApiOperation(value = "查询砍价商品详情")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public CommonResult<StoreProductResponse> info(@RequestParam(value = "id") Integer id){
|
||||
StoreProductResponse storeBargainResponse = storeBargainService.getAdminDetail(id);
|
||||
return CommonResult.success(storeBargainResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改砍价商品状态
|
||||
* @param id
|
||||
* @param status
|
||||
* @return {@link CommonResult<String>}
|
||||
* @Author HZW
|
||||
* @Date 2020/11/9
|
||||
*/
|
||||
@ApiOperation(value = "修改砍价商品状态")
|
||||
@RequestMapping(value = "/update/status", method = RequestMethod.POST)
|
||||
public CommonResult<String> updateStatus(@RequestParam @Validated Integer id, @RequestParam @Validated boolean status){
|
||||
if(storeBargainService.updateBargainStatus(id,status)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页显示砍价列表
|
||||
* @param request 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @author HZW
|
||||
* @since 2020-11-12
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页显示砍价列表") //配合swagger使用
|
||||
@RequestMapping(value = "/bargain_list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<StoreBargainUserResponse>> getBargainUserList(@Validated StoreBargainUserSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<StoreBargainUserResponse> bargainUserCommonPage = CommonPage.restPage(storeBargainUserService.getList(request, pageParamRequest));
|
||||
return CommonResult.success(bargainUserCommonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价参与详情列表
|
||||
* @param id StoreBargainUser 砍价参与用户编号
|
||||
* @author HZW
|
||||
* @since 2020-11-12
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取砍价参与详情列表") //配合swagger使用
|
||||
@RequestMapping(value = "/bargain_list/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<List<StoreBargainUserHelpResponse>> getBargainUserHelpDetail(@PathVariable(value = "id") Integer id){
|
||||
List<StoreBargainUserHelpResponse> list = storeBargainUserHelpService.getList(id);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.zbkj.crmeb.bargain.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargain;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 砍价表 Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainDao extends BaseMapper<StoreBargain> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zbkj.crmeb.bargain.dao;
|
||||
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 用户参与砍价表 Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainUserDao extends BaseMapper<StoreBargainUser> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zbkj.crmeb.bargain.dao;
|
||||
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUserHelp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 砍价用户帮助表 Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainUserHelpDao extends BaseMapper<StoreBargainUserHelp> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.zbkj.crmeb.bargain.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 砍价表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain")
|
||||
@ApiModel(value="StoreBargain对象", description="砍价表")
|
||||
public class StoreBargain implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "关联商品ID")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "砍价开启时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品最低价")
|
||||
private BigDecimal minPrice;
|
||||
|
||||
@ApiModelProperty(value = "购买数量限制")
|
||||
// 单个活动每个用户发起砍价次数限制
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最大金额")
|
||||
private BigDecimal bargainMaxPrice;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最小金额")
|
||||
private BigDecimal bargainMinPrice;
|
||||
|
||||
@ApiModelProperty(value = "帮砍次数")
|
||||
// 单个商品用户可以帮砍的次数,例:次数设置为1,甲和乙同时将商品A的砍价链接发给丙,丙只能帮甲或乙其中一个人砍价
|
||||
private Integer bargainNum;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "反多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否推荐0不推荐1推荐")
|
||||
private Boolean isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否删除 0未删除 1删除")
|
||||
private Boolean isDel;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮 0不包邮 1包邮")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "砍价规则")
|
||||
private String rule;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品浏览量")
|
||||
private Integer look;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品分享量")
|
||||
private Integer share;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价好友人数")
|
||||
private Integer peopleNum;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.zbkj.crmeb.bargain.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 用户参与砍价表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user")
|
||||
@ApiModel(value="StoreBargainUser对象", description="用户参与砍价表")
|
||||
public class StoreBargainUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品id")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "砍价的最低价")
|
||||
private BigDecimal bargainPriceMin;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal bargainPrice;
|
||||
|
||||
@ApiModelProperty(value = "砍掉的价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "参与时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否取消")
|
||||
private Boolean isDel;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zbkj.crmeb.bargain.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 砍价用户帮助表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user_help")
|
||||
@ApiModel(value="StoreBargainUserHelp对象", description="砍价用户帮助表")
|
||||
public class StoreBargainUserHelp implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "砍价用户帮助表ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "帮助的用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表id")
|
||||
private Integer bargainUserId;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价多少金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zbkj.crmeb.store.model.StoreProductAttr;
|
||||
import com.zbkj.crmeb.store.request.StoreProductAttrValueRequest;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 砍价商品Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain")
|
||||
@ApiModel(value="StoreBargain对象", description="砍价表")
|
||||
public class StoreBargainRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "关联商品ID")
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动名称")
|
||||
@NotBlank(message = "砍价活动名称不能为空")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动图片")
|
||||
@NotBlank(message = "砍价活动图片不能为空")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品轮播图")
|
||||
// @NotBlank(message = "砍价商品轮播图不能为空")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "砍价开启时间")
|
||||
@NotBlank(message = "砍价开启时间不能为空")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价结束时间")
|
||||
@NotBlank(message = "砍价结束时间不能为空")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品最低价")
|
||||
private BigDecimal minPrice;
|
||||
|
||||
@ApiModelProperty(value = "购买数量限制")
|
||||
@Min(value = 1, message = "购买数量限制必须大于0")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最大金额")
|
||||
private BigDecimal bargainMaxPrice;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最小金额")
|
||||
private BigDecimal bargainMinPrice;
|
||||
|
||||
@ApiModelProperty(value = "帮砍次数")
|
||||
@Min(value = 1, message = "帮砍次数必须大于0")
|
||||
private Integer bargainNum;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)")
|
||||
@NotNull(message = "砍价活动状态不能为空")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "反多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动简介")
|
||||
@NotBlank(message = "砍价活动简介不能为空")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否推荐0不推荐1推荐")
|
||||
private Boolean isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否删除 0未删除 1删除")
|
||||
private Boolean isDel;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮 0不包邮 1包邮")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "砍价规则")
|
||||
private String rule;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品浏览量")
|
||||
private Integer look;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品分享量")
|
||||
private Integer share;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
@NotNull(message = "运费模板ID不能为空")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动发起人数")
|
||||
// @Size(min = 1, max = 9999, message = "砍价人数在1-9999之间")
|
||||
@Min(value = 2, message = "砍价人数最少两人")
|
||||
@Max(value = 9999, message = "砍价人数最多9999")
|
||||
private Integer peopleNum;
|
||||
|
||||
@ApiModelProperty(value = "商品属性")
|
||||
private List<StoreProductAttr> attr;
|
||||
|
||||
@ApiModelProperty(value = "商品属性详情")
|
||||
private List<StoreProductAttrValueRequest> attrValue;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品名称")
|
||||
@NotBlank(message = "砍价商品名称不能为空")
|
||||
private String proName;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 砍价商品查询Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain")
|
||||
@ApiModel(value="StoreBargain对象", description="砍价表")
|
||||
public class StoreBargainSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "搜索关键字 商品id或者名称")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 砍价用户帮助Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user_help")
|
||||
@ApiModel(value="StoreBargainUserHelp对象", description="砍价用户帮助表")
|
||||
public class StoreBargainUserHelpRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "帮助的用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表id")
|
||||
private Integer bargainUserId;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价多少金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 砍价用户帮助查询Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user_help")
|
||||
@ApiModel(value="StoreBargainUserHelp对象", description="砍价用户帮助表")
|
||||
public class StoreBargainUserHelpSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "帮助的用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表id")
|
||||
private Integer bargainUserId;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价多少金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 用户参与砍价Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user")
|
||||
@ApiModel(value="StoreBargainUser对象", description="用户参与砍价表")
|
||||
public class StoreBargainUserRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品id")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "砍价的最低价")
|
||||
private BigDecimal bargainPriceMin;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal bargainPrice;
|
||||
|
||||
@ApiModelProperty(value = "砍掉的价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "参与时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否取消")
|
||||
private Boolean isDel;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.zbkj.crmeb.bargain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 用户参与砍价查询Request
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_bargain_user")
|
||||
@ApiModel(value="StoreBargainUser对象", description="用户参与砍价表")
|
||||
public class StoreBargainUserSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "today,yesterday,lately7,lately30,month,year,/yyyy-MM-dd hh:mm:ss,yyyy-MM-dd hh:mm:ss/")
|
||||
private String dateLimit;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.zbkj.crmeb.bargain.response;
|
||||
|
||||
import com.zbkj.crmeb.store.model.StoreProductAttr;
|
||||
import com.zbkj.crmeb.store.request.StoreProductAttrValueRequest;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 砍价商品响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StoreBargainResponse {
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "关联商品ID")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "砍价开启时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价结束时间")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品最低价")
|
||||
private BigDecimal minPrice;
|
||||
|
||||
@ApiModelProperty(value = "每次购买的砍价商品数量")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最大金额")
|
||||
private BigDecimal bargainMaxPrice;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的最小金额")
|
||||
private BigDecimal bargainMinPrice;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的次数")
|
||||
private Integer bargainNum;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "反多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "成本价")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否推荐0不推荐1推荐")
|
||||
private Boolean isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否删除 0未删除 1删除")
|
||||
private Boolean isDel;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮 0不包邮 1包邮")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "砍价规则")
|
||||
private String rule;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品浏览量")
|
||||
private Integer look;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品分享量")
|
||||
private Integer share;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "限量剩余")
|
||||
private Integer surplusQuota;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价好友人数")
|
||||
private Integer peopleNum;
|
||||
|
||||
@ApiModelProperty(value = "参与人数")
|
||||
private Long countPeopleAll;
|
||||
|
||||
@ApiModelProperty(value = "帮忙砍价人数")
|
||||
private Long countPeopleHelp;
|
||||
|
||||
@ApiModelProperty(value = "砍价成功人数")
|
||||
private Long countPeopleSuccess;
|
||||
|
||||
@ApiModelProperty(value = "商品属性")
|
||||
private List<StoreProductAttr> attr;
|
||||
|
||||
@ApiModelProperty(value = "商品属性详情")
|
||||
private List<StoreProductAttrValueRequest> attrValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zbkj.crmeb.bargain.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 砍价用户帮助响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StoreBargainUserHelpResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "砍价用户帮助表ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "帮助的用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品ID")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表id")
|
||||
private Integer bargainUserId;
|
||||
|
||||
@ApiModelProperty(value = "帮助砍价多少金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zbkj.crmeb.bargain.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 用户参与砍价响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StoreBargainUserResponse {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "用户参与砍价表ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品id")
|
||||
private Integer bargainId;
|
||||
|
||||
@ApiModelProperty(value = "砍价的最低价")
|
||||
private BigDecimal bargainPriceMin;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private BigDecimal bargainPrice;
|
||||
|
||||
@ApiModelProperty(value = "砍掉的价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "参与时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String dataTime;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "当前价")
|
||||
private BigDecimal nowPrice;
|
||||
|
||||
@ApiModelProperty(value = "剩余砍价次数")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "总砍价次数")
|
||||
private Integer peopleNum;
|
||||
|
||||
@ApiModelProperty(value = "砍价商品")
|
||||
private String title;
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.zbkj.crmeb.bargain.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargain;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainRequest;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainResponse;
|
||||
import com.zbkj.crmeb.front.request.BargainFrontRequest;
|
||||
import com.zbkj.crmeb.front.response.BargainDetailResponse;
|
||||
import com.zbkj.crmeb.store.request.StoreProductStockRequest;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 砍价 Service
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainService extends IService<StoreBargain> {
|
||||
|
||||
/**
|
||||
* 分页显示砍价商品列表
|
||||
* @param request
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreBargainResponse> getList(StoreBargainSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 新增砍价商品
|
||||
* @param storeBargainRequest
|
||||
* @return
|
||||
*/
|
||||
boolean saveBargain(StoreBargainRequest storeBargainRequest);
|
||||
|
||||
/**
|
||||
* 删除砍价商品
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 修改砍价商品
|
||||
* @param storeBargainRequest
|
||||
* @return
|
||||
*/
|
||||
boolean updateBarhain(StoreBargainRequest storeBargainRequest);
|
||||
|
||||
/**
|
||||
* 修改砍价商品状态
|
||||
* @param id
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
boolean updateBargainStatus(Integer id, boolean status);
|
||||
|
||||
/**
|
||||
* 查询砍价商品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreProductResponse getAdminDetail(Integer id);
|
||||
|
||||
/**
|
||||
* H5 砍价商品列表
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreBargainResponse> getH5List(PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* H5 获取查看、分享、参与人数
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getH5Share(Integer id);
|
||||
|
||||
/**
|
||||
* H5 获取砍价商品详情信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
BargainDetailResponse getH5Detail(Integer id);
|
||||
|
||||
/**
|
||||
* 获取当前时间的砍价商品
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
List<StoreBargain> getCurrentBargainByProductId(Integer productId);
|
||||
|
||||
/**
|
||||
* 参与砍价活动
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
*/
|
||||
Boolean start(BargainFrontRequest bargainFrontRequest);
|
||||
|
||||
/**
|
||||
* 砍价商品根据实体查询
|
||||
* @param storeBargainParam
|
||||
* @return
|
||||
*/
|
||||
List<StoreBargain> getByEntity(StoreBargain storeBargainParam);
|
||||
|
||||
/**
|
||||
* 扣减砍价商品库存
|
||||
* @param bargainId 产品id
|
||||
* @param num 商品数量
|
||||
* @param attrValueId
|
||||
* @param type 是否限购 0=不限购
|
||||
* @return
|
||||
*/
|
||||
boolean decProductStock(Integer bargainId, Integer num, Integer attrValueId, Integer type);
|
||||
|
||||
/**
|
||||
* 添加库存
|
||||
* @param stockRequest
|
||||
*/
|
||||
Boolean stockAddRedis(StoreProductStockRequest stockRequest);
|
||||
|
||||
/**
|
||||
* 后台任务批量操作库存
|
||||
*/
|
||||
void consumeProductStock();
|
||||
|
||||
/**
|
||||
* 砍价活动结束后处理
|
||||
*/
|
||||
void stopAfterChange();
|
||||
|
||||
/**
|
||||
* 商品是否存在砍价活动
|
||||
* @param productId 商品编号
|
||||
*/
|
||||
Boolean isExistActivity(Integer productId);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.zbkj.crmeb.bargain.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUserHelp;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserHelpResponse;
|
||||
import com.zbkj.crmeb.front.request.BargainFrontRequest;
|
||||
import com.zbkj.crmeb.front.response.BargainCountResponse;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户帮助砍价 Service
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainUserHelpService extends IService<StoreBargainUserHelp> {
|
||||
|
||||
List<StoreBargainUserHelpResponse> getList(Integer bargainUserId);
|
||||
|
||||
/**
|
||||
* 获取帮忙砍价好友数量
|
||||
* @param bargainId
|
||||
* @return
|
||||
*/
|
||||
Long getHelpCountByBargainId(Integer bargainId);
|
||||
|
||||
/**
|
||||
* 获取帮忙砍价好友数量
|
||||
* @param bargainId
|
||||
* @param bargainUid
|
||||
* @return
|
||||
*/
|
||||
Long getHelpCountByBargainIdAndBargainUid(Integer bargainId, Integer bargainUid);
|
||||
|
||||
/**
|
||||
* H5 获取帮忙好友砍价数据
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
*/
|
||||
BargainCountResponse getH5CountByBargainId(BargainFrontRequest bargainFrontRequest);
|
||||
|
||||
/**
|
||||
* H5 帮忙好友砍价信息列表
|
||||
* @param bargainFrontRequest
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreBargainUserHelpResponse> getHelpList(BargainFrontRequest bargainFrontRequest, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> help(BargainFrontRequest bargainFrontRequest);
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
*/
|
||||
Long getHelpPeopleCount();
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
*/
|
||||
Long getHelpPeopleCountByBargainId(Integer bargainId);
|
||||
|
||||
/**
|
||||
* 获取用户还剩余的砍价金额
|
||||
* @param bargainId 砍价商品编号
|
||||
* @param bargainUserUid 砍价发起用户uid
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getSurplusPrice(Integer bargainId, Integer bargainUserUid);
|
||||
|
||||
/**
|
||||
* 砍价发起用户信息
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
*/
|
||||
Map<String, String> startUser(BargainFrontRequest bargainFrontRequest);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.zbkj.crmeb.bargain.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUser;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainUserSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户参与砍价 Service
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreBargainUserService extends IService<StoreBargainUser> {
|
||||
|
||||
PageInfo<StoreBargainUserResponse> getList(StoreBargainUserSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 获取砍价商品参与用户列表
|
||||
* @param bargainId
|
||||
* @return
|
||||
*/
|
||||
List<StoreBargainUser> getListByBargainId(Integer bargainId);
|
||||
|
||||
/**
|
||||
* 获取砍价商品参与人数
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Long getCountByBargainId(Integer id);
|
||||
|
||||
/**
|
||||
* 获取砍价商品
|
||||
* @param bargainId 砍价商品编号
|
||||
* @param uid 参与用户uid
|
||||
* @return
|
||||
*/
|
||||
StoreBargainUser getByBargainIdAndUid(Integer bargainId, Integer uid);
|
||||
|
||||
/**
|
||||
* 获取砍价中商品
|
||||
* @param bargainId 砍价商品编号
|
||||
* @param uid 参与用户uid
|
||||
* @return
|
||||
*/
|
||||
StoreBargainUser getByBargainIdAndUidAndPink(Integer bargainId, Integer uid);
|
||||
|
||||
/**
|
||||
* 获取用户砍价活动列表
|
||||
* @param bargainId 砍价商品编号
|
||||
* @param uid 参与用户uid
|
||||
* @return
|
||||
*/
|
||||
List<StoreBargainUser> getListByBargainIdAndUid(Integer bargainId, Integer uid);
|
||||
|
||||
/**
|
||||
* 用户是否参与砍价商品活动
|
||||
* @param bargainId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
Boolean isExistByBargainIdAndUid(Integer bargainId, Integer uid);
|
||||
|
||||
/**
|
||||
* 砍价商品用户根据实体查询
|
||||
* @param bargainUser
|
||||
* @return
|
||||
*/
|
||||
List<StoreBargainUser> getByEntity(StoreBargainUser bargainUser);
|
||||
}
|
||||
@@ -0,0 +1,890 @@
|
||||
package com.zbkj.crmeb.bargain.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.zbkj.crmeb.bargain.dao.StoreBargainDao;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargain;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUser;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainRequest;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserHelpService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserService;
|
||||
import com.zbkj.crmeb.front.request.BargainFrontRequest;
|
||||
import com.zbkj.crmeb.front.response.BargainDetailResponse;
|
||||
import com.zbkj.crmeb.store.model.*;
|
||||
import com.zbkj.crmeb.store.request.StoreProductAttrValueRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreProductStockRequest;
|
||||
import com.zbkj.crmeb.store.response.StoreProductAttrValueResponse;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
import com.zbkj.crmeb.store.service.*;
|
||||
import com.zbkj.crmeb.system.service.SystemAttachmentService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* StoreBargainService 实现类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreBargain> implements StoreBargainService {
|
||||
|
||||
@Resource
|
||||
private StoreBargainDao dao;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserService storeBargainUserService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserHelpService storeBargainUserHelpService;
|
||||
|
||||
@Autowired
|
||||
private SystemAttachmentService systemAttachmentService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductAttrService attrService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductAttrValueService attrValueService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductAttrResultService storeProductAttrResultService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductDescriptionService storeProductDescriptionService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductAttrValueService storeProductAttrValueService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private StoreProductService storeProductService;
|
||||
|
||||
@Autowired
|
||||
private StoreOrderService storeOrderService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StoreBargainServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param request 请求参数
|
||||
* @param pageParamRequest 分页类参数
|
||||
* @author HZW
|
||||
* @since 2020-11-06
|
||||
* @return List<StoreBargain>
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StoreBargainResponse> getList(StoreBargainSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
Page<StoreBargain> storeBargainPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<StoreBargain> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(StoreBargain::getIsDel, false);
|
||||
if (StrUtil.isNotEmpty(request.getKeywords())) {
|
||||
lambdaQueryWrapper.and(i -> i.like(StoreBargain::getId, request.getKeywords())
|
||||
.or().like(StoreBargain::getStoreName, request.getKeywords())
|
||||
.or().like(StoreBargain::getTitle, request.getKeywords()));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(request.getStatus())) {
|
||||
lambdaQueryWrapper.eq(StoreBargain::getStatus, request.getStatus());
|
||||
}
|
||||
lambdaQueryWrapper.orderByDesc(StoreBargain::getSort, StoreBargain::getId);
|
||||
List<StoreBargain> storeBargainList = dao.selectList(lambdaQueryWrapper);
|
||||
if (CollUtil.isEmpty(storeBargainList)) {
|
||||
return CommonPage.copyPageInfo(storeBargainPage, CollUtil.newArrayList());
|
||||
}
|
||||
// 1.砍价参与人数,2.帮忙砍价人数,3.砍价成功人数
|
||||
List<StoreBargainResponse> storeProductResponses = CollUtil.newArrayList();
|
||||
for (StoreBargain storeBargain : storeBargainList) {
|
||||
StoreBargainResponse storeBargainResponse = new StoreBargainResponse();
|
||||
BeanUtils.copyProperties(storeBargain, storeBargainResponse);
|
||||
storeBargainResponse.setStartTime(DateUtil.timestamp2DateStr(storeBargain.getStartTime(), Constants.DATE_FORMAT_DATE));
|
||||
storeBargainResponse.setStopTime(DateUtil.timestamp2DateStr(storeBargain.getStopTime(), Constants.DATE_FORMAT_DATE));
|
||||
storeBargainResponse.setAddTime(DateUtil.timestamp2DateStr(storeBargain.getAddTime(), Constants.DATE_FORMAT));
|
||||
List<StoreBargainUser> bargainUserList = storeBargainUserService.getListByBargainId(storeBargain.getId());
|
||||
if (CollUtil.isEmpty(bargainUserList)) {
|
||||
storeBargainResponse.setCountPeopleAll(0L);
|
||||
storeBargainResponse.setCountPeopleHelp(0L);
|
||||
storeBargainResponse.setCountPeopleSuccess(0L);
|
||||
//限量剩余
|
||||
storeBargainResponse.setSurplusQuota(storeBargain.getQuota());
|
||||
storeProductResponses.add(storeBargainResponse);
|
||||
continue ;
|
||||
}
|
||||
//砍价参与人数
|
||||
Integer countPeopleAll = bargainUserList.size();
|
||||
//砍价成功人数
|
||||
Long countPeopleSuccess = bargainUserList.stream().filter(o -> o.getStatus().equals(3)).count();
|
||||
//帮忙砍价人数
|
||||
Long countPeopleHelp = storeBargainUserHelpService.getHelpCountByBargainId(storeBargain.getId());
|
||||
storeBargainResponse.setCountPeopleAll(countPeopleAll.longValue());
|
||||
storeBargainResponse.setCountPeopleHelp(countPeopleHelp);
|
||||
storeBargainResponse.setCountPeopleSuccess(countPeopleSuccess);
|
||||
//限量剩余
|
||||
storeBargainResponse.setSurplusQuota(storeBargain.getQuota());
|
||||
storeProductResponses.add(storeBargainResponse);
|
||||
}
|
||||
return CommonPage.copyPageInfo(storeBargainPage, storeProductResponses);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除砍价商品
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Integer id) {
|
||||
StoreBargain existBargain = getById(id);
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
if (existBargain.getStatus().equals(true) && existBargain.getStartTime() <= timeMillis && timeMillis <= existBargain.getStopTime()) {
|
||||
throw new CrmebException("活动开启中,商品不支持删除");
|
||||
}
|
||||
|
||||
StoreBargain storeBargain = new StoreBargain();
|
||||
storeBargain.setId(id).setIsDel(true);
|
||||
return dao.updateById(storeBargain) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增砍价商品
|
||||
* @param request 砍价商品result
|
||||
* @return 新增结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveBargain(StoreBargainRequest request) {
|
||||
// 参数校验
|
||||
if (null == request.getAttrValue() || request.getAttrValue().size() < 1) {
|
||||
throw new CrmebException("请选择砍价商品的规格属性");
|
||||
}
|
||||
StoreProductAttrValueRequest attrValueRequest = request.getAttrValue().get(0);
|
||||
if (ObjectUtil.isNull(attrValueRequest.getQuota()) || attrValueRequest.getQuota() <= 0) {
|
||||
throw new CrmebException("活动限购数量必须大于0");
|
||||
}
|
||||
|
||||
StoreBargain bargain = new StoreBargain();
|
||||
BeanUtils.copyProperties(request, bargain);
|
||||
bargain.setId(null);
|
||||
// 头图、轮播图
|
||||
bargain.setImage(systemAttachmentService.clearPrefix(request.getImage()));
|
||||
bargain.setImages(systemAttachmentService.clearPrefix(request.getImages()));
|
||||
// 活动开始结束时间
|
||||
bargain.setStartTime(DateUtil.dateStr2Timestamp(request.getStartTime(), Constants.DATE_TIME_TYPE_BEGIN));
|
||||
bargain.setStopTime(DateUtil.dateStr2Timestamp(request.getStopTime(), Constants.DATE_TIME_TYPE_END));
|
||||
bargain.setAddTime(System.currentTimeMillis());
|
||||
bargain.setStoreName(request.getProName());
|
||||
// 砍价商品价格
|
||||
bargain.setPrice(attrValueRequest.getPrice());
|
||||
bargain.setMinPrice(attrValueRequest.getMinPrice());
|
||||
bargain.setCost(attrValueRequest.getCost());
|
||||
bargain.setStock(attrValueRequest.getStock());
|
||||
bargain.setQuota(attrValueRequest.getQuota());
|
||||
bargain.setIsDel(false);
|
||||
bargain.setQuotaShow(bargain.getQuota());
|
||||
bargain.setSales(0);
|
||||
boolean save = save(bargain);
|
||||
if (!save) throw new CrmebException("新增砍价商品失败");
|
||||
|
||||
// 处理商品属性,给砍价商品一份单规格默认属性
|
||||
StoreProductAttr singleAttr = new StoreProductAttr();
|
||||
singleAttr.setProductId(bargain.getId()).setAttrName("规格").setAttrValues("默认").setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
boolean attrAddResult = attrService.save(singleAttr);
|
||||
if (!attrAddResult) throw new CrmebException("新增属性名失败");
|
||||
|
||||
// 处理商品属性值,砍价商品只有一条属性值
|
||||
StoreProductAttrValue singleAttrValue = new StoreProductAttrValue();
|
||||
BeanUtils.copyProperties(attrValueRequest, singleAttrValue);
|
||||
singleAttrValue.setProductId(bargain.getId()).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
singleAttrValue.setImage(systemAttachmentService.clearPrefix(singleAttrValue.getImage()));
|
||||
boolean saveAttrValue = attrValueService.save(singleAttrValue);
|
||||
if(!saveAttrValue) throw new CrmebException("新增属性详情失败");
|
||||
|
||||
// 处理商品属性值result
|
||||
StoreProductAttrResult attrResult = new StoreProductAttrResult(
|
||||
0,
|
||||
bargain.getId(),
|
||||
systemAttachmentService.clearPrefix(JSON.toJSONString(request.getAttrValue())),
|
||||
DateUtil.getNowTime(),Constants.PRODUCT_TYPE_BARGAIN);
|
||||
boolean saveResult = storeProductAttrResultService.save(attrResult);
|
||||
if(!saveResult) throw new CrmebException("新增商品属性详情详情失败");
|
||||
|
||||
// 处理富文本
|
||||
StoreProductDescription spd = new StoreProductDescription(
|
||||
bargain.getId(), request.getContent().length() > 0
|
||||
? systemAttachmentService.clearPrefix(request.getContent()) : "" , Constants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductDescriptionService.deleteByProductId(spd.getProductId(), Constants.PRODUCT_TYPE_BARGAIN);
|
||||
boolean saveDesc = storeProductDescriptionService.save(spd);
|
||||
if (!saveDesc) throw new CrmebException("新增商品富文本失败");
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑砍价商品
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean updateBarhain(StoreBargainRequest request) {
|
||||
StoreBargain existBargain = getById(request.getId());
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
if (existBargain.getStatus().equals(true) && existBargain.getStartTime() <= timeMillis && timeMillis <= existBargain.getStopTime()) {
|
||||
throw new CrmebException("活动开启中,商品不支持修改");
|
||||
}
|
||||
|
||||
if (null == request.getAttrValue() || request.getAttrValue().size() < 1) {
|
||||
throw new CrmebException("请选择砍价商品的规格属性");
|
||||
}
|
||||
StoreProductAttrValueRequest attrValueRequest = request.getAttrValue().get(0);
|
||||
|
||||
StoreBargain bargain = new StoreBargain();
|
||||
BeanUtils.copyProperties(request, bargain);
|
||||
// 头图、轮播图
|
||||
bargain.setImage(systemAttachmentService.clearPrefix(request.getImage()));
|
||||
bargain.setImages(systemAttachmentService.clearPrefix(request.getImages()));
|
||||
// 活动开始结束时间
|
||||
bargain.setStartTime(DateUtil.dateStr2Timestamp(request.getStartTime(), Constants.DATE_TIME_TYPE_BEGIN));
|
||||
bargain.setStopTime(DateUtil.dateStr2Timestamp(request.getStopTime(), Constants.DATE_TIME_TYPE_END));
|
||||
bargain.setStoreName(request.getProName());
|
||||
// 砍价商品价格
|
||||
bargain.setPrice(attrValueRequest.getPrice());
|
||||
bargain.setMinPrice(attrValueRequest.getMinPrice());
|
||||
bargain.setCost(attrValueRequest.getCost());
|
||||
bargain.setStock(attrValueRequest.getStock());
|
||||
bargain.setQuota(attrValueRequest.getQuota());
|
||||
bargain.setQuotaShow(attrValueRequest.getQuota());
|
||||
int saveCount = dao.updateById(bargain);
|
||||
if (saveCount <= 0) {
|
||||
throw new CrmebException("编辑砍价商品失败");
|
||||
}
|
||||
|
||||
// 砍价商品属性attr不用变化,attrValue删除原有的替换为现有的
|
||||
attrValueService.removeByProductId(request.getId(), Constants.PRODUCT_TYPE_BARGAIN);
|
||||
StoreProductAttrValue singleAttrValue = new StoreProductAttrValue();
|
||||
BeanUtils.copyProperties(attrValueRequest, singleAttrValue);
|
||||
singleAttrValue.setProductId(bargain.getId()).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
singleAttrValue.setImage(systemAttachmentService.clearPrefix(singleAttrValue.getImage()));
|
||||
boolean saveAttrValue = attrValueService.save(singleAttrValue);
|
||||
if(!saveAttrValue) throw new CrmebException("编辑属性详情失败");
|
||||
|
||||
// attrResult整存整取,不做更新
|
||||
storeProductAttrResultService.deleteByProductId(bargain.getId(),Constants.PRODUCT_TYPE_BARGAIN);
|
||||
StoreProductAttrResult attrResult = new StoreProductAttrResult(
|
||||
0,
|
||||
bargain.getId(),
|
||||
systemAttachmentService.clearPrefix(JSON.toJSONString(request.getAttrValue())),
|
||||
DateUtil.getNowTime(),Constants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductAttrResultService.save(attrResult);
|
||||
|
||||
return saveCount > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新砍价商品状态
|
||||
* @param id
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean updateBargainStatus(Integer id, boolean status) {
|
||||
StoreBargain temp = getById(id);
|
||||
if (ObjectUtil.isNull(temp) || temp.getIsDel()) {
|
||||
throw new CrmebException("砍价商品不存在");
|
||||
}
|
||||
if (status) {
|
||||
// 判断商品是否存在
|
||||
StoreProduct product = storeProductService.getById(temp.getProductId());
|
||||
if (ObjectUtil.isNull(product)) {
|
||||
throw new CrmebException("关联的商品已删除,无法开启活动");
|
||||
}
|
||||
}
|
||||
|
||||
StoreBargain storeBargain = new StoreBargain();
|
||||
storeBargain.setId(id).setStatus(status);
|
||||
return dao.updateById(storeBargain) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价商品详情
|
||||
* @param bargainId 砍价商品id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StoreProductResponse getAdminDetail(Integer bargainId) {
|
||||
StoreBargain storeBargain = dao.selectById(bargainId);
|
||||
if (ObjectUtil.isNull(storeBargain)) throw new CrmebException("未找到对应砍价商品信息");
|
||||
StoreProductResponse storeProductResponse = new StoreProductResponse();
|
||||
BeanUtils.copyProperties(storeBargain, storeProductResponse);
|
||||
storeProductResponse.setStartTime(new Date(storeBargain.getStartTime()));
|
||||
storeProductResponse.setStopTime(new Date(storeBargain.getStopTime()));
|
||||
storeProductResponse.setStatus(storeBargain.getStatus().equals(true) ? 1 : 0);
|
||||
|
||||
// 查询attr
|
||||
StoreProductAttr spaPram = new StoreProductAttr();
|
||||
spaPram.setProductId(storeBargain.getProductId() ).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttr> attrs = attrService.getByEntity(spaPram);
|
||||
storeProductResponse.setAttr(attrs);
|
||||
storeProductResponse.setSliderImage(String.join(",",storeBargain.getImages()));
|
||||
|
||||
boolean specType = false;
|
||||
if (attrs.size() > 1) {
|
||||
specType = true;
|
||||
}
|
||||
storeProductResponse.setSpecType(specType);
|
||||
|
||||
// 注意:数据瓶装步骤:分别查询砍价和商品本身信息组装sku信息之后,再对比sku属性是否相等来赋值是否砍价sku信息
|
||||
StoreProductAttrValue spavPramBargain = new StoreProductAttrValue();
|
||||
spavPramBargain.setProductId(bargainId).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesBargain = attrValueService.getByEntity(spavPramBargain);
|
||||
List<HashMap<String, Object>> attrValuesBargain = genratorSkuInfo(bargainId, specType, storeBargain, storeProductAttrValuesBargain, Constants.PRODUCT_TYPE_BARGAIN);
|
||||
|
||||
// 查询attrValue
|
||||
StoreProductAttrValue spavPramProduct = new StoreProductAttrValue();
|
||||
spavPramProduct.setProductId(storeBargain.getProductId()).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesProduct = attrValueService.getByEntity(spavPramProduct);
|
||||
List<HashMap<String, Object>> attrValuesProduct = genratorSkuInfo(storeBargain.getProductId(), specType, storeBargain, storeProductAttrValuesProduct, Constants.PRODUCT_TYPE_NORMAL);
|
||||
|
||||
// H5 端用于生成skuList
|
||||
List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
||||
|
||||
for (StoreProductAttrValue storeProductAttrValue : storeProductAttrValuesBargain) {
|
||||
StoreProductAttrValueResponse atr = new StoreProductAttrValueResponse();
|
||||
BeanUtils.copyProperties(storeProductAttrValue, atr);
|
||||
// 单规格秒杀限量数据处理
|
||||
atr.setQuota(storeProductResponse.getQuota());
|
||||
atr.setMinPrice(storeBargain.getMinPrice());
|
||||
atr.setChecked(true);
|
||||
sPAVResponses.add(atr);
|
||||
}
|
||||
|
||||
for (int k = 0; k < attrValuesProduct.size(); k++) {
|
||||
for (int i = 0; i < attrValuesBargain.size(); i++) {
|
||||
HashMap<String, Object> bargainMap = attrValuesBargain.get(i);
|
||||
HashMap<String, Object> productMap = attrValuesProduct.get(k);
|
||||
productMap.put("checked", false);
|
||||
productMap.put("quota", productMap.get("stock"));
|
||||
productMap.put("price", productMap.get("price"));
|
||||
if(bargainMap.get("suk").equals(productMap.get("suk"))){
|
||||
productMap.put("checked", true);
|
||||
productMap.put("quota", bargainMap.get("quota"));
|
||||
productMap.put("price",bargainMap.get("price"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
storeProductResponse.setAttrValues(attrValuesProduct);
|
||||
storeProductResponse.setAttrValue(sPAVResponses);
|
||||
|
||||
StoreProductDescription sd = storeProductDescriptionService.getOne(
|
||||
new LambdaQueryWrapper<StoreProductDescription>()
|
||||
.eq(StoreProductDescription::getProductId, bargainId)
|
||||
.eq(StoreProductDescription::getType, Constants.PRODUCT_TYPE_BARGAIN));
|
||||
if(null != sd){
|
||||
storeProductResponse.setContent(StrUtil.isBlank(sd.getDescription()) ? "" : sd.getDescription());
|
||||
}
|
||||
if (StrUtil.isNotBlank(storeProductResponse.getRule())) {
|
||||
storeProductResponse.setRule(systemAttachmentService.clearPrefix(storeBargain.getRule()));
|
||||
}
|
||||
return storeProductResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* h5 获取砍价商品列表
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StoreBargainResponse> getH5List(PageParamRequest pageParamRequest) {
|
||||
Page<StoreBargain> storeBargainPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<StoreBargain> lqw = new LambdaQueryWrapper();
|
||||
lqw.eq(StoreBargain::getStatus, true);
|
||||
lqw.eq(StoreBargain::getIsDel, false);
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
lqw.le(StoreBargain::getStartTime, timeMillis);
|
||||
lqw.ge(StoreBargain::getStopTime, timeMillis);
|
||||
lqw.orderByDesc(StoreBargain::getSort, StoreBargain::getId);
|
||||
List<StoreBargain> storeBargains = dao.selectList(lqw);
|
||||
List<StoreBargainResponse> bargainResponseList = storeBargains.stream().map(bargain -> {
|
||||
StoreBargainResponse storeBargainResponse = new StoreBargainResponse();
|
||||
Long countByBargainId = storeBargainUserService.getCountByBargainId(bargain.getId());
|
||||
BeanUtils.copyProperties(bargain, storeBargainResponse);
|
||||
storeBargainResponse.setCountPeopleAll(countByBargainId);
|
||||
return storeBargainResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonPage.copyPageInfo(storeBargainPage, bargainResponseList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查看、分享、参与人数
|
||||
* 这里目前是获取总的数据,以后还是要改成获取商品的数据
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getH5Share(Integer bargainId) {
|
||||
QueryWrapper<StoreBargain> qw = new QueryWrapper<>();
|
||||
qw.select("ifnull(sum(look), 0) as lookCount", "ifnull(sum(share), 0) as shareCount");
|
||||
qw.eq("is_del", false);
|
||||
Map<String, Object> map = getMap(qw);
|
||||
// Long userCount = storeBargainUserHelpService.getHelpPeopleCount();
|
||||
Integer count = storeBargainUserHelpService.count();
|
||||
map.put("userCount", count.longValue());
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* H5 砍价商品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public BargainDetailResponse getH5Detail(Integer id) {
|
||||
StoreBargain storeBargain = dao.selectById(id);
|
||||
if (ObjectUtil.isNull(storeBargain)) throw new CrmebException("未找到对应砍价商品信息");
|
||||
StoreProductResponse storeProductResponse = new StoreProductResponse();
|
||||
BeanUtils.copyProperties(storeBargain, storeProductResponse);
|
||||
storeProductResponse.setRule(systemAttachmentService.clearPrefix(storeProductResponse.getRule()));
|
||||
storeProductResponse.setEndTime(storeBargain.getStopTime());
|
||||
|
||||
StoreProductAttr spaPram = new StoreProductAttr();
|
||||
spaPram.setProductId(id).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductResponse.setAttr(attrService.getByEntity(spaPram));
|
||||
|
||||
StoreProductAttrValue spavPramBargain = new StoreProductAttrValue();
|
||||
spavPramBargain.setProductId(id).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesBargain = storeProductAttrValueService.getByEntity(spavPramBargain);
|
||||
|
||||
// 查询attr
|
||||
StoreProductAttr spaPramNormal = new StoreProductAttr();
|
||||
spaPramNormal.setProductId(storeBargain.getProductId() ).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttr> attrs = attrService.getByEntity(spaPramNormal);
|
||||
boolean specType = false;
|
||||
if (attrs.size() > 1) {
|
||||
specType = true;
|
||||
}
|
||||
List<HashMap<String, Object>> attrValuesBargain = genratorSkuInfo(id, specType, storeBargain, storeProductAttrValuesBargain, Constants.PRODUCT_TYPE_BARGAIN);
|
||||
|
||||
// H5 端用于生成skuList
|
||||
List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
||||
|
||||
for (StoreProductAttrValue storeProductAttrValue : storeProductAttrValuesBargain) {
|
||||
StoreProductAttrValueResponse atr = new StoreProductAttrValueResponse();
|
||||
BeanUtils.copyProperties(storeProductAttrValue,atr);
|
||||
atr.setQuota(storeProductAttrValue.getQuota());
|
||||
atr.setMinPrice(storeBargain.getMinPrice());
|
||||
sPAVResponses.add(atr);
|
||||
}
|
||||
storeProductResponse.setAttrValues(attrValuesBargain);
|
||||
storeProductResponse.setAttrValue(sPAVResponses);
|
||||
StoreProductDescription sd = storeProductDescriptionService.getOne(
|
||||
new LambdaQueryWrapper<StoreProductDescription>()
|
||||
.eq(StoreProductDescription::getProductId, id)
|
||||
.eq(StoreProductDescription::getType, Constants.PRODUCT_TYPE_BARGAIN));
|
||||
if(null != sd){
|
||||
storeProductResponse.setContent(null == sd.getDescription()?"":sd.getDescription());
|
||||
}
|
||||
|
||||
User user = userService.getInfo();
|
||||
// 用户发起的砍价活动次数
|
||||
int userBargainStatus = isCanPink(storeBargain, user.getUid());
|
||||
|
||||
// 砍价支付成功订单数量
|
||||
Integer bargainSumCount = storeOrderService.getCountByBargainIdAndUid(storeBargain.getId(), user.getUid());
|
||||
|
||||
BargainDetailResponse bargainDetailResponse = new BargainDetailResponse(storeProductResponse, userBargainStatus, user, bargainSumCount);
|
||||
bargainDetailResponse.setAloneAttrValueId(storeProductResponse.getAttrValue().get(0).getId());
|
||||
|
||||
// 查看人数+1
|
||||
storeBargain.setLook(storeBargain.getLook() + 1);
|
||||
updateById(storeBargain);
|
||||
return bargainDetailResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户砍价活动次数
|
||||
* @param storeBargain
|
||||
* @param uid
|
||||
* @return
|
||||
* 1.用户有没有砍价中的活动
|
||||
* 2.没有的,用户的砍价次数有没有到
|
||||
*/
|
||||
private int isCanPink(StoreBargain storeBargain, Integer uid) {
|
||||
int userBargainStatus = 0; // 能
|
||||
// StoreBargainUser storeBargainUser = storeBargainUserService.getByBargainIdAndUidAndPink(storeBargain.getId(), uid);
|
||||
// if (ObjectUtil.isNotNull(storeBargainUser)) {
|
||||
// userBargainStatus = 1; // 不能
|
||||
// return userBargainStatus;
|
||||
// }
|
||||
// List<StoreBargainUser> list = storeBargainUserService.getListByBargainIdAndUid(storeBargain.getId(), uid);
|
||||
// if (CollUtil.isNotEmpty(list) && list.size() >= storeBargain.getNum()) {
|
||||
// userBargainStatus = 1;
|
||||
// }
|
||||
List<StoreBargainUser> list = storeBargainUserService.getListByBargainIdAndUid(storeBargain.getId(), uid);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
userBargainStatus = list.size();
|
||||
}
|
||||
return userBargainStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间段的砍价商品
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargain> getCurrentBargainByProductId(Integer productId) {
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
PageParamRequest pageParamRequest = new PageParamRequest();
|
||||
LambdaQueryWrapper<StoreBargain> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargain::getProductId, productId);
|
||||
lqw.eq(StoreBargain::getIsDel, false);
|
||||
lqw.le(StoreBargain::getStartTime, timeMillis);
|
||||
lqw.ge(StoreBargain::getStopTime, timeMillis);
|
||||
lqw.orderByDesc(StoreBargain::getSort, StoreBargain::getId);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参与砍价商品活动
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean start(BargainFrontRequest request) {
|
||||
StoreBargain storeBargain = dao.selectById(request.getBargainId());
|
||||
if (ObjectUtil.isNull(storeBargain)) throw new CrmebException("对应的砍价商品不存在");
|
||||
if (!storeBargain.getStatus()) throw new CrmebException("砍价活动已结束");
|
||||
User user = userService.getInfo();
|
||||
|
||||
// 判断是否有正在砍价商品
|
||||
StoreBargainUser spavBargainUser = new StoreBargainUser();
|
||||
spavBargainUser.setIsDel(false).setBargainId(request.getBargainId()).setUid(user.getUid());
|
||||
List<StoreBargainUser> historyList = storeBargainUserService.getByEntity(spavBargainUser);
|
||||
if (CollUtil.isNotEmpty(historyList)) {
|
||||
List<StoreBargainUser> collect = historyList.stream().filter(i -> i.getStatus() == 1).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) throw new CrmebException("请先完成当前砍价活动");
|
||||
// 判断是否达到参与砍价活动上限
|
||||
if (historyList.size() >= storeBargain.getNum()) {
|
||||
throw new CrmebException("您已达到当前砍价活动上限");
|
||||
}
|
||||
}
|
||||
|
||||
StoreBargainUser storeBargainUser = new StoreBargainUser();
|
||||
storeBargainUser.setUid(user.getUid());
|
||||
storeBargainUser.setBargainId(request.getBargainId());
|
||||
storeBargainUser.setBargainPriceMin(storeBargain.getMinPrice());
|
||||
storeBargainUser.setBargainPrice(storeBargain.getPrice());
|
||||
storeBargainUser.setPrice(BigDecimal.ZERO);
|
||||
storeBargainUser.setAddTime(System.currentTimeMillis());
|
||||
storeBargainUser.setStatus(1);
|
||||
return storeBargainUserService.save(storeBargainUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品根据实体查询
|
||||
* @param storeBargainParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargain> getByEntity(StoreBargain storeBargainParam) {
|
||||
LambdaQueryWrapper<StoreBargain> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.setEntity(storeBargainParam);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减砍价商品库存
|
||||
* @param bargainId
|
||||
* @param num
|
||||
* @param attrValueId
|
||||
* @param type
|
||||
* @return
|
||||
* 扣除砍价商品表库存
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean decProductStock(Integer bargainId, Integer num, Integer attrValueId, Integer type) {
|
||||
// 因为attrvalue表中unique使用Id代替,更新前先查询此表是否存在
|
||||
StoreProductAttrValue spavParm = new StoreProductAttrValue();
|
||||
spavParm.setId(attrValueId).setType(type).setProductId(bargainId);
|
||||
List<StoreProductAttrValue> attrvalues = storeProductAttrValueService.getByEntity(spavParm);
|
||||
if (CollUtil.isEmpty(attrvalues)) throw new CrmebException("未找到相关商品属性");
|
||||
|
||||
// 扣除砍价商品属性值表的suk 砍价商品只会有一条sku
|
||||
StoreProductAttrValue storeProductAttrValue = attrvalues.get(0);
|
||||
if (ObjectUtil.isNotNull(storeProductAttrValue)) {
|
||||
boolean updateAttrValue = storeProductAttrValueService.decProductAttrStock(bargainId, attrValueId, num, type);
|
||||
if (!updateAttrValue) {
|
||||
throw new CrmebException("扣减砍价商品sku库存失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 砍价SKU 库存减,销量、限购总数减
|
||||
StoreBargain storeBargain = getById(bargainId);
|
||||
LambdaUpdateWrapper<StoreBargain> luw = new LambdaUpdateWrapper<>();
|
||||
luw.eq(StoreBargain::getId, bargainId);
|
||||
luw.set(StoreBargain::getStock, storeBargain.getStock() - num);
|
||||
luw.set(StoreBargain::getSales, storeBargain.getSales() + num);
|
||||
luw.set(StoreBargain::getQuota, storeBargain.getQuota() - num);
|
||||
boolean update = update(luw);
|
||||
if (!update) {
|
||||
throw new CrmebException("扣减砍价商品库存失败");
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加库存
|
||||
* @param stockRequest StoreProductStockRequest 参数对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean stockAddRedis(StoreProductStockRequest stockRequest) {
|
||||
String _productString = JSON.toJSONString(stockRequest);
|
||||
redisUtil.lPush(Constants.PRODUCT_BARGAIN_STOCK_UPDATE, _productString);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台任务批量操作库存
|
||||
*/
|
||||
@Override
|
||||
public void consumeProductStock() {
|
||||
String redisKey = Constants.PRODUCT_BARGAIN_STOCK_UPDATE;
|
||||
Long size = redisUtil.getListSize(redisKey);
|
||||
logger.info("StoreBargainServiceImpl.consumeProductStock | size:" + size);
|
||||
if (size < 1) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
//如果10秒钟拿不到一个数据,那么退出循环
|
||||
Object data = redisUtil.getRightPop(redisKey, 10L);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
StoreProductStockRequest storeProductStockRequest =
|
||||
com.alibaba.fastjson.JSONObject.toJavaObject(com.alibaba.fastjson.JSONObject.parseObject(data.toString()), StoreProductStockRequest.class);
|
||||
boolean result = doProductStock(storeProductStockRequest);
|
||||
if(!result){
|
||||
redisUtil.lPush(redisKey, data);
|
||||
}
|
||||
}catch (Exception e){
|
||||
redisUtil.lPush(redisKey, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价活动结束后处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void stopAfterChange() {
|
||||
// 查询活动状态为开启,结束时间小于当前时间的数据
|
||||
List<StoreBargain> storeBargainList = getByStatusAndGtStopTime();
|
||||
logger.info("StoreBargainServiceImpl.stopAfterChange | size:" + storeBargainList.size());
|
||||
if (CollUtil.isEmpty(storeBargainList)) {
|
||||
return;
|
||||
}
|
||||
List<StoreBargainUser> bargainUserList = CollUtil.newArrayList();
|
||||
for (StoreBargain bargain : storeBargainList) {
|
||||
// 查询用户参与活动表中状态为进行中的数据
|
||||
StoreBargainUser spavBargainUser = new StoreBargainUser();
|
||||
spavBargainUser.setBargainId(bargain.getId());
|
||||
spavBargainUser.setStatus(1);
|
||||
spavBargainUser.setIsDel(false);
|
||||
List<StoreBargainUser> bargainUsers = storeBargainUserService.getByEntity(spavBargainUser);
|
||||
if (CollUtil.isEmpty(bargainUsers)) {
|
||||
continue ;
|
||||
}
|
||||
for (int i = 0; i < bargainUsers.size(); i++) {
|
||||
bargainUsers.get(i).setStatus(2);
|
||||
}
|
||||
bargainUserList.addAll(bargainUsers);
|
||||
}
|
||||
boolean b = storeBargainUserService.updateBatchById(bargainUserList, 100);
|
||||
if (!b) {
|
||||
logger.error("砍价活动结束后更新用户状态定时任务——————失败");
|
||||
throw new CrmebException("砍价活动结束后更新用户状态失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品是否存在砍价活动
|
||||
* @param productId 商品编号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean isExistActivity(Integer productId) {
|
||||
// 查询商品关联的砍价商品
|
||||
LambdaQueryWrapper<StoreBargain> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargain::getProductId, productId);
|
||||
List<StoreBargain> bargainList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(bargainList)) {
|
||||
return false;
|
||||
}
|
||||
// 判断关联的商品是否处于活动开启状态
|
||||
List<StoreBargain> list = bargainList.stream().filter(i -> i.getStatus().equals(true)).collect(Collectors.toList());
|
||||
return CollUtil.isNotEmpty(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询活动状态为开启,结束时间小于当前时间的数据
|
||||
* @return
|
||||
*/
|
||||
private List<StoreBargain> getByStatusAndGtStopTime() {
|
||||
LambdaQueryWrapper<StoreBargain> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargain::getStatus, true);
|
||||
lqw.lt(StoreBargain::getStopTime, System.currentTimeMillis());
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置生成sku配置信息
|
||||
* @param productId 商品id
|
||||
* @param specType 是否是多规格
|
||||
* @param storeProductAttrValues 属性信息
|
||||
* @param productType 秒杀和正常数据
|
||||
* @return sku信息
|
||||
*/
|
||||
private List<HashMap<String, Object>> genratorSkuInfo(int productId, boolean specType, StoreBargain storeBargain,
|
||||
List<StoreProductAttrValue> storeProductAttrValues,
|
||||
int productType) {
|
||||
List<HashMap<String, Object>> attrValues = new ArrayList<>();
|
||||
if (specType) {
|
||||
StoreProductAttrResult sparPram = new StoreProductAttrResult();
|
||||
sparPram.setProductId(productId).setType(productType);
|
||||
List<StoreProductAttrResult> attrResults = storeProductAttrResultService.getByEntity(sparPram);
|
||||
if (null == attrResults || attrResults.size() == 0) {
|
||||
throw new CrmebException("未找到对应属性值");
|
||||
}
|
||||
StoreProductAttrResult attrResult = attrResults.get(0);
|
||||
//PC 端生成skuAttrInfo
|
||||
List<StoreProductAttrValueRequest> storeProductAttrValueRequests =
|
||||
com.alibaba.fastjson.JSONObject.parseArray(attrResult.getResult(), StoreProductAttrValueRequest.class);
|
||||
if (null != storeProductAttrValueRequests) {
|
||||
for (int i = 0; i < storeProductAttrValueRequests.size(); i++) {
|
||||
HashMap<String, Object> attrValue = new HashMap<>();
|
||||
String currentSku = storeProductAttrValues.get(i).getSuk();
|
||||
List<StoreProductAttrValue> hasCurrentSku =
|
||||
storeProductAttrValues.stream().filter(e -> e.getSuk().equals(currentSku)).collect(Collectors.toList());
|
||||
StoreProductAttrValue currentAttrValue = hasCurrentSku.get(0);
|
||||
attrValue.put("id", hasCurrentSku.size() > 0 ? hasCurrentSku.get(0).getId() : 0);
|
||||
attrValue.put("image", currentAttrValue.getImage());
|
||||
attrValue.put("cost", currentAttrValue.getCost());
|
||||
attrValue.put("price", currentAttrValue.getPrice());
|
||||
attrValue.put("otPrice", currentAttrValue.getOtPrice());
|
||||
attrValue.put("stock", currentAttrValue.getStock());
|
||||
attrValue.put("barCode", currentAttrValue.getBarCode());
|
||||
attrValue.put("weight", currentAttrValue.getWeight());
|
||||
attrValue.put("volume", currentAttrValue.getVolume());
|
||||
attrValue.put("suk", currentSku);
|
||||
attrValue.put("attrValue", JSON.parse(storeProductAttrValues.get(i).getAttrValue(), Feature.OrderedField));
|
||||
attrValue.put("brokerage", currentAttrValue.getBrokerage());
|
||||
attrValue.put("brokerageTwo", currentAttrValue.getBrokerageTwo());
|
||||
attrValue.put("quota", currentAttrValue.getQuota());
|
||||
attrValue.put("minPrice", storeBargain.getMinPrice());
|
||||
String[] skus = currentSku.split(",");
|
||||
for (int k = 0; k < skus.length; k++) {
|
||||
attrValue.put("value" + k, skus[k]);
|
||||
}
|
||||
attrValues.add(attrValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return attrValues;
|
||||
}
|
||||
|
||||
// 砍价操作库存
|
||||
private boolean doProductStock(StoreProductStockRequest storeProductStockRequest){
|
||||
// 砍价商品信息回滚
|
||||
StoreBargain existProduct = getById(storeProductStockRequest.getBargainId());
|
||||
List<StoreProductAttrValue> existAttr =
|
||||
storeProductAttrValueService.getListByProductIdAndAttrId(
|
||||
storeProductStockRequest.getBargainId(),
|
||||
storeProductStockRequest.getAttrId().toString(),
|
||||
storeProductStockRequest.getType());
|
||||
if(ObjectUtil.isNull(existProduct) || ObjectUtil.isNull(existAttr)){ // 未找到商品
|
||||
logger.info("库存修改任务未获取到商品信息"+JSON.toJSONString(storeProductStockRequest));
|
||||
return true;
|
||||
}
|
||||
|
||||
// 回滚商品库存/销量 并更新
|
||||
boolean isPlus = storeProductStockRequest.getOperationType().equals("add");
|
||||
int productStock = isPlus ? existProduct.getStock() + storeProductStockRequest.getNum() : existProduct.getStock() - storeProductStockRequest.getNum();
|
||||
existProduct.setStock(productStock);
|
||||
existProduct.setSales(existProduct.getSales() - storeProductStockRequest.getNum());
|
||||
existProduct.setQuota(existProduct.getQuota() + storeProductStockRequest.getNum());
|
||||
updateById(existProduct);
|
||||
|
||||
// 回滚sku库存
|
||||
for (StoreProductAttrValue attrValue : existAttr) {
|
||||
int productAttrStock = isPlus ? attrValue.getStock() + storeProductStockRequest.getNum() : attrValue.getStock() - storeProductStockRequest.getNum();
|
||||
attrValue.setStock(productAttrStock);
|
||||
attrValue.setSales(attrValue.getSales()-storeProductStockRequest.getNum());
|
||||
attrValue.setQuota(attrValue.getQuota() + storeProductStockRequest.getNum());
|
||||
storeProductAttrValueService.updateById(attrValue);
|
||||
}
|
||||
|
||||
// 商品本身库存回滚
|
||||
// StoreProductStockRequest 创建次对象调用商品扣减库存实现扣减上本本身库存
|
||||
StoreProductResponse existProductLinkedSeckill = storeProductService.getByProductId(storeProductStockRequest.getProductId());
|
||||
for (StoreProductAttrValueResponse attrValueResponse : existProductLinkedSeckill.getAttrValue()) {
|
||||
if(attrValueResponse.getSuk().equals(storeProductStockRequest.getSuk())){
|
||||
StoreProductStockRequest r = new StoreProductStockRequest()
|
||||
.setAttrId(attrValueResponse.getId())
|
||||
.setNum(storeProductStockRequest.getNum())
|
||||
.setOperationType("add")
|
||||
.setProductId(storeProductStockRequest.getProductId())
|
||||
.setType(Constants.PRODUCT_TYPE_NORMAL)
|
||||
.setSuk(storeProductStockRequest.getSuk());
|
||||
storeProductService.doProductStock(r);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
package com.zbkj.crmeb.bargain.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.DateUtil;
|
||||
import com.zbkj.crmeb.bargain.dao.StoreBargainUserHelpDao;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargain;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUser;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUserHelp;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserHelpResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserHelpService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserService;
|
||||
import com.zbkj.crmeb.front.request.BargainFrontRequest;
|
||||
import com.zbkj.crmeb.front.response.BargainCountResponse;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.math.BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* StoreBargainUserHelpService 实现类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUserHelpDao, StoreBargainUserHelp> implements StoreBargainUserHelpService {
|
||||
|
||||
@Resource
|
||||
private StoreBargainUserHelpDao dao;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserService storeBargainUserService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainService storeBargainService;
|
||||
|
||||
@Autowired
|
||||
private TemplateMessageService templateMessageService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param bargainUserId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargainUserHelpResponse> getList(Integer bargainUserId) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUserHelp::getBargainUserId, bargainUserId);
|
||||
lqw.orderByDesc(StoreBargainUserHelp::getId);
|
||||
List<StoreBargainUserHelp> helpList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(helpList)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
List<StoreBargainUserHelpResponse> list = helpList.stream().map(help -> {
|
||||
StoreBargainUserHelpResponse helpResponse = new StoreBargainUserHelpResponse();
|
||||
BeanUtils.copyProperties(help, helpResponse);
|
||||
helpResponse.setAddTime(DateUtil.timestamp2DateStr(help.getAddTime(), Constants.DATE_FORMAT));
|
||||
User user = userService.getById(help.getUid());
|
||||
helpResponse.setAvatar(user.getAvatar());
|
||||
helpResponse.setNickname(user.getNickname());
|
||||
return helpResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助砍价人数
|
||||
* @param bargainId 砍价商品ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpCountByBargainId(Integer bargainId) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(StoreBargainUserHelp::getId);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainId, bargainId);
|
||||
return dao.selectCount(lambdaQueryWrapper).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助砍价人数
|
||||
* @param bargainId 砍价商品ID
|
||||
* @param bargainUserId 砍价商品发起用户表id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpCountByBargainIdAndBargainUid(Integer bargainId, Integer bargainUserId) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(StoreBargainUserHelp::getId);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainId, bargainId);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainUserId, bargainUserId);
|
||||
return dao.selectCount(lambdaQueryWrapper).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮忙好友砍价数据
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public BargainCountResponse getH5CountByBargainId(BargainFrontRequest request) {
|
||||
boolean isConsume = false;
|
||||
User user = userService.getInfo();
|
||||
StoreBargain storeBargain = storeBargainService.getById(request.getBargainId());
|
||||
// 获取砍价商品用户对象
|
||||
StoreBargainUser bargainUser = storeBargainUserService.getByBargainIdAndUidAndPink(request.getBargainId(), request.getBargainUserUid());
|
||||
if (ObjectUtil.isNull(bargainUser)) {
|
||||
// throw new CrmebException("用户砍价对象不存在");
|
||||
return new BargainCountResponse(ZERO, 0, storeBargain.getPrice().subtract(storeBargain.getMinPrice()), 0, 0, true, isConsume);
|
||||
}
|
||||
// 获取砍价好友信息
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUserHelp::getBargainId, request.getBargainId());
|
||||
lqw.eq(StoreBargainUserHelp::getBargainUserId, bargainUser.getId());
|
||||
List<StoreBargainUserHelp> storeBargainUserHelps = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(storeBargainUserHelps)) {
|
||||
return new BargainCountResponse(ZERO, 0, bargainUser.getBargainPrice().subtract(bargainUser.getBargainPriceMin()), 0, 1, true, isConsume);
|
||||
}
|
||||
|
||||
// 已砍金额
|
||||
BigDecimal alreadyPrice = bargainUser.getPrice();
|
||||
// 砍价人数
|
||||
int count = storeBargainUserHelps.size();
|
||||
// 剩余金额
|
||||
BigDecimal price = bargainUser.getBargainPrice().subtract(bargainUser.getBargainPriceMin()).subtract(bargainUser.getPrice());
|
||||
// 砍价百分比
|
||||
int pricePercent = bargainUser.getPrice().multiply(new BigDecimal(100)).divide((bargainUser.getBargainPrice().subtract(bargainUser.getBargainPriceMin())), 0, BigDecimal.ROUND_DOWN).intValue();
|
||||
// 自己的砍价状态
|
||||
boolean userBargainStatus = false;
|
||||
List<StoreBargainUserHelp> collect = storeBargainUserHelps.stream().filter(o -> o.getUid().equals(user.getUid())).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
if (user.getUid().equals(request.getBargainUserUid())) {// 自己的砍价活动
|
||||
userBargainStatus = true;
|
||||
} else {// 其他人的砍价活动
|
||||
// 用户对本商品的砍价次数
|
||||
List<Integer> tempUserIdList = null;
|
||||
List<StoreBargainUser> tempUserList = storeBargainUserService.getListByBargainIdAndUid(storeBargain.getId(), user.getUid());
|
||||
if (CollUtil.isNotEmpty(tempUserList)) {
|
||||
tempUserIdList = tempUserList.stream().map(StoreBargainUser::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Integer helpCount = getUserHelpNum(user.getUid(), storeBargain.getId(), tempUserIdList);
|
||||
if (helpCount == 0 || helpCount < storeBargain.getBargainNum()) {
|
||||
userBargainStatus = true;
|
||||
} else {
|
||||
isConsume = true;
|
||||
}
|
||||
//
|
||||
// LambdaQueryWrapper<StoreBargainUserHelp> lqWrapper = new LambdaQueryWrapper<>();
|
||||
// lqWrapper.eq(StoreBargainUserHelp::getBargainId, request.getBargainId());
|
||||
// lqWrapper.eq(StoreBargainUserHelp::getUid, user.getUid());
|
||||
// lqWrapper.ne(StoreBargainUserHelp::getBargainUserId, bargainUser.getId());
|
||||
// List<StoreBargainUserHelp> myHelps = dao.selectList(lqWrapper);
|
||||
// if (CollUtil.isEmpty(myHelps)) {
|
||||
// userBargainStatus = true;
|
||||
// } else if (myHelps.size() < storeBargain.getBargainNum()) {
|
||||
// userBargainStatus = true;
|
||||
// } else {
|
||||
// isConsume = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// 活动状态
|
||||
Integer status = bargainUser.getStatus();
|
||||
return new BargainCountResponse(alreadyPrice, count, price, pricePercent, status, userBargainStatus, isConsume);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮忙砍价好友信息
|
||||
* @param request
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StoreBargainUserHelpResponse> getHelpList(BargainFrontRequest request, PageParamRequest pageParamRequest) {
|
||||
StoreBargainUser storeBargainUser = storeBargainUserService.getByBargainIdAndUidAndPink(request.getBargainId(), request.getBargainUserUid());
|
||||
Page<StoreBargainUserHelp> helpPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
if (ObjectUtil.isNull(storeBargainUser)) {
|
||||
return CommonPage.copyPageInfo(helpPage, new ArrayList<>());
|
||||
}
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUserHelp::getBargainId, request.getBargainId());
|
||||
lqw.eq(StoreBargainUserHelp::getBargainUserId, storeBargainUser.getId());
|
||||
List<StoreBargainUserHelp> storeBargainUserHelps = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(storeBargainUserHelps)) {
|
||||
return CommonPage.copyPageInfo(helpPage, CollUtil.newArrayList());
|
||||
}
|
||||
List<StoreBargainUserHelpResponse> list = storeBargainUserHelps.stream().map(userHelp -> {
|
||||
StoreBargainUserHelpResponse helpResponse = new StoreBargainUserHelpResponse();
|
||||
BeanUtils.copyProperties(userHelp, helpResponse);
|
||||
helpResponse.setAddTime(DateUtil.timestamp2DateStr(userHelp.getAddTime(), Constants.DATE_FORMAT));
|
||||
User tempUser = userService.getById(userHelp.getUid());
|
||||
helpResponse.setNickname(tempUser.getNickname());
|
||||
helpResponse.setAvatar(tempUser.getAvatar());
|
||||
return helpResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonPage.copyPageInfo(helpPage, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> help(BargainFrontRequest request) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
StoreBargain storeBargain = storeBargainService.getById(request.getBargainId());
|
||||
if (ObjectUtil.isNull(storeBargain)) throw new CrmebException("砍价商品不存在");
|
||||
if (!storeBargain.getStatus()) throw new CrmebException("砍价活动已结束");
|
||||
StoreBargainUser storeBargainUser = storeBargainUserService.getByBargainIdAndUidAndPink(request.getBargainId(), request.getBargainUserUid());
|
||||
if (ObjectUtil.isNull(storeBargainUser)) throw new CrmebException("砍价商品用户信息不存在");
|
||||
User user = userService.getInfo();
|
||||
|
||||
// 判断是否砍价成功
|
||||
if (storeBargainUser.getStatus() == 3 || storeBargainUser.getBargainPriceMin().compareTo(storeBargainUser.getBargainPrice().subtract(storeBargainUser.getPrice())) >= 0) {
|
||||
throw new CrmebException("商品已完成砍价");
|
||||
}
|
||||
|
||||
// 给自己砍价
|
||||
if (user.getUid().equals(storeBargainUser.getUid())) {
|
||||
StoreBargainUserHelp myHelp = getByUidAndBargainIdAndBargainUserId(user.getUid(), storeBargain.getId(), storeBargainUser.getId());
|
||||
if (ObjectUtil.isNotNull(myHelp)) {
|
||||
throw new CrmebException("您已经砍过了");
|
||||
}
|
||||
} else {// 不是给自己砍价,不包含给自己看的
|
||||
// 用户对本商品的砍价次数
|
||||
List<Integer> tempUserIdList = null;
|
||||
List<StoreBargainUser> tempUserList = storeBargainUserService.getListByBargainIdAndUid(storeBargain.getId(), user.getUid());
|
||||
if (CollUtil.isNotEmpty(tempUserList)) {
|
||||
tempUserIdList = tempUserList.stream().map(StoreBargainUser::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Integer helpCount = getUserHelpNum(user.getUid(), storeBargain.getId(), tempUserIdList);
|
||||
if (helpCount >= storeBargain.getBargainNum()) {
|
||||
throw new CrmebException("您的帮砍次数已达上限");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取活动用户的总已砍次数
|
||||
Long helpCount = getHelpCountByBargainIdAndBargainUid(request.getBargainId(), storeBargainUser.getId());
|
||||
// 计算砍价金额
|
||||
BigDecimal bargainPrice = helpBargain(storeBargain, storeBargainUser, helpCount);
|
||||
|
||||
LambdaUpdateWrapper<StoreBargainUser> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(StoreBargainUser::getPrice, storeBargainUser.getPrice().add(bargainPrice));
|
||||
updateWrapper.eq(StoreBargainUser::getId, storeBargainUser.getId());
|
||||
updateWrapper.eq(StoreBargainUser::getPrice, storeBargainUser.getPrice());
|
||||
storeBargainUser.setPrice(storeBargainUser.getPrice().add(bargainPrice));
|
||||
boolean update = storeBargainUserService.update(updateWrapper);
|
||||
if (!update) throw new CrmebException("砍价失败!");
|
||||
|
||||
|
||||
StoreBargainUserHelp userHelp = new StoreBargainUserHelp();
|
||||
userHelp.setBargainId(request.getBargainId());
|
||||
userHelp.setBargainUserId(storeBargainUser.getId());
|
||||
userHelp.setUid(user.getUid());
|
||||
userHelp.setPrice(bargainPrice);
|
||||
userHelp.setAddTime(System.currentTimeMillis());
|
||||
boolean save = save(userHelp);
|
||||
if (!save) throw new CrmebException("砍价失败!!!");
|
||||
|
||||
// 分享人数添加
|
||||
if (!user.getUid().equals(request.getBargainUserUid())) {
|
||||
storeBargain.setShare(storeBargain.getShare() + 1);
|
||||
storeBargainService.updateById(storeBargain);
|
||||
}
|
||||
|
||||
// 如果砍价完成,发送微信模板消息
|
||||
if (storeBargain.getPeopleNum().equals(helpCount.intValue() + 1)) {
|
||||
// 发送微信模板消息
|
||||
HashMap<String, String> temMap = new HashMap<>();
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_FIRST, "好腻害!你的朋友们已经帮你砍到底价了!");
|
||||
temMap.put("keyword1", storeBargain.getTitle());
|
||||
temMap.put("keyword2", storeBargain.getMinPrice().toString());
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_END, "感谢您的参与!");
|
||||
|
||||
templateMessageService.push(Constants.WE_CHAT_TEMP_KEY_BARGAIN_SUCCESS, temMap, storeBargainUser.getUid(), Constants.PAY_TYPE_WE_CHAT_FROM_PUBLIC);
|
||||
}
|
||||
|
||||
map.put("bargainPrice", bargainPrice);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpPeopleCount() {
|
||||
StoreBargainUser storeBargainUser = new StoreBargainUser();
|
||||
storeBargainUser.setIsDel(false);
|
||||
List<StoreBargainUser> userList = storeBargainUserService.getByEntity(storeBargainUser);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return 0L;
|
||||
}
|
||||
int sum = userList.stream().mapToInt(bargainUser -> {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(StoreBargainUserHelp::getId);
|
||||
lqw.eq(StoreBargainUserHelp::getBargainUserId, bargainUser.getId());
|
||||
lqw.groupBy(StoreBargainUserHelp::getUid);
|
||||
return dao.selectCount(lqw);
|
||||
}).sum();
|
||||
return (long) sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
* @param bargainId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpPeopleCountByBargainId(Integer bargainId) {
|
||||
List<StoreBargainUser> userList = storeBargainUserService.getListByBargainId(bargainId);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return 0L;
|
||||
}
|
||||
int sum = userList.stream().mapToInt(bargainUser -> {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(StoreBargainUserHelp::getId);
|
||||
lqw.eq(StoreBargainUserHelp::getBargainUserId, bargainUser.getId());
|
||||
lqw.groupBy(StoreBargainUserHelp::getUid);
|
||||
return dao.selectCount(lqw);
|
||||
}).sum();
|
||||
return (long) sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户还剩余的砍价金额
|
||||
* @param bargainId 砍价商品编号
|
||||
* @param bargainUserUid 砍价发起用户uid
|
||||
* @return surplusPrice 剩余的砍价金额
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getSurplusPrice(Integer bargainId, Integer bargainUserUid) {
|
||||
StoreBargainUser storeBargainUser = storeBargainUserService.getByBargainIdAndUid(bargainId, bargainUserUid);
|
||||
if (ObjectUtil.isNull(storeBargainUser)) throw new CrmebException("砍价用户信息不存在");
|
||||
BigDecimal coverPrice = storeBargainUser.getBargainPrice().subtract(storeBargainUser.getBargainPriceMin());
|
||||
BigDecimal alreadyPrice = storeBargainUser.getPrice();
|
||||
return coverPrice.subtract(alreadyPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价发起用户信息
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> startUser(BargainFrontRequest bargainFrontRequest) {
|
||||
if (ObjectUtil.isNull(bargainFrontRequest.getBargainUserUid())) {
|
||||
throw new CrmebException("砍价发起用户id不能为空");
|
||||
}
|
||||
User user = userService.getById(bargainFrontRequest.getBargainUserUid());
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, String> map = CollUtil.newHashMap();
|
||||
map.put("avatar", Optional.ofNullable(user.getAvatar()).orElse(""));
|
||||
map.put("nickname", Optional.ofNullable(user.getNickname()).orElse(""));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价金额计算
|
||||
* @param storeBargain 砍价商品
|
||||
* @param storeBargainUser 砍价商品用户
|
||||
* @param helpCount 帮助砍价次数
|
||||
* @return
|
||||
* 砍价时在设置好的价格区间内以大于20%小于80%之间随机一个价格后 在总金额中减去,砍价最后一位不可随机价格,直接砍价到设置区间的最低价格为准
|
||||
*/
|
||||
private BigDecimal helpBargain(StoreBargain storeBargain, StoreBargainUser storeBargainUser, Long helpCount) {
|
||||
BigDecimal minPrice = storeBargainUser.getBargainPriceMin();//底价
|
||||
BigDecimal price = storeBargainUser.getBargainPrice();//砍价商品金额
|
||||
BigDecimal userPrice = storeBargainUser.getPrice();//已砍金额
|
||||
Integer peopleNum = storeBargain.getPeopleNum();//帮助砍价好友人数限定
|
||||
|
||||
BigDecimal subtract = price.subtract(minPrice);// 可砍价金额(总)
|
||||
|
||||
BigDecimal bargainPrice = ZERO;
|
||||
// 没有砍过
|
||||
if (helpCount == 0) {
|
||||
bargainPrice = RandomUtil.randomBigDecimal(subtract.multiply(new BigDecimal(Constants.BARGAIN_TATIO_DOWN)), subtract.multiply(new BigDecimal(Constants.BARGAIN_TATIO_UP)));
|
||||
return bargainPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
// 最后一次砍价
|
||||
if (peopleNum - helpCount.intValue() == 1) {
|
||||
return subtract.subtract(userPrice);
|
||||
}
|
||||
// 其他情况
|
||||
BigDecimal remaining = subtract.subtract(userPrice);
|
||||
bargainPrice = RandomUtil.randomBigDecimal(remaining.multiply(new BigDecimal(Constants.BARGAIN_TATIO_DOWN)), remaining.multiply(new BigDecimal(Constants.BARGAIN_TATIO_UP)));
|
||||
return bargainPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助砍价用户的帮砍次数
|
||||
* @return
|
||||
*/
|
||||
private StoreBargainUserHelp getByUidAndBargainIdAndBargainUserId(Integer uid, Integer bargainId, Integer bargainUserId) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getUid, uid);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainId, bargainId);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainUserId, bargainUserId);
|
||||
return dao.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户帮砍次数
|
||||
* 用户对商品砍了几次(不包含自己)
|
||||
* @param uid
|
||||
* @param bargainId
|
||||
* @return
|
||||
*/
|
||||
private Integer getUserHelpNum(Integer uid, Integer bargainId, List<Integer> tempUserIdList) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(StoreBargainUserHelp::getId);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getUid, uid);
|
||||
lambdaQueryWrapper.eq(StoreBargainUserHelp::getBargainId, bargainId);
|
||||
if (CollUtil.isNotEmpty(tempUserIdList)) {
|
||||
lambdaQueryWrapper.notIn(StoreBargainUserHelp::getBargainUserId, tempUserIdList);
|
||||
}
|
||||
return dao.selectCount(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.zbkj.crmeb.bargain.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.vo.dateLimitUtilVo;
|
||||
import com.zbkj.crmeb.bargain.dao.StoreBargainUserDao;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargain;
|
||||
import com.zbkj.crmeb.bargain.model.StoreBargainUser;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainUserSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserHelpService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* StoreBargainUserService 实现类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class StoreBargainUserServiceImpl extends ServiceImpl<StoreBargainUserDao, StoreBargainUser> implements StoreBargainUserService {
|
||||
|
||||
@Resource
|
||||
private StoreBargainUserDao dao;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainService storeBargainService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserHelpService storeBargainUserHelpService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页展示砍价参与用户列表
|
||||
* @param request 请求参数
|
||||
* @param pageParamRequest 分页类参数
|
||||
* @since 2020-11-12
|
||||
* @return List<StoreBargainUser>
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StoreBargainUserResponse> getList(StoreBargainUserSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
Page<StoreBargainUser> startPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(request.getStatus())) {
|
||||
lqw.eq(StoreBargainUser::getStatus, request.getStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getDateLimit())) {
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(request.getDateLimit());
|
||||
lqw.between(StoreBargainUser::getAddTime, DateUtil.dateStr2Timestamp(dateLimit.getStartTime(), Constants.DATE_TIME_TYPE_BEGIN), DateUtil.dateStr2Timestamp(dateLimit.getEndTime(), Constants.DATE_TIME_TYPE_END));
|
||||
}
|
||||
lqw.orderByDesc(StoreBargainUser::getId);
|
||||
List<StoreBargainUser> bargainUserList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(bargainUserList)) {
|
||||
return CommonPage.copyPageInfo(startPage, CollUtil.newArrayList());
|
||||
}
|
||||
List<StoreBargainUserResponse> list = bargainUserList.stream().map(bargainUser -> {
|
||||
StoreBargainUserResponse bargainUserResponse = new StoreBargainUserResponse();
|
||||
BeanUtils.copyProperties(bargainUser, bargainUserResponse);
|
||||
bargainUserResponse.setAddTime(DateUtil.timestamp2DateStr(bargainUser.getAddTime(), Constants.DATE_FORMAT));
|
||||
bargainUserResponse.setNowPrice(bargainUser.getBargainPrice().subtract(bargainUser.getPrice()));
|
||||
// 查询用户信息
|
||||
User user = userService.getById(bargainUser.getUid());
|
||||
bargainUserResponse.setAvatar(user.getAvatar());
|
||||
bargainUserResponse.setNickname(user.getNickname());
|
||||
// 查询砍价商品信息
|
||||
StoreBargain storeBargain = storeBargainService.getById(bargainUser.getBargainId());
|
||||
bargainUserResponse.setTitle(storeBargain.getTitle());
|
||||
|
||||
bargainUserResponse.setDataTime(DateUtil.timestamp2DateStr(storeBargain.getStopTime(), Constants.DATE_FORMAT));
|
||||
bargainUserResponse.setPeopleNum(storeBargain.getPeopleNum());
|
||||
// 剩余砍价次数
|
||||
Long helpCount = storeBargainUserHelpService.getHelpCountByBargainIdAndBargainUid(storeBargain.getId(), bargainUser.getId());
|
||||
bargainUserResponse.setNum(helpCount.intValue());
|
||||
return bargainUserResponse;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return CommonPage.copyPageInfo(startPage, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价用户列表
|
||||
* @param bargainId 砍价商品ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargainUser> getListByBargainId(Integer bargainId) {
|
||||
QueryWrapper<StoreBargainUser> qw = new QueryWrapper<>();
|
||||
qw.select("id", "status");
|
||||
qw.eq("bargain_id", bargainId).eq("is_del", false);
|
||||
return dao.selectList(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价商品参与人数
|
||||
* @param bargainId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getCountByBargainId(Integer bargainId) {
|
||||
QueryWrapper<StoreBargainUser> qw = new QueryWrapper<>();
|
||||
qw.select("id");
|
||||
qw.eq("bargain_id", bargainId).eq("is_del", false);
|
||||
return dao.selectCount(qw).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过砍价商品ID + 用户uid 获取用户砍价商品信息
|
||||
* @param bargainId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StoreBargainUser getByBargainIdAndUid(Integer bargainId, Integer uid) {
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUser::getBargainId, bargainId);
|
||||
lqw.eq(StoreBargainUser::getUid, uid);
|
||||
lqw.eq(StoreBargainUser::getIsDel, false);
|
||||
lqw.orderByDesc(StoreBargainUser::getId);
|
||||
List<StoreBargainUser> userList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return null;
|
||||
}
|
||||
return userList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过砍价商品ID + 用户uid 获取用户砍价中砍价商品信息
|
||||
* @param bargainId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StoreBargainUser getByBargainIdAndUidAndPink(Integer bargainId, Integer uid) {
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUser::getBargainId, bargainId);
|
||||
lqw.eq(StoreBargainUser::getUid, uid);
|
||||
lqw.eq(StoreBargainUser::getIsDel, false);
|
||||
lqw.eq(StoreBargainUser::getStatus, 1);
|
||||
lqw.orderByDesc(StoreBargainUser::getId);
|
||||
List<StoreBargainUser> userList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
return null;
|
||||
}
|
||||
return userList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过砍价商品ID + 用户uid 获取用户砍价中砍价商品信息
|
||||
* @param bargainId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargainUser> getListByBargainIdAndUid(Integer bargainId, Integer uid) {
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUser::getBargainId, bargainId);
|
||||
lqw.eq(StoreBargainUser::getUid, uid);
|
||||
lqw.eq(StoreBargainUser::getIsDel, false);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否参与活动
|
||||
* @param bargainId
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean isExistByBargainIdAndUid(Integer bargainId, Integer uid) {
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StoreBargainUser::getBargainId, bargainId);
|
||||
lqw.eq(StoreBargainUser::getUid, uid);
|
||||
lqw.eq(StoreBargainUser::getIsDel, false);
|
||||
Integer count = dao.selectCount(lqw);
|
||||
if (count > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品用户根据实体查询
|
||||
* @param bargainUser
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargainUser> getByEntity(StoreBargainUser bargainUser) {
|
||||
LambdaQueryWrapper<StoreBargainUser> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.setEntity(bargainUser);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ import java.util.List;
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="type", value="类型ID | 类型,1 产品分类,2 附件分类,3 文章分类, 4 设置分类, 5 菜单分类, 6 配置分类, 7 秒杀配置", example = "1"),
|
||||
@ApiImplicitParam(name="status", value="-1=全部,0=未生效,1=已生效", example = "1"),
|
||||
@ApiImplicitParam(name="status", value="模糊搜索", example = "电视")
|
||||
@ApiImplicitParam(name="name", value="模糊搜索", example = "电视")
|
||||
})
|
||||
public CommonResult<List<CategoryTreeVo>> getListTree(@RequestParam(name = "type") Integer type,
|
||||
@RequestParam(name = "status") Integer status,
|
||||
@@ -172,6 +172,22 @@ import java.util.List;
|
||||
return CommonResult.success(categoryService.getByIds(CrmebUtil.stringToArray(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改分类状态
|
||||
* @param id Integer 分类id
|
||||
* @since 2020-04-16
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "更改分类状态")
|
||||
@RequestMapping(value = "/updateStatus/{id}", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name = "id", value="分类id")
|
||||
public CommonResult<Object> getByIds(@Validated @PathVariable(name = "id") Integer id){
|
||||
if (categoryService.updateStatus(id)) {
|
||||
return CommonResult.success("修改成功");
|
||||
} else {
|
||||
return CommonResult.failed("修改失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,4 +47,6 @@ public interface CategoryService extends IService<Category> {
|
||||
int checkName(String name, Integer type);
|
||||
|
||||
boolean checkUrl(String uri);
|
||||
|
||||
boolean updateStatus(Integer id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.crmeb.category.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
@@ -393,5 +394,12 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
lambdaQueryWrapper.eq(Category::getUrl, uri);
|
||||
return dao.selectCount(lambdaQueryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStatus(Integer id) {
|
||||
Category category = getById(id);
|
||||
category.setStatus(!category.getStatus());
|
||||
return updateById(category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.zbkj.crmeb.combination.controller;
|
||||
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationRequest;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationSearchRequest;
|
||||
import com.zbkj.crmeb.combination.request.StorePinkSearchRequest;
|
||||
import com.zbkj.crmeb.combination.response.StoreCombinationResponse;
|
||||
import com.zbkj.crmeb.combination.response.StorePinkAdminListResponse;
|
||||
import com.zbkj.crmeb.combination.response.StorePinkResponse;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.combination.service.StorePinkService;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 拼团商品表 前端控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/admin/store/combination")
|
||||
@Api(tags = "商品——拼团——商品") //配合swagger使用
|
||||
public class StoreCombinationController {
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
@Autowired
|
||||
private StorePinkService storePinkService;
|
||||
|
||||
/**
|
||||
* 分页显示拼团商品表
|
||||
* @param request 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页显示拼团商品表") //配合swagger使用
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<StoreCombinationResponse>> getList(@Validated StoreCombinationSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<StoreCombinationResponse> commonPage = CommonPage.restPage(storeCombinationService.getList(request, pageParamRequest));
|
||||
return CommonResult.success(commonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增拼团商品表
|
||||
* @param request 新增参数
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
*/
|
||||
@ApiOperation(value = "新增拼团商品")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public CommonResult<String> save(@RequestBody @Validated StoreCombinationRequest request){
|
||||
if(storeCombinationService.saveCombination(request)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除拼团商品表
|
||||
* @param id Integer
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
*/
|
||||
@ApiOperation(value = "删除拼团商品")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public CommonResult<String> delete(@RequestParam(value = "id") Integer id){
|
||||
if(storeCombinationService.deleteById(id)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改拼团商品表
|
||||
* @param id integer id
|
||||
* @param storeCombinationRequest 修改参数
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
*/
|
||||
@ApiOperation(value = "修改拼团商品")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public CommonResult<String> update(@RequestParam Integer id, @RequestBody @Validated StoreCombinationRequest storeCombinationRequest){
|
||||
storeCombinationRequest.setId(id);
|
||||
if(storeCombinationService.updateCombination(storeCombinationRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询拼团商品信息
|
||||
* @param id Integer
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团商品详情")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public CommonResult<StoreProductResponse> info(@RequestParam(value = "id") Integer id){
|
||||
StoreProductResponse detail = storeCombinationService.getAdminDetail(id);
|
||||
return CommonResult.success(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改拼团商品状态
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改拼团商品状态")
|
||||
@RequestMapping(value = "/update/status", method = RequestMethod.POST)
|
||||
public CommonResult<Object> updateStatus(@RequestParam(value = "id") Integer id, @RequestParam @Validated boolean isShow){
|
||||
if(storeCombinationService.updateCombinationShow(id, isShow)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团统计
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团统计")
|
||||
@RequestMapping(value = "/statistics", method = RequestMethod.GET)
|
||||
public CommonResult<Map<String, Object>> statistics() {
|
||||
Map<String, Object> map = storeCombinationService.getAdminStatistics();
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团列表")
|
||||
@RequestMapping(value = "/combine/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<StorePinkAdminListResponse>> getCombineList(@Validated StorePinkSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<StorePinkAdminListResponse> responseCommonPage = CommonPage.restPage(storePinkService.getList(request, pageParamRequest));
|
||||
return CommonResult.success(responseCommonPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团订单列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团订单列表")
|
||||
@RequestMapping(value = "/order_pink/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<List<StorePink>> getPinkList(@PathVariable(value = "id") Integer id) {
|
||||
return CommonResult.success(storePinkService.getAdminList(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zbkj.crmeb.combination.dao;
|
||||
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 拼团商品表 Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreCombinationDao extends BaseMapper<StoreCombination> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zbkj.crmeb.combination.dao;
|
||||
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 拼团表 Mapper 接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StorePinkDao extends BaseMapper<StorePink> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.zbkj.crmeb.combination.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 拼团商品表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_combination")
|
||||
@ApiModel(value="StoreCombination对象", description="拼团商品表")
|
||||
public class StoreCombination implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动属性")
|
||||
private String attr;
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "推荐")
|
||||
private Boolean isHost;
|
||||
|
||||
@ApiModelProperty(value = "商品状态")
|
||||
private Boolean isShow;
|
||||
|
||||
private Boolean isDel;
|
||||
|
||||
private Boolean combination;
|
||||
|
||||
@ApiModelProperty(value = "商户是否可用1可用0不可用")
|
||||
private Boolean merUse;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间(小时)")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "拼图商品成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "单次购买数量")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "每个订单可购买数量")
|
||||
private Integer onceNum;
|
||||
|
||||
@ApiModelProperty(value = "虚拟成团百分比")
|
||||
private Integer virtualRation;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.zbkj.crmeb.combination.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 拼团表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_pink")
|
||||
@ApiModel(value="StorePink对象", description="拼团表")
|
||||
public class StorePink implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "订单id 生成")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "订单id 数据库")
|
||||
private Integer orderIdKey;
|
||||
|
||||
@ApiModelProperty(value = "购买商品个数")
|
||||
private Integer totalNum;
|
||||
|
||||
@ApiModelProperty(value = "购买总金额")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "拼图总人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品单价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "团长id 0为团长")
|
||||
private Integer kId;
|
||||
|
||||
@ApiModelProperty(value = "是否发送模板消息0未发送1已发送")
|
||||
private Boolean isTpl;
|
||||
|
||||
@ApiModelProperty(value = "是否退款 0未退款 1已退款")
|
||||
private Boolean isRefund;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "是否虚拟拼团")
|
||||
private Boolean is_virtual;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.zbkj.crmeb.combination.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zbkj.crmeb.store.model.StoreProductAttr;
|
||||
import com.zbkj.crmeb.store.request.StoreProductAttrValueRequest;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拼团商品表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_combination")
|
||||
@ApiModel(value="StoreCombination对象", description="拼团商品表")
|
||||
public class StoreCombinationRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
@NotNull(message = "商品编号不能为空")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
@NotNull(message = "商品主图不能为空")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
@NotNull(message = "轮播图不能为空")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
@NotNull(message = "拼团名称不能为空")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
@Min(value = 2, message = "拼团人数不能小于2")
|
||||
@Max(value = 99999, message = "拼团人数不能大于99999")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
// @NotNull(message = "拼团简介不能为空")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "推荐")
|
||||
@NotNull(message = "热门推荐不能为空")
|
||||
private Boolean isHost;
|
||||
|
||||
@ApiModelProperty(value = "活动状态")
|
||||
@NotNull(message = "活动状态不能为空")
|
||||
private Boolean isShow;
|
||||
|
||||
private Boolean isDel;
|
||||
|
||||
private Boolean combination;
|
||||
|
||||
@ApiModelProperty(value = "商户是否可用1可用0不可用")
|
||||
private Boolean merUse;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间(小时)")
|
||||
@NotNull(message = "拼团时效不能为空")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
@NotNull(message = "单位不能为空")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
@NotNull(message = "运费模板不能为空")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "购买数量")
|
||||
@Min(value = 1, message = "购买数量限制不能小于1")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "单次购买数量")
|
||||
@Min(value = 1, message = "单次购买数量限制不能小于1")
|
||||
private Integer onceNum;
|
||||
|
||||
@ApiModelProperty(value = "虚拟成团百分比")
|
||||
@Min(value = 1, message = "虚拟成团百分比不能小于1")
|
||||
@Max(value = 100, message = "虚拟成团百分比不能大于100")
|
||||
private Integer virtualRation;
|
||||
|
||||
@ApiModelProperty(value = "商品属性")
|
||||
private List<StoreProductAttr> attr;
|
||||
|
||||
@ApiModelProperty(value = "商品属性详情")
|
||||
private List<StoreProductAttrValueRequest> attrValue;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "规格 0单 1多")
|
||||
private Boolean specType;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zbkj.crmeb.combination.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团商品表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_combination")
|
||||
@ApiModel(value="StoreCombination对象", description="拼团商品表")
|
||||
public class StoreCombinationSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "搜索关键字 商品id或者名称")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(不开启) 1(开启)")
|
||||
private Integer isShow;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zbkj.crmeb.combination.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_pink")
|
||||
@ApiModel(value="StorePink对象", description="拼团表")
|
||||
public class StorePinkRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品id")
|
||||
private Integer cid;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zbkj.crmeb.combination.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团表
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_store_pink")
|
||||
@ApiModel(value="StorePink对象", description="拼团表")
|
||||
public class StorePinkSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "today,yesterday,lately7,lately30,month,year,/yyyy-MM-dd hh:mm:ss,yyyy-MM-dd hh:mm:ss/")
|
||||
private String dateLimit;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.zbkj.crmeb.combination.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团详情响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StoreCombinationInfoResponse {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动属性")
|
||||
private String attr;
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "推荐")
|
||||
private Boolean isHost;
|
||||
|
||||
@ApiModelProperty(value = "商品状态")
|
||||
private Boolean isShow;
|
||||
|
||||
private Boolean isDel;
|
||||
|
||||
private Boolean combination;
|
||||
|
||||
@ApiModelProperty(value = "商户是否可用1可用0不可用")
|
||||
private Boolean merUse;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间(小时)")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "拼图商品成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "单次购买数量")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "每个订单可购买数量")
|
||||
private Integer onceNum;
|
||||
|
||||
@ApiModelProperty(value = "虚拟成团百分比")
|
||||
private Integer virtualRation;
|
||||
|
||||
@ApiModelProperty(value = "收藏标识")
|
||||
private boolean userCollect = false;
|
||||
|
||||
@ApiModelProperty(value = "点赞标识")
|
||||
private boolean userLike = false;
|
||||
|
||||
@ApiModelProperty(value = "主商品价格")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@ApiModelProperty(value = "累计销量")
|
||||
private Integer total;
|
||||
|
||||
@ApiModelProperty(value = "商品详情")
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.zbkj.crmeb.combination.response;
|
||||
|
||||
import com.zbkj.crmeb.store.model.StoreProductAttr;
|
||||
import com.zbkj.crmeb.store.model.StoreProductAttrValue;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拼团商品响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StoreCombinationResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "推荐图")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(value = "轮播图")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动属性")
|
||||
private String attr;
|
||||
|
||||
@ApiModelProperty(value = "参团人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "推荐")
|
||||
private Boolean isHost;
|
||||
|
||||
@ApiModelProperty(value = "商品状态")
|
||||
private Boolean isShow;
|
||||
|
||||
private Boolean isDel;
|
||||
|
||||
private Boolean combination;
|
||||
|
||||
@ApiModelProperty(value = "商户是否可用1可用0不可用")
|
||||
private Boolean merUse;
|
||||
|
||||
@ApiModelProperty(value = "是否包邮1是0否")
|
||||
private Boolean isPostage;
|
||||
|
||||
@ApiModelProperty(value = "邮费")
|
||||
private BigDecimal postage;
|
||||
|
||||
@ApiModelProperty(value = "拼团开始时间")
|
||||
private Long startTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private String stopTimeStr;
|
||||
|
||||
@ApiModelProperty(value = "拼团订单有效时间(小时)")
|
||||
private Integer effectiveTime;
|
||||
|
||||
@ApiModelProperty(value = "拼图商品成本")
|
||||
private BigDecimal cost;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browse;
|
||||
|
||||
@ApiModelProperty(value = "单位名")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "运费模板ID")
|
||||
private Integer tempId;
|
||||
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
@ApiModelProperty(value = "体积")
|
||||
private BigDecimal volume;
|
||||
|
||||
@ApiModelProperty(value = "单次购买数量")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "限购总数")
|
||||
private Integer quota;
|
||||
|
||||
@ApiModelProperty(value = "限量总数显示")
|
||||
private Integer quotaShow;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "每个订单可购买数量")
|
||||
private Integer onceNum;
|
||||
|
||||
@ApiModelProperty(value = "虚拟成团百分比")
|
||||
private Integer virtualRation;
|
||||
|
||||
@ApiModelProperty(value = "拼团人数")
|
||||
private Integer countPeople;
|
||||
|
||||
@ApiModelProperty(value = "参与人数")
|
||||
private Integer countPeopleAll;
|
||||
|
||||
@ApiModelProperty(value = "成团数量")
|
||||
private Integer countPeoplePink;
|
||||
|
||||
@ApiModelProperty(value = "限量剩余")
|
||||
private Integer remainingQuota;
|
||||
|
||||
@ApiModelProperty(value = "商品规格")
|
||||
// private List<StoreProductAttr> productAttr;
|
||||
private List<HashMap<String, Object>> productAttr;
|
||||
|
||||
@ApiModelProperty(value = "商品规格值")
|
||||
// private List<StoreProductAttrValue> productValue;
|
||||
private HashMap<String,Object> productValue;
|
||||
|
||||
@ApiModelProperty(value = "商品单双规格")
|
||||
private Boolean specType;
|
||||
|
||||
@ApiModelProperty(value = "拼团单属性AttrValueId")
|
||||
private Integer aloneAttrValueId;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zbkj.crmeb.combination.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团列表响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StorePinkAdminListResponse {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "拼团总人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "团长id 0为团长")
|
||||
private Integer kId;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "几人参团")
|
||||
private Integer countPeople;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品")
|
||||
private String title;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.zbkj.crmeb.combination.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团响应体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class StorePinkResponse {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "拼团ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "订单id 生成")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "订单id 数据库")
|
||||
private Integer orderIdKey;
|
||||
|
||||
@ApiModelProperty(value = "购买商品个数")
|
||||
private Integer totalNum;
|
||||
|
||||
@ApiModelProperty(value = "购买总金额")
|
||||
private BigDecimal totalPrice;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "拼图总人数")
|
||||
private Integer people;
|
||||
|
||||
@ApiModelProperty(value = "拼团商品单价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Long addTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Long stopTime;
|
||||
|
||||
@ApiModelProperty(value = "团长id 0为团长")
|
||||
private Integer kId;
|
||||
|
||||
@ApiModelProperty(value = "是否发送模板消息0未发送1已发送")
|
||||
private Boolean isTpl;
|
||||
|
||||
@ApiModelProperty(value = "是否退款 0未退款 1已退款")
|
||||
private Boolean isRefund;
|
||||
|
||||
@ApiModelProperty(value = "状态1进行中2已完成3未完成")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "是否虚拟拼团")
|
||||
private Boolean is_virtual;
|
||||
|
||||
@ApiModelProperty(value = "几人参团")
|
||||
private Integer countPeople;
|
||||
|
||||
@ApiModelProperty(value = "还剩几人成团")
|
||||
private Integer count;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.zbkj.crmeb.combination.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationRequest;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationSearchRequest;
|
||||
import com.zbkj.crmeb.combination.request.StorePinkRequest;
|
||||
import com.zbkj.crmeb.front.response.CombinationDetailResponse;
|
||||
import com.zbkj.crmeb.combination.response.StoreCombinationResponse;
|
||||
import com.zbkj.crmeb.front.response.GoPinkResponse;
|
||||
import com.zbkj.crmeb.store.request.StoreProductStockRequest;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StorePinkService
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreCombinationService extends IService<StoreCombination> {
|
||||
|
||||
/**
|
||||
* 分页显示拼团商品表
|
||||
* @param request 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreCombinationResponse> getList(StoreCombinationSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 新增拼团商品
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Boolean saveCombination(StoreCombinationRequest request);
|
||||
|
||||
/**
|
||||
* 删除拼团商品
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 编辑拼团商品
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Boolean updateCombination(StoreCombinationRequest request);
|
||||
|
||||
/**
|
||||
* 查询拼团商品详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreProductResponse getAdminDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 修改拼团商品状态
|
||||
* @param id
|
||||
* @param isShow
|
||||
*/
|
||||
Boolean updateCombinationShow(Integer id, Boolean isShow);
|
||||
|
||||
/**
|
||||
* admin拼团统计
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getAdminStatistics();
|
||||
|
||||
/**
|
||||
* H5拼团商品列表
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreCombination> getH5List(PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* H5 拼团Pink
|
||||
* @return
|
||||
*/
|
||||
HashMap<String,Object> getForH5Pink();
|
||||
|
||||
/**
|
||||
* H5拼团商品详情
|
||||
* @param id 拼团商品编号
|
||||
* @return
|
||||
*/
|
||||
CombinationDetailResponse getH5Detail(Integer id);
|
||||
|
||||
/**
|
||||
* 去拼团
|
||||
* @param pinkId 拼团团长单ID
|
||||
* @return
|
||||
*/
|
||||
GoPinkResponse goPink(Integer pinkId);
|
||||
|
||||
/**
|
||||
* 更多拼团信息
|
||||
* @param pageParamRequest
|
||||
* @param comId
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StoreCombination> getMore(PageParamRequest pageParamRequest, Integer comId);
|
||||
|
||||
/**
|
||||
* 取消拼团
|
||||
* @param storePinkRequest
|
||||
*/
|
||||
Boolean removePink(StorePinkRequest storePinkRequest);
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param storeCombination
|
||||
* @return
|
||||
*/
|
||||
List<StoreCombination> getByEntity(StoreCombination storeCombination);
|
||||
|
||||
/**
|
||||
* 扣减库存加销量
|
||||
* @param combinationId 产品id
|
||||
* @param num 商品数量
|
||||
* @param attrValueId
|
||||
* @param type 是否限购 0=不限购
|
||||
* @return 扣减结果
|
||||
*/
|
||||
Boolean decProductStock(Integer combinationId, Integer num, int attrValueId, int type);
|
||||
|
||||
/**
|
||||
* 添加库存
|
||||
* @param stockRequest
|
||||
*/
|
||||
Boolean stockAddRedis(StoreProductStockRequest stockRequest);
|
||||
|
||||
/**
|
||||
* 后台任务批量操作库存
|
||||
*/
|
||||
void consumeProductStock();
|
||||
|
||||
/**
|
||||
* 拼团海报
|
||||
* @param pinkId 拼团id
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
Boolean poster(Integer pinkId, String from);
|
||||
|
||||
/**
|
||||
* 获取当前时间的拼团商品
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
List<StoreCombination> getCurrentBargainByProductId(Integer productId);
|
||||
|
||||
/**
|
||||
* 商品是否存在拼团活动
|
||||
* @param productId 商品编号
|
||||
* @return
|
||||
*/
|
||||
Boolean isExistActivity(Integer productId);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.zbkj.crmeb.combination.service;
|
||||
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zbkj.crmeb.combination.request.StorePinkSearchRequest;
|
||||
import com.zbkj.crmeb.combination.response.StorePinkAdminListResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* StorePinkService
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StorePinkService extends IService<StorePink> {
|
||||
|
||||
/**
|
||||
* 获取拼团列表
|
||||
* @param request
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StorePinkAdminListResponse> getList(StorePinkSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 获取拼团列表Cid
|
||||
* @param cid 拼团商品id
|
||||
* @return
|
||||
*/
|
||||
List<StorePink> getListByCid(Integer cid);
|
||||
|
||||
/**
|
||||
* 实体查询
|
||||
* @param storePink
|
||||
* @return
|
||||
*/
|
||||
List<StorePink> getByEntity(StorePink storePink);
|
||||
|
||||
/**
|
||||
* PC拼团详情列表
|
||||
* @param pinkId 团长pinkId
|
||||
* @return
|
||||
*/
|
||||
List<StorePink> getAdminList(Integer pinkId);
|
||||
|
||||
/**
|
||||
* 查询拼团列表
|
||||
* @param cid
|
||||
* @param kid
|
||||
*/
|
||||
List<StorePink> getListByCidAndKid(Integer cid, Integer kid);
|
||||
|
||||
/**
|
||||
* 根据团长拼团id获取拼团人数
|
||||
* @param pinkId
|
||||
* @return
|
||||
*/
|
||||
Integer getCountByKid(Integer pinkId);
|
||||
|
||||
/**
|
||||
* 检查状态,更新数据
|
||||
*/
|
||||
void detectionStatus();
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
boolean pinkSuccess(Integer kid);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,306 @@
|
||||
package com.zbkj.crmeb.combination.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.vo.dateLimitUtilVo;
|
||||
import com.zbkj.crmeb.combination.dao.StorePinkDao;
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.zbkj.crmeb.combination.request.StorePinkSearchRequest;
|
||||
import com.zbkj.crmeb.combination.response.StorePinkAdminListResponse;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.combination.service.StorePinkService;
|
||||
import com.zbkj.crmeb.front.request.OrderRefundApplyRequest;
|
||||
import com.zbkj.crmeb.front.service.OrderService;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
import com.zbkj.crmeb.store.service.StoreOrderService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* StorePinkService 实现类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Service
|
||||
public class StorePinkServiceImpl extends ServiceImpl<StorePinkDao, StorePink> implements StorePinkService {
|
||||
|
||||
@Resource
|
||||
private StorePinkDao dao;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private StoreOrderService storeOrderService;
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
@Autowired
|
||||
private TemplateMessageService templateMessageService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param request 请求参数
|
||||
* @param pageParamRequest 分页类参数
|
||||
* @author HZW
|
||||
* @since 2020-11-13
|
||||
* @return List<StorePink>
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StorePinkAdminListResponse> getList(StorePinkSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
Page<StorePink> pinkPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(request.getStatus())) {
|
||||
lqw.eq(StorePink::getStatus, request.getStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getDateLimit())) {
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(request.getDateLimit());
|
||||
lqw.between(StorePink::getAddTime, DateUtil.dateStr2Timestamp(dateLimit.getStartTime(), Constants.DATE_TIME_TYPE_BEGIN), DateUtil.dateStr2Timestamp(dateLimit.getEndTime(), Constants.DATE_TIME_TYPE_END));
|
||||
}
|
||||
lqw.eq(StorePink::getKId, 0);
|
||||
lqw.orderByDesc(StorePink::getId);
|
||||
List<StorePink> storePinks = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(storePinks)) {
|
||||
return CommonPage.copyPageInfo(pinkPage, CollUtil.newArrayList());
|
||||
}
|
||||
List<StorePinkAdminListResponse> list = storePinks.stream().map(pink -> {
|
||||
StorePinkAdminListResponse storePinkResponse = new StorePinkAdminListResponse();
|
||||
BeanUtils.copyProperties(pink, storePinkResponse);
|
||||
Integer countPeople = getCountByKidAndCid(pink.getCid(), pink.getId());
|
||||
storePinkResponse.setCountPeople(countPeople);
|
||||
storePinkResponse.setAddTime(DateUtil.timestamp2DateStr(pink.getAddTime(), Constants.DATE_FORMAT));
|
||||
storePinkResponse.setStopTime(DateUtil.timestamp2DateStr(pink.getStopTime(), Constants.DATE_FORMAT));
|
||||
StoreCombination combination = storeCombinationService.getById(pink.getCid());
|
||||
storePinkResponse.setTitle(combination.getTitle());
|
||||
return storePinkResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return CommonPage.copyPageInfo(pinkPage, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团列表cid
|
||||
* @param cid 拼团商品id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StorePink> getListByCid(Integer cid) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StorePink::getCid, cid);
|
||||
lqw.orderByDesc(StorePink::getId);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团实体查询
|
||||
* @param storePink
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StorePink> getByEntity(StorePink storePink) {
|
||||
LambdaQueryWrapper<StorePink> lqw = Wrappers.lambdaQuery();
|
||||
lqw.setEntity(storePink);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* PC拼团详情列表
|
||||
* @param pinkId 团长pinkId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StorePink> getAdminList(Integer pinkId) {
|
||||
LambdaQueryWrapper<StorePink> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StorePink::getId, pinkId).or().eq(StorePink::getKId, pinkId);
|
||||
lqw.orderByDesc(StorePink::getId);
|
||||
List<StorePink> pinkList = dao.selectList(lqw);
|
||||
// 将拼团状态提换为订单状态
|
||||
pinkList.forEach(i -> {
|
||||
StoreOrder storeOrder = storeOrderService.getByOderId(i.getOrderId());
|
||||
if (ObjectUtil.isNotNull(storeOrder)) {
|
||||
i.setStatus(storeOrder.getStatus());
|
||||
}
|
||||
});
|
||||
return pinkList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorePink> getListByCidAndKid(Integer cid, Integer kid) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StorePink::getCid, cid);
|
||||
lqw.eq(StorePink::getKId, kid);
|
||||
lqw.eq(StorePink::getIsRefund, false);
|
||||
lqw.orderByDesc(StorePink::getId);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountByKid(Integer pinkId) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(StorePink::getId);
|
||||
lqw.eq(StorePink::getIsRefund, false);
|
||||
lqw.and(i -> i.eq(StorePink::getKId, pinkId).or().eq(StorePink::getId, pinkId));
|
||||
return dao.selectCount(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查状态,更新数据
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void detectionStatus() {
|
||||
// 查找所有结束时间小等于当前的进行中拼团团长
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StorePink::getStatus, 1);
|
||||
lqw.eq(StorePink::getKId, 0);
|
||||
lqw.le(StorePink::getStopTime, System.currentTimeMillis());
|
||||
List<StorePink> headList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(headList)) {
|
||||
return ;
|
||||
}
|
||||
/**
|
||||
* 1.判断是否拼团成功
|
||||
* 2.成功的修改状态
|
||||
* 3.失败的拼团改为失败,订单申请退款
|
||||
*/
|
||||
List<StorePink> pinkSuccessList = CollUtil.newArrayList();
|
||||
List<StorePink> pinkFailList = CollUtil.newArrayList();
|
||||
List<OrderRefundApplyRequest> applyList = CollUtil.newArrayList();
|
||||
for (StorePink headPink : headList) {
|
||||
// 查询团员
|
||||
List<StorePink> memberList = getListByCidAndKid(headPink.getCid(), headPink.getId());
|
||||
if (CollUtil.isNotEmpty(memberList)) {
|
||||
if (headPink.getPeople().equals(memberList.size() + 1)) {
|
||||
headPink.setStatus(2);
|
||||
memberList.forEach(i -> i.setStatus(2));
|
||||
pinkSuccessList.add(headPink);
|
||||
pinkSuccessList.addAll(memberList);
|
||||
continue;
|
||||
}
|
||||
// 计算虚拟比例,判断是否拼团成功
|
||||
StoreCombination storeCombination = storeCombinationService.getById(headPink.getCid());
|
||||
Integer virtual = storeCombination.getVirtualRation();// 虚拟成团比例
|
||||
int a = (memberList.size() + 1) * 100;
|
||||
int b = storeCombination.getPeople() * virtual;
|
||||
if (a >= b) {// 可以虚拟成团
|
||||
headPink.setStatus(2).setIs_virtual(true);
|
||||
memberList.forEach(i -> i.setStatus(2).setIs_virtual(true));
|
||||
pinkSuccessList.add(headPink);
|
||||
pinkSuccessList.addAll(memberList);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 失败
|
||||
headPink.setStatus(3);
|
||||
// 订单申请退款
|
||||
OrderRefundApplyRequest refundRequest = new OrderRefundApplyRequest();
|
||||
refundRequest.setId(headPink.getOrderIdKey());
|
||||
refundRequest.setText("拼团订单取消,申请退款");
|
||||
refundRequest.setExplain("用户取消拼团订单,申请退款");
|
||||
pinkFailList.add(headPink);
|
||||
applyList.add(refundRequest);
|
||||
|
||||
// 团员处理
|
||||
if (CollUtil.isNotEmpty(memberList)) {
|
||||
memberList.forEach(i -> i.setStatus(3));
|
||||
List<OrderRefundApplyRequest> tempApplyList = memberList.stream().map(i -> {
|
||||
OrderRefundApplyRequest tempRefundRequest = new OrderRefundApplyRequest();
|
||||
tempRefundRequest.setId(headPink.getOrderIdKey());
|
||||
tempRefundRequest.setText("拼团订单取消,申请退款");
|
||||
tempRefundRequest.setExplain("用户取消拼团订单,申请退款");
|
||||
return tempRefundRequest;
|
||||
}).collect(Collectors.toList());
|
||||
pinkFailList.addAll(memberList);
|
||||
applyList.addAll(tempApplyList);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(pinkFailList) && pinkFailList.size() > 0) {
|
||||
boolean failUpdate = updateBatchById(pinkFailList, 100);
|
||||
if (!failUpdate) throw new CrmebException("批量更新拼团状态,拼团未成功部分,失败");
|
||||
}
|
||||
if (applyList.size() > 0) {
|
||||
boolean task = orderService.refundApplyTask(applyList);
|
||||
if (!task) throw new CrmebException("拼团未成功,订单申请退款失败");
|
||||
}
|
||||
if (CollUtil.isNotEmpty(pinkSuccessList) && pinkSuccessList.size() > 0) {
|
||||
boolean successUpdate = updateBatchById(pinkSuccessList, 100);
|
||||
if (!successUpdate) throw new CrmebException("批量更新拼团状态,拼团成功部分,失败");
|
||||
pinkSuccessList.forEach(i -> {
|
||||
StoreOrder storeOrder = storeOrderService.getByOderId(i.getOrderId());
|
||||
StoreCombination storeCombination = storeCombinationService.getById(i.getCid());
|
||||
// 发送微信模板消息
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put(Constants.WE_CHAT_TEMP_KEY_FIRST, "恭喜您拼团成功!我们将尽快为您发货。");
|
||||
map.put("keyword1", storeOrder.getOrderId());
|
||||
map.put("keyword2", storeCombination.getTitle());
|
||||
map.put(Constants.WE_CHAT_TEMP_KEY_END, "感谢你的使用!");
|
||||
|
||||
templateMessageService.push(Constants.WE_CHAT_TEMP_KEY_COMBINATION_SUCCESS, map, storeOrder.getUid(), Constants.PAY_TYPE_WE_CHAT_FROM_PUBLIC);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
* @param kid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean pinkSuccess(Integer kid) {
|
||||
if (ObjectUtil.isNull(kid)) {
|
||||
return false;
|
||||
}
|
||||
StorePink teamPink = getById(kid);
|
||||
List<StorePink> memberList = getListByCidAndKid(teamPink.getCid(), kid);
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
memberList.add(teamPink);
|
||||
memberList.forEach(i -> {
|
||||
i.setStatus(2);
|
||||
i.setStopTime(timeMillis);
|
||||
});
|
||||
return updateBatchById(memberList);
|
||||
}
|
||||
|
||||
private Integer getCountByKidAndCid(Integer cid, Integer kid) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(StorePink::getId);
|
||||
lqw.eq(StorePink::getCid, cid);
|
||||
lqw.and(i -> i.eq(StorePink::getKId, kid).or().eq(StorePink::getId, kid));
|
||||
lqw.eq(StorePink::getIsRefund, false);
|
||||
return dao.selectCount(lqw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,7 @@ public class CorsConfig{
|
||||
source.registerCorsConfiguration("/**", buildConfig()); //注册
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
|
||||
public static String st = "269pbE47g5wSRco2vNyQ";
|
||||
public static String sk = "1Pdc1e2F5Kyy!p…p+¥OU0oIu(tG2Fqxzfd—";
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class DruidConfig {
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.html,*.png,*.ico,*.js,*.gif,*.jpg,*.css,/druid/*");
|
||||
return filterRegistrationBean ;
|
||||
}
|
||||
@Bean
|
||||
@Bean("dataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSource druidDataSource() {
|
||||
return new DruidDataSource();
|
||||
|
||||
@@ -115,7 +115,7 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
excludePathPatterns("/api/front/seckill/list/*").
|
||||
excludePathPatterns("/api/front/seckill/detail/*").
|
||||
// excludePathPatterns("/api/front/cart/count").
|
||||
excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
|
||||
excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
|
||||
}
|
||||
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.zbkj.crmeb.export.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.common.CommonResult;
|
||||
import com.utils.ExcelUtil;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationSearchRequest;
|
||||
import com.zbkj.crmeb.export.service.ExcelService;
|
||||
import com.zbkj.crmeb.export.vo.ProductExcelVo;
|
||||
import com.zbkj.crmeb.store.request.StoreProductSearchRequest;
|
||||
@@ -14,11 +18,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 商品表 前端控制器
|
||||
* Excel导出 前端控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -33,7 +38,6 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/export/excel")
|
||||
@Api(tags = "导出 -- Excel")
|
||||
|
||||
public class ExcelController {
|
||||
|
||||
@Autowired
|
||||
@@ -47,12 +51,49 @@ public class ExcelController {
|
||||
*/
|
||||
@ApiOperation(value = "产品")
|
||||
@RequestMapping(value = "/product", method = RequestMethod.GET)
|
||||
public void export(@Validated StoreProductSearchRequest request, HttpServletResponse response){
|
||||
List<ProductExcelVo> productExcelVoList = excelService.product(request, response);
|
||||
ExcelUtil.setSheetName("store"); //sheet名称
|
||||
ExcelUtil.setFileName("产品导出"); //文件名称前缀 xx_yyyymmddhhiiss
|
||||
ExcelUtil.writeExcel(response, productExcelVoList, ProductExcelVo.class);
|
||||
public CommonResult<HashMap<String, String>> export(@Validated StoreProductSearchRequest request, HttpServletResponse response){
|
||||
// List<ProductExcelVo> productExcelVoList = excelService.product(request, response);
|
||||
// ExcelUtil.setSheetName("store"); //sheet名称
|
||||
// ExcelUtil.setFileName("产品导出"); //文件名称前缀 xx_yyyymmddhhiiss
|
||||
// ExcelUtil.writeExcel(response, productExcelVoList, ProductExcelVo.class);
|
||||
String fileName = excelService.exportProduct(request, response);
|
||||
HashMap<String, String> map = CollUtil.newHashMap();
|
||||
map.put("fileName", fileName);
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品导出
|
||||
* @param request 搜索条件
|
||||
* @author HZW
|
||||
* @since 2020-05-06
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "砍价商品导出")
|
||||
@RequestMapping(value = "/bargain/product", method = RequestMethod.GET)
|
||||
public CommonResult<HashMap<String, String>> exportBargainProduct(@Validated StoreBargainSearchRequest request, HttpServletResponse response){
|
||||
String fileName = excelService.exportBargainProduct(request, response);
|
||||
HashMap<String, String> map = CollUtil.newHashMap();
|
||||
map.put("fileName", fileName);
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团商品导出
|
||||
* @param request 搜索条件
|
||||
* @author HZW
|
||||
* @since 2020-05-06
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团商品导出")
|
||||
@RequestMapping(value = "/combiantion/product", method = RequestMethod.GET)
|
||||
public CommonResult<HashMap<String, String>> exportCombinationProduct(@Validated StoreCombinationSearchRequest request, HttpServletResponse response){
|
||||
String fileName = excelService.exportCombinationProduct(request, response);
|
||||
HashMap<String, String> map = CollUtil.newHashMap();
|
||||
map.put("fileName", fileName);
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.zbkj.crmeb.export.service;
|
||||
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationSearchRequest;
|
||||
import com.zbkj.crmeb.export.vo.BargainProductExcelVo;
|
||||
import com.zbkj.crmeb.export.vo.ProductExcelVo;
|
||||
import com.zbkj.crmeb.store.request.StoreProductSearchRequest;
|
||||
|
||||
@@ -19,5 +22,11 @@ import java.util.List;
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ExcelService{
|
||||
List<ProductExcelVo> product(StoreProductSearchRequest request, HttpServletResponse response);
|
||||
// List<ProductExcelVo> product(StoreProductSearchRequest request, HttpServletResponse response);
|
||||
|
||||
String exportBargainProduct(StoreBargainSearchRequest request, HttpServletResponse response);
|
||||
|
||||
String exportCombinationProduct(StoreCombinationSearchRequest request, HttpServletResponse response);
|
||||
|
||||
String exportProduct(StoreProductSearchRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,36 @@
|
||||
package com.zbkj.crmeb.export.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.ExportUtil;
|
||||
import com.zbkj.crmeb.bargain.request.StoreBargainSearchRequest;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.category.service.CategoryService;
|
||||
import com.zbkj.crmeb.combination.request.StoreCombinationSearchRequest;
|
||||
import com.zbkj.crmeb.combination.response.StoreCombinationResponse;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.export.service.ExcelService;
|
||||
import com.zbkj.crmeb.export.vo.BargainProductExcelVo;
|
||||
import com.zbkj.crmeb.export.vo.CombinationProductExcelVo;
|
||||
import com.zbkj.crmeb.export.vo.ProductExcelVo;
|
||||
import com.zbkj.crmeb.store.request.StoreProductSearchRequest;
|
||||
import com.zbkj.crmeb.store.response.StoreProductResponse;
|
||||
import com.zbkj.crmeb.store.service.StoreProductRelationService;
|
||||
import com.zbkj.crmeb.store.service.StoreProductService;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -44,19 +56,115 @@ public class ExcelServiceImpl implements ExcelService {
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
private StoreProductRelationService storeProductRelationService;
|
||||
private StoreBargainService storeBargainService;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
/**
|
||||
* 商品列表导出
|
||||
* @param request 请求参数
|
||||
* @param response 返回数据
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-06
|
||||
* 导出砍价商品
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ProductExcelVo> product(StoreProductSearchRequest request, HttpServletResponse response) {
|
||||
public String exportBargainProduct(StoreBargainSearchRequest request, HttpServletResponse response) {
|
||||
PageParamRequest pageParamRequest = new PageParamRequest();
|
||||
pageParamRequest.setPage(Constants.DEFAULT_PAGE);
|
||||
pageParamRequest.setLimit(Constants.EXPORT_MAX_LIMIT);
|
||||
PageInfo<StoreBargainResponse> page = storeBargainService.getList(request, pageParamRequest);
|
||||
if (CollUtil.isEmpty(page.getList())) throw new CrmebException("没有可导出的数据!");
|
||||
List<StoreBargainResponse> list = page.getList();
|
||||
List<BargainProductExcelVo> voList = list.stream().map(temp -> {
|
||||
BargainProductExcelVo vo = new BargainProductExcelVo();
|
||||
BeanUtils.copyProperties(temp, vo);
|
||||
vo.setPrice("¥".concat(temp.getPrice().toString()));
|
||||
vo.setStatus(temp.getStatus() ? "开启" : "关闭");
|
||||
vo.setStartTime(temp.getStartTime());
|
||||
vo.setStopTime(temp.getStopTime());
|
||||
vo.setAddTime(temp.getAddTime());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 上传设置
|
||||
ExportUtil.setUpload(systemConfigService.getValueByKey(Constants.UPLOAD_ROOT_PATH_CONFIG_KEY), Constants.UPLOAD_MODEL_PATH_EXCEL, Constants.UPLOAD_TYPE_FILE);
|
||||
|
||||
// 文件名
|
||||
String fileName = "砍价".concat(DateUtil.nowDateTime(Constants.DATE_TIME_FORMAT_NUM)).concat(CrmebUtil.randomCount(111111111, 999999999).toString()).concat(".xlsx");
|
||||
|
||||
//自定义标题别名
|
||||
LinkedHashMap<String, String> aliasMap = new LinkedHashMap<>();
|
||||
aliasMap.put("title", "砍价活动名称");
|
||||
aliasMap.put("info", "砍价活动简介");
|
||||
aliasMap.put("price", "砍价金额");
|
||||
aliasMap.put("bargainNum", "用户每次砍价的次数");
|
||||
aliasMap.put("status", "砍价状态");
|
||||
aliasMap.put("startTime", "砍价开启时间");
|
||||
aliasMap.put("stopTime", "砍价结束时间");
|
||||
aliasMap.put("sales", "销量");
|
||||
aliasMap.put("stock", "库存");
|
||||
aliasMap.put("giveIntegral", "返多少积分");
|
||||
aliasMap.put("addTime", "添加时间");
|
||||
|
||||
return ExportUtil.exportExecl(fileName, "砍价商品导出", voList, aliasMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出拼团商品
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String exportCombinationProduct(StoreCombinationSearchRequest request, HttpServletResponse response) {
|
||||
PageParamRequest pageParamRequest = new PageParamRequest();
|
||||
pageParamRequest.setPage(Constants.DEFAULT_PAGE);
|
||||
pageParamRequest.setLimit(Constants.EXPORT_MAX_LIMIT);
|
||||
PageInfo<StoreCombinationResponse> page = storeCombinationService.getList(request, pageParamRequest);
|
||||
if (CollUtil.isEmpty(page.getList())) throw new CrmebException("没有可导出的数据!");
|
||||
List<StoreCombinationResponse> list = page.getList();
|
||||
List<CombinationProductExcelVo> voList = list.stream().map(temp -> {
|
||||
CombinationProductExcelVo vo = new CombinationProductExcelVo();
|
||||
BeanUtils.copyProperties(temp, vo);
|
||||
vo.setIsShow(temp.getIsShow() ? "开启" : "关闭");
|
||||
vo.setStopTime(DateUtil.timestamp2DateStr(temp.getStopTime(), Constants.DATE_FORMAT_DATE));
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 上传设置
|
||||
ExportUtil.setUpload(systemConfigService.getValueByKey(Constants.UPLOAD_ROOT_PATH_CONFIG_KEY), Constants.UPLOAD_MODEL_PATH_EXCEL, Constants.UPLOAD_TYPE_FILE);
|
||||
|
||||
// 文件名
|
||||
String fileName = "拼团".concat(DateUtil.nowDateTime(Constants.DATE_TIME_FORMAT_NUM)).concat(CrmebUtil.randomCount(111111111, 999999999).toString()).concat(".xlsx");
|
||||
|
||||
//自定义标题别名
|
||||
LinkedHashMap<String, String> aliasMap = new LinkedHashMap<>();
|
||||
aliasMap.put("id", "编号");
|
||||
aliasMap.put("title", "拼团名称");
|
||||
aliasMap.put("otPrice", "原价");
|
||||
aliasMap.put("price", "拼团价");
|
||||
aliasMap.put("stock", "库存");
|
||||
aliasMap.put("countPeople", "拼团人数");
|
||||
aliasMap.put("countPeopleAll", "参与人数");
|
||||
aliasMap.put("countPeoplePink", "成团数量");
|
||||
aliasMap.put("sales", "销量");
|
||||
aliasMap.put("isShow", "商品状态");
|
||||
aliasMap.put("stopTime", "拼团结束时间");
|
||||
|
||||
return ExportUtil.exportExecl(fileName, "拼团商品导出", voList, aliasMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品导出
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String exportProduct(StoreProductSearchRequest request, HttpServletResponse response) {
|
||||
PageParamRequest pageParamRequest = new PageParamRequest();
|
||||
pageParamRequest.setPage(Constants.DEFAULT_PAGE);
|
||||
pageParamRequest.setLimit(Constants.EXPORT_MAX_LIMIT);
|
||||
@@ -66,9 +174,6 @@ public class ExcelServiceImpl implements ExcelService {
|
||||
throw new CrmebException("没有可导出的数据!");
|
||||
}
|
||||
|
||||
//从集合中取出ID
|
||||
List<Integer> idList = list.stream().map(StoreProductResponse::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
//产品分类id
|
||||
List<String> cateIdListStr = list.stream().map(StoreProductResponse::getCateId).distinct().collect(Collectors.toList());
|
||||
|
||||
@@ -78,31 +183,41 @@ public class ExcelServiceImpl implements ExcelService {
|
||||
List<Integer> cateIdList = CrmebUtil.stringToArray(join);
|
||||
categoryNameList = categoryService.getListInId(cateIdList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//点赞
|
||||
HashMap<Integer, Integer> likeCount = storeProductRelationService.getLikeCountListInProductId(idList);
|
||||
|
||||
//收藏
|
||||
HashMap<Integer, Integer> collectCount = storeProductRelationService.getCollectCountListInProductId(idList);
|
||||
|
||||
ArrayList<ProductExcelVo> productExcelVoList = new ArrayList<>();
|
||||
for (StoreProductResponse storeProductResponse : list ) {
|
||||
productExcelVoList.add(
|
||||
new ProductExcelVo(
|
||||
storeProductResponse.getStoreName(),
|
||||
storeProductResponse.getStoreInfo(),
|
||||
CrmebUtil.getValueByIndex(categoryNameList, storeProductResponse.getCateId()),
|
||||
storeProductResponse.getPrice(),
|
||||
storeProductResponse.getSales(),
|
||||
storeProductResponse.getStock(),
|
||||
CrmebUtil.getIntValueByIndex(likeCount, storeProductResponse.getId()),
|
||||
CrmebUtil.getIntValueByIndex(collectCount, storeProductResponse.getId())
|
||||
)
|
||||
);
|
||||
List<ProductExcelVo> voList = CollUtil.newArrayList();
|
||||
for (StoreProductResponse product : list ) {
|
||||
ProductExcelVo vo = new ProductExcelVo();
|
||||
vo.setStoreName(product.getStoreName());
|
||||
vo.setStoreInfo(product.getStoreInfo());
|
||||
vo.setCateName(CrmebUtil.getValueByIndex(categoryNameList, product.getCateId()));
|
||||
vo.setPrice("¥" + product.getPrice());
|
||||
vo.setStock(product.getStock().toString());
|
||||
vo.setSales(product.getSales().toString());
|
||||
vo.setBrowse(product.getBrowse().toString());
|
||||
voList.add(vo);
|
||||
}
|
||||
return productExcelVoList;
|
||||
|
||||
/**
|
||||
* ===============================
|
||||
* 以下为存储部分
|
||||
* ===============================
|
||||
*/
|
||||
// 上传设置
|
||||
ExportUtil.setUpload(systemConfigService.getValueByKey(Constants.UPLOAD_ROOT_PATH_CONFIG_KEY), Constants.UPLOAD_MODEL_PATH_EXCEL, Constants.UPLOAD_TYPE_FILE);
|
||||
|
||||
// 文件名
|
||||
String fileName = "商品导出_".concat(DateUtil.nowDateTime(Constants.DATE_TIME_FORMAT_NUM)).concat(CrmebUtil.randomCount(111111111, 999999999).toString()).concat(".xlsx");
|
||||
|
||||
//自定义标题别名
|
||||
LinkedHashMap<String, String> aliasMap = new LinkedHashMap<>();
|
||||
aliasMap.put("storeName", "商品名称");
|
||||
aliasMap.put("storeInfo", "商品简介");
|
||||
aliasMap.put("cateName", "商品分类");
|
||||
aliasMap.put("price", "价格");
|
||||
aliasMap.put("stock", "库存");
|
||||
aliasMap.put("sales", "销量");
|
||||
aliasMap.put("browse", "浏览量");
|
||||
|
||||
return ExportUtil.exportExecl(fileName, "商品导出", voList, aliasMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zbkj.crmeb.export.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 砍价商品ExeclVo对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class BargainProductExcelVo {
|
||||
|
||||
@ApiModelProperty(value = "砍价活动名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "砍价活动简介")
|
||||
private String info;
|
||||
|
||||
@ApiModelProperty(value = "砍价金额")
|
||||
private String price;
|
||||
|
||||
@ApiModelProperty(value = "用户每次砍价的次数")
|
||||
private Integer bargainNum;
|
||||
|
||||
@ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(value = "砍价开启时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "砍价结束时间")
|
||||
private String stopTime;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "反多少积分")
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zbkj.crmeb.export.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 拼团商品ExeclVo对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
public class CombinationProductExcelVo {
|
||||
|
||||
@ApiModelProperty(value = "编号")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "拼团名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "原价")
|
||||
private BigDecimal otPrice;
|
||||
|
||||
@ApiModelProperty(value = "拼团价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@ApiModelProperty(value = "拼团人数")
|
||||
private Integer countPeople;
|
||||
|
||||
@ApiModelProperty(value = "参与人数")
|
||||
private Integer countPeopleAll;
|
||||
|
||||
@ApiModelProperty(value = "成团数量")
|
||||
private Integer countPeoplePink;
|
||||
|
||||
@ApiModelProperty(value = "销量")
|
||||
private Integer sales;
|
||||
|
||||
@ApiModelProperty(value = "商品状态")
|
||||
private String isShow;
|
||||
|
||||
@ApiModelProperty(value = "拼团结束时间")
|
||||
private String stopTime;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.export.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -27,40 +28,25 @@ import java.math.BigDecimal;
|
||||
public class ProductExcelVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
public ProductExcelVo() {}
|
||||
public ProductExcelVo(String storeName, String storeInfo, String cateName, BigDecimal price, Integer sales, Integer stock, Integer like, Integer collect) {
|
||||
this.storeName = storeName;
|
||||
this.storeInfo = storeInfo;
|
||||
this.cateName = cateName;
|
||||
this.price = price;
|
||||
this.sales = sales;
|
||||
this.stock = stock;
|
||||
this.like = like;
|
||||
this.collect = collect;
|
||||
}
|
||||
|
||||
@ExcelColumn(value = "商品名称", col = 1)
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String storeName;
|
||||
|
||||
@ExcelColumn(value = "商品简介", col = 2)
|
||||
@ApiModelProperty(value = "商品简介")
|
||||
private String storeInfo;
|
||||
|
||||
@ExcelColumn(value = "分类", col = 3)
|
||||
@ApiModelProperty(value = "商品分类")
|
||||
private String cateName;
|
||||
|
||||
@ExcelColumn(value = "商品价格", col = 4)
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "价格")
|
||||
private String price;
|
||||
|
||||
@ExcelColumn(value = "销量", col = 5)
|
||||
private Integer sales;
|
||||
@ApiModelProperty(value = "库存")
|
||||
private String stock;
|
||||
|
||||
@ExcelColumn(value = "库存", col = 6)
|
||||
private Integer stock;
|
||||
|
||||
@ExcelColumn(value = "点赞人数", col = 7)
|
||||
private Integer like;
|
||||
|
||||
@ExcelColumn(value = "收藏人数", col = 8)
|
||||
private Integer collect;
|
||||
@ApiModelProperty(value = "销量")
|
||||
private String sales;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private String browse;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package com.zbkj.crmeb.express.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressSearchRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateShowRequest;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.zbkj.crmeb.express.service.ExpressService;
|
||||
import com.zbkj.crmeb.express.model.Express;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 快递公司表 前端控制器
|
||||
@@ -33,7 +36,6 @@ import com.zbkj.crmeb.express.model.Express;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/express")
|
||||
@Api(tags = "设置 -- 物流 -- 公司")
|
||||
|
||||
public class ExpressController {
|
||||
|
||||
@Autowired
|
||||
@@ -43,8 +45,6 @@ public class ExpressController {
|
||||
* 分页显示快递公司表
|
||||
* @param request ExpressSearchRequest 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@ApiOperation(value = "分页列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@@ -56,63 +56,45 @@ public class ExpressController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增快递公司表
|
||||
* @param expressRequest 新增参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
* 编辑快递公司
|
||||
*/
|
||||
@ApiOperation(value = "新增")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public CommonResult<String> save(@ModelAttribute ExpressRequest expressRequest){
|
||||
Express express = new Express();
|
||||
BeanUtils.copyProperties(expressRequest, express);
|
||||
|
||||
if(expressService.save(express)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除快递公司表
|
||||
* @param id Integer
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@ApiOperation(value = "删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name="id", value="快递ID")
|
||||
public CommonResult<String> delete(@RequestParam(value = "id") Integer id){
|
||||
if(expressService.removeById(id)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改快递公司表
|
||||
* @param id integer id
|
||||
* @param expressRequest 修改参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@ApiOperation(value = "修改")
|
||||
@ApiOperation(value = "编辑")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@ApiImplicitParam(name="id", value="快递ID")
|
||||
public CommonResult<String> update(@RequestParam Integer id, @ModelAttribute ExpressRequest expressRequest){
|
||||
Express express = new Express();
|
||||
BeanUtils.copyProperties(expressRequest, express);
|
||||
express.setId(id);
|
||||
|
||||
if(expressService.updateById(express)){
|
||||
public CommonResult<String> update(@RequestBody @Validated ExpressUpdateRequest expressRequest){
|
||||
if(expressService.updateExpress(expressRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*修改显示状态
|
||||
*/
|
||||
@ApiOperation(value = "修改显示状态")
|
||||
@RequestMapping(value = "/update/show", method = RequestMethod.POST)
|
||||
public CommonResult<String> update(@RequestBody @Validated ExpressUpdateShowRequest expressRequest){
|
||||
if(expressService.updateExpressShow(expressRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步物流公司
|
||||
*/
|
||||
@ApiOperation(value = "同步物流公司")
|
||||
@RequestMapping(value = "/sync/express", method = RequestMethod.POST)
|
||||
public CommonResult<String> syncExpress(){
|
||||
if(expressService.syncExpress()){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询快递公司表信息
|
||||
* @param id Integer
|
||||
@@ -126,6 +108,26 @@ public class ExpressController {
|
||||
Express express = expressService.getById(id);
|
||||
return CommonResult.success(express);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部物流公司
|
||||
*/
|
||||
@ApiOperation(value = "查询全部物流公司")
|
||||
@RequestMapping(value = "/all", method = RequestMethod.GET)
|
||||
public CommonResult<List<Express>> all() {
|
||||
return CommonResult.success(expressService.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物流公司面单模板
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询物流公司面单模板")
|
||||
@RequestMapping(value = "/template", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name="com", value="快递公司编号")
|
||||
public CommonResult<JSONObject> template(@RequestParam(value = "com") String com) {
|
||||
return CommonResult.success(expressService.template(com));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/express/shipping/free")
|
||||
@Api(tags = "设置 -- 物流 -- 免费")
|
||||
|
||||
public class ShippingTemplatesFreeController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/express/shipping/region")
|
||||
@Api(tags = "设置 -- 物流 -- 付费")
|
||||
|
||||
public class ShippingTemplatesRegionController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -41,11 +41,30 @@ public class Express implements Serializable {
|
||||
@ApiModelProperty(value = "快递公司全称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "是否需要月结账号")
|
||||
private Boolean partnerId;
|
||||
|
||||
@ApiModelProperty(value = "是否需要月结密码")
|
||||
private Boolean partnerKey;
|
||||
|
||||
@ApiModelProperty(value = "是否需要取件网店")
|
||||
private Boolean net;
|
||||
|
||||
@ApiModelProperty(value = "账号")
|
||||
private String account;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "网点名称")
|
||||
private String netName;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示")
|
||||
private Integer isShow;
|
||||
|
||||
private Boolean isShow;
|
||||
|
||||
@ApiModelProperty(value = "是否可用")
|
||||
private Boolean status;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,4 @@ public class ExpressSearchRequest implements Serializable {
|
||||
@ApiModelProperty(value = "搜索关键字", required = true)
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "是否显示 0=否 1=是", required = true)
|
||||
private Integer isShow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.zbkj.crmeb.express.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 快递公司编辑请求体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_express")
|
||||
@ApiModel(value="ExpressRequest对象", description="快递公司编辑请求体")
|
||||
public class ExpressUpdateRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "快递公司id")
|
||||
@NotNull(message = "快递公司id不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "账号")
|
||||
private String account;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "网点名称")
|
||||
private String netName;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示")
|
||||
@NotNull(message = "是否显示不能为空")
|
||||
private Boolean isShow;
|
||||
|
||||
@ApiModelProperty(value = "是否可用")
|
||||
@NotNull(message = "是否可用不能为空")
|
||||
private Boolean status;
|
||||
}
|
||||
@@ -7,12 +7,11 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 快递公司 Request
|
||||
* 快递公司编辑请求体
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -27,26 +26,16 @@ import java.io.Serializable;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_express")
|
||||
@ApiModel(value="ExpressRequest对象", description="快递公司")
|
||||
public class ExpressRequest implements Serializable {
|
||||
@ApiModel(value="ExpressRequest对象", description="快递公司编辑请求体")
|
||||
public class ExpressUpdateShowRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "快递公司简称", required = true)
|
||||
@NotBlank(message = "快递公司简称必须填写")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "快递公司全称", required = true)
|
||||
@NotBlank(message = "快递公司全称必须填写")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@NotNull(message = "排序数字必须填写")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示 0=否 1=是", required = true)
|
||||
@NotNull(message = "请选择是否弃用")
|
||||
private Integer isShow;
|
||||
|
||||
@ApiModelProperty(value = "快递公司id")
|
||||
@NotNull(message = "快递公司id不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "是否显示")
|
||||
@NotNull(message = "是否显示不能为空")
|
||||
private Boolean isShow;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.zbkj.crmeb.express.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.express.model.Express;
|
||||
import com.zbkj.crmeb.express.request.ExpressSearchRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateShowRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,10 +36,43 @@ public interface ExpressService extends IService<Express> {
|
||||
|
||||
Express info(Integer id);
|
||||
|
||||
// /**
|
||||
// * 根据快递单号和快递公司类型查看物流信息
|
||||
// * @param no 单号
|
||||
// * @param type 快递公司类型
|
||||
// */
|
||||
// JSONObject getExpressInfo(String no, String type);
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
Boolean updateExpress(ExpressUpdateRequest expressRequest);
|
||||
|
||||
/**
|
||||
* 修改显示状态
|
||||
*/
|
||||
Boolean updateExpressShow(ExpressUpdateShowRequest expressRequest);
|
||||
|
||||
/**
|
||||
* 同步快递公司
|
||||
*/
|
||||
Boolean syncExpress();
|
||||
|
||||
/**
|
||||
* 查询全部快递公司
|
||||
*/
|
||||
List<Express> findAll();
|
||||
|
||||
/**
|
||||
* 查询快递公司面单模板
|
||||
* @param com 快递公司编号
|
||||
*/
|
||||
JSONObject template(String com);
|
||||
|
||||
/**
|
||||
* 查询快递公司
|
||||
* @param code 快递公司编号
|
||||
* @return
|
||||
*/
|
||||
Express getByCode(String code);
|
||||
|
||||
/**
|
||||
* 打印电子面单
|
||||
* @param cargo 物品名称
|
||||
* @param count 商品数量
|
||||
*/
|
||||
Boolean dump(String cargo, Integer count);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ import com.zbkj.crmeb.express.vo.LogisticsResultVo;
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface LogisticService {
|
||||
LogisticsResultVo info(String expressNo, String type);
|
||||
LogisticsResultVo info(String expressNo, String type, String com, String phone);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
package com.zbkj.crmeb.express.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.OnePassConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.utils.OnePassUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.zbkj.crmeb.express.dao.ExpressDao;
|
||||
import com.zbkj.crmeb.express.model.Express;
|
||||
import com.zbkj.crmeb.express.request.ExpressSearchRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateRequest;
|
||||
import com.zbkj.crmeb.express.request.ExpressUpdateShowRequest;
|
||||
import com.zbkj.crmeb.express.service.ExpressService;
|
||||
import com.zbkj.crmeb.express.vo.ExpressSheetVo;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ExpressServiceImpl 接口实现
|
||||
@@ -37,11 +53,13 @@ public class ExpressServiceImpl extends ServiceImpl<ExpressDao, Express> impleme
|
||||
private ExpressDao dao;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
private OnePassUtil onePassUtil;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
/**
|
||||
* 分页显示快递公司表
|
||||
@@ -54,16 +72,11 @@ public class ExpressServiceImpl extends ServiceImpl<ExpressDao, Express> impleme
|
||||
public List<Express> getList(ExpressSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<Express> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if(request.getIsShow() != null){
|
||||
lambdaQueryWrapper.eq(Express::getIsShow, request.getIsShow());
|
||||
if(StrUtil.isNotBlank(request.getKeywords())){
|
||||
lambdaQueryWrapper.like(Express::getCode, request.getKeywords()).or().like(Express::getName, request.getKeywords());
|
||||
}
|
||||
|
||||
if(!StringUtils.isBlank(request.getKeywords())){
|
||||
lambdaQueryWrapper.and( i-> i.or().like(Express::getCode, request.getKeywords()).
|
||||
or().like(Express::getName, request.getKeywords()));
|
||||
}
|
||||
|
||||
lambdaQueryWrapper.orderByDesc(Express::getSort);
|
||||
lambdaQueryWrapper.orderByDesc(Express::getSort, Express::getId);
|
||||
return dao.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -82,19 +95,177 @@ public class ExpressServiceImpl extends ServiceImpl<ExpressDao, Express> impleme
|
||||
return info;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 查看物流信息
|
||||
// * @param no 单号
|
||||
// * @param type 快递公司类型
|
||||
// */
|
||||
// @Override
|
||||
// public JSONObject getExpressInfo(String no, String type) {
|
||||
// String key = systemConfigService.getValueByKey("system_express_app_code");
|
||||
// if(StringUtils.isEmpty(key)) throw new CrmebException("未配置物流查询");
|
||||
// String url = Constants.LOGISTICS_API_URL+"no="+no+"&type="+type;
|
||||
// HashMap<String,String> headers = new HashMap<>();
|
||||
// headers.put("Authorization", "APPCODE "+key);
|
||||
// return restTemplateUtil.getData(url, headers);
|
||||
// }
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateExpress(ExpressUpdateRequest expressRequest) {
|
||||
Express temp = getById(expressRequest.getId());
|
||||
if (ObjectUtil.isNull(temp)) throw new CrmebException("编辑的记录不存在!");
|
||||
|
||||
if (StrUtil.isBlank(expressRequest.getAccount()) && temp.getPartnerId().equals(true)) {
|
||||
throw new CrmebException("请输入月结账号");
|
||||
}
|
||||
if (StrUtil.isBlank(expressRequest.getPassword()) && temp.getPartnerKey().equals(true)) {
|
||||
throw new CrmebException("请输入月结密码");
|
||||
}
|
||||
if (StrUtil.isBlank(expressRequest.getNetName()) && temp.getNet().equals(true)) {
|
||||
throw new CrmebException("请输入取件网点");
|
||||
}
|
||||
Express express = new Express();
|
||||
BeanUtils.copyProperties(expressRequest, express);
|
||||
return updateById(express);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改显示状态
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateExpressShow(ExpressUpdateShowRequest expressRequest) {
|
||||
Express temp = getById(expressRequest.getId());
|
||||
if (ObjectUtil.isNull(temp)) throw new CrmebException("编辑的记录不存在!");
|
||||
if (temp.getIsShow().equals(expressRequest.getIsShow())) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
Express express = new Express();
|
||||
BeanUtils.copyProperties(expressRequest, express);
|
||||
return updateById(express);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步物流公司
|
||||
*/
|
||||
@Override
|
||||
public Boolean syncExpress() {
|
||||
if (redisUtil.exists(OnePassConstants.ONE_PASS_EXPRESS_CACHE_KEY)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
getExpressList();
|
||||
|
||||
redisUtil.set(OnePassConstants.ONE_PASS_EXPRESS_CACHE_KEY, 1, 3600L, TimeUnit.SECONDS);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部物流公司
|
||||
*/
|
||||
@Override
|
||||
public List<Express> findAll() {
|
||||
LambdaQueryWrapper<Express> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(Express::getIsShow, true);
|
||||
lqw.eq(Express::getStatus, true);
|
||||
lqw.orderByDesc(Express::getSort, Express::getId);
|
||||
return dao.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物流公司面单模板
|
||||
* @param com 快递公司编号
|
||||
*/
|
||||
@Override
|
||||
public JSONObject template(String com) {
|
||||
String token = onePassUtil.getToken();
|
||||
HashMap<String, String> header = onePassUtil.getCommonHeader(token);
|
||||
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
||||
param.add("com", com);
|
||||
return onePassUtil.postFrom(OnePassConstants.ONE_PASS_API_URL + OnePassConstants.ONE_PASS_API_EXPRESS_TEMP_URI, param, header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询快递公司
|
||||
* @param code 快递公司编号
|
||||
*/
|
||||
@Override
|
||||
public Express getByCode(String code) {
|
||||
LambdaQueryWrapper<Express> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(Express::getCode, code);
|
||||
return dao.selectOne(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印电子面单
|
||||
* @param cargo 物品名称
|
||||
* @param count 商品数量
|
||||
* TODO
|
||||
*/
|
||||
@Override
|
||||
public Boolean dump(String cargo, Integer count) {
|
||||
// 获取系统保存的电子面单信息
|
||||
ExpressSheetVo expressSheetVo = systemConfigService.getExpressSheet();
|
||||
Express express = getById(expressSheetVo.getExportId());
|
||||
if (ObjectUtil.isNull(express)) {
|
||||
throw new CrmebException("电子面单中对应的快递公司不存在");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从平台获取物流公司
|
||||
* 并存入数据库
|
||||
*/
|
||||
private void getExpressList() {
|
||||
String token = onePassUtil.getToken();
|
||||
HashMap<String, String> header = onePassUtil.getCommonHeader(token);
|
||||
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
||||
param.add("type", 1);// 国内运输商
|
||||
param.add("page", 0);
|
||||
param.add("limit", 1000);
|
||||
|
||||
JSONObject post = onePassUtil.postFrom(OnePassConstants.ONE_PASS_API_URL + OnePassConstants.ONE_PASS_API_EXPRESS_URI, param, header);
|
||||
System.out.println("OnePass Express ALL post = " + post);
|
||||
JSONObject jsonObject = post.getJSONObject("data");
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
||||
if (CollUtil.isEmpty(jsonArray)) return;
|
||||
|
||||
List<Express> expressList = CollUtil.newArrayList();
|
||||
List<String> codeList = getAllCode();
|
||||
jsonArray.forEach(temp -> {
|
||||
JSONObject object = (JSONObject) temp;
|
||||
if (StrUtil.isBlank(object.getString("code")) || !codeList.contains(object.getString("code"))) {
|
||||
Express express = new Express();
|
||||
express.setName(Optional.ofNullable(object.getString("name")).orElse(""));
|
||||
express.setCode(Optional.ofNullable(object.getString("code")).orElse(""));
|
||||
express.setPartnerId(false);
|
||||
express.setPartnerKey(false);
|
||||
express.setNet(false);
|
||||
if (ObjectUtil.isNotNull(object.getInteger("partner_id"))) {
|
||||
express.setPartnerId(object.getInteger("partner_id") == 1);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(object.getInteger("partner_key"))) {
|
||||
express.setPartnerKey(object.getInteger("partner_key") == 1);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(object.getInteger("net"))) {
|
||||
express.setNet(object.getInteger("net") == 1);
|
||||
}
|
||||
express.setIsShow(true);
|
||||
express.setStatus(false);
|
||||
if (!express.getPartnerId() && !express.getPartnerKey() && !express.getNet()) {
|
||||
express.setStatus(true);
|
||||
}
|
||||
expressList.add(express);
|
||||
}
|
||||
});
|
||||
|
||||
if (CollUtil.isNotEmpty(expressList)) {
|
||||
boolean saveBatch = saveBatch(expressList);
|
||||
if (!saveBatch) throw new CrmebException("同步物流公司失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有物流公司code
|
||||
*/
|
||||
private List<String> getAllCode() {
|
||||
LambdaQueryWrapper<Express> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(Express::getCode);
|
||||
List<Express> expressList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(expressList)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return expressList.stream().map(Express::getCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static String st = "mnc7Yay0RsvF70LWX7i6k";
|
||||
public static String sk = "¥bugJEjOmF01hxGr~qj5";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.zbkj.crmeb.express.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.zbkj.crmeb.express.service.LogisticService;
|
||||
import com.zbkj.crmeb.express.vo.LogisticsResultListVo;
|
||||
import com.zbkj.crmeb.express.vo.LogisticsResultVo;
|
||||
import com.zbkj.crmeb.pass.service.OnePassService;
|
||||
import com.zbkj.crmeb.pass.vo.OnePassLogisticsQueryVo;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -15,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@@ -43,6 +50,9 @@ public class LogisticsServiceImpl implements LogisticService {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private OnePassService onePassService;
|
||||
|
||||
private String redisKey = Constants.LOGISTICS_KEY;
|
||||
private Long redisCacheSeconds = 1800L;
|
||||
|
||||
@@ -52,16 +62,37 @@ public class LogisticsServiceImpl implements LogisticService {
|
||||
/** 快递
|
||||
* @param expressNo String 物流单号
|
||||
* @param type String 快递公司字母简写:不知道可不填 95%能自动识别,填写查询速度会更快 https://market.aliyun.com/products/56928004/cmapi021863.html#sku=yuncode15863000015
|
||||
* @param com 快递公司编号
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-06-10
|
||||
* @return Express
|
||||
*/
|
||||
@Override
|
||||
public LogisticsResultVo info(String expressNo, String type) {
|
||||
public LogisticsResultVo info(String expressNo, String type, String com, String phone) {
|
||||
LogisticsResultVo resultVo = new LogisticsResultVo();
|
||||
setExpressNo(expressNo);
|
||||
JSONObject result = getCache();
|
||||
if(null == result || result.equals("")){
|
||||
if (ObjectUtil.isNotNull(result)) {
|
||||
return JSONObject.toJavaObject(result, LogisticsResultVo.class);
|
||||
}
|
||||
String logisticsType = systemConfigService.getValueByKeyException("logistics_type");
|
||||
if (logisticsType.equals("1")) {// 平台查询
|
||||
OnePassLogisticsQueryVo queryVo = onePassService.exprQuery(expressNo, com);
|
||||
if (ObjectUtil.isNull(queryVo)) {
|
||||
return resultVo;
|
||||
}
|
||||
// 一号通vo转公共返回vo
|
||||
resultVo = queryToResultVo(queryVo);
|
||||
String jsonString = JSONObject.toJSONString(resultVo);
|
||||
saveCache(JSONObject.parseObject(jsonString));
|
||||
}
|
||||
if (logisticsType.equals("2")) {// 阿里云查询
|
||||
String appCode = systemConfigService.getValueByKey(Constants.CONFIG_KEY_LOGISTICS_APP_CODE);
|
||||
|
||||
// 顺丰请输入单号 : 收件人或寄件人手机号后四位。例如:123456789:1234
|
||||
if (StrUtil.isNotBlank(com) && com.equals("shunfengkuaiyun")) {
|
||||
expressNo = expressNo.concat(":").concat(StrUtil.sub(phone, 7, -1));
|
||||
}
|
||||
String url = Constants.LOGISTICS_API_URL + "?no=" + expressNo;
|
||||
if(StringUtils.isNotBlank(type)){
|
||||
url += "&type=" + type;
|
||||
@@ -72,12 +103,59 @@ public class LogisticsServiceImpl implements LogisticService {
|
||||
|
||||
JSONObject data = restTemplateUtil.getData(url, header);
|
||||
checkResult(data);
|
||||
|
||||
//把数据解析成对象返回到前端
|
||||
result = data.getJSONObject("result");
|
||||
saveCache(result);
|
||||
resultVo = JSONObject.toJavaObject(result, LogisticsResultVo.class);
|
||||
}
|
||||
return JSONObject.toJavaObject(result, LogisticsResultVo.class);
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一号通vo转公共返回vo
|
||||
*/
|
||||
private LogisticsResultVo queryToResultVo(OnePassLogisticsQueryVo queryVo) {
|
||||
LogisticsResultVo resultVo = new LogisticsResultVo();
|
||||
resultVo.setNumber(queryVo.getNum());
|
||||
resultVo.setExpName(queryVo.getCom());
|
||||
resultVo.setIsSign(queryVo.getIscheck());
|
||||
switch (queryVo.getStatus()) {
|
||||
case "0":// 在途
|
||||
case "1":// 揽收
|
||||
case "7":// 转单
|
||||
resultVo.setDeliveryStatus("1");
|
||||
break;
|
||||
case "2":// 疑难
|
||||
resultVo.setDeliveryStatus("5");
|
||||
break;
|
||||
case "3":// 签收
|
||||
resultVo.setDeliveryStatus("3");
|
||||
break;
|
||||
case "4":// 退签
|
||||
resultVo.setDeliveryStatus("6");
|
||||
break;
|
||||
case "5":// 派件
|
||||
resultVo.setDeliveryStatus("2");
|
||||
break;
|
||||
case "6":// 退回
|
||||
resultVo.setDeliveryStatus("6");
|
||||
break;
|
||||
default:
|
||||
resultVo.setDeliveryStatus(queryVo.getStatus());
|
||||
}
|
||||
resultVo.setDeliveryStatus(queryVo.getNum());
|
||||
|
||||
if (CollUtil.isNotEmpty(queryVo.getContent())) {
|
||||
List<LogisticsResultListVo> list = CollUtil.newArrayList();
|
||||
queryVo.getContent().forEach(i -> {
|
||||
LogisticsResultListVo listVo = new LogisticsResultListVo();
|
||||
listVo.setTime(i.getTime());
|
||||
listVo.setStatus(i.getContext());
|
||||
list.add(listVo);
|
||||
});
|
||||
resultVo.setList(list);
|
||||
}
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
/** 获取快递缓存
|
||||
@@ -89,7 +167,8 @@ public class LogisticsServiceImpl implements LogisticService {
|
||||
Object data = redisUtil.get(getRedisKey() + getExpressNo());
|
||||
if(null != data){
|
||||
return JSONObject.parseObject(data.toString());
|
||||
}else return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 获取快递缓存
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zbkj.crmeb.express.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统电子面单对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="ExpressSheetVo对象", description="系统电子面单对象")
|
||||
public class ExpressSheetVo {
|
||||
|
||||
public ExpressSheetVo() {
|
||||
}
|
||||
|
||||
public ExpressSheetVo(Integer exportId, String exportCom, String exportTempId, String exportToName, String exportToTel, String exportToAddress, String exportSiid) {
|
||||
this.exportId = exportId;
|
||||
this.exportCom = exportCom;
|
||||
this.exportTempId = exportTempId;
|
||||
this.exportToName = exportToName;
|
||||
this.exportToTel = exportToTel;
|
||||
this.exportToAddress = exportToAddress;
|
||||
this.exportSiid = exportSiid;
|
||||
}
|
||||
|
||||
public ExpressSheetVo(Integer exportId, String exportCom, String exportTempId, String exportToName, String exportToTel, String exportToAddress, String exportSiid, Integer exportOpen) {
|
||||
this.exportId = exportId;
|
||||
this.exportCom = exportCom;
|
||||
this.exportTempId = exportTempId;
|
||||
this.exportToName = exportToName;
|
||||
this.exportToTel = exportToTel;
|
||||
this.exportToAddress = exportToAddress;
|
||||
this.exportSiid = exportSiid;
|
||||
this.exportOpen = exportOpen;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "快递公司简称,物流、电子面单开通必填")
|
||||
private Integer exportId;
|
||||
|
||||
@ApiModelProperty(value = "快递公司简称,物流、电子面单开通必填")
|
||||
private String exportCom;
|
||||
|
||||
@ApiModelProperty(value = "快递公司模板Id、电子面单开通必填")
|
||||
private String exportTempId;
|
||||
|
||||
@ApiModelProperty(value = "快递面单发货人姓名,物流、电子面单开通必填")
|
||||
private String exportToName;
|
||||
|
||||
@ApiModelProperty(value = "快递面单发货人电话,物流、电子面单开通必填")
|
||||
private String exportToTel;
|
||||
|
||||
@ApiModelProperty(value = "发货人详细地址,物流、电子面单开通必填")
|
||||
private String exportToAddress;
|
||||
|
||||
@ApiModelProperty(value = "电子面单打印机编号,物流、电子面单开通必填")
|
||||
private String exportSiid;
|
||||
|
||||
@ApiModelProperty(value = "电子面单是否开启")
|
||||
private Integer exportOpen;
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class LogisticsResultVo {
|
||||
@ApiModelProperty(value = "快递运送轨迹")
|
||||
private List<LogisticsResultListVo> list;
|
||||
|
||||
@ApiModelProperty(value = "快递收件(揽件)1.在途中 2.正在派件 3.已签收 4.派送失败 5.疑难件 6.退件签收 */")
|
||||
@ApiModelProperty(value = "快递收件(揽件)1.在途中 2.正在派件 3.已签收 4.派送失败 5.疑难件 6.退件签收 10待清关,11清关中,12已清关,13清关异常,14收件人拒签 */")
|
||||
@JsonProperty("deliverystatus")
|
||||
private String deliveryStatus;
|
||||
|
||||
|
||||
@@ -3,23 +3,24 @@ package com.zbkj.crmeb.finance.controller;
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.model.UserFundsMonitor;
|
||||
import com.zbkj.crmeb.finance.request.FundsMonitorSearchRequest;
|
||||
import com.zbkj.crmeb.finance.request.FundsMonitorUserSearchRequest;
|
||||
import com.zbkj.crmeb.finance.service.UserFundsMonitorService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserBill;
|
||||
import com.zbkj.crmeb.user.request.UserBillDetailListRequest;
|
||||
import com.zbkj.crmeb.user.response.BillType;
|
||||
import com.zbkj.crmeb.user.response.UserBillResponse;
|
||||
import com.zbkj.crmeb.user.service.UserBillService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -100,7 +101,7 @@ public class FundsMonitorController {
|
||||
public CommonResult<CommonPage<UserBillResponse>> userDetail(UserBillDetailListRequest request,
|
||||
PageParamRequest pageParamRequest,
|
||||
@PathVariable Integer userId){
|
||||
CommonPage<UserBillResponse> ub = CommonPage.restPage(userBillService.getByBaseSearch(userId,request,pageParamRequest));
|
||||
CommonPage<UserBillResponse> ub = CommonPage.restPage(userBillService.getByBaseSearch(userId, request, pageParamRequest));
|
||||
return CommonResult.success(ub);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zbkj.crmeb.finance.controller;
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeRequest;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeRefundRequest;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeSearchRequest;
|
||||
import com.zbkj.crmeb.finance.response.UserRechargeResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.zbkj.crmeb.finance.service.UserRechargeService;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
@@ -93,6 +92,17 @@ public class UserRechargeController {
|
||||
return CommonResult.success(userRechargeService.getBalanceList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值退款
|
||||
*/
|
||||
@ApiOperation(value = "充值退款")
|
||||
@RequestMapping(value = "/refund", method = RequestMethod.POST)
|
||||
public CommonResult<Object> refund(@RequestBody @Validated UserRechargeRefundRequest request) {
|
||||
if (userRechargeService.refund(request)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zbkj.crmeb.finance.request;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 充值退款请求对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="UserRechargeRefundRequest对象", description="")
|
||||
public class UserRechargeRefundRequest {
|
||||
|
||||
@ApiModelProperty(value = "用户充值订单id")
|
||||
@NotNull(message = "用户充值订单编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "退款类型:1-仅本金,2-本金+赠送")
|
||||
@NotNull(message = "退款类型不能为空")
|
||||
@Range(min = 1, max = 2, message = "未知的退款类型")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@@ -4,14 +4,13 @@ import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeRefundRequest;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeSearchRequest;
|
||||
import com.zbkj.crmeb.finance.response.UserRechargeResponse;
|
||||
import com.zbkj.crmeb.front.request.UserRechargeRequest;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserRechargeService 接口
|
||||
@@ -38,4 +37,11 @@ public interface UserRechargeService extends IService<UserRecharge> {
|
||||
Boolean complete(UserRecharge userRecharge);
|
||||
|
||||
BigDecimal getSumBigDecimal(Integer uid);
|
||||
|
||||
/**
|
||||
* 充值退款
|
||||
* @param request 退款参数
|
||||
* @return
|
||||
*/
|
||||
Boolean refund(UserRechargeRefundRequest request);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,11 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
|
||||
//时间范围
|
||||
if(StringUtils.isNotBlank(request.getDateLimit())){
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(request.getDateLimit());
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(request.getDateLimit());
|
||||
if (dateLimit.getStartTime().length() == 10) {
|
||||
dateLimit.setStartTime(dateLimit.getStartTime().concat(" 00:00:00"));
|
||||
dateLimit.setEndTime(dateLimit.getEndTime().concat(" 23:59:59"));
|
||||
}
|
||||
lambdaQueryWrapper.between(UserExtract::getCreateTime, dateLimit.getStartTime(), dateLimit.getEndTime());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,44 @@
|
||||
package com.zbkj.crmeb.finance.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.constants.WeChatConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.utils.XmlUtil;
|
||||
import com.utils.vo.dateLimitUtilVo;
|
||||
import com.zbkj.crmeb.finance.dao.UserRechargeDao;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeRefundRequest;
|
||||
import com.zbkj.crmeb.finance.request.UserRechargeSearchRequest;
|
||||
import com.zbkj.crmeb.finance.response.UserRechargeResponse;
|
||||
import com.zbkj.crmeb.finance.service.UserRechargeService;
|
||||
import com.zbkj.crmeb.front.request.UserRechargeRequest;
|
||||
import com.zbkj.crmeb.payment.vo.wechat.WxRefundResponseVo;
|
||||
import com.zbkj.crmeb.payment.vo.wechat.WxRefundVo;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserBill;
|
||||
import com.zbkj.crmeb.user.service.UserBillService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -55,6 +68,18 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserBillService userBillService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -215,5 +240,154 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
}
|
||||
return userRecharge.getPrice();
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值退款
|
||||
* @param request 退款参数
|
||||
*/
|
||||
@Override
|
||||
public Boolean refund(UserRechargeRefundRequest request) {
|
||||
UserRecharge userRecharge = getById(request.getId());
|
||||
if (ObjectUtil.isNull(userRecharge)) throw new CrmebException("数据不存在!");
|
||||
if (!userRecharge.getPaid()) throw new CrmebException("订单未支付");
|
||||
if (userRecharge.getPrice().compareTo(userRecharge.getRefundPrice()) == 0) {
|
||||
throw new CrmebException("已退完支付金额!不能再退款了");
|
||||
}
|
||||
if (userRecharge.getRechargeType().equals("balance")) {
|
||||
throw new CrmebException("佣金转入余额,不能退款");
|
||||
}
|
||||
|
||||
User user = userService.getById(userRecharge.getUid());
|
||||
if (ObjectUtil.isNull(user)) throw new CrmebException("用户不存在!");
|
||||
|
||||
// 退款金额
|
||||
BigDecimal refundPrice = userRecharge.getPrice();
|
||||
if (request.getType().equals(2)) {// 本金+赠送
|
||||
refundPrice = userRecharge.getPrice().add(userRecharge.getGivePrice());
|
||||
}
|
||||
|
||||
// 判断充值方式进行退款
|
||||
try {
|
||||
if (userRecharge.getRechargeType().equals(Constants.PAY_TYPE_WE_CHAT_FROM_PUBLIC)) {// 公众号
|
||||
refundJSAPI(userRecharge);
|
||||
} else {// 小程序
|
||||
refundMiniWx(userRecharge);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new CrmebException("微信申请退款失败!");
|
||||
}
|
||||
|
||||
userRecharge.setRefundPrice(userRecharge.getPrice());
|
||||
|
||||
user.setNowMoney(user.getNowMoney().subtract(refundPrice));
|
||||
|
||||
UserBill userBill = getRefundBill(userRecharge, user.getNowMoney(), refundPrice);
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
updateById(userRecharge);
|
||||
userService.updateById(user);
|
||||
userBillService.save(userBill);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
if (!execute) throw new CrmebException("充值退款-修改提现数据失败!");
|
||||
// 成功后发送小程序通知
|
||||
return execute;
|
||||
}
|
||||
|
||||
private UserBill getRefundBill(UserRecharge userRecharge, BigDecimal nowMoney, BigDecimal refundPrice) {
|
||||
UserBill userBill = new UserBill();
|
||||
userBill.setUid(userRecharge.getUid());
|
||||
userBill.setLinkId(userRecharge.getOrderId());
|
||||
userBill.setPm(0);
|
||||
userBill.setTitle("系统退款");
|
||||
userBill.setCategory("now_money");
|
||||
userBill.setType("user_recharge_refund");
|
||||
userBill.setNumber(refundPrice);
|
||||
userBill.setBalance(nowMoney.subtract(refundPrice));
|
||||
userBill.setMark(StrUtil.format("退款给用户{}元", userRecharge.getPrice()));
|
||||
userBill.setStatus(1);
|
||||
userBill.setCreateTime(DateUtil.nowDateTime());
|
||||
return userBill;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序退款
|
||||
*/
|
||||
private WxRefundResponseVo refundMiniWx(UserRecharge userRecharge) {
|
||||
WxRefundVo wxRefundVo = new WxRefundVo();
|
||||
|
||||
String appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
String mchId = systemConfigService.getValueByKey(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
wxRefundVo.setAppid(appId);
|
||||
wxRefundVo.setMch_id(mchId);
|
||||
wxRefundVo.setNonce_str(DigestUtils.md5Hex(CrmebUtil.getUuid() + CrmebUtil.randomCount(111111, 666666)));
|
||||
wxRefundVo.setOut_trade_no(userRecharge.getOrderId());
|
||||
wxRefundVo.setOut_refund_no(userRecharge.getOrderId());
|
||||
wxRefundVo.setTotal_fee(userRecharge.getPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
|
||||
wxRefundVo.setRefund_fee(userRecharge.getPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
|
||||
String signKey = systemConfigService.getValueByKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
String sign = CrmebUtil.getSign(CrmebUtil.objectToMap(wxRefundVo), signKey);
|
||||
wxRefundVo.setSign(sign);
|
||||
String path = systemConfigService.getValueByKeyException("pay_mini_client_p12");
|
||||
return commonRefound(wxRefundVo, path);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号退款
|
||||
*/
|
||||
private WxRefundResponseVo refundJSAPI(UserRecharge userRecharge) {
|
||||
WxRefundVo wxRefundVo = new WxRefundVo();
|
||||
|
||||
String appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID);
|
||||
String mchId = systemConfigService.getValueByKey(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID);
|
||||
wxRefundVo.setAppid(appId);
|
||||
wxRefundVo.setMch_id(mchId);
|
||||
wxRefundVo.setNonce_str(DigestUtils.md5Hex(CrmebUtil.getUuid() + CrmebUtil.randomCount(111111, 666666)));
|
||||
wxRefundVo.setOut_trade_no(userRecharge.getOrderId());
|
||||
wxRefundVo.setOut_refund_no(userRecharge.getOrderId());
|
||||
wxRefundVo.setTotal_fee(userRecharge.getPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
|
||||
wxRefundVo.setRefund_fee(userRecharge.getPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
|
||||
String signKey = systemConfigService.getValueByKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
String sign = CrmebUtil.getSign(CrmebUtil.objectToMap(wxRefundVo), signKey);
|
||||
wxRefundVo.setSign(sign);
|
||||
String path = systemConfigService.getValueByKeyException("pay_routine_client_p12");
|
||||
return commonRefound(wxRefundVo, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共退款部分
|
||||
*/
|
||||
private WxRefundResponseVo commonRefound(WxRefundVo wxRefundVo, String path) {
|
||||
String xmlStr = XmlUtil.objectToXml(wxRefundVo);
|
||||
String url = WeChatConstants.PAY_API_URL + WeChatConstants.PAY_REFUND_API_URI_WECHAT;
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
String xml = "";
|
||||
System.out.println("微信申请退款xmlStr = " + xmlStr);
|
||||
try {
|
||||
xml = restTemplateUtil.postWXRefundXml(url, xmlStr, wxRefundVo.getMch_id(), path);
|
||||
map = XmlUtil.xmlToMap(xml);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new CrmebException("xmlToMap错误,xml = " + xml);
|
||||
}
|
||||
if(null == map){
|
||||
throw new CrmebException("微信退款失败!");
|
||||
}
|
||||
|
||||
WxRefundResponseVo responseVo = CrmebUtil.mapToObj(map, WxRefundResponseVo.class);
|
||||
if(responseVo.getReturnCode().toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信退款失败1!" + responseVo.getReturnMsg());
|
||||
}
|
||||
|
||||
if(responseVo.getResultCode().toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信退款失败2!" + responseVo.getErrCodeDes());
|
||||
}
|
||||
System.out.println("================微信申请退款结束=========================");
|
||||
System.out.println("xml = " + xml);
|
||||
return responseVo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.zbkj.crmeb.front.controller;
|
||||
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainResponse;
|
||||
import com.zbkj.crmeb.bargain.response.StoreBargainUserHelpResponse;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainService;
|
||||
import com.zbkj.crmeb.bargain.service.StoreBargainUserHelpService;
|
||||
import com.zbkj.crmeb.front.request.BargainFrontRequest;
|
||||
import com.zbkj.crmeb.front.response.BargainCountResponse;
|
||||
import com.zbkj.crmeb.front.response.BargainDetailResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* H5 砍价
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/front/bargain")
|
||||
@Api(tags = "砍价商品")
|
||||
public class BargainController {
|
||||
|
||||
@Autowired
|
||||
private StoreBargainService storeBargainService;
|
||||
|
||||
@Autowired
|
||||
private StoreBargainUserHelpService storeBargainUserHelpService;
|
||||
|
||||
/**
|
||||
* 砍价商品列表
|
||||
* @return 砍价商品列表
|
||||
*/
|
||||
@ApiOperation(value = "砍价商品列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<PageInfo<StoreBargainResponse>> list(@ModelAttribute PageParamRequest pageParamRequest){
|
||||
PageInfo<StoreBargainResponse> h5List = storeBargainService.getH5List(pageParamRequest);
|
||||
return CommonResult.success(h5List);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查看、分享、参与人数
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取查看、分享、参与人数")
|
||||
@RequestMapping(value = "/share/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<Map<String, Object>> share(@PathVariable(value = "id") Integer id) {
|
||||
Map<String, Object> map = storeBargainService.getH5Share(id);
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮忙好友砍价数据
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取帮忙好友砍价数据")
|
||||
@RequestMapping(value = "/help/count", method = RequestMethod.GET)
|
||||
public CommonResult<BargainCountResponse> count(@ModelAttribute @Validated BargainFrontRequest bargainFrontRequest) {
|
||||
BargainCountResponse bargainCountResponse = storeBargainUserHelpService.getH5CountByBargainId(bargainFrontRequest);
|
||||
return CommonResult.success(bargainCountResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 帮忙好友砍价信息列表
|
||||
* @return 砍价商品列表
|
||||
*/
|
||||
@ApiOperation(value = "帮忙好友砍价信息列表")
|
||||
@RequestMapping(value = "/help/list", method = RequestMethod.GET)
|
||||
public CommonResult<PageInfo<StoreBargainUserHelpResponse>> helpList(@ModelAttribute @Validated BargainFrontRequest bargainFrontRequest, @ModelAttribute PageParamRequest pageParamRequest){
|
||||
PageInfo<StoreBargainUserHelpResponse> list = storeBargainUserHelpService.getHelpList(bargainFrontRequest, pageParamRequest);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品详情
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "砍价商品详情")
|
||||
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<BargainDetailResponse> detail(@PathVariable(value = "id") Integer id) {
|
||||
BargainDetailResponse h5Detail = storeBargainService.getH5Detail(id);
|
||||
return CommonResult.success(h5Detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始砍价
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "开始砍价")
|
||||
@RequestMapping(value = "/start", method = RequestMethod.POST)
|
||||
public CommonResult<Object> start(@RequestBody @Validated BargainFrontRequest bargainFrontRequest) {
|
||||
Boolean start = storeBargainService.start(bargainFrontRequest);
|
||||
if (start) {
|
||||
return CommonResult.success("参与成功");
|
||||
}
|
||||
return CommonResult.failed("参与失败,请重新参与");
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "砍价")
|
||||
@RequestMapping(value = "/help", method = RequestMethod.POST)
|
||||
public CommonResult<Map<String, Object>> help(@RequestBody @Validated BargainFrontRequest bargainFrontRequest) {
|
||||
return CommonResult.success(storeBargainUserHelpService.help(bargainFrontRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价发起用户信息
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "砍价发起用户信息")
|
||||
@RequestMapping(value = "/start/user", method = RequestMethod.GET)
|
||||
public CommonResult<Map<String, String>> startUser(@ModelAttribute @Validated BargainFrontRequest bargainFrontRequest) {
|
||||
return CommonResult.success(storeBargainUserHelpService.startUser(bargainFrontRequest));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.zbkj.crmeb.front.controller;
|
||||
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.zbkj.crmeb.combination.request.StorePinkRequest;
|
||||
import com.zbkj.crmeb.front.response.CombinationDetailResponse;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.front.response.GoPinkResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 拼团商品
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/front/combination")
|
||||
@Api(tags = "拼团商品")
|
||||
public class CombinationController {
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
/**
|
||||
* 拼团Pink
|
||||
*/
|
||||
@ApiOperation(value = "拼团Pink")
|
||||
@RequestMapping(value = "/pink", method = RequestMethod.GET)
|
||||
public CommonResult<HashMap<String,Object>> pink(){
|
||||
return CommonResult.success(storeCombinationService.getForH5Pink());
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品列表
|
||||
* @return 砍价商品列表
|
||||
*/
|
||||
@ApiOperation(value = "拼团商品列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<PageInfo<StoreCombination>> list(@ModelAttribute PageParamRequest pageParamRequest) {
|
||||
PageInfo<StoreCombination> h5List = storeCombinationService.getH5List(pageParamRequest);
|
||||
return CommonResult.success(h5List);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团商品详情
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "拼团商品详情")
|
||||
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<CombinationDetailResponse> detail(@PathVariable(value = "id") Integer id) {
|
||||
CombinationDetailResponse h5Detail = storeCombinationService.getH5Detail(id);
|
||||
return CommonResult.success(h5Detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去拼团
|
||||
* @param pinkId 拼团团长单id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "去拼团")
|
||||
@RequestMapping(value = "/pink/{pinkId}", method = RequestMethod.GET)
|
||||
public CommonResult<GoPinkResponse> goPink(@PathVariable(value = "pinkId") Integer pinkId) {
|
||||
GoPinkResponse goPinkResponse = storeCombinationService.goPink(pinkId);
|
||||
return CommonResult.success(goPinkResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更多拼团
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "更多拼团")
|
||||
@RequestMapping(value = "/more", method = RequestMethod.GET)
|
||||
public CommonResult<PageInfo<StoreCombination>> getMore(@RequestParam Integer comId, @Validated PageParamRequest pageParamRequest) {
|
||||
PageInfo<StoreCombination> more = storeCombinationService.getMore(pageParamRequest, comId);
|
||||
return CommonResult.success(more);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消拼团
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "取消拼团")
|
||||
@RequestMapping(value = "/remove", method = RequestMethod.POST)
|
||||
public CommonResult<Object> remove(@RequestBody @Validated StorePinkRequest storePinkRequest) {
|
||||
if (storeCombinationService.removePink(storePinkRequest)) {
|
||||
return CommonResult.success("取消成功");
|
||||
} else {
|
||||
return CommonResult.failed("取消失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团海报
|
||||
*/
|
||||
// @ApiOperation(value = "拼团海报")
|
||||
// @RequestMapping(value = "/poster", method = RequestMethod.POST)
|
||||
// public CommonResult<Object> poster(@Validated @RequestParam Integer pinkId, @Validated @RequestParam String from) {
|
||||
// if (storeCombinationService.poster(pinkId, from)) {
|
||||
// return CommonResult.success("取消成功");
|
||||
// } else {
|
||||
// return CommonResult.failed("取消失败");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -80,6 +81,11 @@ public class CouponController {
|
||||
@ApiOperation(value = "当前购物车可用优惠券")
|
||||
@RequestMapping(value = "coupons/order", method = RequestMethod.GET)
|
||||
public CommonResult<List<StoreCouponUserOrder>> getCouponsListByCartId(@RequestParam String cartId){
|
||||
try {
|
||||
CrmebUtil.stringToArrayInt(cartId);
|
||||
} catch (NumberFormatException e) {
|
||||
return CommonResult.success(new ArrayList<StoreCouponUserOrder>());
|
||||
}
|
||||
return CommonResult.success(storeCouponUserService.getListByCartIds(CrmebUtil.stringToArrayInt(cartId)));
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user