1.3.2
This commit is contained in:
@@ -78,4 +78,17 @@ public class CommonPage<T> {
|
||||
BeanUtils.copyProperties(originPageInfo, pageInfo, "list");
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象A复制对象B的分页信息 //TODO 多次数据查询导致分页数据异常解决办法
|
||||
*/
|
||||
public static <T> PageInfo<T> copyPageInfo(PageInfo<?> originPageInfo, List<T> list) {
|
||||
PageInfo<T> pageInfo = new PageInfo<>(list);
|
||||
pageInfo.setPages(originPageInfo.getPages());
|
||||
pageInfo.setPageNum(originPageInfo.getPageNum());
|
||||
pageInfo.setPageSize(originPageInfo.getPageSize());
|
||||
pageInfo.setTotal(originPageInfo.getTotal());
|
||||
pageInfo.setList(list);
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
|
||||
24
crmeb/src/main/java/com/constants/BargainConstants.java
Normal file
24
crmeb/src/main/java/com/constants/BargainConstants.java
Normal file
@@ -0,0 +1,24 @@
|
||||
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 BargainConstants {
|
||||
|
||||
/** 用户砍价状态-参与中 */
|
||||
public static final Integer BARGAIN_USER_STATUS_PARTICIPATE = 1;
|
||||
/** 用户砍价状态-活动结束参与失败 */
|
||||
public static final Integer BARGAIN_USER_STATUS_FAIL = 2;
|
||||
/** 用户砍价状态-活动结束参与成功 */
|
||||
public static final Integer BARGAIN_USER_STATUS_SUCCESS = 3;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 BrokerageRecordConstants {
|
||||
|
||||
/** 佣金记录类型—增加 */
|
||||
public static final Integer BROKERAGE_RECORD_TYPE_ADD = 1;
|
||||
|
||||
/** 佣金记录类型—扣减 */
|
||||
public static final Integer BROKERAGE_RECORD_TYPE_SUB = 2;
|
||||
|
||||
/** 佣金记录状态—创建 */
|
||||
public static final Integer BROKERAGE_RECORD_STATUS_CREATE = 1;
|
||||
|
||||
/** 佣金记录状态—冻结期 */
|
||||
public static final Integer BROKERAGE_RECORD_STATUS_FROZEN = 2;
|
||||
|
||||
/** 佣金记录状态—完成 */
|
||||
public static final Integer BROKERAGE_RECORD_STATUS_COMPLETE = 3;
|
||||
|
||||
/** 佣金记录状态—失效(订单退款) */
|
||||
public static final Integer BROKERAGE_RECORD_STATUS_INVALIDATION = 4;
|
||||
|
||||
/** 佣金记录状态—提现申请 */
|
||||
public static final Integer BROKERAGE_RECORD_STATUS_WITHDRAW = 5;
|
||||
|
||||
/** 佣金记录关联类型—订单 */
|
||||
public static final String BROKERAGE_RECORD_LINK_TYPE_ORDER = "order";
|
||||
|
||||
/** 佣金记录关联类型—提现 */
|
||||
public static final String BROKERAGE_RECORD_LINK_TYPE_WITHDRAW = "withdraw";
|
||||
|
||||
/** 佣金记录关联类型—转余额 */
|
||||
public static final String BROKERAGE_RECORD_LINK_TYPE_YUE = "yue";
|
||||
|
||||
/** 佣金记录标题—订单获得佣金 */
|
||||
public static final String BROKERAGE_RECORD_TITLE_ORDER = "获得推广佣金";
|
||||
|
||||
/** 佣金记录标题—提现申请 */
|
||||
public static final String BROKERAGE_RECORD_TITLE_WITHDRAW_APPLY = "提现申请";
|
||||
|
||||
/** 佣金记录标题—提现拒绝 */
|
||||
public static final String BROKERAGE_RECORD_TITLE_WITHDRAW_FAIL = "提现申请拒绝";
|
||||
|
||||
/** 佣金记录标题—提现拒绝 */
|
||||
public static final String BROKERAGE_RECORD_TITLE_BROKERAGE_YUE = "佣金转余额";
|
||||
}
|
||||
37
crmeb/src/main/java/com/constants/CategoryConstants.java
Normal file
37
crmeb/src/main/java/com/constants/CategoryConstants.java
Normal file
@@ -0,0 +1,37 @@
|
||||
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 CategoryConstants {
|
||||
|
||||
/** 分类状态-正常 */
|
||||
public static final Integer CATEGORY_STATUS_NORMAL = 1;
|
||||
/** 分类状态-失效 */
|
||||
public static final Integer CATEGORY_STATUS_INVALID = 0;
|
||||
|
||||
/** 分类类型-产品分类 */
|
||||
public static final Integer CATEGORY_TYPE_PRODUCT = 1;
|
||||
/** 分类类型-附件分类 */
|
||||
public static final Integer CATEGORY_TYPE_ATTACHMENT = 2;
|
||||
/** 分类类型-文章分类 */
|
||||
public static final Integer CATEGORY_TYPE_ARTICLE = 3;
|
||||
/** 分类类型-设置分类 */
|
||||
public static final Integer CATEGORY_TYPE_SETTING = 4;
|
||||
/** 分类类型-菜单分类 */
|
||||
public static final Integer CATEGORY_TYPE_MENU = 5;
|
||||
/** 分类类型-配置分类 */
|
||||
public static final Integer CATEGORY_TYPE_CONFIG = 6;
|
||||
/** 分类类型-秒杀配置 */
|
||||
public static final Integer CATEGORY_TYPE_SECKILL = 7;
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class Constants {
|
||||
public static final String USER_LOGIN_PASSWORD_MD5_KEYWORDS = "crmeb";
|
||||
|
||||
//用户登token redis存储前缀
|
||||
public static final String USER_TOKEN_REDIS_KEY_PREFIX = "TOKEN_USER_";
|
||||
public static final String USER_TOKEN_REDIS_KEY_PREFIX = "TOKEN_USER:";
|
||||
|
||||
|
||||
//用户登录方式 h5
|
||||
@@ -101,7 +101,8 @@ public class Constants {
|
||||
public static final Integer PRODUCT_SELECT_CATEGORY_NUM_MAX = 10;
|
||||
|
||||
//上传类型
|
||||
public static final String UPLOAD_TYPE_IMAGE = "image";
|
||||
// public static final String UPLOAD_TYPE_IMAGE = "image";
|
||||
public static final String UPLOAD_TYPE_IMAGE = "crmebimage";
|
||||
|
||||
//上传类型
|
||||
public static final String UPLOAD_TYPE_FILE = "file";
|
||||
@@ -119,6 +120,9 @@ public class Constants {
|
||||
|
||||
public static final int UPLOAD_TYPE_USER = 7; //用户上传
|
||||
|
||||
// 移动端文章顶部的banner图最大数量 配置数据最小3最大10
|
||||
public static final String ARTICLE_BANNER_LIMIT = "news_slides_limit";
|
||||
|
||||
//城市数据 redis key
|
||||
public static final String CITY_LIST = "city_list";
|
||||
//城市数据 tree redis key
|
||||
@@ -158,7 +162,8 @@ 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 = "login_logo"; //logo地址
|
||||
public static final String CONFIG_KEY_SITE_LOGO = "mobile_top_logo"; //logo地址
|
||||
public static final String CONFIG_KEY_MOBILE_LOGIN_LOGO = "mobile_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"; //可提现银行
|
||||
@@ -191,20 +196,17 @@ public class Constants {
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_RATE_ONE = "store_brokerage_ratio"; //一级返佣比例前缀
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_RATE_TWO = "store_brokerage_two"; //二级返佣比例前缀
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_USER_EXTRACT_MIN_PRICE = "user_extract_min_price"; //提现最低金额
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_MODEL = "brokerage_func_status"; //分销模式
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_MODEL = "store_brokerage_status"; //分销模式1-指定分销2-人人分销
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_USER_EXTRACT_BANK = "user_extract_bank"; //提现银行卡
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_EXTRACT_TIME = "extract_time"; //冻结时间
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_PERSON_PRICE = "store_brokerage_price"; //人人分销满足金额
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_IS_OPEN = "brokerage_func_status"; //分销启用
|
||||
public static final String CONFIG_KEY_STORE_BROKERAGE_BIND_TYPE = "brokerageBindind"; //分销关系绑定0-所有游湖,2-新用户
|
||||
|
||||
//积分
|
||||
public static final String CONFIG_KEY_INTEGRAL_RATE = "integral_ratio"; //积分抵用比例(1积分抵多少金额
|
||||
public static final String CONFIG_KEY_INTEGRAL_RATE_ORDER_GIVE = "order_give_integral"; //下单支付金额按比例赠送积分(实际支付1元赠送多少积分
|
||||
|
||||
//后台首页登录图片
|
||||
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"; //登录页背景图
|
||||
|
||||
//分销
|
||||
public static final String CONFIG_KEY_DISTRIBUTION_TYPE = "brokerage_bindind";
|
||||
|
||||
@@ -213,7 +215,7 @@ public class Constants {
|
||||
|
||||
|
||||
//config配置的formId
|
||||
public static final int CONFIG_FORM_ID_INDEX = 69; //首页配置
|
||||
public static final int CONFIG_FORM_ID_INDEX = 133; //首页配置
|
||||
public static final int CONFIG_FORM_ID_PUBLIC = 65; //公众号配置
|
||||
|
||||
|
||||
@@ -428,7 +430,7 @@ public class Constants {
|
||||
|
||||
// 订单缓存
|
||||
public static final long ORDER_CASH_CONFIRM = (60);
|
||||
public static final String ORDER_CACHE_PER = "ORDER_CACHE"; // redis缓存订单前缀
|
||||
public static final String ORDER_CACHE_PER = "ORDER_CACHE:"; // redis缓存订单前缀
|
||||
|
||||
//订单操作类型 -> 消息
|
||||
public static final String ORDER_LOG_MESSAGE_REFUND_PRICE = "退款给用户{amount}元"; //退款
|
||||
@@ -446,16 +448,27 @@ public class Constants {
|
||||
public static final int ORDER_PAY_CHANNEL_PROGRAM = 1; //小程序
|
||||
|
||||
//微信消息模板 tempKey
|
||||
public static final String WE_CHAT_TEMP_KEY_EXPRESS = "OPENTM200565259";
|
||||
public static final String WE_CHAT_TEMP_KEY_DELIVERY = "OPENTM207707249";
|
||||
public static final String WE_CHAT_TEMP_KEY_FIRST = "first";
|
||||
public static final String WE_CHAT_TEMP_KEY_END = "remark";
|
||||
public static final String WE_CHAT_PUBLIC_TEMP_KEY_RECHARGE = "OPENTM200565260";
|
||||
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";// 砍价成功
|
||||
public static final String WE_CHAT_TEMP_KEY_EXPRESS = "OPENTM200565259";// 订单发货提醒
|
||||
public static final String WE_CHAT_TEMP_KEY_DELIVERY = "OPENTM207707249";// 订单配送通知
|
||||
public static final String WE_CHAT_TEMP_KEY_ORDER_PAY = "OPENTM207791277";// 订单支付成功通知
|
||||
public static final String WE_CHAT_TEMP_KEY_ORDER_RECEIVING = "OPENTM413386489";// 订单收货通知
|
||||
public static final String WE_CHAT_TEMP_KEY_ORDER_REFUND = "OPENTM207791277";// 退款进度通知
|
||||
public static final String WE_CHAT_PUBLIC_TEMP_KEY_RECHARGE = "OPENTM200565260";// 充值成功
|
||||
|
||||
// 小程序服务通知
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_COMBINATION_SUCCESS = "5164";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_BARGAIN_SUCCESS = "2920";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_EXPRESS = "467";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_DELIVERY = "14198";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_ORDER_PAY = "516";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_ORDER_RECEIVING = "9283";
|
||||
public static final String WE_CHAT_PROGRAM_TEMP_KEY_RECHARGE = "OPENTM200565260";
|
||||
|
||||
|
||||
|
||||
//CND URL测试用
|
||||
@@ -510,4 +523,7 @@ public class Constants {
|
||||
|
||||
public static final String FAIL = "FAIL";
|
||||
public static final String SUCCESS = "SUCCESS";
|
||||
|
||||
// 订单取消Key
|
||||
public static final String ORDER_AUTO_CANCEL_KEY = "order_auto_cancel_key";
|
||||
}
|
||||
|
||||
40
crmeb/src/main/java/com/constants/ProductConstants.java
Normal file
40
crmeb/src/main/java/com/constants/ProductConstants.java
Normal file
@@ -0,0 +1,40 @@
|
||||
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 ProductConstants {
|
||||
|
||||
/** 单规格属性 */
|
||||
public static final String SINGLE_ATTR_NAME = "规格";
|
||||
/** 单规格属性值 */
|
||||
public static final String SINGLE_ATTR_VALUE = "默认";
|
||||
|
||||
// 商品类型 活动类型 0=商品,1=秒杀,2=砍价,3=拼团 attrResult表用到
|
||||
/** 商品活动类型——普通商品 */
|
||||
public static final Integer PRODUCT_TYPE_NORMAL = 0;
|
||||
/** 商品活动类型——普通商品文字 */
|
||||
public static final String PRODUCT_TYPE_NORMAL_STR = "默认";
|
||||
/** 商品活动类型——秒杀商品 */
|
||||
public static final Integer PRODUCT_TYPE_SECKILL = 1;
|
||||
/** 商品活动类型——秒杀商品文字 */
|
||||
public static final String PRODUCT_TYPE_SECKILL_STR = "秒杀";
|
||||
/** 商品活动类型——砍价商品 */
|
||||
public static final Integer PRODUCT_TYPE_BARGAIN = 2;
|
||||
/** 商品活动类型——砍价商品文字 */
|
||||
public static final String PRODUCT_TYPE_BARGAIN_STR = "砍价";
|
||||
/** 商品活动类型——拼团商品 */
|
||||
public static final Integer PRODUCT_TYPE_PINGTUAN= 3;
|
||||
/** 商品活动类型——拼团商品文字 */
|
||||
public static final String PRODUCT_TYPE_PINGTUAN_STR= "拼团";
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.constants;
|
||||
|
||||
/**
|
||||
* 短信配置常量类
|
||||
* 短信常量类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -13,112 +13,103 @@ 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_PAY_NOTIFY_URI = "/api/sms/pay/notify";
|
||||
//验证码接口
|
||||
// public static final String SMS_API_CAPTCHA_URI = "sms/captcha";
|
||||
public static final String SMS_API_CAPTCHA_URI = "user/code";
|
||||
//账号注册地址
|
||||
// public static final String SMS_API_REGISTER_URI = "sms/register";
|
||||
public static final String SMS_API_REGISTER_URI = "user/register";
|
||||
//公共短信模板列表
|
||||
public static final String SMS_API_PUBLIC_TEMP_URI = "sms/publictemp";
|
||||
//公共短信模板添加
|
||||
public static final String SMS_API_PUBLIC_TEMP_USE_URI = "sms/use";
|
||||
//获取账号信息
|
||||
// public static final String SMS_API_USER_INFO_URI = "sms/userinfo";
|
||||
public static final String SMS_API_USER_INFO_URI = "sms_v2/info";
|
||||
//支付套餐
|
||||
// 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";
|
||||
public static final String SMS_API_APPLY_TEMP_MESSAGE_URI = "sms_v2/apply";
|
||||
//短信模板列表
|
||||
// public static final String SMS_API_TEMP_LIST_URI = "sms/template";
|
||||
public static final String SMS_API_TEMP_LIST_URI = "sms_v2/temps";
|
||||
// 发送短信
|
||||
// public static final String SMS_API_SEND_URI = "sms/send";
|
||||
public static final String SMS_API_SEND_URI = "sms_v2/send";
|
||||
// 获取发送状态
|
||||
public static final String SMS_API_SEND_STATUS = "sms/status";
|
||||
// 用户登录地址
|
||||
public static final String SMS_API_USER_LOGIN = "user/login";
|
||||
// 短信用户开通服务
|
||||
public static final String SMS_API_USER_OPEN = "sms_v2/open";
|
||||
|
||||
//接口异常错误码
|
||||
/** 接口异常错误码 */
|
||||
public static final Integer SMS_ERROR_CODE = 400;
|
||||
|
||||
//短信发送队列key
|
||||
/** 短信发送队列key */
|
||||
public static final String SMS_SEND_KEY = "sms_send_list";
|
||||
// 发送短信后状态同步key
|
||||
public static final String SMS_SEND_RESULT_KEY = "sms_send_result_list";
|
||||
|
||||
// 短信模版配置开关常量
|
||||
public static final String SMS_CONFIG_VERIFICATION_CODE = "verificationCode";// 验证码
|
||||
public static final Integer SMS_CONFIG_VERIFICATION_CODE_TEMP_ID = 518076;//
|
||||
/** 手机验证码redis key */
|
||||
public static final String SMS_VALIDATE_PHONE = "sms_validate_code:";
|
||||
|
||||
public static final String SMS_CONFIG_LOWER_ORDER_SWITCH = "lowerOrderSwitch";// 支付成功短信提醒
|
||||
public static final Integer SMS_CONFIG_LOWER_ORDER_SWITCH_TEMP_ID = 520268;// 对应的模版id
|
||||
/**
|
||||
* ---------------------
|
||||
* 短信模版配置开关常量
|
||||
* ---------------------
|
||||
*/
|
||||
/** 验证码 */
|
||||
public static final String SMS_CONFIG_VERIFICATION_CODE = "verificationCode";
|
||||
// public static final Integer SMS_CONFIG_VERIFICATION_CODE_TEMP_ID = 518076;
|
||||
/** 验证码模板ID */
|
||||
public static final Integer SMS_CONFIG_VERIFICATION_CODE_TEMP_ID = 435250;
|
||||
|
||||
public static final String SMS_CONFIG_DELIVER_GOODS_SWITCH = "deliverGoodsSwitch";// 发货短信提醒
|
||||
// public static final Integer SMS_CONFIG_DELIVER_GOODS_SWITCH_TEMP_ID = 520269;
|
||||
/** 支付成功短信提醒 */
|
||||
public static final String SMS_CONFIG_LOWER_ORDER_SWITCH = "lowerOrderSwitch";
|
||||
/** 支付成功短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_LOWER_ORDER_SWITCH_TEMP_ID = 440396;
|
||||
|
||||
/** 发货短信提醒 */
|
||||
public static final String SMS_CONFIG_DELIVER_GOODS_SWITCH = "deliverGoodsSwitch";
|
||||
/** 发货短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_DELIVER_GOODS_SWITCH_TEMP_ID = 441596;
|
||||
|
||||
public static final String SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH = "confirmTakeOverSwitch";// 确认收货短信提醒
|
||||
/** 确认收货短信提醒 */
|
||||
public static final String SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH = "confirmTakeOverSwitch";
|
||||
/** 确认收货短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID = 520271;
|
||||
|
||||
public static final String SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH = "adminLowerOrderSwitch";// 用户下单管理员短信提醒
|
||||
public static final Integer SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH_TEMP_ID = 520272;
|
||||
/** 用户下单管理员短信提醒 */
|
||||
public static final String SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH = "adminLowerOrderSwitch";
|
||||
/** 用户下单管理员短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH_TEMP_ID = 440405;
|
||||
|
||||
public static final String SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH = "adminPaySuccessSwitch";// 支付成功管理员短信提醒
|
||||
public static final Integer SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH_TEMP_ID = 520273;
|
||||
/** 支付成功管理员短信提醒 */
|
||||
public static final String SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH = "adminPaySuccessSwitch";
|
||||
/** 支付成功管理员短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH_TEMP_ID = 440406;
|
||||
|
||||
public static final String SMS_CONFIG_ADMIN_REFUND_SWITCH = "adminRefundSwitch";// 用户确认收货管理员短信提醒
|
||||
public static final Integer SMS_CONFIG_ADMIN_REFUND_SWITCH_TEMP_ID = 520422;
|
||||
/** 用户确认收货管理员短信提醒 */
|
||||
public static final String SMS_CONFIG_ADMIN_REFUND_SWITCH = "adminRefundSwitch";
|
||||
/** 用户确认收货管理员短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_ADMIN_REFUND_SWITCH_TEMP_ID = 440408;
|
||||
|
||||
public static final String SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH = "adminConfirmTakeOverSwitch";// 用户发起退款管理员短信提醒
|
||||
public static final Integer SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID = 520274;
|
||||
/** 用户发起退款管理员短信提醒 */
|
||||
public static final String SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH = "adminConfirmTakeOverSwitch";
|
||||
/** 用户发起退款管理员短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID = 440407;
|
||||
|
||||
public static final String SMS_CONFIG_PRICE_REVISION_SWITCH = "priceRevisionSwitch";// 改价短信提醒
|
||||
// public static final Integer SMS_CONFIG_PRICE_REVISION_SWITCH_TEMP_ID = 528288;
|
||||
/** 改价短信提醒 */
|
||||
public static final String SMS_CONFIG_PRICE_REVISION_SWITCH = "priceRevisionSwitch";
|
||||
/** 改价短信提醒模版ID */
|
||||
public static final Integer SMS_CONFIG_PRICE_REVISION_SWITCH_TEMP_ID = 440410;
|
||||
|
||||
public static final String SMS_CONFIG_ORDER_PAY_FALSE = "orderPayFalse";// 订单未支付
|
||||
/** 订单未支付 */
|
||||
public static final String SMS_CONFIG_ORDER_PAY_FALSE = "orderPayFalse";
|
||||
/** 订单未支付模版ID */
|
||||
public static final Integer SMS_CONFIG_ORDER_PAY_FALSE_TEMP_ID = 528116;
|
||||
|
||||
/**
|
||||
* 短信类型
|
||||
* 短信模版配置开关常量
|
||||
*/
|
||||
/** 验证码 */
|
||||
public static final int SMS_CONFIG_TYPE_VERIFICATION_CODE = 1;
|
||||
/** 支付成功短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_LOWER_ORDER_SWITCH = 2;
|
||||
/** 发货短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_DELIVER_GOODS_SWITCH = 3;
|
||||
/** 确认收货短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_CONFIRM_TAKE_OVER_SWITCH = 4;
|
||||
/** 用户下单管理员短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_LOWER_ORDER_SWITCH = 5;
|
||||
/** 支付成功管理员短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_PAY_SUCCESS_SWITCH = 6;
|
||||
/** 用户确认收货管理员短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_REFUND_SWITCH = 7;
|
||||
/** 用户发起退款管理员短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_CONFIRM_TAKE_OVER_SWITCH = 8;
|
||||
/** 改价短信提醒 */
|
||||
public static final int SMS_CONFIG_TYPE_PRICE_REVISION_SWITCH = 9;
|
||||
/** 订单未支付 */
|
||||
public static final int SMS_CONFIG_TYPE_ORDER_PAY_FALSE = 10;
|
||||
|
||||
//支付
|
||||
public static final String PAY_DEFAULT_PAY_TYPE = "weixin";
|
||||
|
||||
//手机验证码redis key
|
||||
public static final String SMS_VALIDATE_PHONE = "sms_validate_code_";
|
||||
|
||||
//短信类型
|
||||
// 短信模版配置开关常量
|
||||
public static final int SMS_CONFIG_TYPE_VERIFICATION_CODE = 1;// 验证码
|
||||
public static final int SMS_CONFIG_TYPE_LOWER_ORDER_SWITCH = 2;// 支付成功短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_DELIVER_GOODS_SWITCH = 3;// 发货短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_CONFIRM_TAKE_OVER_SWITCH = 4;// 确认收货短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_LOWER_ORDER_SWITCH = 5;// 用户下单管理员短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_PAY_SUCCESS_SWITCH = 6;// 支付成功管理员短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_REFUND_SWITCH = 7;// 用户确认收货管理员短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_ADMIN_CONFIRM_TAKE_OVER_SWITCH = 8;// 用户发起退款管理员短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_PRICE_REVISION_SWITCH = 9;// 改价短信提醒
|
||||
public static final int SMS_CONFIG_TYPE_ORDER_PAY_FALSE = 10;// 订单未支付
|
||||
|
||||
// 用户token的redis前缀 拼接secret
|
||||
public static final String SMS_USER_TOKEN_REDIS_PREFIX = "sms_user_token_{}";
|
||||
// 发送短信参数模板
|
||||
/** 发送短信参数模板 */
|
||||
public static final String SMS_COMMON_PARAM_FORMAT = "param[{}]";
|
||||
// 用户token前缀
|
||||
public static final String SMS_USER_TOKEN_PREFIX = "Bearer-";
|
||||
}
|
||||
// /** 用户token前缀 */
|
||||
// public static final String SMS_USER_TOKEN_PREFIX = "Bearer-";
|
||||
// /** 支付 */
|
||||
// public static final String PAY_DEFAULT_PAY_TYPE = "weixin";
|
||||
// /** 用户token的redis前缀 拼接secret */
|
||||
// public static final String SMS_USER_TOKEN_REDIS_PREFIX = "sms_user_token_{}";
|
||||
}
|
||||
|
||||
25
crmeb/src/main/java/com/constants/SysConfigConstants.java
Normal file
25
crmeb/src/main/java/com/constants/SysConfigConstants.java
Normal file
@@ -0,0 +1,25 @@
|
||||
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 SysConfigConstants {
|
||||
|
||||
//后台首页登录图片
|
||||
/** 登录页LOGO */
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_LOGO_LEFT_TOP = "site_logo_lefttop";
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_LOGO_LOGIN = "site_logo_login";
|
||||
/** 登录页背景图 */
|
||||
public static final String CONFIG_KEY_ADMIN_LOGIN_BACKGROUND_IMAGE = "admin_login_bg_pic";
|
||||
|
||||
|
||||
}
|
||||
56
crmeb/src/main/java/com/constants/SysGroupDataConstants.java
Normal file
56
crmeb/src/main/java/com/constants/SysGroupDataConstants.java
Normal file
@@ -0,0 +1,56 @@
|
||||
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 SysGroupDataConstants {
|
||||
|
||||
/** 中部推荐banner图 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_BEST_BANNER = 37;
|
||||
/** 首页banner滚动图 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_BANNER = 48;
|
||||
/** 首页精品推荐Banner图片 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_RECOMMEND_BANNER = 52;
|
||||
/** 订单详情状态图 */
|
||||
public static final Integer GROUP_DATA_ID_ORDER_STATUS_PIC = 53;
|
||||
/** 个人中心菜单 */
|
||||
public static final Integer GROUP_DATA_ID_USER_CENTER_MENU = 54;
|
||||
/** 签到配置 */
|
||||
public static final Integer GROUP_DATA_ID_SIGN = 55;
|
||||
/** 热门搜索 */
|
||||
public static final Integer GROUP_DATA_ID_HOT_SEARCH = 56;
|
||||
/** 热门榜单推荐Banner图片 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_HOT_BANNER = 57;
|
||||
/** 首发新品推荐Banner图片 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_NEW_BANNER = 58;
|
||||
/** 首页促销单品推荐Banner图片 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_BENEFIT_BANNER = 59;
|
||||
/** 推广海报图 */
|
||||
public static final Integer GROUP_DATA_ID_SPREAD_BANNER_LIST = 60;
|
||||
/** 充值金额设置 */
|
||||
public static final Integer GROUP_DATA_ID_RECHARGE_LIST = 62;
|
||||
/** 个人中心轮播图 */
|
||||
public static final Integer GROUP_DATA_ID_USER_CENTER_BANNER = 65;
|
||||
/** 导航模块 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_MENU = 67;
|
||||
/** 首页滚动新闻 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_NEWS_BANNER = 68;
|
||||
/** 首页活动区域图片 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_ACTIVITY_BANNER = 69;
|
||||
/** 首页超值爆款 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_EX_BANNER = 70;
|
||||
/** 热门搜索 */
|
||||
public static final Integer GROUP_DATA_ID_INDEX_KEYWORDS = 71;
|
||||
/** 后台登录页面轮播图 */
|
||||
public static final Integer GROUP_DATA_ID_ADMIN_LOGIN_BANNER_IMAGE_LIST = 72;
|
||||
|
||||
}
|
||||
35
crmeb/src/main/java/com/constants/UserConstants.java
Normal file
35
crmeb/src/main/java/com/constants/UserConstants.java
Normal file
@@ -0,0 +1,35 @@
|
||||
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 UserConstants {
|
||||
|
||||
/** 用户类型——H5 */
|
||||
public static final String USER_TYPE_H5 = "h5";
|
||||
/** 用户类型——公众号 */
|
||||
public static final String USER_TYPE_WECHAT = "wechat";
|
||||
/** 用户类型——小程序 */
|
||||
public static final String USER_TYPE_ROUTINE = "routine";
|
||||
|
||||
/**
|
||||
* =========================================================
|
||||
* UserToken部分
|
||||
* =========================================================
|
||||
*/
|
||||
/** 用户Token类型——公众号 */
|
||||
public static final Integer USER_TOKEN_TYPE_WECHAT = 1;
|
||||
/** 用户Token类型——小程序 */
|
||||
public static final Integer USER_TOKEN_TYPE_ROUTINE = 2;
|
||||
/** 用户Token类型——unionid */
|
||||
public static final Integer USER_TOKEN_TYPE_UNIONID = 3;
|
||||
}
|
||||
@@ -29,7 +29,8 @@ public class ResponseRouter {
|
||||
|
||||
|
||||
//根据需要处理返回值
|
||||
if(data.contains("image/") && !data.contains("data:image/png;base64")){
|
||||
// if(data.contains("image/") && !data.contains("data:image/png;base64")){
|
||||
if(data.contains("crmebimage/") && !data.contains("data:image/png;base64")){
|
||||
data = SpringUtil.getBean(SystemAttachmentService.class).prefixImage(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -603,6 +603,7 @@ public class CrmebUtil {
|
||||
|
||||
/**
|
||||
* 同比率计算 //同比增长率= ((当前周期 - 上一个周期) ÷ 上一个周期 ) *100%
|
||||
* 如果上个周期为0, = 当前周期 * 100%
|
||||
* @param b1 当前周期
|
||||
* @param b2 上一个周期
|
||||
* @author Mr.Zhang
|
||||
@@ -619,7 +620,7 @@ public class CrmebUtil {
|
||||
|
||||
if(b2.equals(BigDecimal.ZERO)){
|
||||
//b2是0
|
||||
return BigDecimal.TEN.multiply(BigDecimal.TEN).setScale(2, BigDecimal.ROUND_UP);
|
||||
return b1.setScale(2, BigDecimal.ROUND_UP);
|
||||
}
|
||||
|
||||
return (b1.subtract(b2)).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).divide(b2, BigDecimal.ROUND_UP);
|
||||
@@ -679,7 +680,7 @@ public class CrmebUtil {
|
||||
* @return 生成的随机码
|
||||
*/
|
||||
public static String getOrderNo(String payType){
|
||||
return getOrderNoPrefix(payType) + DateUtil.nowDate(Constants.DATE_TIME_FORMAT_NUM) + randomCount(11111, 99999);
|
||||
return payType + DateUtil.nowDate(Constants.DATE_TIME_FORMAT_NUM) + randomCount(11111, 99999);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,7 +99,8 @@ public class RequestUtil extends HttpServlet{
|
||||
public static String getUri(HttpServletRequest request){
|
||||
String uri = request.getRequestURI();
|
||||
List<String> list = CrmebUtil.stringToArrayStrRegex(uri, "/");
|
||||
list.removeIf(StringUtils::isNumeric);
|
||||
list.removeIf(StringUtils::isNumeric); //去掉url中的数字参数
|
||||
list.removeIf(c -> c.contains(","));// 去掉url中的逗号分隔参数
|
||||
return StringUtils.join(list, "/");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ 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.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -68,6 +69,17 @@ public class RestTemplateUtil {
|
||||
" (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
|
||||
") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
|
||||
|
||||
// /**
|
||||
// * 设置超时时间
|
||||
// */
|
||||
// public RestTemplateUtil() {
|
||||
// SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
// //30s
|
||||
// requestFactory.setConnectTimeout(30*1000);
|
||||
// requestFactory.setReadTimeout(30*1000);
|
||||
// restTemplate = new RestTemplate(requestFactory);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 发送GET请求
|
||||
* @param url
|
||||
@@ -436,6 +448,11 @@ public class RestTemplateUtil {
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity =
|
||||
new HttpEntity<>(params, headers);
|
||||
|
||||
// SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
// //30s
|
||||
// requestFactory.setConnectTimeout(30*1000);
|
||||
// requestFactory.setReadTimeout(30*1000);
|
||||
// restTemplate = new RestTemplate(requestFactory);
|
||||
return restTemplate.postForEntity(url, requestEntity, String.class).getBody();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.utils;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.zbkj.crmeb.upload.vo.FileResultVo;
|
||||
@@ -35,7 +36,8 @@ public class UploadUtil {
|
||||
|
||||
//类型
|
||||
// private static String imagePath = "/image";
|
||||
private static String type = "/image";
|
||||
// private static String type = "/image";
|
||||
private static String type = "/crmebimage";
|
||||
|
||||
|
||||
//模块
|
||||
@@ -260,12 +262,17 @@ public class UploadUtil {
|
||||
}
|
||||
// 文件名
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
System.out.println("fileName = " + fileName);
|
||||
// 文件后缀名
|
||||
String extName = FilenameUtils.getExtension(fileName);
|
||||
if (StringUtils.isEmpty(extName)) {
|
||||
throw new RuntimeException("文件类型未定义不能上传...");
|
||||
}
|
||||
|
||||
if (fileName.length() > 99) {
|
||||
fileName = StrUtil.subPre(fileName, 90).concat(".").concat(extName);
|
||||
}
|
||||
|
||||
//文件大小验证
|
||||
checkSize(multipartFile.getSize());
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/article")
|
||||
@Api(tags = "文章管理")
|
||||
|
||||
public class ArticleController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -3,6 +3,8 @@ 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.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
@@ -18,16 +20,20 @@ import com.zbkj.crmeb.article.service.ArticleService;
|
||||
import com.zbkj.crmeb.article.vo.ArticleVo;
|
||||
import com.zbkj.crmeb.category.model.Category;
|
||||
import com.zbkj.crmeb.category.service.CategoryService;
|
||||
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.annotation.Resource;
|
||||
import java.io.Console;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.constants.Constants.ARTICLE_BANNER_LIMIT;
|
||||
|
||||
/**
|
||||
* ArticleServiceImpl 接口实现
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -49,7 +55,8 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
/**
|
||||
* 列表
|
||||
* @param request ArticleSearchRequest 请求参数
|
||||
@@ -62,7 +69,7 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
public PageInfo<ArticleVo> getList(ArticleSearchRequest request, PageParamRequest pageParamRequest) {
|
||||
Page<Article> articlePage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
|
||||
LambdaQueryWrapper<Article> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<Article> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
|
||||
if(StringUtils.isNotBlank(request.getCid())){
|
||||
lambdaQueryWrapper.eq(Article::getCid, request.getCid());
|
||||
@@ -104,6 +111,9 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
if(articleList.size() < 1){
|
||||
return CommonPage.copyPageInfo(articlePage, articleVoArrayList);
|
||||
}
|
||||
// 根据配置控制banner的数量
|
||||
String articleBannerLimitString = systemConfigService.getValueByKey(ARTICLE_BANNER_LIMIT);
|
||||
int articleBannerLimit = Integer.parseInt(articleBannerLimitString);
|
||||
|
||||
for (Article article : articleList) {
|
||||
ArticleVo articleVo = new ArticleVo();
|
||||
@@ -113,6 +123,9 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleDao, Article> impleme
|
||||
articleVo.setImageInputs(article.getImageInput());
|
||||
}
|
||||
articleVoArrayList.add(articleVo);
|
||||
if(articleVoArrayList.size() >= articleBannerLimit){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CommonPage.copyPageInfo(articlePage, articleVoArrayList);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.zbkj.crmeb.authorization.controller;
|
||||
|
||||
import com.common.CheckAdminToken;
|
||||
import com.common.CommonResult;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.zbkj.crmeb.system.request.SystemAdminLoginRequest;
|
||||
import com.zbkj.crmeb.system.response.SystemAdminResponse;
|
||||
import com.zbkj.crmeb.system.service.SystemAdminService;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Admin 平台用户
|
||||
* +----------------------------------------------------------------------
|
||||
* | 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")
|
||||
@Api(tags = "Admin 平台用户")
|
||||
public class AdminUserController {
|
||||
|
||||
@Autowired
|
||||
private SystemAdminService systemAdminService;
|
||||
|
||||
@Autowired
|
||||
private CheckAdminToken checkAdminToken;
|
||||
|
||||
@ApiOperation(value="PC登录")
|
||||
@PostMapping(value = "/login", produces = "application/json")
|
||||
public CommonResult<SystemAdminResponse> SystemAdminLogin(@RequestBody @Validated SystemAdminLoginRequest systemAdminLoginRequest, HttpServletRequest request) throws Exception {
|
||||
String ip = CrmebUtil.getClientIp(request);
|
||||
SystemAdminResponse systemAdminResponse = systemAdminService.login(systemAdminLoginRequest, ip);
|
||||
// if(StringUtils.isNotBlank(systemAdminLoginRequest.getWxCode())){
|
||||
// systemAdminService.bind(systemAdminLoginRequest.getWxCode(), systemAdminResponse.getId());
|
||||
// }
|
||||
return CommonResult.success(systemAdminResponse, "login success");
|
||||
}
|
||||
|
||||
@ApiOperation(value="PC登出")
|
||||
@GetMapping(value = "/logout")
|
||||
public CommonResult<SystemAdminResponse> SystemAdminLogout(HttpServletRequest request) throws Exception {
|
||||
String token = checkAdminToken.getTokenFormRequest(request);
|
||||
systemAdminService.logout(token);
|
||||
return CommonResult.success("logout success");
|
||||
}
|
||||
|
||||
@ApiOperation(value="获取用户详情")
|
||||
@GetMapping(value = "/getAdminInfoByToken")
|
||||
public CommonResult<SystemAdminResponse> getAdminInfo(HttpServletRequest request) throws Exception{
|
||||
String token = checkAdminToken.getTokenFormRequest(request);
|
||||
SystemAdminResponse systemAdminResponse = systemAdminService.getInfoByToken(token);
|
||||
|
||||
return CommonResult.success(systemAdminResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录页图片
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@ApiOperation(value = "获取登录页图片")
|
||||
@RequestMapping(value = "/getLoginPic", method = RequestMethod.GET)
|
||||
public CommonResult<Map<String, Object>> getLoginPic(){
|
||||
return CommonResult.success(systemAdminService.getLoginPic());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 微信登录公共号授权登录
|
||||
// * @author Mr.Zhang
|
||||
// * @since 2020-05-25
|
||||
// */
|
||||
// @ApiOperation(value = "微信登录公共号授权登录")
|
||||
// @RequestMapping(value = "/authorize/login", method = RequestMethod.GET)
|
||||
// public CommonResult<SystemAdminResponse> login(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
|
||||
// return CommonResult.success(systemAdminService.weChatAuthorizeLogin(code, CrmebUtil.getClientIp(request)));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 解绑微信
|
||||
// * @author Mr.Zhang
|
||||
// * @since 2020-05-25
|
||||
// */
|
||||
// @ApiOperation(value = "解绑微信")
|
||||
// @RequestMapping(value = "/unbind", method = RequestMethod.GET)
|
||||
// public CommonResult<Boolean> bind(){
|
||||
// return CommonResult.success(systemAdminService.unBind());
|
||||
// }
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
package com.zbkj.crmeb.authorization.controller;
|
||||
|
||||
import com.common.CheckAdminToken;
|
||||
import com.common.CommonResult;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.exception.ExceptionCodeEnum;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.zbkj.crmeb.system.request.SystemAdminLoginRequest;
|
||||
import com.zbkj.crmeb.system.request.SystemAdminRequest;
|
||||
import com.zbkj.crmeb.system.response.SystemAdminResponse;
|
||||
import com.zbkj.crmeb.system.response.SystemGroupDataAdminLoginBannerResponse;
|
||||
import com.zbkj.crmeb.system.service.SystemAdminService;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import com.zbkj.crmeb.system.service.SystemGroupDataService;
|
||||
import com.zbkj.crmeb.validatecode.model.ValidateCode;
|
||||
import com.zbkj.crmeb.validatecode.service.ValidateCodeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Admin 平台用户
|
||||
* +----------------------------------------------------------------------
|
||||
* | 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")
|
||||
@Api(tags = "Admin 平台用户")
|
||||
public class adminUser {
|
||||
|
||||
@Autowired
|
||||
private SystemAdminService systemAdminService;
|
||||
|
||||
@Autowired
|
||||
private CheckAdminToken checkAdminToken;
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Autowired
|
||||
private SystemGroupDataService systemGroupDataService;
|
||||
|
||||
@Autowired
|
||||
private ValidateCodeService validateCodeService;
|
||||
|
||||
@ApiOperation(value="AdminUserLogin")
|
||||
@PostMapping(value = "/login", produces = "application/json")
|
||||
public CommonResult<SystemAdminResponse> SystemAdminLogin(@RequestBody @Validated SystemAdminLoginRequest systemAdminLoginRequest, HttpServletRequest request) throws Exception {
|
||||
// 判断验证码
|
||||
ValidateCode validateCode = new ValidateCode(systemAdminLoginRequest.getKey(),systemAdminLoginRequest.getCode());
|
||||
boolean codeCheckResult = validateCodeService.check(validateCode);
|
||||
if(!codeCheckResult) throw new CrmebException("验证码不正确");
|
||||
// 执行登录
|
||||
SystemAdminRequest systemAdminRequest = new SystemAdminRequest();
|
||||
systemAdminRequest.setAccount(systemAdminLoginRequest.getAccount());
|
||||
systemAdminRequest.setPwd(systemAdminLoginRequest.getPwd());
|
||||
SystemAdminResponse systemAdminResponse = systemAdminService.login(systemAdminRequest, CrmebUtil.getClientIp(request));
|
||||
if(null == systemAdminResponse){
|
||||
return CommonResult.failed(ExceptionCodeEnum.FAILED, "login failed");
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(systemAdminLoginRequest.getWxCode())){
|
||||
systemAdminService.bind(systemAdminLoginRequest.getWxCode(), systemAdminResponse.getId());
|
||||
}
|
||||
return CommonResult.success(systemAdminResponse, "login success");
|
||||
}
|
||||
|
||||
@ApiOperation(value="AdminUserLogout")
|
||||
@GetMapping(value = "/logout")
|
||||
public CommonResult<SystemAdminResponse> SystemAdminLogout(HttpServletRequest request) throws Exception {
|
||||
String token = checkAdminToken.getTokenFormRequest(request);
|
||||
// TokenModel tokenModel = tokenManager.getToken(token);
|
||||
// if(StringUtils.isEmpty(tokenModel.getUserNo())){
|
||||
// throw new CrmebException("");
|
||||
// }
|
||||
systemAdminService.logout(token);
|
||||
return CommonResult.success("logout success");
|
||||
}
|
||||
|
||||
@ApiOperation(value="GetAdminUserByToken")
|
||||
@GetMapping(value = "/getAdminInfoByToken")
|
||||
public CommonResult<SystemAdminResponse> getAdminInfo(HttpServletRequest request) throws Exception{
|
||||
String token = checkAdminToken.getTokenFormRequest(request);
|
||||
SystemAdminResponse systemAdminResponse = systemAdminService.getInfoByToken(token);
|
||||
|
||||
return CommonResult.success(systemAdminResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录页图片
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@ApiOperation(value = "获取登录页图片")
|
||||
@RequestMapping(value = "/getLoginPic", method = RequestMethod.GET)
|
||||
public CommonResult<Map<String, Object>> getLoginPic(){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//背景图
|
||||
map.put("backgroundImage", systemConfigService.getValueByKey(Constants.CONFIG_KEY_ADMIN_LOGIN_BACKGROUND_IMAGE));
|
||||
//logo
|
||||
map.put("logo", systemConfigService.getValueByKey(Constants.CONFIG_KEY_ADMIN_LOGIN_LOGO));
|
||||
//轮播图
|
||||
List<SystemGroupDataAdminLoginBannerResponse> bannerList = systemGroupDataService.getListByGid(Constants.GROUP_DATA_ID_ADMIN_LOGIN_BANNER_IMAGE_LIST, SystemGroupDataAdminLoginBannerResponse.class);
|
||||
map.put("banner", bannerList);
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信登录公共号授权登录
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-25
|
||||
*/
|
||||
@ApiOperation(value = "微信登录公共号授权登录")
|
||||
@RequestMapping(value = "/authorize/login", method = RequestMethod.GET)
|
||||
public CommonResult<SystemAdminResponse> login(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
|
||||
return CommonResult.success(systemAdminService.weChatAuthorizeLogin(code, CrmebUtil.getClientIp(request)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑微信
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-25
|
||||
*/
|
||||
@ApiOperation(value = "解绑微信")
|
||||
@RequestMapping(value = "/unbind", method = RequestMethod.GET)
|
||||
public CommonResult<Boolean> bind(){
|
||||
return CommonResult.success(systemAdminService.unBind());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.zbkj.crmeb.authorization.manager;
|
||||
|
||||
import cn.hutool.Hutool;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.common.CheckAdminToken;
|
||||
import com.common.CommonResult;
|
||||
@@ -16,10 +15,8 @@ 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;
|
||||
|
||||
@@ -21,14 +21,15 @@ import java.util.Locale;
|
||||
*/
|
||||
@Data
|
||||
public class TokenModel implements Serializable {
|
||||
private static final long serialVersionUID = 4903514237492573024L;
|
||||
// 加密后的token key
|
||||
public static final String TOKEN_KEY = "TOKEN";
|
||||
// Redis 存储的key
|
||||
public static final String TOKEN_REDIS = "TOKEN_ADMIN_";
|
||||
public static final String TOKEN_REDIS = "TOKEN:ADMIN:";
|
||||
// 用户号
|
||||
private String userNo;
|
||||
private Integer userId;
|
||||
private String Token;
|
||||
private String token;
|
||||
// 最后访问时间
|
||||
private long lastAccessedTime = System.currentTimeMillis();
|
||||
// 过期时间
|
||||
@@ -43,12 +44,12 @@ public class TokenModel implements Serializable {
|
||||
private SystemAdmin systemAdmin;
|
||||
|
||||
public String getAuthorization() throws Exception {
|
||||
return CrmebUtil.encryptPassword(userNo+"_"+Token, TOKEN_KEY);
|
||||
return CrmebUtil.encryptPassword(userNo+"_"+ token, TOKEN_KEY);
|
||||
}
|
||||
|
||||
public TokenModel(String userno, String token){
|
||||
this.userNo = userno;
|
||||
this.Token = token;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public TokenModel() {
|
||||
|
||||
@@ -12,7 +12,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.BargainConstants;
|
||||
import com.constants.Constants;
|
||||
import com.constants.ProductConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -158,7 +160,8 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
//砍价参与人数
|
||||
Integer countPeopleAll = bargainUserList.size();
|
||||
//砍价成功人数
|
||||
Long countPeopleSuccess = bargainUserList.stream().filter(o -> o.getStatus().equals(3)).count();
|
||||
Long countPeopleSuccess = bargainUserList.stream()
|
||||
.filter(o -> o.getStatus().equals(BargainConstants.BARGAIN_USER_STATUS_SUCCESS)).count();
|
||||
//帮忙砍价人数
|
||||
Long countPeopleHelp = storeBargainUserHelpService.getHelpCountByBargainId(storeBargain.getId());
|
||||
storeBargainResponse.setCountPeopleAll(countPeopleAll.longValue());
|
||||
@@ -231,14 +234,15 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
// 处理商品属性,给砍价商品一份单规格默认属性
|
||||
StoreProductAttr singleAttr = new StoreProductAttr();
|
||||
singleAttr.setProductId(bargain.getId()).setAttrName("规格").setAttrValues("默认").setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
singleAttr.setProductId(bargain.getId()).setAttrName(ProductConstants.SINGLE_ATTR_NAME)
|
||||
.setAttrValues(ProductConstants.SINGLE_ATTR_VALUE).setType(ProductConstants.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.setProductId(bargain.getId()).setType(ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
singleAttrValue.setImage(systemAttachmentService.clearPrefix(singleAttrValue.getImage()));
|
||||
boolean saveAttrValue = attrValueService.save(singleAttrValue);
|
||||
if(!saveAttrValue) throw new CrmebException("新增属性详情失败");
|
||||
@@ -248,15 +252,15 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
0,
|
||||
bargain.getId(),
|
||||
systemAttachmentService.clearPrefix(JSON.toJSONString(request.getAttrValue())),
|
||||
DateUtil.getNowTime(),Constants.PRODUCT_TYPE_BARGAIN);
|
||||
DateUtil.getNowTime(),ProductConstants.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);
|
||||
? systemAttachmentService.clearPrefix(request.getContent()) : "" , ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductDescriptionService.deleteByProductId(spd.getProductId(), ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
boolean saveDesc = storeProductDescriptionService.save(spd);
|
||||
if (!saveDesc) throw new CrmebException("新增商品富文本失败");
|
||||
|
||||
@@ -303,21 +307,21 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
}
|
||||
|
||||
// 砍价商品属性attr不用变化,attrValue删除原有的替换为现有的
|
||||
attrValueService.removeByProductId(request.getId(), Constants.PRODUCT_TYPE_BARGAIN);
|
||||
attrValueService.removeByProductId(request.getId(), ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
StoreProductAttrValue singleAttrValue = new StoreProductAttrValue();
|
||||
BeanUtils.copyProperties(attrValueRequest, singleAttrValue);
|
||||
singleAttrValue.setProductId(bargain.getId()).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
singleAttrValue.setProductId(bargain.getId()).setType(ProductConstants.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);
|
||||
storeProductAttrResultService.deleteByProductId(bargain.getId(),ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
StoreProductAttrResult attrResult = new StoreProductAttrResult(
|
||||
0,
|
||||
bargain.getId(),
|
||||
systemAttachmentService.clearPrefix(JSON.toJSONString(request.getAttrValue())),
|
||||
DateUtil.getNowTime(),Constants.PRODUCT_TYPE_BARGAIN);
|
||||
DateUtil.getNowTime(),ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductAttrResultService.save(attrResult);
|
||||
|
||||
return saveCount > 0;
|
||||
@@ -325,9 +329,9 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
/**
|
||||
* 更新砍价商品状态
|
||||
* @param id
|
||||
* @param status
|
||||
* @return
|
||||
* @param id 砍价商品id
|
||||
* @param status 砍价商品状态
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean updateBargainStatus(Integer id, boolean status) {
|
||||
@@ -365,7 +369,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
// 查询attr
|
||||
StoreProductAttr spaPram = new StoreProductAttr();
|
||||
spaPram.setProductId(storeBargain.getProductId() ).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
spaPram.setProductId(storeBargain.getProductId() ).setType(ProductConstants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttr> attrs = attrService.getByEntity(spaPram);
|
||||
storeProductResponse.setAttr(attrs);
|
||||
storeProductResponse.setSliderImage(String.join(",",storeBargain.getImages()));
|
||||
@@ -378,15 +382,15 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
// 注意:数据瓶装步骤:分别查询砍价和商品本身信息组装sku信息之后,再对比sku属性是否相等来赋值是否砍价sku信息
|
||||
StoreProductAttrValue spavPramBargain = new StoreProductAttrValue();
|
||||
spavPramBargain.setProductId(bargainId).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
spavPramBargain.setProductId(bargainId).setType(ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesBargain = attrValueService.getByEntity(spavPramBargain);
|
||||
List<HashMap<String, Object>> attrValuesBargain = genratorSkuInfo(bargainId, specType, storeBargain, storeProductAttrValuesBargain, Constants.PRODUCT_TYPE_BARGAIN);
|
||||
List<HashMap<String, Object>> attrValuesBargain = genratorSkuInfo(bargainId, specType, storeBargain, storeProductAttrValuesBargain, ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
|
||||
// 查询attrValue
|
||||
StoreProductAttrValue spavPramProduct = new StoreProductAttrValue();
|
||||
spavPramProduct.setProductId(storeBargain.getProductId()).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
spavPramProduct.setProductId(storeBargain.getProductId()).setType(ProductConstants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesProduct = attrValueService.getByEntity(spavPramProduct);
|
||||
List<HashMap<String, Object>> attrValuesProduct = genratorSkuInfo(storeBargain.getProductId(), specType, storeBargain, storeProductAttrValuesProduct, Constants.PRODUCT_TYPE_NORMAL);
|
||||
List<HashMap<String, Object>> attrValuesProduct = genratorSkuInfo(storeBargain.getProductId(), specType, storeBargain, storeProductAttrValuesProduct, ProductConstants.PRODUCT_TYPE_NORMAL);
|
||||
|
||||
// H5 端用于生成skuList
|
||||
List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
||||
@@ -423,7 +427,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
StoreProductDescription sd = storeProductDescriptionService.getOne(
|
||||
new LambdaQueryWrapper<StoreProductDescription>()
|
||||
.eq(StoreProductDescription::getProductId, bargainId)
|
||||
.eq(StoreProductDescription::getType, Constants.PRODUCT_TYPE_BARGAIN));
|
||||
.eq(StoreProductDescription::getType, ProductConstants.PRODUCT_TYPE_BARGAIN));
|
||||
if(null != sd){
|
||||
storeProductResponse.setContent(StrUtil.isBlank(sd.getDescription()) ? "" : sd.getDescription());
|
||||
}
|
||||
@@ -470,7 +474,6 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
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;
|
||||
@@ -478,8 +481,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
/**
|
||||
* H5 砍价商品详情
|
||||
* @param id
|
||||
* @return
|
||||
* @param id 砍价商品id
|
||||
*/
|
||||
@Override
|
||||
public BargainDetailResponse getH5Detail(Integer id) {
|
||||
@@ -491,22 +493,22 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
storeProductResponse.setEndTime(storeBargain.getStopTime());
|
||||
|
||||
StoreProductAttr spaPram = new StoreProductAttr();
|
||||
spaPram.setProductId(id).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
spaPram.setProductId(id).setType(ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductResponse.setAttr(attrService.getByEntity(spaPram));
|
||||
|
||||
StoreProductAttrValue spavPramBargain = new StoreProductAttrValue();
|
||||
spavPramBargain.setProductId(id).setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
spavPramBargain.setProductId(id).setType(ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
List<StoreProductAttrValue> storeProductAttrValuesBargain = storeProductAttrValueService.getByEntity(spavPramBargain);
|
||||
|
||||
// 查询attr
|
||||
StoreProductAttr spaPramNormal = new StoreProductAttr();
|
||||
spaPramNormal.setProductId(storeBargain.getProductId() ).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
spaPramNormal.setProductId(storeBargain.getProductId() ).setType(ProductConstants.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);
|
||||
List<HashMap<String, Object>> attrValuesBargain = genratorSkuInfo(id, specType, storeBargain, storeProductAttrValuesBargain, ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
|
||||
// H5 端用于生成skuList
|
||||
List<StoreProductAttrValueResponse> sPAVResponses = new ArrayList<>();
|
||||
@@ -523,7 +525,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
StoreProductDescription sd = storeProductDescriptionService.getOne(
|
||||
new LambdaQueryWrapper<StoreProductDescription>()
|
||||
.eq(StoreProductDescription::getProductId, id)
|
||||
.eq(StoreProductDescription::getType, Constants.PRODUCT_TYPE_BARGAIN));
|
||||
.eq(StoreProductDescription::getType, ProductConstants.PRODUCT_TYPE_BARGAIN));
|
||||
if(null != sd){
|
||||
storeProductResponse.setContent(null == sd.getDescription()?"":sd.getDescription());
|
||||
}
|
||||
@@ -546,23 +548,14 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
/**
|
||||
* 用户砍价活动次数
|
||||
* @param storeBargain
|
||||
* @param uid
|
||||
* @param storeBargain 砍价商品
|
||||
* @param uid 用户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();
|
||||
@@ -572,13 +565,12 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
/**
|
||||
* 获取当前时间段的砍价商品
|
||||
* @param productId
|
||||
* @param productId 砍价商品id
|
||||
* @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);
|
||||
@@ -590,8 +582,8 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
|
||||
/**
|
||||
* 参与砍价商品活动
|
||||
* @param request
|
||||
* @return
|
||||
* @param request 请求参数
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean start(BargainFrontRequest request) {
|
||||
@@ -605,7 +597,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
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());
|
||||
List<StoreBargainUser> collect = historyList.stream().filter(i -> i.getStatus().equals(BargainConstants.BARGAIN_USER_STATUS_PARTICIPATE)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) throw new CrmebException("请先完成当前砍价活动");
|
||||
// 判断是否达到参与砍价活动上限
|
||||
if (historyList.size() >= storeBargain.getNum()) {
|
||||
@@ -620,14 +612,14 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
storeBargainUser.setBargainPrice(storeBargain.getPrice());
|
||||
storeBargainUser.setPrice(BigDecimal.ZERO);
|
||||
storeBargainUser.setAddTime(System.currentTimeMillis());
|
||||
storeBargainUser.setStatus(1);
|
||||
storeBargainUser.setStatus(BargainConstants.BARGAIN_USER_STATUS_PARTICIPATE);
|
||||
return storeBargainUserService.save(storeBargainUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价商品根据实体查询
|
||||
* @param storeBargainParam
|
||||
* @return
|
||||
* @param storeBargainParam 请求参数
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<StoreBargain> getByEntity(StoreBargain storeBargainParam) {
|
||||
@@ -650,7 +642,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
// 因为attrvalue表中unique使用Id代替,更新前先查询此表是否存在
|
||||
StoreProductAttrValue spavParm = new StoreProductAttrValue();
|
||||
spavParm.setProductId(bargainId);
|
||||
spavParm.setType(Constants.PRODUCT_TYPE_BARGAIN);
|
||||
spavParm.setType(ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
spavParm.setId(attrValueId);
|
||||
List<StoreProductAttrValue> attrvalues = storeProductAttrValueService.getByEntity(spavParm);
|
||||
if (CollUtil.isEmpty(attrvalues)) throw new CrmebException("未找到相关商品属性");
|
||||
@@ -658,7 +650,7 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
// 对应的主商品sku
|
||||
List<StoreProductAttrValue> currentProAttrValues = storeProductAttrValueService.getListByProductId(productId);
|
||||
List<StoreProductAttrValue> existAttrValues = currentProAttrValues.stream().filter(e ->
|
||||
e.getSuk().equals(bargaunAttrValue.getSuk()) && e.getType().equals(Constants.PRODUCT_TYPE_NORMAL))
|
||||
e.getSuk().equals(bargaunAttrValue.getSuk()) && e.getType().equals(ProductConstants.PRODUCT_TYPE_NORMAL))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(existAttrValues)) throw new CrmebException("未找到扣减库存的商品");
|
||||
// 砍价SKU 库存减,销量、限购总数减
|
||||
@@ -674,8 +666,8 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
if (ObjectUtil.isNull(storeBargainUser)) throw new CrmebException("砍价用户信息不存在");
|
||||
storeBargainUser.setStatus(3);
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
storeProductAttrValueService.decProductAttrStock(bargainId, attrValueId, num, Constants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductService.decProductStock(productId, num, existAttrValues.get(0).getId(), Constants.PRODUCT_TYPE_NORMAL);
|
||||
storeProductAttrValueService.decProductAttrStock(bargainId, attrValueId, num, ProductConstants.PRODUCT_TYPE_BARGAIN);
|
||||
storeProductService.decProductStock(productId, num, existAttrValues.get(0).getId(), ProductConstants.PRODUCT_TYPE_NORMAL);
|
||||
update(luw);
|
||||
storeBargainUserService.updateById(storeBargainUser);
|
||||
return Boolean.TRUE;
|
||||
@@ -743,14 +735,14 @@ public class StoreBargainServiceImpl extends ServiceImpl<StoreBargainDao, StoreB
|
||||
// 查询用户参与活动表中状态为进行中的数据
|
||||
StoreBargainUser spavBargainUser = new StoreBargainUser();
|
||||
spavBargainUser.setBargainId(bargain.getId());
|
||||
spavBargainUser.setStatus(1);
|
||||
spavBargainUser.setStatus(BargainConstants.BARGAIN_USER_STATUS_PARTICIPATE);
|
||||
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);
|
||||
bargainUsers.get(i).setStatus(BargainConstants.BARGAIN_USER_STATUS_FAIL);
|
||||
}
|
||||
bargainUserList.addAll(bargainUsers);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ 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.BargainConstants;
|
||||
import com.constants.Constants;
|
||||
import com.constants.UserConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -25,7 +27,9 @@ 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.model.UserToken;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.user.service.UserTokenService;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -68,6 +72,9 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
@Autowired
|
||||
private TemplateMessageService templateMessageService;
|
||||
|
||||
@Autowired
|
||||
private UserTokenService userTokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -145,7 +152,7 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
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);
|
||||
return new BargainCountResponse(ZERO, 0, bargainUser.getBargainPrice().subtract(bargainUser.getBargainPriceMin()), 0, BargainConstants.BARGAIN_USER_STATUS_PARTICIPATE, true, isConsume);
|
||||
}
|
||||
|
||||
// 已砍金额
|
||||
@@ -176,19 +183,6 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
} 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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +240,7 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
User user = userService.getInfo();
|
||||
|
||||
// 判断是否砍价成功
|
||||
if (storeBargainUser.getStatus() == 3 || storeBargainUser.getBargainPriceMin().compareTo(storeBargainUser.getBargainPrice().subtract(storeBargainUser.getPrice())) >= 0) {
|
||||
if (storeBargainUser.getStatus().equals(BargainConstants.BARGAIN_USER_STATUS_SUCCESS) || storeBargainUser.getBargainPriceMin().compareTo(storeBargainUser.getBargainPrice().subtract(storeBargainUser.getPrice())) >= 0) {
|
||||
throw new CrmebException("商品已完成砍价");
|
||||
}
|
||||
|
||||
@@ -302,22 +296,61 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
// 如果砍价完成,发送微信模板消息
|
||||
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, "感谢您的参与!");
|
||||
// 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);
|
||||
|
||||
templateMessageService.push(Constants.WE_CHAT_TEMP_KEY_BARGAIN_SUCCESS, temMap, storeBargainUser.getUid(), Constants.PAY_TYPE_WE_CHAT_FROM_PUBLIC);
|
||||
User tempUser = userService.getById(storeBargainUser.getUid());
|
||||
pushMessageOrder(storeBargain, tempUser);
|
||||
}
|
||||
|
||||
map.put("bargainPrice", bargainPrice);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息通知
|
||||
* @param storeBargain 砍价商品
|
||||
* @param user 发起砍价用户
|
||||
*/
|
||||
private void pushMessageOrder(StoreBargain storeBargain, User user) {
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_H5)) {
|
||||
return;
|
||||
}
|
||||
UserToken userToken;
|
||||
HashMap<String, String> temMap = new HashMap<>();
|
||||
// 公众号
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_WECHAT)) {
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_WECHAT);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 发送微信模板消息
|
||||
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.pushTemplateMessage(Constants.WE_CHAT_TEMP_KEY_BARGAIN_SUCCESS, temMap, userToken.getToken());
|
||||
return;
|
||||
}
|
||||
// 小程序发送订阅消息
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_ROUTINE);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 组装数据
|
||||
temMap.put("thing6", storeBargain.getTitle());
|
||||
temMap.put("amount3", storeBargain.getMinPrice().toString() + "元");
|
||||
temMap.put("thing7", "好腻害!你的朋友们已经帮你砍到底价了!");
|
||||
templateMessageService.pushMiniTemplateMessage(Constants.WE_CHAT_PROGRAM_TEMP_KEY_BARGAIN_SUCCESS, temMap, userToken.getToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpPeopleCount() {
|
||||
@@ -339,8 +372,7 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
|
||||
/**
|
||||
* 获取参与砍价人员数量
|
||||
* @param bargainId
|
||||
* @return
|
||||
* @param bargainId 砍价商品id
|
||||
*/
|
||||
@Override
|
||||
public Long getHelpPeopleCountByBargainId(Integer bargainId) {
|
||||
@@ -375,8 +407,7 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
|
||||
/**
|
||||
* 砍价发起用户信息
|
||||
* @param bargainFrontRequest
|
||||
* @return
|
||||
* @param bargainFrontRequest 砍价公共请求参数
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> startUser(BargainFrontRequest bargainFrontRequest) {
|
||||
@@ -427,7 +458,6 @@ public class StoreBargainUserHelpServiceImpl extends ServiceImpl<StoreBargainUse
|
||||
|
||||
/**
|
||||
* 获取帮助砍价用户的帮砍次数
|
||||
* @return
|
||||
*/
|
||||
private StoreBargainUserHelp getByUidAndBargainIdAndBargainUserId(Integer uid, Integer bargainId, Integer bargainUserId) {
|
||||
LambdaQueryWrapper<StoreBargainUserHelp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.BargainConstants;
|
||||
import com.constants.Constants;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -100,7 +101,7 @@ public class StoreBargainUserServiceImpl extends ServiceImpl<StoreBargainUserDao
|
||||
bargainUserResponse.setPeopleNum(storeBargain.getPeopleNum());
|
||||
// 剩余砍价次数
|
||||
Long helpCount = storeBargainUserHelpService.getHelpCountByBargainIdAndBargainUid(storeBargain.getId(), bargainUser.getId());
|
||||
bargainUserResponse.setNum(helpCount.intValue());
|
||||
bargainUserResponse.setNum(storeBargain.getPeopleNum() - helpCount.intValue());
|
||||
return bargainUserResponse;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@@ -165,7 +166,7 @@ public class StoreBargainUserServiceImpl extends ServiceImpl<StoreBargainUserDao
|
||||
lqw.eq(StoreBargainUser::getBargainId, bargainId);
|
||||
lqw.eq(StoreBargainUser::getUid, uid);
|
||||
lqw.eq(StoreBargainUser::getIsDel, false);
|
||||
lqw.eq(StoreBargainUser::getStatus, 1);
|
||||
lqw.eq(StoreBargainUser::getStatus, BargainConstants.BARGAIN_USER_STATUS_PARTICIPATE);
|
||||
lqw.orderByDesc(StoreBargainUser::getId);
|
||||
List<StoreBargainUser> userList = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
|
||||
@@ -66,23 +66,11 @@ import java.util.List;
|
||||
/**
|
||||
* 新增分类表
|
||||
* @param categoryRequest 新增参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
@ApiOperation(value = "新增")
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public CommonResult<String> save(@Validated CategoryRequest categoryRequest){
|
||||
Category category = new Category();
|
||||
|
||||
//检测标题是否存在
|
||||
if(categoryService.checkName(categoryRequest.getName(), category.getType()) > 0){
|
||||
throw new CrmebException("此分类已存在");
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(categoryRequest, category);
|
||||
category.setPath(categoryService.getPathByPId(category.getPid()));
|
||||
category.setExtra(systemAttachmentService.clearPrefix(category.getExtra()));
|
||||
if(categoryService.save(category)){
|
||||
if(categoryService.create(categoryRequest)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
|
||||
@@ -36,8 +36,6 @@ public interface CategoryService extends IService<Category> {
|
||||
|
||||
HashMap<Integer, String> getListInId(List<Integer> cateIdList);
|
||||
|
||||
void checkCategoryIsExist(List<Integer> categoryIdList);
|
||||
|
||||
Boolean checkAuth(List<Integer> pathIdList, String uri);
|
||||
|
||||
boolean update(CategoryRequest request, Integer id);
|
||||
@@ -49,4 +47,9 @@ public interface CategoryService extends IService<Category> {
|
||||
boolean checkUrl(String uri);
|
||||
|
||||
boolean updateStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 新增分类表
|
||||
*/
|
||||
Boolean create(CategoryRequest categoryRequest);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.crmeb.category.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.CategoryConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.utils.CrmebUtil;
|
||||
@@ -17,7 +19,9 @@ import com.zbkj.crmeb.category.request.CategoryRequest;
|
||||
import com.zbkj.crmeb.category.request.CategorySearchRequest;
|
||||
import com.zbkj.crmeb.category.service.CategoryService;
|
||||
import com.zbkj.crmeb.category.vo.CategoryTreeVo;
|
||||
import com.zbkj.crmeb.system.service.SystemAttachmentService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -25,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* CategoryServiceImpl 接口实现
|
||||
@@ -44,6 +49,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
@Resource
|
||||
private CategoryDao dao;
|
||||
|
||||
@Autowired
|
||||
private SystemAttachmentService systemAttachmentService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分类下子类的数量
|
||||
@@ -57,7 +65,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
public List<Category> getList(CategorySearchRequest request, PageParamRequest pageParamRequest) {
|
||||
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
LambdaQueryWrapper<Category> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// objectQueryWrapper.setEntity(category);
|
||||
if(null != request.getPid()){
|
||||
lambdaQueryWrapper.eq(Category::getPid, request.getPid());
|
||||
}
|
||||
@@ -65,7 +72,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
lambdaQueryWrapper.eq(Category::getType, request.getType());
|
||||
}
|
||||
if(ObjectUtil.isNotNull(request.getStatus()) && request.getStatus() >= 0){
|
||||
lambdaQueryWrapper.eq(Category::getStatus, request.getStatus().equals(1));
|
||||
lambdaQueryWrapper.eq(Category::getStatus, request.getStatus().equals(CategoryConstants.CATEGORY_STATUS_NORMAL));
|
||||
}
|
||||
if(null != request.getName()){
|
||||
lambdaQueryWrapper.like(Category::getName, request.getName());
|
||||
@@ -106,28 +113,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询分类id是否合法
|
||||
* @param categoryIdList List<Integer> id集合
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
@Override
|
||||
public void checkCategoryIsExist(List<Integer> categoryIdList) {
|
||||
//查询分类id是否合法
|
||||
HashMap<Integer, String> categoryServiceListInId = getListInId(categoryIdList);
|
||||
if(categoryServiceListInId.size() != categoryIdList.size()){
|
||||
for (Integer categoryId: categoryIdList) {
|
||||
String categoryName = CrmebUtil.getStrValueByIndex(categoryServiceListInId, categoryId);
|
||||
|
||||
if(categoryName.equals("")){
|
||||
//如果取出的分类名称是空, 那么有问题
|
||||
throw new CrmebException("ID是 " + categoryId + "的分类不存在,或者分类名称为空!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询id和url是否存在
|
||||
* @author Mr.Zhang
|
||||
@@ -213,7 +198,6 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
private int getChildCountByPid(Integer pid) {
|
||||
//查看是否有子类
|
||||
QueryWrapper<Category> objectQueryWrapper = new QueryWrapper<>();
|
||||
// objectQueryWrapper.eq("status", 1);
|
||||
objectQueryWrapper.like("path", "/"+pid+"/");
|
||||
return dao.selectCount(objectQueryWrapper);
|
||||
}
|
||||
@@ -297,10 +281,14 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
// 根据名称搜索特殊处理 这里仅仅处理两层搜索后有子父级关系的数据
|
||||
if(StringUtils.isNotBlank(name) && allTree.size() >0){
|
||||
List<Category> searchCategory = new ArrayList<>();
|
||||
for (Category category : allTree) {
|
||||
if(category.getPid() >0){
|
||||
searchCategory.add(dao.selectById(category.getPid()));
|
||||
}
|
||||
List<Integer> categoryIds = allTree.stream().map(Category::getId).collect(Collectors.toList());
|
||||
|
||||
List<Integer> pidList = allTree.stream().filter(c -> c.getPid() > 0 && !categoryIds.contains(c.getPid()))
|
||||
.map(Category::getPid).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(pidList)) {
|
||||
pidList.forEach(pid -> {
|
||||
searchCategory.add(dao.selectById(pid));
|
||||
});
|
||||
}
|
||||
allTree.addAll(searchCategory);
|
||||
}
|
||||
@@ -361,7 +349,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
public List<Category> getChildVoListByPid(Integer pid) {
|
||||
//查看是否有子类
|
||||
QueryWrapper<Category> objectQueryWrapper = new QueryWrapper<>();
|
||||
objectQueryWrapper.eq("status", 1);
|
||||
objectQueryWrapper.eq("status", CategoryConstants.CATEGORY_STATUS_NORMAL);
|
||||
objectQueryWrapper.like("path", "/"+pid+"/");
|
||||
return dao.selectList(objectQueryWrapper);
|
||||
}
|
||||
@@ -377,8 +365,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
@Override
|
||||
public int checkName(String name, Integer type) {
|
||||
LambdaQueryWrapper<Category> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(Category::getName, name)
|
||||
.eq(Category::getType, type);
|
||||
lambdaQueryWrapper.eq(Category::getName, name);
|
||||
if (ObjectUtil.isNotNull(type)) {
|
||||
lambdaQueryWrapper.eq(Category::getType, type);
|
||||
}
|
||||
return dao.selectCount(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -402,5 +392,22 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, Category> impl
|
||||
category.setStatus(!category.getStatus());
|
||||
return updateById(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分类
|
||||
* @param categoryRequest
|
||||
*/
|
||||
@Override
|
||||
public Boolean create(CategoryRequest categoryRequest) {
|
||||
//检测标题是否存在
|
||||
if(checkName(categoryRequest.getName(), null) > 0){
|
||||
throw new CrmebException("此分类已存在");
|
||||
}
|
||||
Category category = new Category();
|
||||
BeanUtils.copyProperties(categoryRequest, category);
|
||||
category.setPath(getPathByPId(category.getPid()));
|
||||
category.setExtra(systemAttachmentService.clearPrefix(category.getExtra()));
|
||||
return save(category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -155,9 +153,8 @@ public class StoreCombinationRequest implements Serializable {
|
||||
@Min(value = 1, message = "单次购买数量限制不能小于1")
|
||||
private Integer onceNum;
|
||||
|
||||
@ApiModelProperty(value = "虚拟成团百分比")
|
||||
@Min(value = 1, message = "虚拟成团百分比不能小于1")
|
||||
@Max(value = 100, message = "虚拟成团百分比不能大于100")
|
||||
@ApiModelProperty(value = "虚拟成团数量")
|
||||
@Min(value = 0, message = "虚拟成团数量不能小于0")
|
||||
private Integer virtualRation;
|
||||
|
||||
@ApiModelProperty(value = "商品属性")
|
||||
|
||||
@@ -78,4 +78,11 @@ public interface StorePinkService extends IService<StorePink> {
|
||||
* @return
|
||||
*/
|
||||
boolean pinkSuccess(Integer kid);
|
||||
|
||||
/**
|
||||
* 根据订单编号获取
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
StorePink getByOrderId(String orderId);
|
||||
}
|
||||
@@ -432,7 +432,10 @@ public class StoreCombinationServiceImpl extends ServiceImpl<StoreCombinationDao
|
||||
storeProductResponse.setSliderImage(String.join(",",storeCombination.getImages()));
|
||||
|
||||
boolean specType = false;
|
||||
if (attrs.size() > 1) {
|
||||
StoreProductAttr proPram = new StoreProductAttr();
|
||||
spaPram.setProductId(id).setType(Constants.PRODUCT_TYPE_NORMAL);
|
||||
List<StoreProductAttr> proAttrs = storeProductAttrService.getByEntity(proPram);
|
||||
if (proAttrs.size() > 1) {
|
||||
specType = true;
|
||||
}
|
||||
storeProductResponse.setSpecType(specType);
|
||||
@@ -860,15 +863,16 @@ public class StoreCombinationServiceImpl extends ServiceImpl<StoreCombinationDao
|
||||
public Boolean removePink(StorePinkRequest storePinkRequest) {
|
||||
StorePink userPink = storePinkService.getById(storePinkRequest.getId());
|
||||
if (ObjectUtil.isNull(userPink)) throw new CrmebException("未查到拼团信息,无法取消");
|
||||
if (userPink.getIsRefund()) throw new CrmebException("拼团已取消");
|
||||
if (userPink.getIsRefund()) throw new CrmebException("拼团订单已退款");
|
||||
// 获取是否拼团成功
|
||||
if (userPink.getStatus() == 2) {
|
||||
throw new CrmebException("拼团已完成,无法取消");
|
||||
}
|
||||
Integer count = storePinkService.getCountByKid(userPink.getKId());
|
||||
Integer kid = userPink.getKId() > 0 ? userPink.getKId() : userPink.getId();
|
||||
Integer count = storePinkService.getCountByKid(kid);
|
||||
if (count.equals(userPink.getPeople())) {
|
||||
// 拼团完成操作
|
||||
storePinkService.pinkSuccess(userPink.getId());
|
||||
storePinkService.pinkSuccess(kid);
|
||||
throw new CrmebException("拼团已完成,无法取消");
|
||||
}
|
||||
if (userPink.getStatus() == 3) {
|
||||
@@ -884,6 +888,7 @@ public class StoreCombinationServiceImpl extends ServiceImpl<StoreCombinationDao
|
||||
// 订单申请退款
|
||||
OrderRefundApplyRequest refundRequest = new OrderRefundApplyRequest();
|
||||
refundRequest.setId(order.getId());
|
||||
refundRequest.setUni(order.getOrderId());
|
||||
refundRequest.setText("拼团订单取消,申请退款");
|
||||
refundRequest.setExplain("用户取消拼团订单,申请退款");
|
||||
boolean apply = orderService.refundApply(refundRequest);
|
||||
|
||||
@@ -7,8 +7,10 @@ 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.MyRecord;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.constants.UserConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -27,7 +29,10 @@ 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.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserToken;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.user.service.UserTokenService;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -72,6 +77,9 @@ public class StorePinkServiceImpl extends ServiceImpl<StorePinkDao, StorePink> i
|
||||
@Autowired
|
||||
private TemplateMessageService templateMessageService;
|
||||
|
||||
@Autowired
|
||||
private UserTokenService userTokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -207,26 +215,20 @@ public class StorePinkServiceImpl extends ServiceImpl<StorePinkDao, StorePink> i
|
||||
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;
|
||||
}
|
||||
memberList.add(headPink);
|
||||
if (headPink.getPeople().equals(memberList.size())) {
|
||||
memberList.forEach(i -> i.setStatus(2));
|
||||
pinkSuccessList.addAll(memberList);
|
||||
continue;
|
||||
}
|
||||
// 计算虚拟比例,判断是否拼团成功
|
||||
StoreCombination storeCombination = storeCombinationService.getById(headPink.getCid());
|
||||
Integer virtual = storeCombination.getVirtualRation();// 虚拟成团比例
|
||||
if (headPink.getPeople() <= memberList.size() + virtual) {
|
||||
// 可以虚拟成团
|
||||
memberList.forEach(i -> i.setStatus(2).setIs_virtual(true));
|
||||
pinkSuccessList.addAll(memberList);
|
||||
continue;
|
||||
}
|
||||
// 失败
|
||||
headPink.setStatus(3);
|
||||
@@ -266,18 +268,61 @@ public class StorePinkServiceImpl extends ServiceImpl<StorePinkDao, StorePink> i
|
||||
pinkSuccessList.forEach(i -> {
|
||||
StoreOrder storeOrder = storeOrderService.getByOderId(i.getOrderId());
|
||||
StoreCombination storeCombination = storeCombinationService.getById(i.getCid());
|
||||
User tempUser = userService.getById(i.getUid());
|
||||
// 发送微信模板消息
|
||||
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);
|
||||
MyRecord record = new MyRecord();
|
||||
record.set("orderNo", storeOrder.getOrderId());
|
||||
record.set("proName", storeCombination.getTitle());
|
||||
pushMessageOrder(record, tempUser);
|
||||
// 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 record 参数
|
||||
* @param user 拼团用户
|
||||
*/
|
||||
private void pushMessageOrder(MyRecord record, User user) {
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_H5)) {
|
||||
return;
|
||||
}
|
||||
UserToken userToken;
|
||||
HashMap<String, String> temMap = new HashMap<>();
|
||||
// 公众号
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_WECHAT)) {
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_WECHAT);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 发送微信模板消息
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_FIRST, "恭喜您拼团成功!我们将尽快为您发货。");
|
||||
temMap.put("keyword1", record.getStr("orderNo"));
|
||||
temMap.put("keyword2", record.getStr("proName"));
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_END, "感谢你的使用!");
|
||||
templateMessageService.pushTemplateMessage(Constants.WE_CHAT_TEMP_KEY_COMBINATION_SUCCESS, temMap, userToken.getToken());
|
||||
return;
|
||||
}
|
||||
// 小程序发送订阅消息
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_ROUTINE);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 组装数据
|
||||
temMap.put("character_string1", record.getStr("orderNo"));
|
||||
temMap.put("thing2", record.getStr("proName"));
|
||||
temMap.put("thing5", "恭喜您拼团成功!我们将尽快为您发货。");
|
||||
templateMessageService.pushMiniTemplateMessage(Constants.WE_CHAT_PROGRAM_TEMP_KEY_COMBINATION_SUCCESS, temMap, userToken.getToken());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
* @param kid
|
||||
@@ -299,6 +344,18 @@ public class StorePinkServiceImpl extends ServiceImpl<StorePinkDao, StorePink> i
|
||||
return updateBatchById(memberList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单编号获取
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StorePink getByOrderId(String orderId) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(StorePink::getOrderId, orderId);
|
||||
return dao.selectOne(lqw);
|
||||
}
|
||||
|
||||
private Integer getCountByKidAndCid(Integer cid, Integer kid) {
|
||||
LambdaQueryWrapper<StorePink> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.select(StorePink::getId);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递公司表
|
||||
* </p>
|
||||
*
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_express")
|
||||
@ApiModel(value="ExpressRequest对象", description="快递公司")
|
||||
public class ExpressRequest 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;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.crmeb.express.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.common.PageParamRequest;
|
||||
import com.exception.CrmebException;
|
||||
@@ -140,7 +141,7 @@ public class ShippingTemplatesServiceImpl extends ServiceImpl<ShippingTemplatesD
|
||||
shippingTemplatesRegionService.saveAll(shippingTemplatesRegionRequestList, request.getType(), shippingTemplates.getId());
|
||||
|
||||
List<ShippingTemplatesFreeRequest> shippingTemplatesFreeRequestList = request.getShippingTemplatesFreeRequestList();
|
||||
if(shippingTemplatesFreeRequestList.size() > 0 && request.getAppoint()){
|
||||
if(CollUtil.isNotEmpty(shippingTemplatesFreeRequestList) && request.getAppoint()){
|
||||
shippingTemplatesFreeService.saveAll(shippingTemplatesFreeRequestList, request.getType(), shippingTemplates.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,14 @@ 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.FundsMonitorRequest;
|
||||
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.model.UserBrokerageRecord;
|
||||
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;
|
||||
@@ -59,8 +55,8 @@ public class FundsMonitorController {
|
||||
*/
|
||||
@ApiOperation(value = "资金监控")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<UserBillResponse>> getList(@Validated FundsMonitorSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<UserBillResponse> userExtractCommonPage = CommonPage.restPage(userBillService.getListAdmin(request, pageParamRequest));
|
||||
public CommonResult<CommonPage<UserBillResponse>> getList(@Validated FundsMonitorRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
CommonPage<UserBillResponse> userExtractCommonPage = CommonPage.restPage(userBillService.fundMonitoring(request, pageParamRequest));
|
||||
return CommonResult.success(userExtractCommonPage);
|
||||
}
|
||||
|
||||
@@ -75,7 +71,7 @@ public class FundsMonitorController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页显示资金监控
|
||||
* 佣金记录
|
||||
* @param request 搜索条件
|
||||
* @param pageParamRequest 分页参数
|
||||
* @author Mr.Zhang
|
||||
@@ -91,18 +87,17 @@ public class FundsMonitorController {
|
||||
|
||||
/**
|
||||
* 佣金详细记录
|
||||
* @param request 查询基本参数
|
||||
* @param pageParamRequest 分页参数
|
||||
* @param userId 被查询的用户id
|
||||
* @return 佣金查询结果
|
||||
*/
|
||||
@ApiOperation(value = "佣金详细记录")
|
||||
@RequestMapping(value = "/list/user/detail/{userId}", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<UserBillResponse>> userDetail(UserBillDetailListRequest request,
|
||||
PageParamRequest pageParamRequest,
|
||||
@PathVariable Integer userId){
|
||||
CommonPage<UserBillResponse> ub = CommonPage.restPage(userBillService.getByBaseSearch(userId, request, pageParamRequest));
|
||||
return CommonResult.success(ub);
|
||||
public CommonResult<CommonPage<UserBrokerageRecord>> userDetail(PageParamRequest pageParamRequest,
|
||||
@RequestParam(value = "dateLimit", required = false) String dateLimit,
|
||||
@PathVariable Integer userId){
|
||||
CommonPage<UserBrokerageRecord> commonPage = CommonPage.restPage(userFundsMonitorService.getFundsMonitorDetail(userId, dateLimit, pageParamRequest));
|
||||
return CommonResult.success(commonPage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("api/admin/finance/apply")
|
||||
@Api(tags = "财务 -- 提现申请")
|
||||
|
||||
public class UserExtractController {
|
||||
|
||||
@Autowired
|
||||
@@ -81,26 +80,17 @@ public class UserExtractController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现总金额
|
||||
* 提现统计
|
||||
* @Param dateLimit 时间限制 today,yesterday,lately7,lately30,month,year,/yyyy-MM-dd hh:mm:ss,yyyy-MM-dd hh:mm:ss/
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-11
|
||||
*/
|
||||
@ApiOperation(value = "提现总金额")
|
||||
@ApiOperation(value = "提现统计")
|
||||
@RequestMapping(value = "/balance", method = RequestMethod.POST)
|
||||
public CommonResult<BalanceResponse> balance(
|
||||
@RequestParam(value = "dateLimit", required = false,
|
||||
defaultValue = "")
|
||||
@RequestParam(value = "dateLimit", required = false,defaultValue = "")
|
||||
String dateLimit){
|
||||
String startTime = null;
|
||||
String endTime = null;
|
||||
if(StringUtils.isNotBlank(dateLimit)){
|
||||
dateLimitUtilVo dateRage = DateUtil.getDateLimit(dateLimit);
|
||||
startTime = dateRage.getStartTime();
|
||||
endTime = dateRage.getEndTime();
|
||||
}
|
||||
|
||||
return CommonResult.success(userExtractService.getBalance(startTime,endTime));
|
||||
return CommonResult.success(userExtractService.getBalance(dateLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,6 +51,7 @@ public class UserRechargeController {
|
||||
@ApiOperation(value = "分页列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<UserRechargeResponse>> getList(@Validated UserRechargeSearchRequest request, @Validated PageParamRequest pageParamRequest){
|
||||
request.setPaid(true);
|
||||
CommonPage<UserRechargeResponse> userRechargeCommonPage = CommonPage.restPage(userRechargeService.getList(request, pageParamRequest));
|
||||
return CommonResult.success(userRechargeCommonPage);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zbkj.crmeb.finance.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
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;
|
||||
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)
|
||||
@ApiModel(value="FundsMonitorRequest对象", description="资金监控")
|
||||
public class FundsMonitorRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3362714265772774491L;
|
||||
|
||||
@ApiModelProperty(value = "搜索关键字")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String dateLimit;
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class UserExtractRequest implements Serializable {
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "提现方式| alipay=支付宝,bank=银行卡,weixin=微信", allowableValues = "range[alipay,weixin,bank]")
|
||||
@NotBlank(message = "请选择提现方式, 支付宝|者微信|银行卡")
|
||||
@NotBlank(message = "请选择提现方式, 支付宝|微信|银行卡")
|
||||
private String extractType;
|
||||
|
||||
@ApiModelProperty(value = "银行卡")
|
||||
|
||||
@@ -31,11 +31,8 @@ public interface UserExtractService extends IService<UserExtract> {
|
||||
|
||||
/**
|
||||
* 提现总金额
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-11
|
||||
* @return BalanceResponse
|
||||
*/
|
||||
BalanceResponse getBalance(String startTime,String endTime);
|
||||
BalanceResponse getBalance(String dateLimit);
|
||||
|
||||
/**
|
||||
* 提现总金额
|
||||
@@ -76,9 +73,15 @@ public interface UserExtractService extends IService<UserExtract> {
|
||||
* @param backMessage 驳回原因
|
||||
* @return 审核结果
|
||||
*/
|
||||
boolean updateStatus(Integer id,Integer status,String backMessage);
|
||||
Boolean updateStatus(Integer id,Integer status,String backMessage);
|
||||
|
||||
PageInfo<UserExtractRecordResponse> getExtractRecord(Integer userId, PageParamRequest pageParamRequest);
|
||||
|
||||
BigDecimal getExtractTotalMoney(Integer userId);
|
||||
|
||||
/**
|
||||
* 提现申请
|
||||
* @return
|
||||
*/
|
||||
Boolean extractApply(UserExtractRequest request);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package com.zbkj.crmeb.finance.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.model.UserFundsMonitor;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.zbkj.crmeb.finance.request.FundsMonitorUserSearchRequest;
|
||||
import com.zbkj.crmeb.user.model.UserBrokerageRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,4 +30,13 @@ public interface UserFundsMonitorService extends IService<UserFundsMonitor> {
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserFundsMonitor> getFundsMonitor(FundsMonitorUserSearchRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 佣金详细记录
|
||||
* @param uid 用户uid
|
||||
* @param dateLimit 时间参数
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return
|
||||
*/
|
||||
PageInfo<UserBrokerageRecord> getFundsMonitorDetail(Integer uid, String dateLimit, PageParamRequest pageParamRequest);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zbkj.crmeb.finance.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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;
|
||||
@@ -9,6 +10,7 @@ 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.BrokerageRecordConstants;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.Page;
|
||||
@@ -27,7 +29,9 @@ import com.zbkj.crmeb.front.response.UserExtractRecordResponse;
|
||||
import com.zbkj.crmeb.system.service.SystemAttachmentService;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserBrokerageRecord;
|
||||
import com.zbkj.crmeb.user.service.UserBillService;
|
||||
import com.zbkj.crmeb.user.service.UserBrokerageRecordService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.wechat.service.impl.WechatSendMessageForMinService;
|
||||
import com.zbkj.crmeb.wechat.vo.WechatSendMessageForCash;
|
||||
@@ -35,6 +39,7 @@ 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.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -79,6 +84,12 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
@Autowired
|
||||
private SystemAttachmentService systemAttachmentService;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserBrokerageRecordService userBrokerageRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -138,9 +149,6 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
|
||||
/**
|
||||
* 提现总金额
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-11
|
||||
* @return BalanceResponse
|
||||
* 总佣金 = 已提现佣金 + 未提现佣金
|
||||
* 已提现佣金 = 用户成功提现的金额
|
||||
* 未提现佣金 = 用户未提现的佣金 = 可提现佣金 + 冻结佣金 = 用户佣金
|
||||
@@ -150,28 +158,26 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
* 退回佣金 = 因退款导致的冻结佣金退回
|
||||
*/
|
||||
@Override
|
||||
public BalanceResponse getBalance(String startTime,String endTime) {
|
||||
// BigDecimal withdrawn = getWithdrawn(startTime,endTime);//已提现
|
||||
// BigDecimal unDrawn = getUnDrawn(startTime,endTime);//审核中现
|
||||
//// BigDecimal commissionTotal = user.getBrokeragePrice();//佣金总金额
|
||||
// BigDecimal commissionTotal = userBillService.getSumBrokerage();//佣金总金额
|
||||
// BigDecimal toBeWithdrawn = getWaiteForDrawn(startTime,endTime); //待提现
|
||||
|
||||
BigDecimal withdrawn = getWithdrawn(startTime,endTime);//已提现
|
||||
BigDecimal toBeWithdrawn = getWithdrawning(startTime,endTime); //待提现(审核中)
|
||||
// BigDecimal unDrawn = userService.getUnCommissionPrice();//未提现
|
||||
//未提现佣金 = (单位时间内) 增加的佣金 - 消耗的佣金(佣金转余额) - 待提现的佣金 - 已提现金额 (可能会产生负值)
|
||||
String date = null;
|
||||
if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
|
||||
date = startTime.concat(",").concat(endTime);
|
||||
public BalanceResponse getBalance(String dateLimit) {
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
if(StringUtils.isNotBlank(dateLimit)){
|
||||
dateLimitUtilVo dateRage = DateUtil.getDateLimit(dateLimit);
|
||||
startTime = dateRage.getStartTime();
|
||||
endTime = dateRage.getEndTime();
|
||||
}
|
||||
BigDecimal addSum = userBillService.getSumBigDecimal(1, null, Constants.USER_BILL_CATEGORY_BROKERAGE_PRICE, date, null);
|
||||
BigDecimal subSum = userBillService.getSumBigDecimal(0, null, Constants.USER_BILL_CATEGORY_BROKERAGE_PRICE, date, null);
|
||||
BigDecimal unDrawn = addSum.subtract(subSum).subtract(toBeWithdrawn).subtract(withdrawn);
|
||||
|
||||
//佣金总金额 = 已提现 + 待提现 + 未提现
|
||||
BigDecimal commissionTotal = withdrawn.add(toBeWithdrawn).add(unDrawn);//佣金总金额
|
||||
// 已提现
|
||||
BigDecimal withdrawn = getWithdrawn(startTime, endTime);
|
||||
// 待提现(审核中)
|
||||
BigDecimal toBeWithdrawn = getWithdrawning(startTime, endTime);
|
||||
|
||||
// 佣金总金额(单位时间)
|
||||
BigDecimal commissionTotal = userBrokerageRecordService.getTotalSpreadPriceBydateLimit(dateLimit);
|
||||
// 单位时间消耗的佣金
|
||||
BigDecimal subWithdarw = userBrokerageRecordService.getSubSpreadPriceByDateLimit(dateLimit);
|
||||
// 未提现
|
||||
BigDecimal unDrawn = commissionTotal.subtract(subWithdarw);
|
||||
return new BalanceResponse(withdrawn, unDrawn, commissionTotal, toBeWithdrawn);
|
||||
}
|
||||
|
||||
@@ -183,8 +189,8 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
* @return BalanceResponse
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getWithdrawn(String startTime,String endTime) {
|
||||
return getSum(null,1,startTime,endTime);
|
||||
public BigDecimal getWithdrawn(String startTime, String endTime) {
|
||||
return getSum(null, 1, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +201,7 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getWithdrawning(String startTime, String endTime) {
|
||||
return getSum(null, 0,startTime,endTime);
|
||||
return getSum(null, 0, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,24 +331,22 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
|
||||
/**
|
||||
* 根据状态获取总额
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-11 edite by stivepeim 2020-09-29
|
||||
* @return BigDecimal
|
||||
*/
|
||||
private BigDecimal getSum(Integer userId, int status, String startTime, String endTime) {
|
||||
LambdaQueryWrapper<UserExtract> lqw = Wrappers.lambdaQuery();
|
||||
if(null != userId) lqw.eq(UserExtract::getUid,userId);
|
||||
if(null != userId) {
|
||||
lqw.eq(UserExtract::getUid,userId);
|
||||
}
|
||||
lqw.eq(UserExtract::getStatus,status);
|
||||
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
||||
lqw.between(UserExtract::getCreateTime,startTime,endTime);
|
||||
lqw.between(UserExtract::getCreateTime, startTime, endTime);
|
||||
}
|
||||
List<UserExtract> userExtracts = dao.selectList(lqw);
|
||||
// double sum = 0;
|
||||
BigDecimal sum = ZERO;
|
||||
if(null != userExtracts && userExtracts.size() > 0) {
|
||||
if(CollUtil.isNotEmpty(userExtracts)) {
|
||||
sum = userExtracts.stream().map(UserExtract::getExtractPrice).reduce(ZERO, BigDecimal::add);
|
||||
}
|
||||
// sum = userExtracts.stream().mapToDouble(e -> e.getExtractPrice().doubleValue()).sum();
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -393,18 +397,66 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
* @return 审核结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateStatus(Integer id, Integer status, String backMessage) {
|
||||
public Boolean updateStatus(Integer id, Integer status, String backMessage) {
|
||||
if(status == -1 && StringUtils.isBlank(backMessage))
|
||||
throw new CrmebException("驳回时请填写驳回原因");
|
||||
|
||||
UserExtract ue = new UserExtract().setId(id).setStatus(status).setFailMsg(backMessage);
|
||||
if (status == -1) {//未通过时恢复用户总金额
|
||||
UserExtract userExtract = getById(id);
|
||||
User user = userService.getById(userExtract.getUid());
|
||||
userService.upadteBrokeragePrice(user, user.getBrokeragePrice().add(userExtract.getExtractPrice()));
|
||||
UserExtract userExtract = getById(id);
|
||||
if (ObjectUtil.isNull(userExtract)) {
|
||||
throw new CrmebException("提现申请记录不存在");
|
||||
}
|
||||
//TODO 审核申请通过已提现,是否添加user_bill用户账单表记录
|
||||
return dao.updateById(ue) > 0;
|
||||
if (userExtract.getStatus() != 0) {
|
||||
throw new CrmebException("提现申请已处理过");
|
||||
}
|
||||
userExtract.setStatus(status);
|
||||
|
||||
User user = userService.getById(userExtract.getUid());
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
throw new CrmebException("提现用户数据异常");
|
||||
}
|
||||
|
||||
Boolean execute = false;
|
||||
|
||||
// 拒绝
|
||||
if (status == -1) {//未通过时恢复用户总金额
|
||||
userExtract.setFailMsg(backMessage);
|
||||
// 添加提现申请拒绝佣金记录
|
||||
UserBrokerageRecord brokerageRecord = new UserBrokerageRecord();
|
||||
brokerageRecord.setUid(user.getUid());
|
||||
brokerageRecord.setLinkId(userExtract.getId().toString());
|
||||
brokerageRecord.setLinkType(BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_WITHDRAW);
|
||||
brokerageRecord.setType(BrokerageRecordConstants.BROKERAGE_RECORD_TYPE_ADD);
|
||||
brokerageRecord.setTitle(BrokerageRecordConstants.BROKERAGE_RECORD_TITLE_WITHDRAW_FAIL);
|
||||
brokerageRecord.setPrice(userExtract.getExtractPrice());
|
||||
brokerageRecord.setBalance(user.getBrokeragePrice().add(userExtract.getExtractPrice()));
|
||||
brokerageRecord.setMark(StrUtil.format("提现申请拒绝返还佣金{}", userExtract.getExtractPrice()));
|
||||
brokerageRecord.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_COMPLETE);
|
||||
brokerageRecord.setCreateTime(DateUtil.nowDateTime());
|
||||
|
||||
execute = transactionTemplate.execute(e -> {
|
||||
// 返还佣金
|
||||
userService.operationBrokerage(userExtract.getUid(), userExtract.getExtractPrice(), user.getBrokeragePrice(), "add");
|
||||
updateById(userExtract);
|
||||
userBrokerageRecordService.save(brokerageRecord);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
}
|
||||
|
||||
// 同意
|
||||
if (status == 1) {
|
||||
// 获取佣金提现记录
|
||||
UserBrokerageRecord brokerageRecord = userBrokerageRecordService.getByLinkIdAndLinkType(userExtract.getId().toString(), BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_WITHDRAW);
|
||||
if (ObjectUtil.isNull(brokerageRecord)) {
|
||||
throw new CrmebException("对应的佣金记录不存在");
|
||||
}
|
||||
execute = transactionTemplate.execute(e -> {
|
||||
updateById(userExtract);
|
||||
brokerageRecord.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_COMPLETE);
|
||||
userBrokerageRecordService.updateById(brokerageRecord);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
}
|
||||
return execute;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,11 +486,11 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
}
|
||||
|
||||
private List<UserExtract> getListByMonth(Integer userId, String date) {
|
||||
LambdaQueryWrapper<UserExtract> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserExtract::getUid, userId);
|
||||
// lambdaQueryWrapper.in(UserExtract::getStatus, -1, 1);
|
||||
lambdaQueryWrapper.orderByDesc(UserExtract::getCreateTime, UserExtract::getId);
|
||||
return dao.selectList(lambdaQueryWrapper);
|
||||
QueryWrapper<UserExtract> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("uid", userId);
|
||||
queryWrapper.apply(StrUtil.format(" left(create_time, 7) = '{}'", date));
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return dao.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,5 +502,68 @@ public class UserExtractServiceImpl extends ServiceImpl<UserExtractDao, UserExtr
|
||||
public BigDecimal getExtractTotalMoney(Integer userId){
|
||||
return getSum(userId, 1, null, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现申请
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean extractApply(UserExtractRequest request) {
|
||||
//添加判断,提现金额不能后台配置金额
|
||||
String value = systemConfigService.getValueByKeyException(Constants.CONFIG_EXTRACT_MIN_PRICE);
|
||||
BigDecimal ten = new BigDecimal(value);
|
||||
if (request.getExtractPrice().compareTo(ten) < 0) {
|
||||
throw new CrmebException(StrUtil.format("最低提现金额{}元", ten));
|
||||
}
|
||||
|
||||
User user = userService.getInfo();
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
throw new CrmebException("提现用户信息异常");
|
||||
}
|
||||
BigDecimal money = user.getBrokeragePrice();//可提现总金额
|
||||
if(money.compareTo(ZERO) < 1){
|
||||
throw new CrmebException("您当前没有金额可以提现");
|
||||
}
|
||||
|
||||
if(money.compareTo(request.getExtractPrice()) < 0){
|
||||
throw new CrmebException("你当前最多可提现 " + money + "元");
|
||||
}
|
||||
|
||||
UserExtract userExtract = new UserExtract();
|
||||
BeanUtils.copyProperties(request, userExtract);
|
||||
userExtract.setUid(user.getUid());
|
||||
userExtract.setBalance(money.subtract(request.getExtractPrice()));
|
||||
//存入银行名称
|
||||
if (StrUtil.isNotBlank(userExtract.getQrcodeUrl())) {
|
||||
userExtract.setQrcodeUrl(systemAttachmentService.clearPrefix(userExtract.getQrcodeUrl()));
|
||||
}
|
||||
|
||||
// 添加佣金记录
|
||||
UserBrokerageRecord brokerageRecord = new UserBrokerageRecord();
|
||||
brokerageRecord.setUid(user.getUid());
|
||||
brokerageRecord.setLinkType(BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_WITHDRAW);
|
||||
brokerageRecord.setType(BrokerageRecordConstants.BROKERAGE_RECORD_TYPE_SUB);
|
||||
brokerageRecord.setTitle(BrokerageRecordConstants.BROKERAGE_RECORD_TITLE_WITHDRAW_APPLY);
|
||||
brokerageRecord.setPrice(userExtract.getExtractPrice());
|
||||
brokerageRecord.setBalance(money.subtract(userExtract.getExtractPrice()));
|
||||
brokerageRecord.setMark(StrUtil.format("提现申请扣除佣金{}", userExtract.getExtractPrice()));
|
||||
brokerageRecord.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_WITHDRAW);
|
||||
brokerageRecord.setCreateTime(DateUtil.nowDateTime());
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
// 保存提现记录
|
||||
save(userExtract);
|
||||
// 修改用户佣金
|
||||
userService.operationBrokerage(user.getUid(), userExtract.getExtractPrice(), money, "sub");
|
||||
// 添加佣金记录
|
||||
brokerageRecord.setLinkId(userExtract.getId().toString());
|
||||
userBrokerageRecordService.save(brokerageRecord);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
//todo 提现申请通知
|
||||
return execute;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.zbkj.crmeb.finance.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.dao.UserFundsMonitorDao;
|
||||
import com.zbkj.crmeb.finance.model.UserFundsMonitor;
|
||||
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.service.UserService;
|
||||
import com.zbkj.crmeb.user.service.impl.UserServiceImpl;
|
||||
import com.zbkj.crmeb.user.model.UserBrokerageRecord;
|
||||
import com.zbkj.crmeb.user.service.UserBrokerageRecordService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +17,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* UserRechargeServiceImpl 接口实现
|
||||
@@ -42,7 +37,7 @@ public class UserFundsMonitorServiceImpl extends ServiceImpl<UserFundsMonitorDao
|
||||
private UserFundsMonitorDao dao;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
private UserBrokerageRecordService userBrokerageRecordService;
|
||||
|
||||
/**
|
||||
* 佣金列表
|
||||
@@ -67,22 +62,32 @@ public class UserFundsMonitorServiceImpl extends ServiceImpl<UserFundsMonitorDao
|
||||
}
|
||||
map.put("sort", sort);
|
||||
List<UserFundsMonitor> monitorList = dao.getFundsMonitor(map);
|
||||
List<Integer> spreadUidList = monitorList.stream().map(UserFundsMonitor::getSpreadUid).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(spreadUidList)) {
|
||||
return monitorList;
|
||||
}
|
||||
HashMap<Integer, User> mapListInUid = userService.getMapListInUid(spreadUidList);
|
||||
for (UserFundsMonitor temp: monitorList) {
|
||||
if (ObjectUtil.isNotNull(temp.getSpreadUid())) {
|
||||
User user = mapListInUid.get(temp.getSpreadUid());
|
||||
if (ObjectUtil.isNotNull(user)) {
|
||||
temp.setSpreadName(Optional.ofNullable(user.getNickname()).orElse(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (CollUtil.isEmpty(monitorList)) {
|
||||
// return monitorList;
|
||||
// }
|
||||
// List<Integer> spreadUidList = monitorList.stream().map(UserFundsMonitor::getSpreadUid).distinct().collect(Collectors.toList());
|
||||
// HashMap<Integer, User> mapListInUid = userService.getMapListInUid(spreadUidList);
|
||||
// for (UserFundsMonitor temp: monitorList) {
|
||||
// if (ObjectUtil.isNotNull(temp.getSpreadUid())) {
|
||||
// User user = mapListInUid.get(temp.getSpreadUid());
|
||||
// if (ObjectUtil.isNotNull(user)) {
|
||||
// temp.setSpreadName(Optional.ofNullable(user.getNickname()).orElse(""));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return monitorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 佣金详细记录
|
||||
* @param uid 用户uid
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<UserBrokerageRecord> getFundsMonitorDetail(Integer uid, String dateLimit, PageParamRequest pageParamRequest) {
|
||||
return userBrokerageRecordService.getFundsMonitorDetail(uid, dateLimit, pageParamRequest);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -261,9 +261,11 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
if (ObjectUtil.isNull(user)) throw new CrmebException("用户不存在!");
|
||||
|
||||
// 退款金额
|
||||
BigDecimal refundPrice = userRecharge.getPrice();
|
||||
BigDecimal refundPrice;
|
||||
if (request.getType().equals(2)) {// 本金+赠送
|
||||
refundPrice = userRecharge.getPrice().add(userRecharge.getGivePrice());
|
||||
} else {
|
||||
refundPrice = userRecharge.getPrice();
|
||||
}
|
||||
|
||||
// 判断充值方式进行退款
|
||||
@@ -286,7 +288,8 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
updateById(userRecharge);
|
||||
userService.updateById(user);
|
||||
userService.operationNowMoney(user.getUid(), refundPrice, user.getNowMoney(), "sub");
|
||||
// userService.updateById(user);
|
||||
userBillService.save(userBill);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
@@ -301,9 +304,9 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
userBill.setUid(userRecharge.getUid());
|
||||
userBill.setLinkId(userRecharge.getOrderId());
|
||||
userBill.setPm(0);
|
||||
userBill.setTitle("系统退款");
|
||||
userBill.setCategory("now_money");
|
||||
userBill.setType("user_recharge_refund");
|
||||
userBill.setTitle("系统充值退款");
|
||||
userBill.setCategory(Constants.USER_BILL_CATEGORY_MONEY);
|
||||
userBill.setType(Constants.USER_BILL_TYPE_USER_RECHARGE_REFUND);
|
||||
userBill.setNumber(refundPrice);
|
||||
userBill.setBalance(nowMoney.subtract(refundPrice));
|
||||
userBill.setMark(StrUtil.format("退款给用户{}元", userRecharge.getPrice()));
|
||||
@@ -327,7 +330,7 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
|
||||
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 signKey = systemConfigService.getValueByKey(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
String sign = CrmebUtil.getSign(CrmebUtil.objectToMap(wxRefundVo), signKey);
|
||||
wxRefundVo.setSign(sign);
|
||||
String path = systemConfigService.getValueByKeyException("pay_mini_client_p12");
|
||||
|
||||
@@ -59,9 +59,8 @@ public class CartController {
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<StoreCartResponse>> getList(@RequestParam Boolean isValid, @Validated PageParamRequest pageParamRequest){
|
||||
StoreCart storeCart = new StoreCart();
|
||||
storeCart.setUid(userService.getUserIdException());
|
||||
CommonPage<StoreCartResponse> storeCartCommonPage =
|
||||
CommonPage.restPage(storeCartService.getList(pageParamRequest, storeCart, isValid));
|
||||
CommonPage.restPage(storeCartService.getList(pageParamRequest, isValid));
|
||||
return CommonResult.success(storeCartCommonPage);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.zbkj.crmeb.front.request.LoginMobileRequest;
|
||||
import com.zbkj.crmeb.front.request.LoginRequest;
|
||||
import com.zbkj.crmeb.front.request.RegisterRequest;
|
||||
import com.zbkj.crmeb.front.response.LoginResponse;
|
||||
import com.zbkj.crmeb.front.service.LoginService;
|
||||
import com.zbkj.crmeb.sms.service.SmsService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -49,6 +50,9 @@ public class LoginController {
|
||||
@Autowired
|
||||
private SmsService smsService;
|
||||
|
||||
@Autowired
|
||||
private LoginService loginService;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号登录接口
|
||||
@@ -59,9 +63,7 @@ public class LoginController {
|
||||
@RequestMapping(value = "/login/mobile", method = RequestMethod.POST)
|
||||
public CommonResult<LoginResponse> phoneLogin(@RequestBody @Validated LoginMobileRequest loginRequest, HttpServletRequest request) throws Exception {
|
||||
String clientIp = CrmebUtil.getClientIp(request);
|
||||
RegisterRequest registerRequest = new RegisterRequest();
|
||||
BeanUtils.copyProperties(loginRequest, registerRequest);
|
||||
return CommonResult.success(userService.register(registerRequest, clientIp));
|
||||
return CommonResult.success(loginService.phoneLogin(loginRequest, clientIp));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +74,7 @@ public class LoginController {
|
||||
@ApiOperation(value = "账号密码登录")
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
public CommonResult<LoginResponse> login(@RequestBody @Validated LoginRequest loginRequest) throws Exception {
|
||||
return CommonResult.success(userService.login(loginRequest));
|
||||
return CommonResult.success(loginService.login(loginRequest));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,18 +91,18 @@ public class LoginController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* 发送短信登录验证码
|
||||
* @param phone 手机号码
|
||||
* @return 发送是否成功
|
||||
*/
|
||||
@ApiOperation(value = " 发送短信")
|
||||
@ApiOperation(value = "发送短信登录验证码")
|
||||
@RequestMapping(value = "/sendCode", method = RequestMethod.POST)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="phone", value="手机号码", required = true)
|
||||
})
|
||||
public CommonResult<Object> sendCode(@RequestParam String phone){
|
||||
ValidateFormUtil.isPhone(phone,"手机号码错误");
|
||||
if(smsService.pushCodeToList(phone,1, null)){
|
||||
if(smsService.sendCommonCode(phone)){
|
||||
return CommonResult.success("发送成功");
|
||||
}else{
|
||||
return CommonResult.failed("发送失败");
|
||||
|
||||
@@ -62,7 +62,7 @@ public class StoreOrderController {
|
||||
@ApiOperation(value = "生成订单")
|
||||
@RequestMapping(value = "/create/{key}", method = RequestMethod.POST)
|
||||
public CommonResult<Map<String, Object>> createOrder(@PathVariable String key, @Validated @RequestBody OrderCreateRequest orderRequest, HttpServletRequest request){
|
||||
return CommonResult.success(orderService.createOrder_1_3_1(orderRequest, key));
|
||||
return CommonResult.success(orderService.createOrder(orderRequest, key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.request.UserExtractRequest;
|
||||
import com.zbkj.crmeb.front.request.PasswordRequest;
|
||||
import com.zbkj.crmeb.front.request.UserBindingRequest;
|
||||
@@ -23,7 +23,6 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -146,16 +145,26 @@ public class UserController {
|
||||
return CommonResult.success(userCenterService.getCommission());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 推广佣金明细
|
||||
// * @author Mr.Zhang
|
||||
// * @since 2020-06-08
|
||||
// */
|
||||
// @ApiOperation(value = "推广佣金明细")
|
||||
// @RequestMapping(value = "/spread/commission/{type}", method = RequestMethod.GET)
|
||||
// @ApiImplicitParam(name = "type", value = "类型 佣金类型|0=全部,1=消费,2=充值,3=返佣,4=提现", allowableValues = "range[0,1,2,3,4]", dataType = "int")
|
||||
// public CommonResult<CommonPage<UserSpreadCommissionResponse>> getSpreadCommissionByType(@PathVariable int type, @Validated PageParamRequest pageParamRequest){
|
||||
// return CommonResult.success(CommonPage.restPage(userCenterService.getSpreadCommissionByType(type, pageParamRequest)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 推广佣金明细
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-06-08
|
||||
*/
|
||||
@ApiOperation(value = "推广佣金明细")
|
||||
@RequestMapping(value = "/spread/commission/{type}", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name = "type", value = "类型 佣金类型|0=全部,1=消费,2=充值,3=返佣,4=提现", allowableValues = "range[0,1,2,3,4]", dataType = "int")
|
||||
public CommonResult<CommonPage<UserSpreadCommissionResponse>> getSpreadCommissionByType(@PathVariable int type, @Validated PageParamRequest pageParamRequest){
|
||||
return CommonResult.success(CommonPage.restPage(userCenterService.getSpreadCommissionByType(type, pageParamRequest)));
|
||||
@RequestMapping(value = "/spread/commission/detail", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<SpreadCommissionDetailResponse>> getSpreadCommissionDetail(@Validated PageParamRequest pageParamRequest){
|
||||
PageInfo<SpreadCommissionDetailResponse> commissionDetail = userCenterService.getSpreadCommissionDetail(pageParamRequest);
|
||||
return CommonResult.success(CommonPage.restPage(commissionDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,36 +189,6 @@ public class UserController {
|
||||
@ApiOperation(value = "提现申请")
|
||||
@RequestMapping(value = "/extract/cash", method = RequestMethod.POST)
|
||||
public CommonResult<Boolean> extractCash(@RequestBody @Validated UserExtractRequest request){
|
||||
switch (request.getExtractType()){
|
||||
case "weixin":
|
||||
if(StringUtils.isBlank(request.getWechat())){
|
||||
throw new CrmebException("请填写微信号!");
|
||||
}
|
||||
request.setAlipayCode(null);
|
||||
request.setBankCode(null);
|
||||
request.setBankName(null);
|
||||
break;
|
||||
case "alipay":
|
||||
if(StringUtils.isBlank(request.getAlipayCode())){
|
||||
throw new CrmebException("请填写支付宝账号!");
|
||||
}
|
||||
request.setWechat(null);
|
||||
request.setBankCode(null);
|
||||
request.setBankName(null);
|
||||
break;
|
||||
case "bank":
|
||||
if(StringUtils.isBlank(request.getBankName())){
|
||||
throw new CrmebException("请填写银行名称!");
|
||||
}
|
||||
if(StringUtils.isBlank(request.getBankCode())){
|
||||
throw new CrmebException("请填写银行卡号!");
|
||||
}
|
||||
request.setWechat(null);
|
||||
request.setAlipayCode(null);
|
||||
break;
|
||||
default:
|
||||
throw new CrmebException("请选择支付方式");
|
||||
}
|
||||
return CommonResult.success(userCenterService.extractCash(request));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,37 +57,17 @@ public class UserCouponController {
|
||||
/**
|
||||
* 领券
|
||||
* @param request UserCouponReceiveRequest 新增参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-18
|
||||
*/
|
||||
@ApiOperation(value = "领券")
|
||||
@RequestMapping(value = "/receive", method = RequestMethod.POST)
|
||||
public CommonResult<String> receive(@RequestBody @Validated UserCouponReceiveRequest request){
|
||||
StoreCouponUserRequest storeCouponUserRequest = new StoreCouponUserRequest();
|
||||
storeCouponUserRequest.setUid(userService.getUserIdException().toString());
|
||||
storeCouponUserRequest.setCouponId(request.getCouponId()[0]);
|
||||
if(storeCouponUserService.receive(storeCouponUserRequest)){
|
||||
if(storeCouponUserService.receiveCoupon(request)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 领券
|
||||
* @param request UserCouponReceiveRequest 新增参数
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-18
|
||||
*/
|
||||
@ApiOperation(value = "批量领券")
|
||||
@RequestMapping(value = "/receive/batch", method = RequestMethod.POST)
|
||||
public CommonResult<String> receiveAll(@RequestBody @Validated UserCouponReceiveRequest request){
|
||||
if(storeCouponUserService.receiveAll(request, userService.getUserIdException(), "get")){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.zbkj.crmeb.front.controller;
|
||||
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.zbkj.crmeb.front.request.UserRechargeRequest;
|
||||
import com.zbkj.crmeb.front.response.UserRechargePaymentResponse;
|
||||
import com.zbkj.crmeb.front.response.OrderPayResultResponse;
|
||||
import com.zbkj.crmeb.front.response.UserRechargeBillRecordResponse;
|
||||
import com.zbkj.crmeb.front.response.UserRechargeResponse;
|
||||
import com.zbkj.crmeb.front.service.UserCenterService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -60,11 +64,12 @@ public class UserRechargeController {
|
||||
@RequestMapping(value = "/routine", method = RequestMethod.POST)
|
||||
public CommonResult<Map<String, Object>> routineRecharge(HttpServletRequest httpServletRequest, @RequestBody @Validated UserRechargeRequest request){
|
||||
request.setFromType(Constants.PAY_TYPE_WE_CHAT_FROM_PROGRAM);
|
||||
UserRechargePaymentResponse responseVo = userCenterService.recharge(request);
|
||||
// UserRechargePaymentResponse responseVo = userCenterService.recharge(request);
|
||||
OrderPayResultResponse recharge = userCenterService.recharge(request);
|
||||
request.setClientIp(CrmebUtil.getClientIp(httpServletRequest));
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("data", responseVo);
|
||||
map.put("data", recharge);
|
||||
map.put("type", request.getFromType());
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
@@ -73,10 +78,11 @@ public class UserRechargeController {
|
||||
* 充值
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-18
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "公众号充值")
|
||||
@RequestMapping(value = "/wechat", method = RequestMethod.POST)
|
||||
public CommonResult<UserRechargePaymentResponse> weChatRecharge(HttpServletRequest httpServletRequest, @RequestBody @Validated UserRechargeRequest request){
|
||||
public CommonResult<OrderPayResultResponse> weChatRecharge(HttpServletRequest httpServletRequest, @RequestBody @Validated UserRechargeRequest request){
|
||||
request.setClientIp(CrmebUtil.getClientIp(httpServletRequest));
|
||||
return CommonResult.success(userCenterService.recharge(request));
|
||||
}
|
||||
@@ -91,6 +97,17 @@ public class UserRechargeController {
|
||||
public CommonResult<Boolean> transferIn(@RequestParam(name = "price") BigDecimal price){
|
||||
return CommonResult.success(userCenterService.transferIn(price));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户账单记录
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户账单记录")
|
||||
@RequestMapping(value = "/bill/record", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name = "type", value = "记录类型:all-全部,expenditure-支出,income-收入", required = true)
|
||||
public CommonResult<CommonPage<UserRechargeBillRecordResponse>> billRecord(@RequestParam(name = "type") String type, @ModelAttribute PageParamRequest pageRequest){
|
||||
return CommonResult.success(userCenterService.nowMoneyBillRecord(type, pageRequest));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.zbkj.crmeb.front.controller;
|
||||
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.front.response.LoginResponse;
|
||||
import com.zbkj.crmeb.front.service.UserCenterService;
|
||||
import com.zbkj.crmeb.user.request.RegisterThirdUserRequest;
|
||||
import com.zbkj.crmeb.wechat.model.TemplateMessage;
|
||||
import com.zbkj.crmeb.wechat.model.WechatProgramMyTemp;
|
||||
import com.zbkj.crmeb.wechat.request.WechatProgramMyTempSearchRequest;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import com.zbkj.crmeb.wechat.service.WeChatService;
|
||||
import com.zbkj.crmeb.wechat.service.WechatProgramMyTempService;
|
||||
@@ -130,13 +127,12 @@ public class WeChatController {
|
||||
|
||||
/**
|
||||
* 订阅消息模板列表
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-06-03
|
||||
*/
|
||||
@ApiOperation(value = "订阅消息模板列表")
|
||||
@RequestMapping(value = "/program/my/temp/list", method = RequestMethod.POST)
|
||||
public CommonResult<List<WechatProgramMyTemp>> programMyTempList(@RequestBody @Validated WechatProgramMyTempSearchRequest request, PageParamRequest pageParamRequest){
|
||||
return CommonResult.success(wechatProgramMyTempService.getList(request, pageParamRequest));
|
||||
@RequestMapping(value = "/program/my/temp/list", method = RequestMethod.GET)
|
||||
@ApiImplicitParam(name = "type", value = "支付之前:beforePay|支付成功:afterPay|申请退款:refundApply|充值之前:beforeRecharge|创建砍价:createBargain|参与拼团:pink|取消拼团:cancelPink")
|
||||
public CommonResult<List<TemplateMessage>> programMyTempList(@RequestParam(name = "type") String type){
|
||||
return CommonResult.success(templateMessageService.getMiniTempList(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 手机快速登录
|
||||
* 移动端手机密码登录请求对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -26,7 +26,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="LoginRequest对象", description="手机快速登录")
|
||||
@ApiModel(value="LoginRequest对象", description="移动端手机密码登录请求对象")
|
||||
public class LoginRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@@ -8,11 +8,12 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户领券
|
||||
* 用户领取优惠券请求对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -26,12 +27,12 @@ import java.io.Serializable;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="UserCouponReceiveRequest对象", description="用户领券")
|
||||
@ApiModel(value="UserCouponReceiveRequest对象", description="用户领取优惠券请求对象")
|
||||
public class UserCouponReceiveRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "优惠券id")
|
||||
@Size(min = 1, message = "请选择优惠券")
|
||||
private Integer[] couponId;
|
||||
@NotNull(message = "优惠券编号不能为空")
|
||||
private Integer couponId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.zbkj.crmeb.front.response;
|
||||
|
||||
import com.zbkj.crmeb.user.model.UserBrokerageRecord;
|
||||
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.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)
|
||||
@ApiModel(value = "SpreadCommissionDetailResponse对象", description = "推广佣金明细响应对象")
|
||||
public class SpreadCommissionDetailResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SpreadCommissionDetailResponse() {}
|
||||
|
||||
public SpreadCommissionDetailResponse(String date, List<UserBrokerageRecord> list) {
|
||||
this.date = date;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "月份")
|
||||
private String date;
|
||||
|
||||
@ApiModelProperty(value = "数据")
|
||||
private List<UserBrokerageRecord> list;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.zbkj.crmeb.front.response;
|
||||
|
||||
import com.zbkj.crmeb.user.model.UserBill;
|
||||
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.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)
|
||||
@ApiModel(value="UserRechargeBillRecordResponse对象", description="用户余额账单记录")
|
||||
public class UserRechargeBillRecordResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "月份")
|
||||
private String date;
|
||||
|
||||
@ApiModelProperty(value = "数据")
|
||||
private List<UserBill> list;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="UserSpreadPeopleResponse对象", description="推广人信息")
|
||||
@ApiModel(value="UserSpreadPeopleItemResponse对象", description="推广人信息")
|
||||
public class UserSpreadPeopleItemResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.zbkj.crmeb.front.service;
|
||||
|
||||
import com.zbkj.crmeb.front.request.LoginMobileRequest;
|
||||
import com.zbkj.crmeb.front.request.LoginRequest;
|
||||
import com.zbkj.crmeb.front.response.LoginResponse;
|
||||
|
||||
/**
|
||||
* 移动端登录服务类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface LoginService {
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
* @return LoginResponse
|
||||
*/
|
||||
LoginResponse login(LoginRequest loginRequest) throws Exception;
|
||||
|
||||
/**
|
||||
* 手机号验证码登录
|
||||
*/
|
||||
LoginResponse phoneLogin(LoginMobileRequest loginRequest, String clientIp) throws Exception;
|
||||
}
|
||||
@@ -38,21 +38,13 @@ public interface OrderService {
|
||||
ConfirmOrderResponse confirmOrder(ConfirmOrderRequest request);
|
||||
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param request 创建订单参数
|
||||
* @param key 订单key
|
||||
* @return payResponse
|
||||
*/
|
||||
OrderPayResponse createOrder(OrderCreateRequest request, String key, String ip);
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param request 创建订单参数
|
||||
* @param key 订单key
|
||||
* @return MyRecord
|
||||
*/
|
||||
MyRecord createOrder_1_3_1(OrderCreateRequest request, String key);
|
||||
MyRecord createOrder(OrderCreateRequest request, String key);
|
||||
|
||||
/**
|
||||
* 再次下单
|
||||
@@ -114,7 +106,7 @@ public interface OrderService {
|
||||
|
||||
/**
|
||||
* 订单退款申请Task使用
|
||||
* @param request
|
||||
* @param applyList
|
||||
* @return
|
||||
*/
|
||||
Boolean refundApplyTask(List<OrderRefundApplyRequest> applyList);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.zbkj.crmeb.front.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.CommonPage;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.model.UserExtract;
|
||||
import com.zbkj.crmeb.finance.request.UserExtractRequest;
|
||||
import com.zbkj.crmeb.front.request.UserRechargeRequest;
|
||||
import com.zbkj.crmeb.front.request.UserSpreadPeopleRequest;
|
||||
@@ -51,7 +51,7 @@ public interface UserCenterService extends IService<User> {
|
||||
|
||||
UserSpreadOrderResponse getSpreadOrder(PageParamRequest pageParamRequest);
|
||||
|
||||
UserRechargePaymentResponse recharge(UserRechargeRequest request);
|
||||
OrderPayResultResponse recharge(UserRechargeRequest request);
|
||||
|
||||
LoginResponse weChatAuthorizeLogin(String code, Integer spreadUid);
|
||||
|
||||
@@ -72,4 +72,17 @@ public interface UserCenterService extends IService<User> {
|
||||
PageInfo<UserExtractRecordResponse> getExtractRecord(PageParamRequest pageParamRequest);
|
||||
|
||||
BigDecimal getExtractTotalMoney();
|
||||
|
||||
/**
|
||||
* 推广佣金明细
|
||||
* @param pageParamRequest 分页参数
|
||||
*/
|
||||
PageInfo<SpreadCommissionDetailResponse> getSpreadCommissionDetail(PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 用户账单记录(现金)
|
||||
* @param type 记录类型:all-全部,expenditure-支出,income-收入
|
||||
* @return CommonPage
|
||||
*/
|
||||
CommonPage<UserRechargeBillRecordResponse> nowMoneyBillRecord(String type, PageParamRequest pageRequest);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.zbkj.crmeb.front.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.constants.Constants;
|
||||
import com.constants.SmsConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.RedisUtil;
|
||||
import com.zbkj.crmeb.front.request.LoginMobileRequest;
|
||||
import com.zbkj.crmeb.front.request.LoginRequest;
|
||||
import com.zbkj.crmeb.front.response.LoginResponse;
|
||||
import com.zbkj.crmeb.front.service.LoginService;
|
||||
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.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 移动端登录服务类
|
||||
* +----------------------------------------------------------------------
|
||||
* | 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 LoginServiceImpl implements LoginService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LoginServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LoginResponse login(LoginRequest loginRequest) throws Exception {
|
||||
User user = userService.getUserByAccount(loginRequest.getPhone());
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
throw new CrmebException("此账号未注册");
|
||||
}
|
||||
if(!user.getStatus()){
|
||||
throw new CrmebException("此账号被禁用");
|
||||
}
|
||||
|
||||
// 校验密码
|
||||
String password = CrmebUtil.encryptPassword(loginRequest.getPassword(), loginRequest.getPhone());
|
||||
if(!user.getPwd().equals(password)){
|
||||
throw new CrmebException("密码错误");
|
||||
}
|
||||
|
||||
LoginResponse loginResponse = new LoginResponse();
|
||||
String token = userService.token(user);
|
||||
loginResponse.setToken(token);
|
||||
user.setPwd(null);
|
||||
|
||||
//绑定推广关系
|
||||
if (user.getSpreadUid() < 1 && loginRequest.getSpreadPid() > 0) {
|
||||
bindSpread(user, loginRequest.getSpreadPid());
|
||||
}
|
||||
|
||||
// 记录最后一次登录时间
|
||||
user.setLastLoginTime(DateUtil.nowDateTime());
|
||||
userService.updateById(user);
|
||||
|
||||
loginResponse.setUser(user);
|
||||
long time = Constants.TOKEN_EXPRESS_MINUTES * 60;
|
||||
loginResponse.setExpiresTime(DateUtil.addSecond(DateUtil.nowDateTime(), (int)time));
|
||||
return loginResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号验证码登录
|
||||
* @param loginRequest 登录请求信息
|
||||
* @param clientIp ip
|
||||
* @return LoginResponse
|
||||
*/
|
||||
@Override
|
||||
public LoginResponse phoneLogin(LoginMobileRequest loginRequest, String clientIp) throws Exception {
|
||||
//检测验证码
|
||||
checkValidateCode(loginRequest.getPhone(), loginRequest.getValidateCode());
|
||||
|
||||
//查询手机号信息
|
||||
User user = userService.getUserByAccount(loginRequest.getPhone());
|
||||
Integer spread = Optional.ofNullable(loginRequest.getSpread()).orElse(0);
|
||||
if(ObjectUtil.isNull(user)){
|
||||
//此用户不存在,走新用户注册流程
|
||||
user = userService.registerPhone(loginRequest.getPhone(), spread, clientIp);
|
||||
} else {
|
||||
// 正常流程
|
||||
// 绑定推广关系
|
||||
if (user.getSpreadUid() < 1 && spread > 0) {
|
||||
bindSpread(user, spread);
|
||||
}
|
||||
}
|
||||
|
||||
// 记录最后一次登录时间
|
||||
user.setLastLoginTime(DateUtil.nowDateTime());
|
||||
userService.updateById(user);
|
||||
|
||||
//生成token
|
||||
LoginResponse loginResponse = new LoginResponse();
|
||||
String token = userService.token(user);
|
||||
loginResponse.setToken(token);
|
||||
user.setPwd(null);
|
||||
|
||||
loginResponse.setUser(user);
|
||||
long time = Constants.TOKEN_EXPRESS_MINUTES * 60;
|
||||
loginResponse.setExpiresTime(DateUtil.addSecond(DateUtil.nowDateTime(), (int)time));
|
||||
return loginResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测手机验证码
|
||||
* @param phone 手机号
|
||||
* @param code 验证码
|
||||
*/
|
||||
private void checkValidateCode(String phone, String code) {
|
||||
Object validateCode = redisUtil.get(SmsConstants.SMS_VALIDATE_PHONE + phone);
|
||||
if(validateCode == null){
|
||||
throw new CrmebException("验证码已过期");
|
||||
}
|
||||
|
||||
if(!validateCode.toString().equals(code)){
|
||||
throw new CrmebException("验证码错误");
|
||||
}
|
||||
|
||||
//删除验证码
|
||||
redisUtil.remove(SmsConstants.SMS_VALIDATE_PHONE + phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定分销关系
|
||||
* @param user User 用户user类
|
||||
* @param spreadUid Integer 推广人id
|
||||
* @return Boolean
|
||||
* 1.判断分销功能是否启用
|
||||
* 2.判断分销模式
|
||||
* 3.根据不同的分销模式校验
|
||||
* 4.指定分销,只有分销员才可以分销,需要spreadUid是推广员才可以绑定
|
||||
* 5.满额分销,同上
|
||||
* 6.人人分销,可以直接绑定
|
||||
*/
|
||||
private Boolean bindSpread(User user, Integer spreadUid) {
|
||||
Boolean checkBingSpread = userService.checkBingSpread(user, spreadUid, "old");
|
||||
if (!checkBingSpread) return false;
|
||||
|
||||
user.setSpreadUid(spreadUid);
|
||||
user.setSpreadTime(DateUtil.nowDateTime());
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
userService.updateById(user);
|
||||
userService.updateSpreadCountByUid(spreadUid);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if (!execute) {
|
||||
logger.error(StrUtil.format("绑定推广人时出错,userUid = {}, spreadUid = {}", user.getUid(), spreadUid));
|
||||
}
|
||||
return execute;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,12 @@ 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.common.MyRecord;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.constants.PayConstants;
|
||||
import com.constants.SmsConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.DateUtil;
|
||||
@@ -39,8 +41,10 @@ import com.zbkj.crmeb.store.response.StoreCartResponse;
|
||||
import com.zbkj.crmeb.store.service.*;
|
||||
import com.zbkj.crmeb.store.utilService.OrderUtils;
|
||||
import com.zbkj.crmeb.store.vo.StoreOrderInfoVo;
|
||||
import com.zbkj.crmeb.system.model.SystemAdmin;
|
||||
import com.zbkj.crmeb.system.model.SystemAttachment;
|
||||
import com.zbkj.crmeb.system.model.SystemStore;
|
||||
import com.zbkj.crmeb.system.service.SystemAdminService;
|
||||
import com.zbkj.crmeb.system.service.SystemAttachmentService;
|
||||
import com.zbkj.crmeb.system.service.SystemConfigService;
|
||||
import com.zbkj.crmeb.system.service.SystemStoreService;
|
||||
@@ -52,8 +56,11 @@ import com.zbkj.crmeb.wechat.service.impl.WechatSendMessageForMinService;
|
||||
import com.zbkj.crmeb.wechat.vo.WechatSendMessageForCreateOrder;
|
||||
import com.zbkj.crmeb.wechat.vo.WechatSendMessageForReFundNotify;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
@@ -77,6 +84,8 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@@ -138,6 +147,12 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private SystemAdminService systemAdminService;
|
||||
|
||||
@Autowired
|
||||
private SmsService smsService;
|
||||
|
||||
/**
|
||||
* 确认订单
|
||||
* @return 确认订单response
|
||||
@@ -245,98 +260,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* @param request 创建订单参数
|
||||
* @param orderKey orderKey
|
||||
* @return 创建订单结果
|
||||
*/
|
||||
@Override
|
||||
public OrderPayResponse createOrder(OrderCreateRequest request, String orderKey, String ip) {
|
||||
OrderPayResponse orderPayResponse = new OrderPayResponse();
|
||||
User currentUser = userService.getInfo();
|
||||
if (ObjectUtil.isNull(currentUser)) throw new CrmebException("当前用户不存在!");
|
||||
// 检查订单是否存在
|
||||
if(orderUtils.checkOrderExist(orderKey, currentUser.getUid())) throw new CrmebException(orderKey + "订单已存在");
|
||||
|
||||
// 检测支付方式
|
||||
if(!orderUtils.checkPayType(request.getPayType())) throw new CrmebException("暂不支持该支付方式,请刷新页面或者联系管理员");
|
||||
|
||||
// 判断订单是否过期
|
||||
String existCacheOrder = orderUtils.cacheGetOrderInfo(currentUser.getUid(), orderKey);
|
||||
if(null == existCacheOrder) throw new CrmebException("订单已过期,请刷新当前页面!");
|
||||
|
||||
ConfirmOrderResponse cor = JSONObject.parseObject(existCacheOrder,ConfirmOrderResponse.class);
|
||||
|
||||
// 缓存订单并做计算
|
||||
orderUtils.computedOrder(request, cor, orderKey, currentUser);
|
||||
|
||||
// 检查订单状态
|
||||
StoreOrder orderCreated = orderUtils.createOrder(request, cor, 0, request.getStoreId(), orderKey);
|
||||
if(null == orderCreated)
|
||||
throw new CrmebException("订单生成失败");
|
||||
|
||||
// 立即购买支付
|
||||
if(request.getIsNew()){
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
OrderPayRequest orderPayRequest = new OrderPayRequest();
|
||||
// orderPayRequest.setFrom(request.getFrom());
|
||||
orderPayRequest.setPayType(request.getPayType());
|
||||
orderPayRequest.setUni(orderCreated.getOrderId());
|
||||
boolean b = doPayOrder(orderPayRequest, ip, resultMap, orderCreated);
|
||||
OrderPayItemResponse itemResponse = new OrderPayItemResponse();
|
||||
String payType = null;
|
||||
switch (request.getPayType()){
|
||||
case Constants.PAY_TYPE_WE_CHAT:
|
||||
case Constants.PAY_TYPE_WE_CHAT_FROM_PROGRAM:
|
||||
payType = "微信支付下单成功 请支付";
|
||||
orderPayResponse.setStatus("WECHAT_PAY");
|
||||
orderPayResponse.setJsConfig(resultMap.get("jsConfig"));
|
||||
break;
|
||||
case Constants.PAY_TYPE_YUE:
|
||||
payType = "余额支付成功";
|
||||
orderPayResponse.setStatus("SUCCESS");
|
||||
break;
|
||||
case Constants.PAY_TYPE_OFFLINE:
|
||||
payType = "线下支付";
|
||||
orderPayResponse.setStatus("SUCCESS");
|
||||
break;
|
||||
}
|
||||
itemResponse.setKey(orderCreated.getOrderId());
|
||||
itemResponse.setOrderId(orderKey);
|
||||
orderPayResponse.setResult(itemResponse);
|
||||
}else{
|
||||
String tempStatus = "";
|
||||
switch (request.getPayType()){
|
||||
case Constants.PAY_TYPE_WE_CHAT:tempStatus="WECHAT_H5_PAY"; break;
|
||||
case Constants.PAY_TYPE_YUE:tempStatus="SUCCESS"; break;
|
||||
case Constants.PAY_TYPE_OFFLINE:tempStatus="SUCCESS"; break;
|
||||
}
|
||||
orderPayResponse.setStatus(tempStatus);
|
||||
OrderPayItemResponse itemResponse = new OrderPayItemResponse();
|
||||
itemResponse.setKey(orderCreated.getOrderId());
|
||||
itemResponse.setOrderId(orderKey);
|
||||
orderPayResponse.setResult(itemResponse);
|
||||
}
|
||||
|
||||
// 清除购物车数据
|
||||
List<StoreCartResponse> cartInfo = cor.getCartInfo();
|
||||
List<StoreCartResponse> cartList = cartInfo.stream().filter(i -> ObjectUtil.isNotNull(i.getId())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(cartList)) {
|
||||
List<Integer> cartIdList = cartList.stream().map(temp -> temp.getId().intValue()).collect(Collectors.toList());
|
||||
storeCartService.deleteCartByIds(cartIdList);
|
||||
}
|
||||
|
||||
// 小程序消息订阅发送
|
||||
WechatSendMessageForCreateOrder createOrder = new WechatSendMessageForCreateOrder(
|
||||
orderUtils.getPayTypeStrByOrder(orderCreated),orderUtils.getStoreNameAndCarNumString(orderCreated.getId()),
|
||||
orderCreated.getPayPrice()+"",orderCreated.getId()+"","CRMEB",orderCreated.getCreateTime()+"","创建订单成功","暂无地址",
|
||||
orderUtils.getPayTypeStrByOrder(orderCreated),orderCreated.getUserAddress());
|
||||
wechatSendMessageForMinService.sendCreateOrderMessage(createOrder, userService.getUserIdException());
|
||||
|
||||
return orderPayResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* 订单创建只生成订单返回订单编号
|
||||
@@ -346,7 +269,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
* @return 创建订单结果
|
||||
*/
|
||||
@Override
|
||||
public MyRecord createOrder_1_3_1(OrderCreateRequest request, String orderKey) {
|
||||
public MyRecord createOrder(OrderCreateRequest request, String orderKey) {
|
||||
User currentUser = userService.getInfo();
|
||||
if (ObjectUtil.isNull(currentUser)) throw new CrmebException("当前用户不存在!");
|
||||
// 检查订单是否存在
|
||||
@@ -383,12 +306,40 @@ public class OrderServiceImpl implements OrderService {
|
||||
List<Integer> cartIdList = cartList.stream().map(temp -> temp.getId().intValue()).collect(Collectors.toList());
|
||||
storeCartService.deleteCartByIds(cartIdList);
|
||||
}
|
||||
// 加入自动未支付自动取消队列
|
||||
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, orderCreated.getOrderId());
|
||||
|
||||
// 发送后台管理员下单提醒通知短信
|
||||
sendAdminOrderNotice(orderCreated.getOrderId());
|
||||
|
||||
MyRecord record = new MyRecord();
|
||||
record.set("orderNo", orderCreated.getOrderId());
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送后台管理员下单提醒通知短信
|
||||
* @param orderNo 订单编号
|
||||
*/
|
||||
@Async
|
||||
public void sendAdminOrderNotice(String orderNo) {
|
||||
// 系统是否开启用户下单管理员提醒开关
|
||||
String smsSwitch = systemConfigService.getValueByKey(SmsConstants.SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH);
|
||||
if (StrUtil.isBlank(smsSwitch) || smsSwitch.equals("1")) {
|
||||
return ;
|
||||
}
|
||||
// 查询可已发送短信的管理员
|
||||
List<SystemAdmin> systemAdminList = systemAdminService.findIsSmsList();
|
||||
if (CollUtil.isEmpty(systemAdminList)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
// 发送短信
|
||||
systemAdminList.forEach(admin -> {
|
||||
smsService.sendCreateOrderNotice(admin.getPhone(), orderNo, admin.getRealName());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除已完成订单
|
||||
@@ -539,6 +490,20 @@ public class OrderServiceImpl implements OrderService {
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
if (execute) {
|
||||
// 发送用户退款管理员提醒短信
|
||||
String smsSwitch = systemConfigService.getValueByKey(SmsConstants.SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH);
|
||||
if (StrUtil.isNotBlank(smsSwitch) || smsSwitch.equals("1")) {
|
||||
// 查询可已发送短信的管理员
|
||||
List<SystemAdmin> systemAdminList = systemAdminService.findIsSmsList();
|
||||
if (CollUtil.isNotEmpty(systemAdminList)) {
|
||||
// 发送短信
|
||||
systemAdminList.forEach(admin -> {
|
||||
smsService.sendOrderRefundApplyNotice(admin.getPhone(), existStoreOrder.getOrderId(), admin.getRealName());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!execute) throw new CrmebException("申请退款失败");
|
||||
|
||||
// HashMap<String, Object> smsInfo = new HashMap<>();
|
||||
@@ -571,24 +536,32 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (CollUtil.isEmpty(applyList)) {
|
||||
return false;
|
||||
}
|
||||
String smsSwitch = systemConfigService.getValueByKey(SmsConstants.SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH);
|
||||
List<StoreOrder> orderList = CollUtil.newArrayList();
|
||||
List<Map<String, Object>> notifyMapList = CollUtil.newArrayList();
|
||||
for (OrderRefundApplyRequest request : applyList) {
|
||||
StoreOrder storeOrder = storeOrderService.getById(request.getId());
|
||||
if(ObjectUtil.isNull(storeOrder)){
|
||||
//订单号错误
|
||||
throw new CrmebException("没有找到相关订单信息!");
|
||||
// throw new CrmebException("没有找到相关订单信息!");
|
||||
logger.error("拼团自动处理订单申请退款:没有找到相关订单信息!");
|
||||
continue;
|
||||
}
|
||||
if(storeOrder.getRefundStatus() == 1){
|
||||
throw new CrmebException("正在申请退款中");
|
||||
// throw new CrmebException("正在申请退款中");
|
||||
logger.error("拼团自动处理订单申请退款:正在申请退款中!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(storeOrder.getRefundStatus() == 2){
|
||||
throw new CrmebException("订单已退款");
|
||||
// throw new CrmebException("订单已退款");
|
||||
logger.error("拼团自动处理订单申请退款:订单已退款!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(storeOrder.getRefundStatus() == 3){
|
||||
throw new CrmebException("订单退款中");
|
||||
// throw new CrmebException("订单退款中");
|
||||
logger.error("拼团自动处理订单申请退款:订单退款中!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// if(storeOrder.getStatus() == 1){
|
||||
@@ -602,32 +575,20 @@ public class OrderServiceImpl implements OrderService {
|
||||
storeOrder.setRefundReasonTime(DateUtil.nowDateTime());
|
||||
orderList.add(storeOrder);
|
||||
|
||||
// 发送微信小程序订阅消息
|
||||
String storeNameAndCarNumString = orderUtils.getStoreNameAndCarNumString(storeOrder.getId());
|
||||
if(StringUtils.isNotBlank(storeNameAndCarNumString)){
|
||||
WechatSendMessageForReFundNotify notify = new WechatSendMessageForReFundNotify(
|
||||
storeNameAndCarNumString,storeOrder.getPayPrice().toString(),
|
||||
storeOrder.getCreateTime().toString(),storeOrder.getOrderId()+"",DateUtil.nowDateTimeStr(),
|
||||
"CRMEB","发起申请",request.getExplain(),storeOrder.getPayPrice()+"",
|
||||
request.getText(),storeOrder.getUserPhone(),"CRMEB");
|
||||
Map<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("notify", notify);
|
||||
map.put("uid", storeOrder.getUid());
|
||||
notifyMapList.add(map);
|
||||
// 发送用户退款管理员提醒短信
|
||||
if (StrUtil.isNotBlank(smsSwitch) || smsSwitch.equals("1")) {
|
||||
// 查询可已发送短信的管理员
|
||||
List<SystemAdmin> systemAdminList = systemAdminService.findIsSmsList();
|
||||
if (CollUtil.isNotEmpty(systemAdminList)) {
|
||||
// 发送短信
|
||||
systemAdminList.forEach(admin -> {
|
||||
smsService.sendOrderRefundApplyNotice(admin.getPhone(), storeOrder.getOrderId(), admin.getRealName());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean batch = storeOrderService.updateBatchById(orderList, 100);
|
||||
if (batch && notifyMapList.size() > 0) {
|
||||
// 发送微信小程序订阅消息
|
||||
notifyMapList.forEach(i -> {
|
||||
WechatSendMessageForReFundNotify notify = (WechatSendMessageForReFundNotify) i.get("notify");
|
||||
Integer uid = (Integer) i.get("uid");
|
||||
wechatSendMessageForMinService.sendReFundNotifyMessage(notify, uid);
|
||||
});
|
||||
}
|
||||
|
||||
return batch;
|
||||
return storeOrderService.updateBatchById(orderList, 100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,17 @@ public class ProductServiceImpl implements ProductService {
|
||||
if(null != user && null != user.getUid()){
|
||||
storeInfo.setUserLike(storeProductRelationService.getLikeOrCollectByUser(user.getUid(),id,true).size() > 0);
|
||||
storeInfo.setUserCollect(storeProductRelationService.getLikeOrCollectByUser(user.getUid(),id,false).size() > 0);
|
||||
productDetailResponse.setPriceName(getPacketPriceRange(productResponse, user.getIsPromoter()));
|
||||
|
||||
// 判断是否开启分销
|
||||
String brokerageFuncStatus = systemConfigService.getValueByKey("brokerage_func_status");
|
||||
String storeBrokerageStatus = systemConfigService.getValueByKey("store_brokerage_status");
|
||||
if (brokerageFuncStatus.equals("1")) {
|
||||
if (storeBrokerageStatus.equals("1")) {
|
||||
productDetailResponse.setPriceName(getPacketPriceRange(productResponse, user.getIsPromoter()));
|
||||
} else {
|
||||
productDetailResponse.setPriceName(getPacketPriceRange(productResponse, true));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
storeInfo.setUserLike(false);
|
||||
storeInfo.setUserCollect(false);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,9 @@ public class StoreProductLogServiceImpl extends ServiceImpl<StoreProductLogDao,
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(time);
|
||||
//时间范围
|
||||
if(dateLimit.getStartTime() != null && dateLimit.getEndTime() != null){
|
||||
lqw.between(StoreProductLog::getAddTime, dateLimit.getStartTime(), dateLimit.getEndTime());
|
||||
Long startTime = DateUtil.dateStr2Timestamp(dateLimit.getStartTime(), Constants.DATE_TIME_TYPE_BEGIN);
|
||||
Long endTime = DateUtil.dateStr2Timestamp(dateLimit.getEndTime(), Constants.DATE_TIME_TYPE_END);
|
||||
lqw.between(StoreProductLog::getAddTime, startTime, endTime);
|
||||
}
|
||||
return dao.selectCount(lqw);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StoreCouponUser implements Serializable {
|
||||
@ApiModelProperty(value = "最低消费多少金额可用优惠券")
|
||||
private BigDecimal minPrice;
|
||||
|
||||
@ApiModelProperty(value = "获取方式")
|
||||
@ApiModelProperty(value = "获取方式,send后台发放, 用户领取 get,register用户注册")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已失效)")
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.zbkj.crmeb.marketing.request.StoreCouponRequest;
|
||||
import com.zbkj.crmeb.marketing.request.StoreCouponSearchRequest;
|
||||
import com.zbkj.crmeb.marketing.response.StoreCouponFrontResponse;
|
||||
import com.zbkj.crmeb.marketing.response.StoreCouponInfoResponse;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,4 +46,18 @@ public interface StoreCouponService extends IService<StoreCoupon> {
|
||||
* @return
|
||||
*/
|
||||
List<StoreCoupon> getByIds(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 扣减数量
|
||||
* @param id 优惠券id
|
||||
* @param num 数量
|
||||
* @param isLimited 是否限量
|
||||
*/
|
||||
Boolean deduction(Integer id, Integer num, Boolean isLimited);
|
||||
|
||||
/**
|
||||
* 获取用户注册赠送新人券
|
||||
* @return
|
||||
*/
|
||||
List<StoreCoupon> findRegisterList();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.marketing.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.MyRecord;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.front.request.UserCouponReceiveRequest;
|
||||
@@ -70,4 +71,17 @@ public interface StoreCouponUserService extends IService<StoreCouponUser> {
|
||||
* 优惠券过期定时任务
|
||||
*/
|
||||
void overdueTask();
|
||||
|
||||
/**
|
||||
* 用户领取优惠券
|
||||
*/
|
||||
Boolean receiveCoupon(UserCouponReceiveRequest request);
|
||||
|
||||
/**
|
||||
* 支付成功赠送处理
|
||||
* @param couponId 优惠券编号
|
||||
* @param uid 用户uid
|
||||
* @return
|
||||
*/
|
||||
MyRecord paySuccessGiveAway(Integer couponId, Integer uid);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.zbkj.crmeb.marketing.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.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
@@ -32,6 +36,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* StoreCouponServiceImpl 接口实现
|
||||
@@ -320,6 +325,59 @@ public class StoreCouponServiceImpl extends ServiceImpl<StoreCouponDao, StoreCou
|
||||
return dao.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减数量
|
||||
* @param id 优惠券id
|
||||
* @param num 数量
|
||||
* @param isLimited 是否限量
|
||||
*/
|
||||
@Override
|
||||
public Boolean deduction(Integer id, Integer num, Boolean isLimited) {
|
||||
UpdateWrapper<StoreCoupon> updateWrapper = new UpdateWrapper<>();
|
||||
if (isLimited) {
|
||||
updateWrapper.setSql(StrUtil.format("last_total = last_total - {}", num));
|
||||
updateWrapper.last(StrUtil.format(" and (last_total - {} >= 0)", num));
|
||||
} else {
|
||||
updateWrapper.setSql(StrUtil.format("last_total = last_total + {}", num));
|
||||
}
|
||||
updateWrapper.eq("id", id);
|
||||
return update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户注册赠送新人券
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StoreCoupon> findRegisterList() {
|
||||
String dateStr = DateUtil.nowDate(Constants.DATE_FORMAT);
|
||||
LambdaQueryWrapper<StoreCoupon> lqw = new LambdaQueryWrapper<>();
|
||||
// lqw.gt(StoreCoupon::getLastTotal, 0);
|
||||
lqw.eq(StoreCoupon::getType, 2);
|
||||
lqw.eq(StoreCoupon::getStatus, true);
|
||||
lqw.eq(StoreCoupon::getIsDel, false);
|
||||
lqw.le(StoreCoupon::getReceiveStartTime, dateStr);
|
||||
List<StoreCoupon> list = dao.selectList(lqw);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
List<StoreCoupon> couponList = list.stream().filter(coupon -> {
|
||||
// 是否限量
|
||||
if (coupon.getIsLimited() && coupon.getLastTotal() <= 0) {
|
||||
return false;
|
||||
}
|
||||
// 是否有领取结束时间
|
||||
if (ObjectUtil.isNotNull(coupon.getReceiveEndTime())) {
|
||||
int compareDate = DateUtil.compareDate(dateStr, DateUtil.dateToStr(coupon.getReceiveEndTime(), Constants.DATE_FORMAT), Constants.DATE_FORMAT);
|
||||
if (compareDate > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
return couponList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户可领取的优惠券
|
||||
* @author Mr.Zhang
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.zbkj.crmeb.marketing.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.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.CommonPage;
|
||||
import com.common.MyRecord;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
@@ -30,7 +32,6 @@ import com.zbkj.crmeb.store.service.StoreCartService;
|
||||
import com.zbkj.crmeb.store.service.StoreProductService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.wechat.vo.WechatSendMessageForOrderCancel;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -365,12 +366,20 @@ public class StoreCouponUserServiceImpl extends ServiceImpl<StoreCouponUserDao,
|
||||
List<Integer> primaryKeyIdList = CrmebUtil.stringToArray(storeCouponUser.getPrimaryKey());
|
||||
|
||||
//取两个集合的交集,如果是false则证明没有相同的值
|
||||
if(storeCouponUser.getUseType() == 2 && !primaryKeyIdList.retainAll(productIdList)){
|
||||
throw new CrmebException("此优惠券为商品券,请购买相关商品之后再使用!");
|
||||
//oldList.retainAll(newList)返回值代表oldList是否保持原样,如果old和new完全相同,那old保持原样并返回false。
|
||||
//交集:listA.retainAll(listB) ——listA内容变为listA和listB都存在的对象;listB不变
|
||||
if(storeCouponUser.getUseType() == 2){
|
||||
primaryKeyIdList.retainAll(productIdList);
|
||||
if (CollUtil.isEmpty(primaryKeyIdList)) {
|
||||
throw new CrmebException("此优惠券为商品券,请购买相关商品之后再使用!");
|
||||
}
|
||||
}
|
||||
|
||||
if(storeCouponUser.getUseType() == 3 && !primaryKeyIdList.retainAll(categoryIdList)){
|
||||
throw new CrmebException("此优惠券为分类券,请购买相关分类下的商品之后再使用!");
|
||||
if(storeCouponUser.getUseType() == 3){
|
||||
primaryKeyIdList.retainAll(categoryIdList);
|
||||
if (CollUtil.isEmpty(primaryKeyIdList)) {
|
||||
throw new CrmebException("此优惠券为分类券,请购买相关分类下的商品之后再使用!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -580,10 +589,12 @@ public class StoreCouponUserServiceImpl extends ServiceImpl<StoreCouponUserDao,
|
||||
List<StoreCouponUser> updateList = CollUtil.newArrayList();
|
||||
String nowDateStr = DateUtil.nowDate(Constants.DATE_FORMAT);
|
||||
couponList.forEach(coupon -> {
|
||||
String endDateStr = DateUtil.dateToStr(coupon.getEndTime(), Constants.DATE_FORMAT);
|
||||
if (DateUtil.compareDate(nowDateStr, endDateStr, Constants.DATE_FORMAT) >= 0) {
|
||||
coupon.setStatus(2);
|
||||
updateList.add(coupon);
|
||||
if (ObjectUtil.isNotNull(coupon.getEndTime())) {
|
||||
String endDateStr = DateUtil.dateToStr(coupon.getEndTime(), Constants.DATE_FORMAT);
|
||||
if (DateUtil.compareDate(nowDateStr, endDateStr, Constants.DATE_FORMAT) >= 0) {
|
||||
coupon.setStatus(2);
|
||||
updateList.add(coupon);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -594,6 +605,134 @@ public class StoreCouponUserServiceImpl extends ServiceImpl<StoreCouponUserDao,
|
||||
if (!update) throw new CrmebException("批量更新优惠券过期动作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户领取优惠券
|
||||
*/
|
||||
@Override
|
||||
public Boolean receiveCoupon(UserCouponReceiveRequest request) {
|
||||
// 获取优惠券信息
|
||||
StoreCoupon storeCoupon = storeCouponService.getInfoException(request.getCouponId());
|
||||
|
||||
Integer userId = userService.getUserIdException();
|
||||
|
||||
//看是否有剩余数量,是否够给当前用户
|
||||
if(storeCoupon.getIsLimited() && storeCoupon.getLastTotal() < 1){
|
||||
throw new CrmebException("当前剩余数量不够领取!");
|
||||
}
|
||||
|
||||
//过滤掉已经领取过的用户
|
||||
List<Integer> uidList = CollUtil.newArrayList();
|
||||
uidList.add(userId);
|
||||
filterReceiveUserInUid(storeCoupon.getId(), uidList);
|
||||
if(uidList.size() < 1){
|
||||
//都已经领取过了
|
||||
throw new CrmebException("当前用户已经领取过此优惠券了!");
|
||||
|
||||
}
|
||||
|
||||
//是否有固定的使用时间
|
||||
if(!storeCoupon.getIsFixedTime()){
|
||||
String endTime = DateUtil.addDay(DateUtil.nowDate(Constants.DATE_FORMAT), storeCoupon.getDay(), Constants.DATE_FORMAT);
|
||||
storeCoupon.setUseEndTime(DateUtil.strToDate(endTime, Constants.DATE_FORMAT));
|
||||
storeCoupon.setUseStartTime(DateUtil.nowDateTimeReturnDate(Constants.DATE_FORMAT));
|
||||
}
|
||||
|
||||
|
||||
StoreCouponUser storeCouponUser = new StoreCouponUser();
|
||||
storeCouponUser.setCouponId(storeCoupon.getId());
|
||||
storeCouponUser.setUid(userId);
|
||||
storeCouponUser.setName(storeCoupon.getName());
|
||||
storeCouponUser.setMoney(storeCoupon.getMoney());
|
||||
storeCouponUser.setMinPrice(storeCoupon.getMinPrice());
|
||||
storeCouponUser.setStartTime(storeCoupon.getUseStartTime());
|
||||
storeCouponUser.setEndTime(storeCoupon.getUseEndTime());
|
||||
storeCouponUser.setUseType(storeCoupon.getUseType());
|
||||
storeCouponUser.setType("receive");
|
||||
if (storeCoupon.getUseType() > 1) {
|
||||
storeCouponUser.setPrimaryKey(storeCoupon.getPrimaryKey());
|
||||
}
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
save(storeCouponUser);
|
||||
storeCouponService.deduction(storeCoupon.getId(), 1, storeCoupon.getIsLimited());
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
return execute;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功赠送处理
|
||||
* @param couponId 优惠券编号
|
||||
* @param uid 用户uid
|
||||
* @return MyRecord
|
||||
*/
|
||||
@Override
|
||||
public MyRecord paySuccessGiveAway(Integer couponId, Integer uid) {
|
||||
MyRecord record = new MyRecord();
|
||||
record.set("status", "fail");
|
||||
// 获取优惠券信息
|
||||
StoreCoupon storeCoupon = storeCouponService.getById(couponId);
|
||||
if(ObjectUtil.isNull(storeCoupon) || storeCoupon.getIsDel() || !storeCoupon.getStatus()){
|
||||
record.set("errMsg", "优惠券信息不存在或者已失效!");
|
||||
return record;
|
||||
}
|
||||
|
||||
//看是否过期
|
||||
if(!(storeCoupon.getReceiveEndTime() == null || storeCoupon.getReceiveEndTime().equals(""))){
|
||||
//非永久可领取
|
||||
String date = DateUtil.nowDateTimeStr();
|
||||
int result = DateUtil.compareDate(date, DateUtil.dateToStr(storeCoupon.getReceiveEndTime(), Constants.DATE_FORMAT), Constants.DATE_FORMAT);
|
||||
if(result == 1){
|
||||
//过期了
|
||||
record.set("errMsg", "已超过优惠券领取最后期限!");
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
||||
//看是否有剩余数量
|
||||
if(storeCoupon.getIsLimited() && storeCoupon.getLastTotal() < 1){
|
||||
record.set("errMsg", "此优惠券已经被领完了!");
|
||||
return record;
|
||||
}
|
||||
|
||||
//过滤掉已经领取过的用户
|
||||
List<Integer> uidList = CollUtil.newArrayList();
|
||||
uidList.add(uid);
|
||||
filterReceiveUserInUid(storeCoupon.getId(), uidList);
|
||||
if(uidList.size() < 1){
|
||||
//都已经领取过了
|
||||
record.set("errMsg", "当前用户已经领取过此优惠券了!");
|
||||
return record;
|
||||
}
|
||||
|
||||
//是否有固定的使用时间
|
||||
if(!storeCoupon.getIsFixedTime()){
|
||||
String endTime = DateUtil.addDay(DateUtil.nowDate(Constants.DATE_FORMAT), storeCoupon.getDay(), Constants.DATE_FORMAT);
|
||||
storeCoupon.setUseEndTime(DateUtil.strToDate(endTime, Constants.DATE_FORMAT));
|
||||
storeCoupon.setUseStartTime(DateUtil.nowDateTimeReturnDate(Constants.DATE_FORMAT));
|
||||
}
|
||||
|
||||
|
||||
StoreCouponUser storeCouponUser = new StoreCouponUser();
|
||||
storeCouponUser.setCouponId(storeCoupon.getId());
|
||||
storeCouponUser.setUid(uid);
|
||||
storeCouponUser.setName(storeCoupon.getName());
|
||||
storeCouponUser.setMoney(storeCoupon.getMoney());
|
||||
storeCouponUser.setMinPrice(storeCoupon.getMinPrice());
|
||||
storeCouponUser.setStartTime(storeCoupon.getUseStartTime());
|
||||
storeCouponUser.setEndTime(storeCoupon.getUseEndTime());
|
||||
storeCouponUser.setUseType(storeCoupon.getUseType());
|
||||
storeCouponUser.setType("receive");
|
||||
if (storeCoupon.getUseType() > 1) {
|
||||
storeCouponUser.setPrimaryKey(storeCoupon.getPrimaryKey());
|
||||
}
|
||||
record.set("status", "ok");
|
||||
record.set("storeCouponUser", storeCouponUser);
|
||||
record.set("isLimited", storeCoupon.getIsLimited());
|
||||
return record;
|
||||
}
|
||||
|
||||
private void getPrimaryKeySql(LambdaQueryWrapper<StoreCouponUser> lambdaQueryWrapper, String productIdStr){
|
||||
if(StringUtils.isBlank(productIdStr)){
|
||||
return;
|
||||
|
||||
@@ -115,6 +115,17 @@ public class OnePassController {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手机号——验证账号密码
|
||||
*/
|
||||
@ApiOperation(value = "修改手机号——验证账号密码")
|
||||
@RequestMapping(value = "/update/phone/validator", method = RequestMethod.POST)
|
||||
public CommonResult<JSONObject> updatePhone(@Validated @RequestBody OnePassLoginRequest request){
|
||||
if (onePassService.beforeUpdatePhoneValidator(request)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手机号
|
||||
|
||||
@@ -106,4 +106,10 @@ public interface OnePassService {
|
||||
* @return OnePassLogisticsQueryVo
|
||||
*/
|
||||
OnePassLogisticsQueryVo exprQuery(String expressNo, String com);
|
||||
|
||||
/**
|
||||
* 修改手机号——验证账号密码
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean beforeUpdatePhoneValidator(OnePassLoginRequest request);
|
||||
}
|
||||
|
||||
@@ -399,6 +399,23 @@ public class OnePassServiceImpl implements OnePassService {
|
||||
return JSONObject.toJavaObject(jsonObject, OnePassLogisticsQueryVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手机号——验证账号密码
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean beforeUpdatePhoneValidator(OnePassLoginRequest request) {
|
||||
OnePassLoginVo loginVo = onePassUtil.getLoginVo();
|
||||
if (!loginVo.getAccount().equals(request.getAccount())) {
|
||||
throw new CrmebException("账号不匹配");
|
||||
}
|
||||
String secret = SecureUtil.md5(request.getAccount() + SecureUtil.md5(request.getPassword()));
|
||||
if (!loginVo.getSecret().equals(secret)) {
|
||||
throw new CrmebException("密码不匹配");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 物流、电子面单开通参数校验
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,6 @@ public interface RechargePayService {
|
||||
/**
|
||||
* 支付成功处理
|
||||
* @param userRecharge 充值订单
|
||||
* @param userToken 用户Token
|
||||
*/
|
||||
Boolean paySuccess(UserRecharge userRecharge, UserToken userToken);
|
||||
Boolean paySuccess(UserRecharge userRecharge);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.payment.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
@@ -9,6 +10,10 @@ import com.common.MyRecord;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.*;
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.combination.service.StorePinkService;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.zbkj.crmeb.finance.service.UserRechargeService;
|
||||
import com.zbkj.crmeb.payment.service.CallbackService;
|
||||
@@ -23,6 +28,7 @@ import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserToken;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.user.service.UserTokenService;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,6 +39,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Security;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -84,6 +91,12 @@ public class CallbackServiceImpl implements CallbackService {
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
@Autowired
|
||||
private StorePinkService storePinkService;
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
* @author Mr.Zhang
|
||||
@@ -128,11 +141,11 @@ public class CallbackServiceImpl implements CallbackService {
|
||||
AttachVo attachVo = JSONObject.toJavaObject(JSONObject.parseObject(callbackVo.getAttach()), AttachVo.class);
|
||||
|
||||
//判断openid
|
||||
UserToken userToken = userTokenService.getByOpenid(callbackVo.getOpenid());
|
||||
if(null == userToken || !userToken.getUid().equals(attachVo.getUserId())){
|
||||
//用户信息错误
|
||||
throw new CrmebException("用户信息错误!");
|
||||
}
|
||||
// UserToken userToken = userTokenService.getByOpenid(callbackVo.getOpenid());
|
||||
// if(null == userToken || !userToken.getUid().equals(attachVo.getUserId())){
|
||||
// //用户信息错误
|
||||
// throw new CrmebException("用户信息错误!");
|
||||
// }
|
||||
User user = userService.getById(attachVo.getUserId());
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
//用户信息错误
|
||||
@@ -168,6 +181,57 @@ public class CallbackServiceImpl implements CallbackService {
|
||||
if (storeOrder.getUseIntegral() > 0) {
|
||||
userService.updateIntegral(user, storeOrder.getUseIntegral(), "sub");
|
||||
}
|
||||
|
||||
// 处理拼团
|
||||
if (storeOrder.getCombinationId() > 0) {
|
||||
// 判断拼团团长是否存在
|
||||
StorePink headPink = new StorePink();
|
||||
Integer pinkId = storeOrder.getPinkId();
|
||||
if (pinkId > 0) {
|
||||
headPink = storePinkService.getById(pinkId);
|
||||
if (ObjectUtil.isNull(headPink) || headPink.getIsRefund().equals(true) || headPink.getStatus() == 3) {
|
||||
pinkId = 0;
|
||||
}
|
||||
}
|
||||
StoreCombination storeCombination = storeCombinationService.getById(storeOrder.getCombinationId());
|
||||
// 生成拼团表数据
|
||||
StorePink storePink = new StorePink();
|
||||
storePink.setUid(user.getUid());
|
||||
storePink.setAvatar(user.getAvatar());
|
||||
storePink.setNickname(user.getNickname());
|
||||
storePink.setOrderId(storeOrder.getOrderId());
|
||||
storePink.setOrderIdKey(storeOrder.getId());
|
||||
storePink.setTotalNum(storeOrder.getTotalNum());
|
||||
storePink.setTotalPrice(storeOrder.getTotalPrice());
|
||||
storePink.setCid(storeCombination.getId());
|
||||
storePink.setPid(storeCombination.getProductId());
|
||||
storePink.setPeople(storeCombination.getPeople());
|
||||
storePink.setPrice(storeCombination.getPrice());
|
||||
Integer effectiveTime = storeCombination.getEffectiveTime();// 有效小时数
|
||||
DateTime dateTime = cn.hutool.core.date.DateUtil.date();
|
||||
storePink.setAddTime(dateTime.getTime());
|
||||
if (pinkId > 0) {
|
||||
storePink.setStopTime(headPink.getStopTime());
|
||||
} else {
|
||||
DateTime hourTime = cn.hutool.core.date.DateUtil.offsetHour(dateTime, effectiveTime);
|
||||
long stopTime = hourTime.getTime();
|
||||
if (stopTime > storeCombination.getStopTime()) {
|
||||
stopTime = storeCombination.getStopTime();
|
||||
}
|
||||
storePink.setStopTime(stopTime);
|
||||
}
|
||||
storePink.setKId(pinkId);
|
||||
storePink.setIsTpl(false);
|
||||
storePink.setIsRefund(false);
|
||||
storePink.setStatus(1);
|
||||
storePinkService.save(storePink);
|
||||
// 如果是开团,需要更新订单数据
|
||||
if (storePink.getKId() == 0) {
|
||||
storeOrder.setPinkId(storePink.getId());
|
||||
storeOrderService.updateById(storeOrder);
|
||||
}
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if (!execute) {
|
||||
@@ -195,7 +259,7 @@ public class CallbackServiceImpl implements CallbackService {
|
||||
return sb.toString();
|
||||
}
|
||||
// 支付成功处理
|
||||
Boolean rechargePayAfter = rechargePayService.paySuccess(userRecharge, userToken);
|
||||
Boolean rechargePayAfter = rechargePayService.paySuccess(userRecharge);
|
||||
if (!rechargePayAfter) {
|
||||
logger.error("wechat pay error : 数据保存失败==》" + callbackVo.getOutTradeNo());
|
||||
throw new CrmebException("wechat pay error : 数据保存失败==》" + callbackVo.getOutTradeNo());
|
||||
@@ -334,7 +398,14 @@ public class CallbackServiceImpl implements CallbackService {
|
||||
return signKey;
|
||||
}
|
||||
|
||||
public String decryptToStr(String reqInfo, String signKey) throws Exception {
|
||||
/**
|
||||
* java自带的是PKCS5Padding填充,不支持PKCS7Padding填充。
|
||||
* 通过BouncyCastle组件来让java里面支持PKCS7Padding填充
|
||||
* 在加解密之前加上:Security.addProvider(new BouncyCastleProvider()),
|
||||
* 并给Cipher.getInstance方法传入参数来指定Java使用这个库里的加/解密算法。
|
||||
*/
|
||||
public static String decryptToStr(String reqInfo, String signKey) throws Exception {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
byte[] decodeReqInfo = Base64.decode(reqInfo);
|
||||
SecretKeySpec key = new SecretKeySpec(SecureUtil.md5(signKey).toLowerCase().getBytes(), "AES");
|
||||
Cipher cipher;
|
||||
|
||||
@@ -5,8 +5,7 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.common.MyRecord;
|
||||
import com.constants.Constants;
|
||||
import com.constants.PayConstants;
|
||||
import com.constants.*;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.DateUtil;
|
||||
import com.utils.RedisUtil;
|
||||
@@ -21,7 +20,8 @@ import com.zbkj.crmeb.front.request.OrderPayRequest;
|
||||
import com.zbkj.crmeb.front.response.OrderPayResultResponse;
|
||||
import com.zbkj.crmeb.front.response.UserRechargePaymentResponse;
|
||||
import com.zbkj.crmeb.front.vo.WxPayJsResultVo;
|
||||
import com.zbkj.crmeb.marketing.request.StoreCouponUserRequest;
|
||||
import com.zbkj.crmeb.marketing.model.StoreCouponUser;
|
||||
import com.zbkj.crmeb.marketing.service.StoreCouponService;
|
||||
import com.zbkj.crmeb.marketing.service.StoreCouponUserService;
|
||||
import com.zbkj.crmeb.payment.service.OrderPayService;
|
||||
import com.zbkj.crmeb.payment.service.PayService;
|
||||
@@ -36,12 +36,14 @@ import com.zbkj.crmeb.store.model.StoreProductCoupon;
|
||||
import com.zbkj.crmeb.store.service.*;
|
||||
import com.zbkj.crmeb.store.utilService.OrderUtils;
|
||||
import com.zbkj.crmeb.store.vo.StoreOrderInfoVo;
|
||||
import com.zbkj.crmeb.system.model.SystemAdmin;
|
||||
import com.zbkj.crmeb.system.service.SystemAdminService;
|
||||
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.UserLevelService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.user.model.UserBrokerageRecord;
|
||||
import com.zbkj.crmeb.user.model.UserToken;
|
||||
import com.zbkj.crmeb.user.service.*;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import com.zbkj.crmeb.wechat.service.WeChatService;
|
||||
import com.zbkj.crmeb.wechat.vo.WechatSendMessageForPaySuccess;
|
||||
@@ -57,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -152,6 +155,18 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
@Autowired
|
||||
private StorePinkService storePinkService;
|
||||
|
||||
@Autowired
|
||||
private UserBrokerageRecordService userBrokerageRecordService;
|
||||
|
||||
@Autowired
|
||||
private StoreCouponService storeCouponService;
|
||||
|
||||
@Autowired
|
||||
private SystemAdminService systemAdminService;
|
||||
|
||||
@Autowired
|
||||
private UserTokenService userTokenService;
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
* @param orderId Integer 订单号
|
||||
@@ -315,7 +330,7 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
Integer integral = 0;
|
||||
// 下单赠送积分
|
||||
//赠送积分比例
|
||||
String integralStr = systemConfigService.getValueByKey(Constants.CONFIG_KEY_INTEGRAL_RATE);
|
||||
String integralStr = systemConfigService.getValueByKey(Constants.CONFIG_KEY_INTEGRAL_RATE_ORDER_GIVE);
|
||||
if (StrUtil.isNotBlank(integralStr)) {
|
||||
BigDecimal integralBig = new BigDecimal(integralStr);
|
||||
integral = integralBig.multiply(storeOrder.getPayPrice()).setScale(0, BigDecimal.ROUND_DOWN).intValue();
|
||||
@@ -348,6 +363,11 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
// 更新用户下单数量
|
||||
user.setPayCount(user.getPayCount() + 1);
|
||||
|
||||
/**
|
||||
* 计算佣金,生成佣金记录
|
||||
*/
|
||||
List<UserBrokerageRecord> recordList = assignCommission(storeOrder);
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
//订单日志
|
||||
storeOrderStatusService.addLog(storeOrder.getId(), Constants.ORDER_LOG_PAY_SUCCESS, Constants.ORDER_LOG_MESSAGE_PAY_SUCCESS);
|
||||
@@ -361,6 +381,14 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
//经验升级
|
||||
userLevelService.upLevel(user);
|
||||
|
||||
// 佣金记录
|
||||
if (CollUtil.isNotEmpty(recordList)) {
|
||||
recordList.forEach(temp -> {
|
||||
temp.setLinkId(storeOrder.getOrderId());
|
||||
});
|
||||
userBrokerageRecordService.saveBatch(recordList);
|
||||
}
|
||||
|
||||
// 如果是砍价商品,修改砍价状态
|
||||
if (storeOrder.getBargainId() > 0) {
|
||||
StoreBargainUser storeBargainUser = storeBargainUserService.getByBargainIdAndUid(storeOrder.getBargainId(), user.getUid());
|
||||
@@ -371,72 +399,235 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
// TODO 拼团整体逻辑需调整
|
||||
// TODO 将拼团生成放到订单生成,如果取消订单,则删除生成的拼团的数据
|
||||
// TODO 在这里,只负责将拼团状态改为已完成(用消息列队发送拼团task形式处理)
|
||||
if (storeOrder.getCombinationId() > 0) {
|
||||
// 判断拼团团长是否存在
|
||||
StorePink headPink = new StorePink();
|
||||
Integer pinkId = storeOrder.getPinkId();
|
||||
if (pinkId > 0) {
|
||||
headPink = storePinkService.getById(pinkId);
|
||||
if (ObjectUtil.isNull(headPink) || headPink.getIsRefund().equals(true) || headPink.getStatus() == 3) {
|
||||
pinkId = 0;
|
||||
}
|
||||
}
|
||||
StoreCombination storeCombination = storeCombinationService.getById(storeOrder.getCombinationId());
|
||||
// 生成拼团表数据
|
||||
StorePink storePink = new StorePink();
|
||||
storePink.setUid(user.getUid());
|
||||
storePink.setAvatar(user.getAvatar());
|
||||
storePink.setNickname(user.getNickname());
|
||||
storePink.setOrderId(storeOrder.getOrderId());
|
||||
storePink.setOrderIdKey(storeOrder.getId());
|
||||
storePink.setTotalNum(storeOrder.getTotalNum());
|
||||
storePink.setTotalPrice(storeOrder.getTotalPrice());
|
||||
storePink.setCid(storeCombination.getId());
|
||||
storePink.setPid(storeCombination.getProductId());
|
||||
storePink.setPeople(storeCombination.getPeople());
|
||||
storePink.setPrice(storeCombination.getPrice());
|
||||
Integer effectiveTime = storeCombination.getEffectiveTime();// 有效小时数
|
||||
DateTime dateTime = cn.hutool.core.date.DateUtil.date();
|
||||
storePink.setAddTime(dateTime.getTime());
|
||||
if (pinkId > 0) {
|
||||
storePink.setStopTime(headPink.getStopTime());
|
||||
} else {
|
||||
DateTime hourTime = cn.hutool.core.date.DateUtil.offsetHour(dateTime, effectiveTime);
|
||||
long stopTime = hourTime.getTime();
|
||||
if (stopTime > storeCombination.getStopTime()) {
|
||||
stopTime = storeCombination.getStopTime();
|
||||
}
|
||||
storePink.setStopTime(stopTime);
|
||||
}
|
||||
storePink.setKId(pinkId);
|
||||
storePink.setIsTpl(false);
|
||||
storePink.setIsRefund(false);
|
||||
storePink.setStatus(1);
|
||||
storePinkService.save(storePink);
|
||||
// 如果是开团,需要更新订单数据
|
||||
if (storePink.getKId() == 0) {
|
||||
storeOrder.setPinkId(storePink.getId());
|
||||
storeOrderService.updateById(storeOrder);
|
||||
}
|
||||
}
|
||||
// if (storeOrder.getCombinationId() > 0) {
|
||||
// // 判断拼团团长是否存在
|
||||
// StorePink headPink = new StorePink();
|
||||
// Integer pinkId = storeOrder.getPinkId();
|
||||
// if (pinkId > 0) {
|
||||
// headPink = storePinkService.getById(pinkId);
|
||||
// if (ObjectUtil.isNull(headPink) || headPink.getIsRefund().equals(true) || headPink.getStatus() == 3) {
|
||||
// pinkId = 0;
|
||||
// }
|
||||
// }
|
||||
// StoreCombination storeCombination = storeCombinationService.getById(storeOrder.getCombinationId());
|
||||
// // 生成拼团表数据
|
||||
// StorePink storePink = new StorePink();
|
||||
// storePink.setUid(user.getUid());
|
||||
// storePink.setAvatar(user.getAvatar());
|
||||
// storePink.setNickname(user.getNickname());
|
||||
// storePink.setOrderId(storeOrder.getOrderId());
|
||||
// storePink.setOrderIdKey(storeOrder.getId());
|
||||
// storePink.setTotalNum(storeOrder.getTotalNum());
|
||||
// storePink.setTotalPrice(storeOrder.getTotalPrice());
|
||||
// storePink.setCid(storeCombination.getId());
|
||||
// storePink.setPid(storeCombination.getProductId());
|
||||
// storePink.setPeople(storeCombination.getPeople());
|
||||
// storePink.setPrice(storeCombination.getPrice());
|
||||
// Integer effectiveTime = storeCombination.getEffectiveTime();// 有效小时数
|
||||
// DateTime dateTime = cn.hutool.core.date.DateUtil.date();
|
||||
// storePink.setAddTime(dateTime.getTime());
|
||||
// if (pinkId > 0) {
|
||||
// storePink.setStopTime(headPink.getStopTime());
|
||||
// } else {
|
||||
// DateTime hourTime = cn.hutool.core.date.DateUtil.offsetHour(dateTime, effectiveTime);
|
||||
// long stopTime = hourTime.getTime();
|
||||
// if (stopTime > storeCombination.getStopTime()) {
|
||||
// stopTime = storeCombination.getStopTime();
|
||||
// }
|
||||
// storePink.setStopTime(stopTime);
|
||||
// }
|
||||
// storePink.setKId(pinkId);
|
||||
// storePink.setIsTpl(false);
|
||||
// storePink.setIsRefund(false);
|
||||
// storePink.setStatus(1);
|
||||
// storePinkService.save(storePink);
|
||||
// // 如果是开团,需要更新订单数据
|
||||
// if (storePink.getKId() == 0) {
|
||||
// storeOrder.setPinkId(storePink.getId());
|
||||
// storeOrderService.updateById(storeOrder);
|
||||
// }
|
||||
// }
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
if (execute) {
|
||||
try {
|
||||
// 发送短信
|
||||
if (StrUtil.isNotBlank(user.getPhone())) {
|
||||
// 支付成功提醒开关
|
||||
String lowerOrderSwitch = systemConfigService.getValueByKey(SmsConstants.SMS_CONFIG_LOWER_ORDER_SWITCH);
|
||||
if (StrUtil.isNotBlank(lowerOrderSwitch) && lowerOrderSwitch.equals("1")) {
|
||||
smsService.sendPaySuccess(user.getPhone(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
||||
}
|
||||
}
|
||||
|
||||
// 发送用户支付成功管理员提醒短信
|
||||
String smsSwitch = systemConfigService.getValueByKey(SmsConstants.SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH);
|
||||
if (StrUtil.isNotBlank(smsSwitch) || smsSwitch.equals("1")) {
|
||||
// 查询可已发送短信的管理员
|
||||
List<SystemAdmin> systemAdminList = systemAdminService.findIsSmsList();
|
||||
if (CollUtil.isNotEmpty(systemAdminList)) {
|
||||
// 发送短信
|
||||
systemAdminList.forEach(admin -> {
|
||||
smsService.sendOrderPaySuccessNotice(admin.getPhone(), storeOrder.getOrderId(), admin.getRealName());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//下发模板通知
|
||||
pushTempMessageOrder(storeOrder);
|
||||
pushMessageOrder(storeOrder, user);
|
||||
|
||||
// 购买成功后根据配置送优惠券
|
||||
autoSendCoupons(storeOrder);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("模板通知或优惠券异常");
|
||||
logger.error("短信、模板通知或优惠券异常");
|
||||
}
|
||||
}
|
||||
return execute;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配佣金
|
||||
* @param storeOrder
|
||||
* @return
|
||||
*/
|
||||
private List<UserBrokerageRecord> assignCommission(StoreOrder storeOrder) {
|
||||
// 检测商城是否开启分销功能
|
||||
String isOpen = systemConfigService.getValueByKey(Constants.CONFIG_KEY_STORE_BROKERAGE_IS_OPEN);
|
||||
if(StrUtil.isBlank(isOpen) || isOpen.equals("0")){
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 营销产品不参与
|
||||
if(storeOrder.getCombinationId() > 0 || storeOrder.getSeckillId() > 0 || storeOrder.getBargainId() > 0){
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 查找订单所属人信息
|
||||
User user = userService.getById(storeOrder.getUid());
|
||||
// 当前用户不存在 没有上级 或者 当用用户上级时自己 直接返回
|
||||
if(null == user.getSpreadUid() || user.getSpreadUid() < 1 || user.getSpreadUid().equals(storeOrder.getUid())){
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 获取参与分佣的人(两级)
|
||||
List<MyRecord> spreadRecordList = getSpreadRecordList(user.getSpreadUid());
|
||||
if (CollUtil.isEmpty(spreadRecordList)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
// 获取佣金冻结期
|
||||
String fronzenTime = systemConfigService.getValueByKey(Constants.CONFIG_KEY_STORE_BROKERAGE_EXTRACT_TIME);
|
||||
|
||||
// 生成佣金记录
|
||||
List<UserBrokerageRecord> brokerageRecordList = spreadRecordList.stream().map(record -> {
|
||||
BigDecimal brokerage = calculateCommission(record, storeOrder.getId());
|
||||
UserBrokerageRecord brokerageRecord = new UserBrokerageRecord();
|
||||
brokerageRecord.setUid(record.getInt("spreadUid"));
|
||||
brokerageRecord.setLinkType(BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_ORDER);
|
||||
brokerageRecord.setType(BrokerageRecordConstants.BROKERAGE_RECORD_TYPE_ADD);
|
||||
brokerageRecord.setTitle(BrokerageRecordConstants.BROKERAGE_RECORD_TITLE_ORDER);
|
||||
brokerageRecord.setPrice(brokerage);
|
||||
brokerageRecord.setMark(StrUtil.format("获得推广佣金,分佣{}", brokerage));
|
||||
brokerageRecord.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_CREATE);
|
||||
brokerageRecord.setFrozenTime(Integer.valueOf(Optional.ofNullable(fronzenTime).orElse("0")));
|
||||
brokerageRecord.setCreateTime(DateUtil.nowDateTime());
|
||||
return brokerageRecord;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return brokerageRecordList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算佣金
|
||||
* @param record index-分销级数,spreadUid-分销人
|
||||
* @param orderId 订单id
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal calculateCommission(MyRecord record, Integer orderId) {
|
||||
BigDecimal brokeragePrice = BigDecimal.ZERO;
|
||||
//先看商品是否有固定分佣
|
||||
List<StoreOrderInfoVo> orderInfoVoList = storeOrderInfoService.getOrderListByOrderId(orderId);
|
||||
if(null == orderInfoVoList || orderInfoVoList.size() < 1){
|
||||
return brokeragePrice;
|
||||
}
|
||||
|
||||
//查询对应等级的分销比例
|
||||
Integer index = record.getInt("index");
|
||||
String key = "";
|
||||
if (index == 1) {
|
||||
key = Constants.CONFIG_KEY_STORE_BROKERAGE_RATE_ONE;
|
||||
}
|
||||
if (index == 2) {
|
||||
key = Constants.CONFIG_KEY_STORE_BROKERAGE_RATE_TWO;
|
||||
}
|
||||
String rate = systemConfigService.getValueByKey(key);
|
||||
if(StringUtils.isBlank(rate)){
|
||||
rate = "1";
|
||||
}
|
||||
//佣金比例整数存储, 例如80, 所以计算的时候要除以 10*10
|
||||
BigDecimal rateBigDecimal = brokeragePrice;
|
||||
if(StringUtils.isNotBlank(rate)){
|
||||
rateBigDecimal = new BigDecimal(rate).divide(BigDecimal.TEN.multiply(BigDecimal.TEN));
|
||||
}
|
||||
|
||||
BigDecimal totalBrokerPrice = BigDecimal.ZERO;
|
||||
for (StoreOrderInfoVo orderInfoVo : orderInfoVoList) {
|
||||
if(index == 1){
|
||||
brokeragePrice = orderInfoVo.getInfo().getProductInfo().getAttrInfo().getBrokerage();
|
||||
}
|
||||
if(index == 2){
|
||||
brokeragePrice = orderInfoVo.getInfo().getProductInfo().getAttrInfo().getBrokerageTwo();
|
||||
}
|
||||
|
||||
if(brokeragePrice.compareTo(BigDecimal.ZERO) == 0 && !rateBigDecimal.equals(BigDecimal.ZERO)){
|
||||
// 商品没有分销金额, 并且有设置对应等级的分佣比例
|
||||
// 舍入模式向零舍入。
|
||||
brokeragePrice = orderInfoVo.getInfo().getTruePrice().multiply(rateBigDecimal).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
}
|
||||
|
||||
totalBrokerPrice = totalBrokerPrice.add(brokeragePrice);
|
||||
}
|
||||
return totalBrokerPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参与奋勇人员(两级)
|
||||
* @param spreadUid 一级奋分佣人Uid
|
||||
* @return
|
||||
*/
|
||||
private List<MyRecord> getSpreadRecordList(Integer spreadUid) {
|
||||
List<MyRecord> recordList = CollUtil.newArrayList();
|
||||
|
||||
// 第一级
|
||||
User spreadUser = userService.getById(spreadUid);
|
||||
if (ObjectUtil.isNull(spreadUser)) {
|
||||
return recordList;
|
||||
}
|
||||
// 判断分销模式
|
||||
String model = systemConfigService.getValueByKey(Constants.CONFIG_KEY_STORE_BROKERAGE_MODEL);
|
||||
if (StrUtil.isNotBlank(model) && model.equals("1") && !spreadUser.getIsPromoter()) {
|
||||
// 指定分销模式下:不是推广员不参与分销
|
||||
return recordList;
|
||||
}
|
||||
MyRecord firstRecord = new MyRecord();
|
||||
firstRecord.set("index", 1);
|
||||
firstRecord.set("spreadUid", spreadUid);
|
||||
recordList.add(firstRecord);
|
||||
|
||||
// 第二级
|
||||
User spreadSpreadUser = userService.getById(spreadUser.getSpreadUid());
|
||||
if (ObjectUtil.isNull(spreadSpreadUser)) {
|
||||
return recordList;
|
||||
}
|
||||
if (StrUtil.isNotBlank(model) && model.equals("1") && !spreadSpreadUser.getIsPromoter()) {
|
||||
// 指定分销模式下:不是推广员不参与分销
|
||||
return recordList;
|
||||
}
|
||||
MyRecord secondRecord = new MyRecord();
|
||||
secondRecord.set("index", 2);
|
||||
secondRecord.set("spreadUid", spreadSpreadUser.getUid());
|
||||
recordList.add(secondRecord);
|
||||
return recordList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
* @param storeOrder 订单
|
||||
@@ -647,17 +838,48 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送模板消息通知
|
||||
* 发送消息通知
|
||||
* 根据用户类型发送
|
||||
* 公众号模板消息
|
||||
* 小程序订阅消息
|
||||
*/
|
||||
private void pushTempMessageOrder(StoreOrder storeOrder) {
|
||||
// 小程序发送订阅消息
|
||||
String storeNameAndCarNumString = orderUtils.getStoreNameAndCarNumString(storeOrder.getId());
|
||||
if(StringUtils.isNotBlank(storeNameAndCarNumString)){
|
||||
WechatSendMessageForPaySuccess paySuccess = new WechatSendMessageForPaySuccess(
|
||||
storeOrder.getId()+"",storeOrder.getPayPrice()+"",storeOrder.getPayTime()+"","暂无",
|
||||
storeOrder.getTotalPrice()+"",storeNameAndCarNumString);
|
||||
orderUtils.sendWeiChatMiniMessageForPaySuccess(paySuccess, userService.getById(storeOrder).getUid());
|
||||
private void pushMessageOrder(StoreOrder storeOrder, User user) {
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_H5)) {
|
||||
return;
|
||||
}
|
||||
UserToken userToken;
|
||||
HashMap<String, String> temMap = new HashMap<>();
|
||||
// 公众号
|
||||
if (user.getUserType().equals(UserConstants.USER_TYPE_WECHAT)) {
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_WECHAT);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 发送微信模板消息
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_FIRST, "您的订单已支付成功!");
|
||||
temMap.put("keyword1", storeOrder.getOrderId());
|
||||
temMap.put("keyword2", storeOrder.getPayPrice().toString());
|
||||
temMap.put(Constants.WE_CHAT_TEMP_KEY_END, "欢迎下次再来!");
|
||||
templateMessageService.pushTemplateMessage(Constants.WE_CHAT_TEMP_KEY_ORDER_PAY, temMap, userToken.getToken());
|
||||
return;
|
||||
}
|
||||
// 小程序发送订阅消息
|
||||
userToken = userTokenService.getTokenByUserId(user.getUid(), UserConstants.USER_TOKEN_TYPE_ROUTINE);
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
return ;
|
||||
}
|
||||
// 组装数据
|
||||
temMap.put("character_string1", storeOrder.getOrderId());
|
||||
temMap.put("amount2", storeOrder.getPayPrice().toString() + "元");
|
||||
temMap.put("thing7", "您的订单已支付成功");
|
||||
templateMessageService.pushMiniTemplateMessage(Constants.WE_CHAT_PROGRAM_TEMP_KEY_ORDER_PAY, temMap, userToken.getToken());
|
||||
// String storeNameAndCarNumString = orderUtils.getStoreNameAndCarNumString(storeOrder.getId());
|
||||
// if(StringUtils.isNotBlank(storeNameAndCarNumString)){
|
||||
// WechatSendMessageForPaySuccess paySuccess = new WechatSendMessageForPaySuccess(
|
||||
// storeOrder.getId()+"",storeOrder.getPayPrice()+"",storeOrder.getPayTime()+"","暂无",
|
||||
// storeOrder.getTotalPrice()+"",storeNameAndCarNumString);
|
||||
// orderUtils.sendWeiChatMiniMessageForPaySuccess(paySuccess, userService.getById(storeOrder).getUid());
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,16 +905,45 @@ public class OrderPayServiceImpl extends PayService implements OrderPayService {
|
||||
if(null == orders){
|
||||
return;
|
||||
}
|
||||
List<StoreCouponUser> couponUserList = CollUtil.newArrayList();
|
||||
Map<Integer, Boolean> couponMap = CollUtil.newHashMap();
|
||||
for (StoreOrderInfoVo order : orders) {
|
||||
List<StoreProductCoupon> couponsForGiveUser = storeProductCouponService.getListByProductId(order.getProductId());
|
||||
User currentUser = userService.getById(storeOrder.getUid());
|
||||
for (StoreProductCoupon storeProductCoupon : couponsForGiveUser) {
|
||||
StoreCouponUserRequest crp = new StoreCouponUserRequest();
|
||||
crp.setUid(currentUser.getUid()+"");
|
||||
crp.setCouponId(storeProductCoupon.getIssueCouponId());
|
||||
storeCouponUserService.receive(crp);
|
||||
// User currentUser = userService.getById(storeOrder.getUid());
|
||||
// for (StoreProductCoupon storeProductCoupon : couponsForGiveUser) {
|
||||
// StoreCouponUserRequest crp = new StoreCouponUserRequest();
|
||||
// crp.setUid(currentUser.getUid()+"");
|
||||
// crp.setCouponId(storeProductCoupon.getIssueCouponId());
|
||||
// storeCouponUserService.receive(crp);
|
||||
// }
|
||||
for (int i = 0; i < couponsForGiveUser.size();) {
|
||||
StoreProductCoupon storeProductCoupon = couponsForGiveUser.get(i);
|
||||
MyRecord record = storeCouponUserService.paySuccessGiveAway(storeProductCoupon.getIssueCouponId(), storeOrder.getUid());
|
||||
if (record.getStr("status").equals("fail")) {
|
||||
logger.error(StrUtil.format("支付成功领取优惠券失败,失败原因:{}", record.getStr("errMsg")));
|
||||
couponsForGiveUser.remove(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
StoreCouponUser storeCouponUser = record.get("storeCouponUser");
|
||||
couponUserList.add(storeCouponUser);
|
||||
couponMap.put(storeCouponUser.getCouponId(), record.getBoolean("isLimited"));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
if (CollUtil.isNotEmpty(couponUserList)) {
|
||||
storeCouponUserService.saveBatch(couponUserList);
|
||||
couponUserList.forEach(i -> {
|
||||
storeCouponService.deduction(i.getCouponId(), 1, couponMap.get(i.getCouponId()));
|
||||
});
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if (!execute) {
|
||||
logger.error(StrUtil.format("支付成功领取优惠券,更新数据库失败,订单编号:{}", storeOrder.getOrderId()));
|
||||
}
|
||||
}
|
||||
|
||||
private void userBillCreate() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.crmeb.payment.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.constants.Constants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.DateUtil;
|
||||
@@ -13,8 +14,10 @@ import com.zbkj.crmeb.payment.vo.wechat.PayParamsVo;
|
||||
import com.zbkj.crmeb.payment.wechat.WeChatPayService;
|
||||
import com.zbkj.crmeb.sms.service.SmsService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.model.UserBill;
|
||||
import com.zbkj.crmeb.user.model.UserToken;
|
||||
import com.zbkj.crmeb.user.request.UserOperateFundsRequest;
|
||||
import com.zbkj.crmeb.user.service.UserBillService;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import com.zbkj.crmeb.wechat.service.TemplateMessageService;
|
||||
import lombok.Data;
|
||||
@@ -27,6 +30,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@@ -67,6 +71,9 @@ public class RechargePayServiceImpl extends PayService implements RechargePaySer
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserBillService userBillService;
|
||||
|
||||
//订单类
|
||||
private UserRecharge userRecharge;
|
||||
|
||||
@@ -155,14 +162,33 @@ public class RechargePayServiceImpl extends PayService implements RechargePaySer
|
||||
|
||||
/**
|
||||
* 支付成功处理
|
||||
* 增加余额,userBill记录
|
||||
* @param userRecharge 充值订单
|
||||
* @param userToken 用户Token
|
||||
*/
|
||||
@Override
|
||||
public Boolean paySuccess(UserRecharge userRecharge, UserToken userToken) {
|
||||
public Boolean paySuccess(UserRecharge userRecharge) {
|
||||
userRecharge.setPaid(true);
|
||||
userRecharge.setPayTime(DateUtil.nowDateTime());
|
||||
|
||||
User user = userService.getById(userRecharge.getUid());
|
||||
|
||||
BigDecimal payPrice = userRecharge.getPrice().add(userRecharge.getGivePrice());
|
||||
BigDecimal balance = user.getNowMoney().add(payPrice);
|
||||
// 余额变动对象
|
||||
UserBill userBill = new UserBill();
|
||||
userBill.setUid(userRecharge.getUid());
|
||||
userBill.setLinkId(userRecharge.getOrderId());
|
||||
userBill.setPm(1);
|
||||
userBill.setTitle("充值支付");
|
||||
userBill.setCategory(Constants.USER_BILL_CATEGORY_MONEY);
|
||||
userBill.setType(Constants.USER_BILL_TYPE_PAY_RECHARGE);
|
||||
userBill.setNumber(payPrice);
|
||||
userBill.setBalance(balance);
|
||||
userBill.setMark(StrUtil.format("余额增加了{}元", payPrice));
|
||||
userBill.setStatus(1);
|
||||
userBill.setCreateTime(DateUtil.nowDateTime());
|
||||
|
||||
|
||||
UserOperateFundsRequest userOperateFundsRequest = new UserOperateFundsRequest();
|
||||
userOperateFundsRequest.setValue(userRecharge.getPrice().add(userRecharge.getGivePrice()));
|
||||
userOperateFundsRequest.setFoundsType(Constants.USER_BILL_TYPE_PAY_RECHARGE);
|
||||
@@ -174,15 +200,15 @@ public class RechargePayServiceImpl extends PayService implements RechargePaySer
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
// 订单变动
|
||||
userRechargeService.updateById(userRecharge);
|
||||
//余额变动
|
||||
userService.updateFounds(userOperateFundsRequest, true);
|
||||
//增加经验、积分
|
||||
userService.consumeAfterUpdateUserFounds(userRecharge.getUid(), userRecharge.getPrice(), Constants.USER_BILL_TYPE_PAY_RECHARGE);
|
||||
// 余额变动
|
||||
userService.operationNowMoney(user.getUid(), payPrice, user.getNowMoney(), "add");
|
||||
// 创建记录
|
||||
userBillService.save(userBill);
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if (execute) {
|
||||
//下发模板通知
|
||||
pushTempMessageRecharge(userRecharge);
|
||||
// pushTempMessageRecharge(userRecharge);
|
||||
}
|
||||
return execute;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zbkj.crmeb.payment.wechat;
|
||||
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.zbkj.crmeb.payment.vo.wechat.CreateOrderResponseVo;
|
||||
import com.zbkj.crmeb.payment.vo.wechat.PayParamsVo;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
@@ -35,4 +36,12 @@ public interface WeChatPayService {
|
||||
* @return
|
||||
*/
|
||||
Boolean queryPayResult(String orderNo);
|
||||
|
||||
/**
|
||||
* 微信充值预下单接口
|
||||
* @param userRecharge 充值订单
|
||||
* @param clientIp ip
|
||||
* @return 获取wechat.requestPayment()参数
|
||||
*/
|
||||
Map<String, String> unifiedRecharge(UserRecharge userRecharge, String clientIp);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.payment.wechat.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -10,6 +11,13 @@ import com.constants.PayConstants;
|
||||
import com.constants.WeChatConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.utils.*;
|
||||
import com.zbkj.crmeb.combination.model.StoreCombination;
|
||||
import com.zbkj.crmeb.combination.model.StorePink;
|
||||
import com.zbkj.crmeb.combination.service.StoreCombinationService;
|
||||
import com.zbkj.crmeb.combination.service.StorePinkService;
|
||||
import com.zbkj.crmeb.finance.model.UserRecharge;
|
||||
import com.zbkj.crmeb.finance.service.UserRechargeService;
|
||||
import com.zbkj.crmeb.payment.service.RechargePayService;
|
||||
import com.zbkj.crmeb.payment.vo.wechat.*;
|
||||
import com.zbkj.crmeb.payment.wechat.WeChatPayService;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
@@ -87,6 +95,18 @@ public class WeChatPayServiceImpl implements WeChatPayService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserRechargeService userRechargeService;
|
||||
|
||||
@Autowired
|
||||
private RechargePayService rechargePayService;
|
||||
|
||||
@Autowired
|
||||
private StoreCombinationService storeCombinationService;
|
||||
|
||||
@Autowired
|
||||
private StorePinkService storePinkService;
|
||||
|
||||
/**
|
||||
* 统一下单
|
||||
* @param payParamsVo PayParamsVo 支付参数
|
||||
@@ -343,66 +363,227 @@ public class WeChatPayServiceImpl implements WeChatPayService {
|
||||
if (StrUtil.isBlank(orderNo)) {
|
||||
throw new CrmebException("订单编号不能为空");
|
||||
}
|
||||
StoreOrder storeOrder = storeOrderService.getByOderId(orderNo);
|
||||
if (ObjectUtil.isNull(storeOrder)) {
|
||||
throw new CrmebException("订单不存在");
|
||||
}
|
||||
if (storeOrder.getIsDel()) {
|
||||
throw new CrmebException("订单已被删除");
|
||||
}
|
||||
if (!storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
||||
throw new CrmebException("不是微信支付类型订单,请重新选择支付方式");
|
||||
}
|
||||
// 切割字符串,判断是支付订单还是充值订单
|
||||
String pre = StrUtil.subPre(orderNo, 5);
|
||||
if (pre.equals("order")) {// 支付订单
|
||||
StoreOrder storeOrder = storeOrderService.getByOderId(orderNo);
|
||||
if (ObjectUtil.isNull(storeOrder)) {
|
||||
throw new CrmebException("订单不存在");
|
||||
}
|
||||
if (storeOrder.getIsDel()) {
|
||||
throw new CrmebException("订单已被删除");
|
||||
}
|
||||
if (!storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
||||
throw new CrmebException("不是微信支付类型订单,请重新选择支付方式");
|
||||
}
|
||||
|
||||
if (storeOrder.getPaid()) {
|
||||
if (storeOrder.getPaid()) {
|
||||
// throw new CrmebException("订单已支付");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
User user = userService.getById(storeOrder.getUid());
|
||||
if (ObjectUtil.isNull(user)) throw new CrmebException("用户不存在");
|
||||
|
||||
|
||||
// 获取appid、mch_id
|
||||
// 微信签名key
|
||||
String appId = "";
|
||||
String mchId = "";
|
||||
String signKey = "";
|
||||
if (storeOrder.getIsChannel() == 0) {// 公众号
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
}
|
||||
if (storeOrder.getIsChannel() == 1) {// 小程序
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
}
|
||||
if (storeOrder.getIsChannel() == 2) {// H5
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
}
|
||||
|
||||
// 生成查询订单对象
|
||||
Map<String, String> payVo = getWxChantQueryPayVo(orderNo, appId, mchId, signKey);
|
||||
// 查询订单信息
|
||||
MyRecord record = orderPayQuery(payVo);
|
||||
|
||||
Boolean updatePaid = transactionTemplate.execute(e -> {
|
||||
storeOrderService.updatePaid(orderNo);
|
||||
if (storeOrder.getUseIntegral() > 0) {
|
||||
userService.updateIntegral(user, storeOrder.getUseIntegral(), "sub");
|
||||
}
|
||||
// 处理拼团
|
||||
if (storeOrder.getCombinationId() > 0) {
|
||||
// 判断拼团团长是否存在
|
||||
StorePink headPink = new StorePink();
|
||||
Integer pinkId = storeOrder.getPinkId();
|
||||
if (pinkId > 0) {
|
||||
headPink = storePinkService.getById(pinkId);
|
||||
if (ObjectUtil.isNull(headPink) || headPink.getIsRefund().equals(true) || headPink.getStatus() == 3) {
|
||||
pinkId = 0;
|
||||
}
|
||||
}
|
||||
StoreCombination storeCombination = storeCombinationService.getById(storeOrder.getCombinationId());
|
||||
// 生成拼团表数据
|
||||
StorePink storePink = new StorePink();
|
||||
storePink.setUid(user.getUid());
|
||||
storePink.setAvatar(user.getAvatar());
|
||||
storePink.setNickname(user.getNickname());
|
||||
storePink.setOrderId(storeOrder.getOrderId());
|
||||
storePink.setOrderIdKey(storeOrder.getId());
|
||||
storePink.setTotalNum(storeOrder.getTotalNum());
|
||||
storePink.setTotalPrice(storeOrder.getTotalPrice());
|
||||
storePink.setCid(storeCombination.getId());
|
||||
storePink.setPid(storeCombination.getProductId());
|
||||
storePink.setPeople(storeCombination.getPeople());
|
||||
storePink.setPrice(storeCombination.getPrice());
|
||||
Integer effectiveTime = storeCombination.getEffectiveTime();// 有效小时数
|
||||
DateTime dateTime = cn.hutool.core.date.DateUtil.date();
|
||||
storePink.setAddTime(dateTime.getTime());
|
||||
if (pinkId > 0) {
|
||||
storePink.setStopTime(headPink.getStopTime());
|
||||
} else {
|
||||
DateTime hourTime = cn.hutool.core.date.DateUtil.offsetHour(dateTime, effectiveTime);
|
||||
long stopTime = hourTime.getTime();
|
||||
if (stopTime > storeCombination.getStopTime()) {
|
||||
stopTime = storeCombination.getStopTime();
|
||||
}
|
||||
storePink.setStopTime(stopTime);
|
||||
}
|
||||
storePink.setKId(pinkId);
|
||||
storePink.setIsTpl(false);
|
||||
storePink.setIsRefund(false);
|
||||
storePink.setStatus(1);
|
||||
storePinkService.save(storePink);
|
||||
// 如果是开团,需要更新订单数据
|
||||
if (storePink.getKId() == 0) {
|
||||
storeOrder.setPinkId(storePink.getId());
|
||||
storeOrderService.updateById(storeOrder);
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
if (!updatePaid) {
|
||||
throw new CrmebException("支付成功更新订单失败");
|
||||
}
|
||||
// 添加支付成功task
|
||||
redisUtil.lPush(Constants.ORDER_TASK_PAY_SUCCESS_AFTER, orderNo);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
// 充值订单
|
||||
UserRecharge userRecharge = new UserRecharge();
|
||||
userRecharge.setOrderId(orderNo);
|
||||
userRecharge = userRechargeService.getInfoByEntity(userRecharge);
|
||||
if(ObjectUtil.isNull(userRecharge)){
|
||||
throw new CrmebException("没有找到订单信息");
|
||||
}
|
||||
if(userRecharge.getPaid()){
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
// 查询订单
|
||||
// 获取appid、mch_id
|
||||
// 微信签名key
|
||||
String appId = "";
|
||||
String mchId = "";
|
||||
String signKey = "";
|
||||
if (userRecharge.getRechargeType().equals("public")) {// 公众号
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
}
|
||||
if (userRecharge.getRechargeType().equals("routine")) {// 小程序
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
}
|
||||
// 生成查询订单对象
|
||||
Map<String, String> payVo = getWxChantQueryPayVo(orderNo, appId, mchId, signKey);
|
||||
// 查询订单信息
|
||||
MyRecord record = orderPayQuery(payVo);
|
||||
// 支付成功处理
|
||||
Boolean rechargePayAfter = rechargePayService.paySuccess(userRecharge);
|
||||
if (!rechargePayAfter) {
|
||||
throw new CrmebException("wechat pay error : 数据保存失败==》" + orderNo);
|
||||
}
|
||||
return rechargePayAfter;
|
||||
}
|
||||
|
||||
User user = userService.getById(storeOrder.getUid());
|
||||
if (ObjectUtil.isNull(user)) throw new CrmebException("用户不存在");
|
||||
/**
|
||||
* 微信充值预下单接口
|
||||
* @param userRecharge 充值订单
|
||||
* @param clientIp ip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> unifiedRecharge(UserRecharge userRecharge, String clientIp) {
|
||||
if (ObjectUtil.isNull(userRecharge)) {
|
||||
throw new CrmebException("订单不存在");
|
||||
}
|
||||
// if (userRecharge.getPaid()) {
|
||||
// throw new CrmebException("订单已支付");
|
||||
// }
|
||||
// 获取用户openId
|
||||
// 根据订单支付类型来判断获取公众号openId还是小程序openId
|
||||
UserToken userToken = new UserToken();
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_PUBLIC)) {// 公众号
|
||||
userToken = userTokenService.getTokenByUserId(userRecharge.getUid(), 1);
|
||||
}
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_PROGRAM)) {// 小程序
|
||||
userToken = userTokenService.getTokenByUserId(userRecharge.getUid(), 2);
|
||||
}
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_H5)) {// H5
|
||||
// userTokenService.getByUid(storeOrder.getUid());
|
||||
userToken.setToken("");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNull(userToken)) {
|
||||
throw new CrmebException("该用户没有openId");
|
||||
}
|
||||
|
||||
// 获取appid、mch_id
|
||||
// 微信签名key
|
||||
String appId = "";
|
||||
String mchId = "";
|
||||
String signKey = "";
|
||||
if (storeOrder.getIsChannel() == 0) {// 公众号
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_PUBLIC)) {// 公众号
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
}
|
||||
if (storeOrder.getIsChannel() == 1) {// 小程序
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_PROGRAM)) {// 小程序
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
}
|
||||
if (storeOrder.getIsChannel() == 2) {// H5
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY);
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_H5)) {// H5,使用公众号的
|
||||
appId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID);
|
||||
mchId = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID);
|
||||
signKey = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY);
|
||||
}
|
||||
|
||||
// 生成查询订单对象
|
||||
Map<String, String> payVo = getWxChantQueryPayVo(orderNo, appId, mchId, signKey);
|
||||
// 查询订单信息
|
||||
MyRecord record = orderPayQuery(payVo);
|
||||
// 获取微信预下单对象
|
||||
CreateOrderRequestVo unifiedorderVo = getUnifiedorderVo(userRecharge, userToken.getToken(), clientIp, appId, mchId, signKey);
|
||||
// 预下单
|
||||
CreateOrderResponseVo responseVo = unifiedOrder(unifiedorderVo);
|
||||
|
||||
Boolean updatePaid = transactionTemplate.execute(e -> {
|
||||
storeOrderService.updatePaid(orderNo);
|
||||
if (storeOrder.getUseIntegral() > 0) {
|
||||
userService.updateIntegral(user, storeOrder.getUseIntegral(), "sub");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
});
|
||||
|
||||
if (!updatePaid) {
|
||||
throw new CrmebException("支付成功更新订单失败");
|
||||
// 组装前端预下单参数
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("appId", unifiedorderVo.getAppid());
|
||||
map.put("nonceStr", WxPayUtil.getNonceStr());
|
||||
map.put("package", "prepay_id=".concat(responseVo.getPrepayId()));
|
||||
map.put("signType", unifiedorderVo.getSign_type());
|
||||
map.put("timeStamp", Long.toString(WxPayUtil.getCurrentTimestamp()));
|
||||
String paySign = WxPayUtil.getSign(map, signKey);
|
||||
map.put("paySign", paySign);
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_H5)) {
|
||||
map.put("mweb_url", responseVo.getMWebUrl());
|
||||
}
|
||||
// 添加支付成功task
|
||||
redisUtil.lPush(Constants.ORDER_TASK_PAY_SUCCESS_AFTER, orderNo);
|
||||
return Boolean.TRUE;
|
||||
return map;
|
||||
}
|
||||
|
||||
private MyRecord orderPayQuery(Map<String, String> payVo) {
|
||||
@@ -416,13 +597,17 @@ public class WeChatPayServiceImpl implements WeChatPayService {
|
||||
throw new CrmebException("微信订单查询失败!");
|
||||
}
|
||||
record.setColums(map);
|
||||
if(record.getStr("return_code").toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信下单失败1!" + record.getStr("return_msg"));
|
||||
if (record.getStr("return_code").toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信订单查询失败1!" + record.getStr("return_msg"));
|
||||
}
|
||||
|
||||
if(record.getStr("result_code").toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信下单失败2!" + record.getStr("err_code_des"));
|
||||
if (record.getStr("result_code").toUpperCase().equals("FAIL")){
|
||||
throw new CrmebException("微信订单查询失败2!" + record.getStr("err_code") + record.getStr("err_code_des"));
|
||||
}
|
||||
if (!record.getStr("trade_state").toUpperCase().equals("SUCCESS")){
|
||||
throw new CrmebException("微信订单支付失败!" + record.getStr("trade_state"));
|
||||
}
|
||||
|
||||
return record;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -487,6 +672,48 @@ public class WeChatPayServiceImpl implements WeChatPayService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信预下单对象
|
||||
* @return
|
||||
*/
|
||||
private CreateOrderRequestVo getUnifiedorderVo(UserRecharge userRecharge, String openid, String ip, String appId, String mchId, String signKey) {
|
||||
|
||||
// 获取域名
|
||||
String domain = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_SITE_URL);
|
||||
String apiDomain = systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_API_URL);
|
||||
|
||||
AttachVo attachVo = new AttachVo(Constants.SERVICE_PAY_TYPE_RECHARGE, userRecharge.getUid());
|
||||
CreateOrderRequestVo vo = new CreateOrderRequestVo();
|
||||
|
||||
vo.setAppid(appId);
|
||||
vo.setMch_id(mchId);
|
||||
vo.setNonce_str(WxPayUtil.getNonceStr());
|
||||
vo.setSign_type(PayConstants.WX_PAY_SIGN_TYPE_MD5);
|
||||
vo.setBody(PayConstants.PAY_BODY);
|
||||
vo.setAttach(JSONObject.toJSONString(attachVo));
|
||||
vo.setOut_trade_no(userRecharge.getOrderId());
|
||||
// 订单中使用的是BigDecimal,这里要转为Integer类型
|
||||
vo.setTotal_fee(userRecharge.getPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
|
||||
vo.setSpbill_create_ip(ip);
|
||||
vo.setNotify_url(apiDomain + PayConstants.WX_PAY_NOTIFY_API_URI);
|
||||
vo.setTrade_type(PayConstants.WX_PAY_TRADE_TYPE_JS);
|
||||
vo.setOpenid(openid);
|
||||
if (userRecharge.getRechargeType().equals(PayConstants.PAY_CHANNEL_WE_CHAT_H5)){// H5
|
||||
vo.setTrade_type(PayConstants.WX_PAY_TRADE_TYPE_H5);
|
||||
vo.setOpenid(null);
|
||||
}
|
||||
CreateOrderH5SceneInfoVo createOrderH5SceneInfoVo = new CreateOrderH5SceneInfoVo(
|
||||
new CreateOrderH5SceneInfoDetailVo(
|
||||
domain,
|
||||
systemConfigService.getValueByKeyException(Constants.CONFIG_KEY_SITE_NAME)
|
||||
)
|
||||
);
|
||||
vo.setScene_info(JSONObject.toJSONString(createOrderH5SceneInfoVo));
|
||||
String sign = WxPayUtil.getSign(vo, signKey);
|
||||
vo.setSign(sign);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作用:统一下单<br>
|
||||
* 场景:公共号支付、扫码支付、APP支付
|
||||
|
||||
@@ -7,9 +7,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -43,19 +47,28 @@ public class WeChatMessageController {
|
||||
public String webHook(HttpServletRequest request){
|
||||
return weChatMessageService.init(request);
|
||||
}
|
||||
//微信推送地址验证
|
||||
// @RequestMapping(value = { "/webHook" }, method = RequestMethod.GET)
|
||||
// private void webHook(
|
||||
// @RequestParam(value = "signature", required = false) String signature,
|
||||
// @RequestParam(value = "timestamp", required = false) String timestamp,
|
||||
// @RequestParam(value = "nonce", required = false) String nonce,
|
||||
// @RequestParam(value = "echostr") String echostr,
|
||||
// HttpServletResponse response) throws IOException {
|
||||
// PrintWriter writer = response.getWriter();
|
||||
// writer.print(echostr);
|
||||
// writer.flush();
|
||||
// writer.close();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 微信推送地址验证
|
||||
* @param signature
|
||||
* @param timestamp
|
||||
* @param nonce
|
||||
* @param echostr
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = { "/webHook" }, method = RequestMethod.GET)
|
||||
private void webHook(
|
||||
@RequestParam(value = "signature", required = false) String signature,
|
||||
@RequestParam(value = "timestamp", required = false) String timestamp,
|
||||
@RequestParam(value = "nonce", required = false) String nonce,
|
||||
@RequestParam(value = "echostr") String echostr,
|
||||
HttpServletResponse response) throws IOException {
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.print(echostr);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class StoreSeckillMangerController {
|
||||
StoreSeckillManger storeSeckillManger = new StoreSeckillManger();
|
||||
BeanUtils.copyProperties(request, storeSeckillManger);
|
||||
// 对request中的time做分割后赋值给mode中的start和end属性
|
||||
setTimeRangeFromRequest(request, storeSeckillManger);
|
||||
storeSeckillMangerService.setTimeRangeFromRequest(request, storeSeckillManger);
|
||||
CommonPage<StoreSeckillManagerResponse> storeSeckillMangerCommonPage =
|
||||
CommonPage.restPage(storeSeckillMangerService.getList(storeSeckillManger, pageParamRequest));
|
||||
return CommonResult.success(storeSeckillMangerCommonPage);
|
||||
@@ -81,7 +81,7 @@ public class StoreSeckillMangerController {
|
||||
StoreSeckillManger storeSeckillManger = new StoreSeckillManger();
|
||||
BeanUtils.copyProperties(storeSeckillMangerRequest, storeSeckillManger);
|
||||
// 对request中的time做分割后赋值给mode中的start和end属性
|
||||
setTimeRangeFromRequest(storeSeckillMangerRequest, storeSeckillManger);
|
||||
storeSeckillMangerService.setTimeRangeFromRequest(storeSeckillMangerRequest, storeSeckillManger);
|
||||
List<StoreSeckillManger> storeSeckillMangers = storeSeckillMangerService.checkTimeRangeUnique(storeSeckillManger);
|
||||
if(storeSeckillMangers.size() > 0){
|
||||
throw new CrmebException("当前时间段的秒杀配置已存在");
|
||||
@@ -122,29 +122,7 @@ public class StoreSeckillMangerController {
|
||||
@ApiOperation(value = "修改")
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public CommonResult<String> update(@RequestParam Integer id, @RequestBody @Validated StoreSeckillMangerRequest storeSeckillMangerRequest){
|
||||
StoreSeckillManger storeSeckillManger = new StoreSeckillManger();
|
||||
BeanUtils.copyProperties(storeSeckillMangerRequest, storeSeckillManger);
|
||||
storeSeckillManger.setId(id);
|
||||
// 对request中的time做分割后赋值给mode中的start和end属性
|
||||
setTimeRangeFromRequest(storeSeckillMangerRequest, storeSeckillManger);
|
||||
List<StoreSeckillManger> existTimes = storeSeckillMangerService.checkTimeRangeUnique(storeSeckillManger);
|
||||
if(existTimes.size() == 0){
|
||||
storeSeckillMangerService.updateByCondition(storeSeckillManger);
|
||||
}else{
|
||||
// 更新时排除自身更新
|
||||
StoreSeckillManger ssm = existTimes.get(0);
|
||||
if(ssm.getId() == id && ssm.getStartTime() == storeSeckillManger.getStartTime()
|
||||
&& ssm.getEndTime() == storeSeckillManger.getEndTime()){
|
||||
if(storeSeckillMangerService.updateByCondition(storeSeckillManger)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}else{
|
||||
throw new CrmebException("当前时间段的秒杀配置已存在");
|
||||
}
|
||||
}
|
||||
return CommonResult.failed();
|
||||
return storeSeckillMangerService.update(id,storeSeckillMangerRequest) ? CommonResult.success() : CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,38 +154,7 @@ public class StoreSeckillMangerController {
|
||||
return CommonResult.success(storeSeckillMangerService.updateStatus(id,status));
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容时间参数 request中String格式 mode中Integer
|
||||
* @param storeSeckillMangerRequest request参数
|
||||
* @param storeSeckillManger 秒杀配置实体
|
||||
*/
|
||||
private void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerRequest storeSeckillMangerRequest, StoreSeckillManger storeSeckillManger) {
|
||||
if(!storeSeckillMangerRequest.getTime().contains(",")){
|
||||
throw new CrmebException("时间参数不正确 例如:01:00,02:00");
|
||||
}
|
||||
String[] timeRage = storeSeckillMangerRequest.getTime().split(",");
|
||||
Integer startTime = Integer.parseInt(timeRage[0].split(":")[0]);
|
||||
Integer endTime = Integer.parseInt(timeRage[1].split(":")[0]);
|
||||
storeSeckillManger.setStartTime(startTime);
|
||||
storeSeckillManger.setEndTime(endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容时间参数 request中String格式 mode中Integer
|
||||
* @param request request参数
|
||||
* @param storeSeckillManger 秒杀配置实体
|
||||
*/
|
||||
private void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerSearchRequest request, StoreSeckillManger storeSeckillManger) {
|
||||
if(null == request.getTime()) return;
|
||||
if(!request.getTime().contains(",")){
|
||||
throw new CrmebException("时间参数不正确 例如:01:00,02:00");
|
||||
}
|
||||
String[] timeRage = request.getTime().split(",");
|
||||
Integer startTime = Integer.parseInt(timeRage[0].split(":")[0]);
|
||||
Integer endTime = Integer.parseInt(timeRage[1].split(":")[0]);
|
||||
storeSeckillManger.setStartTime(startTime);
|
||||
storeSeckillManger.setEndTime(endTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.zbkj.crmeb.seckill.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.seckill.model.StoreSeckillManger;
|
||||
import com.zbkj.crmeb.seckill.request.StoreSeckillMangerRequest;
|
||||
import com.zbkj.crmeb.seckill.request.StoreSeckillMangerSearchRequest;
|
||||
import com.zbkj.crmeb.seckill.response.StoreSeckillManagerResponse;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -64,4 +68,14 @@ public interface StoreSeckillMangerService extends IService<StoreSeckillManger>
|
||||
* @return 结果
|
||||
*/
|
||||
boolean updateStatus(int id, boolean status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新秒杀配置
|
||||
* @param id id
|
||||
* @param storeSeckillMangerRequest 秒杀配置
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(Integer id,StoreSeckillMangerRequest storeSeckillMangerRequest);
|
||||
void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerRequest storeSeckillMangerRequest, StoreSeckillManger storeSeckillManger);
|
||||
void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerSearchRequest request, StoreSeckillManger storeSeckillManger);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.zbkj.crmeb.seckill.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -11,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.utils.DateUtil;
|
||||
import com.zbkj.crmeb.seckill.dao.StoreSeckillMangerDao;
|
||||
import com.zbkj.crmeb.seckill.model.StoreSeckillManger;
|
||||
import com.zbkj.crmeb.seckill.request.StoreSeckillMangerRequest;
|
||||
import com.zbkj.crmeb.seckill.request.StoreSeckillMangerSearchRequest;
|
||||
import com.zbkj.crmeb.seckill.response.StoreSeckillManagerResponse;
|
||||
import com.zbkj.crmeb.seckill.service.StoreSeckillMangerService;
|
||||
@@ -18,6 +22,8 @@ import com.zbkj.crmeb.system.service.SystemAttachmentService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
@@ -172,6 +178,52 @@ public class StoreSeckillMangerServiceImpl extends ServiceImpl<StoreSeckillMange
|
||||
return dao.updateById(ssm) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新秒杀配置
|
||||
* @param id id
|
||||
* @param storeSeckillMangerRequest 秒杀配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(Integer id,StoreSeckillMangerRequest storeSeckillMangerRequest) {
|
||||
StoreSeckillManger storeSeckillManger = new StoreSeckillManger();
|
||||
BeanUtils.copyProperties(storeSeckillMangerRequest, storeSeckillManger);
|
||||
storeSeckillManger.setId(id);
|
||||
// 对request中的time做分割后赋值给mode中的start和end属性
|
||||
setTimeRangeFromRequest(storeSeckillMangerRequest, storeSeckillManger);
|
||||
List<StoreSeckillManger> existTimes = checkTimeRangeUnique(storeSeckillManger);
|
||||
if(existTimes.size() == 0){
|
||||
return updateByCondition(storeSeckillManger);
|
||||
}
|
||||
// 更新时排除自身更新
|
||||
StoreSeckillManger ssm = existTimes.get(0);
|
||||
// if(ssm.getStartTime().equals(storeSeckillManger.getStartTime())
|
||||
// && ssm.getEndTime().equals(storeSeckillManger.getEndTime())){
|
||||
// return updateByCondition(storeSeckillManger);
|
||||
// // 更新时 时间更改的判断
|
||||
// }else
|
||||
if (!ssm.getStartTime().equals(storeSeckillManger.getStartTime())
|
||||
|| !ssm.getEndTime().equals(storeSeckillManger.getEndTime())){
|
||||
// 判断开始时间 结束时间 是否被包涵
|
||||
LambdaQueryWrapper<StoreSeckillManger> startAndEndExcuseQuery = Wrappers.lambdaQuery();
|
||||
startAndEndExcuseQuery.ge(StoreSeckillManger::getStartTime,storeSeckillManger.getStartTime())
|
||||
.or()
|
||||
.le(StoreSeckillManger::getEndTime,storeSeckillManger.getEndTime());
|
||||
List<StoreSeckillManger> storeSeckillMangers = dao.selectList(startAndEndExcuseQuery);
|
||||
// 时间区间改大 不存在的情况
|
||||
if(CollUtil.isEmpty(storeSeckillMangers) && storeSeckillMangers.size() == 0){
|
||||
return updateByCondition(storeSeckillManger);
|
||||
// 时间区间改小 id一样且仅仅存在一条
|
||||
}else if(storeSeckillMangers.size() == 1 && storeSeckillMangers.get(0).getId().equals(id)){
|
||||
return updateByCondition(storeSeckillManger);
|
||||
}else{
|
||||
throw new CrmebException("当前时间段的秒杀配置已存在");
|
||||
}
|
||||
}else {
|
||||
throw new CrmebException("当前时间段的秒杀配置已存在");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////// 自定义方法
|
||||
|
||||
// 列表用 格式化time 对前端输出一致
|
||||
@@ -192,5 +244,40 @@ public class StoreSeckillMangerServiceImpl extends ServiceImpl<StoreSeckillMange
|
||||
String endTime = pEndTime.length() == 1? "0"+pEndTime:pEndTime;
|
||||
r.setTime(startTime+":00,"+endTime+":00");
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容时间参数 request中String格式 mode中Integer
|
||||
* @param storeSeckillMangerRequest request参数
|
||||
* @param storeSeckillManger 秒杀配置实体
|
||||
*/
|
||||
@Override
|
||||
public void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerRequest storeSeckillMangerRequest, StoreSeckillManger storeSeckillManger) {
|
||||
if(!storeSeckillMangerRequest.getTime().contains(",")){
|
||||
throw new CrmebException("时间参数不正确 例如:01:00,02:00");
|
||||
}
|
||||
String[] timeRage = storeSeckillMangerRequest.getTime().split(",");
|
||||
Integer startTime = Integer.parseInt(timeRage[0].split(":")[0]);
|
||||
Integer endTime = Integer.parseInt(timeRage[1].split(":")[0]);
|
||||
storeSeckillManger.setStartTime(startTime);
|
||||
storeSeckillManger.setEndTime(endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容时间参数 request中String格式 mode中Integer
|
||||
* @param request request参数
|
||||
* @param storeSeckillManger 秒杀配置实体
|
||||
*/
|
||||
@Override
|
||||
public void setTimeRangeFromRequest(@Validated @RequestBody StoreSeckillMangerSearchRequest request, StoreSeckillManger storeSeckillManger) {
|
||||
if(null == request.getTime()) return;
|
||||
if(!request.getTime().contains(",")){
|
||||
throw new CrmebException("时间参数不正确 例如:01:00,02:00");
|
||||
}
|
||||
String[] timeRage = request.getTime().split(",");
|
||||
Integer startTime = Integer.parseInt(timeRage[0].split(":")[0]);
|
||||
Integer endTime = Integer.parseInt(timeRage[1].split(":")[0]);
|
||||
storeSeckillManger.setStartTime(startTime);
|
||||
storeSeckillManger.setEndTime(endTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,21 +87,21 @@ public class SmsRecordController {
|
||||
return CommonResult.success(smsService.applys(type, pageParamRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* @param phone 手机号码
|
||||
* @return 发送是否成功
|
||||
*/
|
||||
@ApiOperation(value = " 发送短信")
|
||||
@RequestMapping(value = "/sendCode", method = RequestMethod.POST)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="phone", value="手机号码", required = true)
|
||||
})
|
||||
public CommonResult<Object> sendCode(@RequestParam String phone){
|
||||
ValidateFormUtil.isPhone(phone,"手机号码错误");
|
||||
boolean codeResult = smsService.pushCodeToList(phone,1, null);
|
||||
return codeResult ? CommonResult.success("短信加入发送队列成功"):CommonResult.failed("短信加入发送队列失败");
|
||||
}
|
||||
// /**
|
||||
// * 发送短信
|
||||
// * @param phone 手机号码
|
||||
// * @return 发送是否成功
|
||||
// */
|
||||
// @ApiOperation(value = " 发送短信")
|
||||
// @RequestMapping(value = "/sendCode", method = RequestMethod.POST)
|
||||
// @ApiImplicitParams({
|
||||
// @ApiImplicitParam(name="phone", value="手机号码", required = true)
|
||||
// })
|
||||
// public CommonResult<Object> sendCode(@RequestParam String phone){
|
||||
// ValidateFormUtil.isPhone(phone,"手机号码错误");
|
||||
// boolean codeResult = smsService.pushCodeToList(phone,1, null);
|
||||
// return codeResult ? CommonResult.success("短信加入发送队列成功"):CommonResult.failed("短信加入发送队列失败");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.zbkj.crmeb.sms.request.SendSmsVo;
|
||||
import com.zbkj.crmeb.sms.request.SmsApplyTempRequest;
|
||||
import com.zbkj.crmeb.sms.request.SmsModifySignRequest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@@ -20,41 +21,98 @@ import java.util.HashMap;
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface SmsService{
|
||||
public interface SmsService {
|
||||
|
||||
/**
|
||||
* 发送短信到短信列表
|
||||
*/
|
||||
Boolean pushCodeToList(String phone, Integer tag,HashMap<String, Object> pram);
|
||||
|
||||
void push(String phone,String tempKey,Integer msgTempId,boolean valid, HashMap<String,Object> mapPram);
|
||||
void push(String phone, String tempKey, Integer msgTempId, HashMap<String, Object> mapPram);
|
||||
|
||||
void consume();
|
||||
|
||||
boolean sendCode(SendSmsVo sendSmsVo);
|
||||
Boolean sendCode(SendSmsVo sendSmsVo);
|
||||
|
||||
/**
|
||||
* 修改签名
|
||||
* @return
|
||||
*/
|
||||
Boolean modifySign(SmsModifySignRequest request);
|
||||
|
||||
/**
|
||||
* 短信模板
|
||||
* @return
|
||||
*/
|
||||
MyRecord temps(PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 申请模板消息
|
||||
* @return
|
||||
*/
|
||||
Boolean applyTempMessage(SmsApplyTempRequest request);
|
||||
|
||||
/**
|
||||
* 模板申请记录
|
||||
*
|
||||
* @param type (1=验证码 2=通知 3=推广)
|
||||
* @return
|
||||
*/
|
||||
MyRecord applys(Integer type, PageParamRequest pageParamRequest);
|
||||
|
||||
/**
|
||||
* 发送公共验证码
|
||||
*
|
||||
* @param phone 手机号
|
||||
*/
|
||||
Boolean sendCommonCode(String phone);
|
||||
|
||||
/**
|
||||
* 发送支付成功短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param payPrice 支付金额
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean sendPaySuccess(String phone, String orderNo, BigDecimal payPrice);
|
||||
|
||||
/**
|
||||
* 发送管理员下单短信提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
*/
|
||||
Boolean sendCreateOrderNotice(String phone, String orderNo, String realName);
|
||||
|
||||
/**
|
||||
* 发送订单支付成功管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
*/
|
||||
Boolean sendOrderPaySuccessNotice(String phone, String orderNo, String realName);
|
||||
|
||||
/**
|
||||
* 发送用户退款管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
*/
|
||||
Boolean sendOrderRefundApplyNotice(String phone, String orderNo, String realName);
|
||||
|
||||
/**
|
||||
* 发送用户确认收货管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
*/
|
||||
Boolean sendOrderReceiptNotice(String phone, String orderNo, String realName);
|
||||
|
||||
/**
|
||||
* 发送订单改价提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param price 修改后的支付金额
|
||||
*/
|
||||
Boolean sendOrderEditPriceNotice(String phone, String orderNo, BigDecimal price);
|
||||
|
||||
/**
|
||||
* 发送订单发货提醒短信
|
||||
* @param phone 手机号
|
||||
* @param nickName 用户昵称
|
||||
* @param storeName 商品名称
|
||||
* @param orderNo 订单编号
|
||||
*/
|
||||
Boolean sendOrderDeliverNotice(String phone, String nickName, String storeName, String orderNo);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -50,7 +51,6 @@ import java.util.stream.Collectors;
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@Service
|
||||
public class SmsServiceImpl implements SmsService {
|
||||
|
||||
@@ -78,72 +78,71 @@ public class SmsServiceImpl implements SmsService {
|
||||
* 添加到短信队列
|
||||
* 验证码特殊处理其他的参数自行根据要求处理
|
||||
* 参数处理逻辑 {code:value,code1:value1}
|
||||
*
|
||||
* @param phone String 手机号码
|
||||
* @return boolean
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
*/
|
||||
@Override
|
||||
public Boolean pushCodeToList(String phone, Integer tag, HashMap<String, Object> pram) {
|
||||
private Boolean pushCodeToList(String phone, Integer tag, HashMap<String, Object> pram) {
|
||||
//发送手机验证码, 记录到redis sms_validate_code_手机号
|
||||
switch (tag) {
|
||||
case SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE: // 验证码 特殊处理 code
|
||||
//获取短信验证码过期时间
|
||||
String codeExpireStr = systemConfigService.getValueByKey(Constants.CONFIG_KEY_SMS_CODE_EXPIRE);
|
||||
if (StringUtils.isBlank(codeExpireStr) || Integer.parseInt(codeExpireStr) == 0) {
|
||||
codeExpireStr = Constants.NUM_FIVE + "";
|
||||
codeExpireStr = Constants.NUM_FIVE + "";// 默认5分钟过期
|
||||
}
|
||||
Integer code = CrmebUtil.randomCount(111111, 999999);
|
||||
HashMap<String, Object> justPram = new HashMap<>();
|
||||
justPram.put("code", code);
|
||||
justPram.put("time", codeExpireStr);
|
||||
push(phone, SmsConstants.SMS_CONFIG_VERIFICATION_CODE,
|
||||
SmsConstants.SMS_CONFIG_VERIFICATION_CODE_TEMP_ID, false, justPram);
|
||||
|
||||
redisUtil.set(userService.getValidateCodeRedisKey(phone), code, Long.valueOf(codeExpireStr), TimeUnit.MINUTES);//5分钟过期
|
||||
SmsConstants.SMS_CONFIG_VERIFICATION_CODE_TEMP_ID, justPram);
|
||||
|
||||
// 将验证码存入redis
|
||||
redisUtil.set(userService.getValidateCodeRedisKey(phone), code, Long.valueOf(codeExpireStr), TimeUnit.MINUTES);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_LOWER_ORDER_SWITCH: // 支付成功短信提醒 pay_price order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_LOWER_ORDER_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_LOWER_ORDER_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_LOWER_ORDER_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_DELIVER_GOODS_SWITCH: // 发货短信提醒 nickname store_name
|
||||
push(phone, SmsConstants.SMS_CONFIG_DELIVER_GOODS_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_DELIVER_GOODS_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_DELIVER_GOODS_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_CONFIRM_TAKE_OVER_SWITCH: // 确认收货短信提醒 order_id store_name
|
||||
push(phone, SmsConstants.SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_ADMIN_LOWER_ORDER_SWITCH: // 用户下单管理员短信提醒 admin_name order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_ADMIN_LOWER_ORDER_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_ADMIN_PAY_SUCCESS_SWITCH: // 支付成功管理员短信提醒 admin_name order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_ADMIN_PAY_SUCCESS_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_ADMIN_REFUND_SWITCH: // 用户确认收货管理员短信提醒 admin_name order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_ADMIN_REFUND_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_ADMIN_REFUND_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_ADMIN_REFUND_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_ADMIN_CONFIRM_TAKE_OVER_SWITCH: // 用户发起退款管理员短信提醒 admin_name order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_ADMIN_CONFIRM_TAKE_OVER_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_PRICE_REVISION_SWITCH: // 改价短信提醒 order_id pay_price
|
||||
push(phone, SmsConstants.SMS_CONFIG_PRICE_REVISION_SWITCH,
|
||||
SmsConstants.SMS_CONFIG_PRICE_REVISION_SWITCH_TEMP_ID, true, pram);
|
||||
SmsConstants.SMS_CONFIG_PRICE_REVISION_SWITCH_TEMP_ID, pram);
|
||||
break;
|
||||
case SmsConstants.SMS_CONFIG_TYPE_ORDER_PAY_FALSE: // 订单未支付 order_id
|
||||
push(phone, SmsConstants.SMS_CONFIG_ORDER_PAY_FALSE,
|
||||
SmsConstants.SMS_CONFIG_ORDER_PAY_FALSE_TEMP_ID, false, pram);
|
||||
SmsConstants.SMS_CONFIG_ORDER_PAY_FALSE_TEMP_ID, pram);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendCode(SendSmsVo sendSmsVo) {
|
||||
public Boolean sendCode(SendSmsVo sendSmsVo) {
|
||||
String result;
|
||||
try {
|
||||
String token = onePassUtil.getToken();
|
||||
@@ -154,7 +153,7 @@ public class SmsServiceImpl implements SmsService {
|
||||
param.add("phone", sendSmsVo.getMobile());
|
||||
param.add("temp_id", sendSmsVo.getTemplate());
|
||||
map.entrySet().stream().forEach(entry -> param.add(StrUtil.format(SmsConstants.SMS_COMMON_PARAM_FORMAT, entry.getKey()), entry.getValue()));
|
||||
|
||||
System.out.println("============发送短信=========header = " + header);
|
||||
result = restTemplateUtil.postFromUrlencoded(OnePassConstants.ONE_PASS_API_URL + OnePassConstants.ONE_PASS_API_SEND_URI, param, header);
|
||||
} catch (Exception e) {
|
||||
//接口请求异常,需要重新发送
|
||||
@@ -227,9 +226,14 @@ public class SmsServiceImpl implements SmsService {
|
||||
|
||||
/**
|
||||
* 添加待发送消息到redis队列
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param tempKey 模板key
|
||||
* @param msgTempId 模板id
|
||||
* @param mapPram 参数map
|
||||
*/
|
||||
@Override
|
||||
public void push(String phone, String tempKey, Integer msgTempId, boolean valid, HashMap<String, Object> mapPram) {
|
||||
public void push(String phone, String tempKey, Integer msgTempId, HashMap<String, Object> mapPram) {
|
||||
if (StringUtils.isBlank(phone) || StringUtils.isBlank(tempKey) || msgTempId <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -242,14 +246,7 @@ public class SmsServiceImpl implements SmsService {
|
||||
mParam.put("template", msgTempId);
|
||||
mParam.put("param", JSONObject.toJSONString(mapPram));
|
||||
|
||||
if (!valid) {
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_KEY, JSONObject.toJSONString(mParam));
|
||||
return;
|
||||
}
|
||||
String value = systemConfigService.getValueByKey(tempKey);
|
||||
if (value.equals("1")) {
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_KEY, JSONObject.toJSONString(mParam));
|
||||
}
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_KEY, JSONObject.toJSONString(mParam));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,7 +326,7 @@ public class SmsServiceImpl implements SmsService {
|
||||
/**
|
||||
* 模板申请记录
|
||||
*
|
||||
* @param type (1=验证码 2=通知 3=推广)
|
||||
* @param type (1=验证码 2=通知 3=推广)
|
||||
*/
|
||||
@Override
|
||||
public MyRecord applys(Integer type, PageParamRequest pageParamRequest) {
|
||||
@@ -371,6 +368,123 @@ public class SmsServiceImpl implements SmsService {
|
||||
return myRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送公共验证码
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendCommonCode(String phone) {
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送支付成功短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param payPrice 支付金额
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendPaySuccess(String phone, String orderNo, BigDecimal payPrice) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("pay_price", payPrice);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_LOWER_ORDER_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送管理员下单短信提醒
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendCreateOrderNotice(String phone, String orderNo, String realName) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("admin_name", realName);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_ADMIN_LOWER_ORDER_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送订单支付成功管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendOrderPaySuccessNotice(String phone, String orderNo, String realName) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("admin_name", realName);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_ADMIN_PAY_SUCCESS_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送用户退款管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendOrderRefundApplyNotice(String phone, String orderNo, String realName) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("admin_name", realName);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_ADMIN_CONFIRM_TAKE_OVER_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送用户确认收货管理员提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param realName 管理员名称
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendOrderReceiptNotice(String phone, String orderNo, String realName) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("admin_name", realName);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_ADMIN_REFUND_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送订单改价提醒短信
|
||||
* @param phone 手机号
|
||||
* @param orderNo 订单编号
|
||||
* @param price 修改后的支付金额
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendOrderEditPriceNotice(String phone, String orderNo, BigDecimal price) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("order_id", orderNo);
|
||||
map.put("pay_price", price);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_PRICE_REVISION_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送订单发货提醒短信
|
||||
* @param phone 手机号
|
||||
* @param nickName 用户昵称
|
||||
* @param storeName 商品名称
|
||||
* @param orderNo 订单编号
|
||||
*/
|
||||
@Override
|
||||
public Boolean sendOrderDeliverNotice(String phone, String nickName, String storeName, String orderNo) {
|
||||
HashMap<String, Object> map = CollUtil.newHashMap();
|
||||
map.put("nickname", nickName);
|
||||
map.put("store_name", storeName);
|
||||
map.put("order_id", orderNo);
|
||||
return pushCodeToList(phone, SmsConstants.SMS_CONFIG_TYPE_DELIVER_GOODS_SWITCH, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* post请求from表单模式提交
|
||||
*/
|
||||
|
||||
@@ -3,17 +3,13 @@ package com.zbkj.crmeb.store.controller;
|
||||
import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.finance.service.UserExtractService;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
import com.zbkj.crmeb.store.request.RetailShopRequest;
|
||||
import com.zbkj.crmeb.store.request.RetailShopStairUserRequest;
|
||||
import com.zbkj.crmeb.store.response.RetailShopStatisticsResponse;
|
||||
import com.zbkj.crmeb.store.response.RetailShopUserResponse;
|
||||
import com.zbkj.crmeb.store.service.RetailShopService;
|
||||
import com.zbkj.crmeb.store.service.StoreOrderService;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.response.UserResponse;
|
||||
import com.zbkj.crmeb.user.response.SpreadUserResponse;
|
||||
import com.zbkj.crmeb.user.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -24,11 +20,6 @@ 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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 分销模块
|
||||
* +----------------------------------------------------------------------
|
||||
@@ -53,37 +44,29 @@ public class RetailShopController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreOrderService storeOrderService;
|
||||
|
||||
@Autowired
|
||||
private UserExtractService userExtractService;
|
||||
|
||||
/**
|
||||
* 分销列表
|
||||
* @param keywords
|
||||
* @param dateLimit
|
||||
* @param pageParamRequest
|
||||
* @return
|
||||
* 分销员列表
|
||||
* @param keywords 搜索参数
|
||||
* @param dateLimit 时间参数
|
||||
* @param pageParamRequest 分页参数
|
||||
*/
|
||||
@ApiOperation(value = "分销列表")
|
||||
@ApiOperation(value = "分销员列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "keywords", value = "搜索关键字[身份证,手机,昵称,备注等]"),
|
||||
@ApiImplicitParam(name = "dateLimit", value = "today,yesterday,lately7,lately30,month,year,/yyyy-MM-dd hh:mm:ss,yyyy-MM-dd hh:mm:ss/")
|
||||
})
|
||||
public CommonResult<CommonPage<RetailShopUserResponse>> getList(@RequestParam(required = false) String keywords,
|
||||
@RequestParam(required = false) String dateLimit,
|
||||
@ModelAttribute PageParamRequest pageParamRequest){
|
||||
return CommonResult.success(retailShopService.getList(keywords,dateLimit,pageParamRequest));
|
||||
public CommonResult<CommonPage<SpreadUserResponse>> getList(@RequestParam(required = false) String keywords,
|
||||
@RequestParam(required = false) String dateLimit,
|
||||
@ModelAttribute PageParamRequest pageParamRequest) {
|
||||
return CommonResult.success(retailShopService.getSpreadPeopleList(keywords, dateLimit, pageParamRequest));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销头部信息
|
||||
* @param keywords 搜索参数
|
||||
* @param keywords 搜索参数
|
||||
* @param dateLimit 时间参数
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分销头部数据")
|
||||
@RequestMapping(value = "/statistics", method = RequestMethod.GET)
|
||||
@@ -92,14 +75,14 @@ public class RetailShopController {
|
||||
@ApiImplicitParam(name = "dateLimit", value = "today,yesterday,lately7,lately30,month,year,/yyyy-MM-dd hh:mm:ss,yyyy-MM-dd hh:mm:ss/")
|
||||
})
|
||||
public CommonResult<RetailShopStatisticsResponse> getStatistics(@RequestParam(required = false) String keywords,
|
||||
@RequestParam(required = false) String dateLimit){
|
||||
@RequestParam(required = false) String dateLimit) {
|
||||
return CommonResult.success(retailShopService.getAdminStatistics(keywords, dateLimit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加推广关系
|
||||
* @param currentUserId 当前用户id
|
||||
* @param spreadUserId 推广人用户id
|
||||
* @param spreadUserId 推广人用户id
|
||||
* @return 结果
|
||||
*/
|
||||
@ApiOperation(value = "添加推广关系")
|
||||
@@ -108,35 +91,35 @@ public class RetailShopController {
|
||||
@ApiImplicitParam(name = "currentUserId", value = "当前用户id"),
|
||||
@ApiImplicitParam(name = "spreadUserId", value = "推广人id")
|
||||
})
|
||||
public CommonResult<Object> save(Integer currentUserId, Integer spreadUserId){
|
||||
public CommonResult<Object> save(Integer currentUserId, Integer spreadUserId) {
|
||||
return CommonResult.success(userService.spread(currentUserId, spreadUserId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户参数获取推广人列表
|
||||
* @param request 查询参数
|
||||
* @param request 查询参数
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return 查询结果推广人列表
|
||||
*/
|
||||
@ApiOperation(value = "根据条件获取推广人列表")
|
||||
@RequestMapping(value = "/spread/userlist", method = RequestMethod.POST)
|
||||
public CommonResult<CommonPage<User>> getUserListBySpreadLevel(@RequestBody @Validated RetailShopStairUserRequest request,
|
||||
@ModelAttribute PageParamRequest pageParamRequest){
|
||||
return CommonResult.success(CommonPage.restPage(userService.getUserListBySpreadLevel(request,pageParamRequest)));
|
||||
@ModelAttribute PageParamRequest pageParamRequest) {
|
||||
return CommonResult.success(CommonPage.restPage(userService.getUserListBySpreadLevel(request, pageParamRequest)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据参数获取推广订单列表
|
||||
* @param request 查询参数
|
||||
* @param request 查询参数
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return 查询结果推广人订单列表
|
||||
*/
|
||||
@ApiOperation(value = "根据条件获取推广人订单")
|
||||
@RequestMapping(value = "/spread/orderlist", method = RequestMethod.POST)
|
||||
public CommonResult<CommonPage<StoreOrder>> getOrdersBySpreadLevel(@RequestBody @Validated RetailShopStairUserRequest request,
|
||||
@ModelAttribute PageParamRequest pageParamRequest){
|
||||
return CommonResult.success(CommonPage.restPage(userService.getOrderListBySpreadLevel(request,pageParamRequest)));
|
||||
@ModelAttribute PageParamRequest pageParamRequest) {
|
||||
return CommonResult.success(CommonPage.restPage(userService.getOrderListBySpreadLevel(request, pageParamRequest)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +129,7 @@ public class RetailShopController {
|
||||
*/
|
||||
@ApiOperation(value = "清除上级推广人")
|
||||
@RequestMapping(value = "/spread/clean/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<Object> clearSpread(@PathVariable Integer id){
|
||||
public CommonResult<Object> clearSpread(@PathVariable Integer id) {
|
||||
return CommonResult.success(userService.clearSpread(id));
|
||||
}
|
||||
|
||||
@@ -156,7 +139,7 @@ public class RetailShopController {
|
||||
*/
|
||||
@ApiOperation(value = "分销配置信息获取")
|
||||
@RequestMapping(value = "/spread/manage/get", method = RequestMethod.GET)
|
||||
public CommonResult<Object> getSpreadInfo(){
|
||||
public CommonResult<Object> getSpreadInfo() {
|
||||
return CommonResult.success(retailShopService.getManageInfo());
|
||||
}
|
||||
|
||||
@@ -167,7 +150,7 @@ public class RetailShopController {
|
||||
*/
|
||||
@ApiOperation(value = "分销管理信息保存")
|
||||
@RequestMapping(value = "/spread/manage/set", method = RequestMethod.POST)
|
||||
public CommonResult<Object> setSpreadInfo(@RequestBody @Validated RetailShopRequest retailShopRequest){
|
||||
public CommonResult<Object> setSpreadInfo(@RequestBody @Validated RetailShopRequest retailShopRequest) {
|
||||
return CommonResult.success(retailShopService.setManageInfo(retailShopRequest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,15 +247,9 @@ public class StoreOrderController {
|
||||
* @since 2020-09-01
|
||||
*/
|
||||
@ApiOperation(value = "一键改价")
|
||||
@RequestMapping(value = "/editPrice", method = RequestMethod.GET)
|
||||
public CommonResult<Object> editOrderPrice(
|
||||
@RequestParam String orderId, @RequestParam(required = true,defaultValue = "0") BigDecimal price){
|
||||
try {
|
||||
if(price.compareTo(BigDecimal.ZERO) < 0) throw new CrmebException("请输入合法参数");
|
||||
}catch (Exception e){
|
||||
throw new CrmebException("价格参数错误");
|
||||
}
|
||||
return CommonResult.success(storeOrderService.editPrice(orderId,price));
|
||||
@RequestMapping(value = "/editPrice", method = RequestMethod.POST)
|
||||
public CommonResult<Object> editOrderPrice(@RequestBody @Validated StoreOrderEditPriceRequest request){
|
||||
return CommonResult.success(storeOrderService.editPrice(request));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.common.CommonPage;
|
||||
import com.common.CommonResult;
|
||||
import com.common.PageParamRequest;
|
||||
import com.zbkj.crmeb.store.model.StoreProduct;
|
||||
import com.zbkj.crmeb.store.request.StoreCopyProductRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreProductRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreProductSearchRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreProductStockRequest;
|
||||
@@ -158,17 +159,11 @@ public class StoreProductController {
|
||||
|
||||
/**
|
||||
* 上架
|
||||
* @param id integer id
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-06
|
||||
*/
|
||||
@ApiOperation(value = "上架")
|
||||
@RequestMapping(value = "/putOnShell/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<String> putOn(@PathVariable Integer id){
|
||||
StoreProduct storeProduct = new StoreProduct();
|
||||
storeProduct.setId(id);
|
||||
storeProduct.setIsShow(true);
|
||||
if(storeProductService.updateById(storeProduct)){
|
||||
if(storeProductService.putOnShelf(id)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
@@ -177,17 +172,11 @@ public class StoreProductController {
|
||||
|
||||
/**
|
||||
* 下架
|
||||
* @param id integer id
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-06
|
||||
*/
|
||||
@ApiOperation(value = "下架")
|
||||
@RequestMapping(value = "/offShell/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<String> offShell(@PathVariable Integer id){
|
||||
StoreProduct storeProduct = storeProductService.getById(id);
|
||||
storeProduct.setIsShow(false);
|
||||
if(storeProductService.updateById(storeProduct)){
|
||||
storeCartService.productStatusNotEnable(id);
|
||||
if(storeProductService.offShelf(id)){
|
||||
return CommonResult.success();
|
||||
}else{
|
||||
return CommonResult.failed();
|
||||
@@ -278,9 +267,8 @@ public class StoreProductController {
|
||||
|
||||
@ApiOperation(value = "复制平台商品")
|
||||
@RequestMapping(value = "/copy/product", method = RequestMethod.POST)
|
||||
@ApiImplicitParam(name = "url", value = "URL", dataType = "String", required = true)
|
||||
public CommonResult<Map<String, Object>> copyProduct(@RequestParam @Valid String url) {
|
||||
return CommonResult.success(storeProductService.copyProduct(url));
|
||||
public CommonResult<Map<String, Object>> copyProduct(@RequestBody @Valid StoreCopyProductRequest request) {
|
||||
return CommonResult.success(storeProductService.copyProduct(request.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ public class RetailShopRequest {
|
||||
public RetailShopRequest() {
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "是否启用分销")
|
||||
@ApiModelProperty(value = "是否启用分销:1-启用,0-禁止")
|
||||
@NotNull(message = "是否启用分销 不能为空")
|
||||
private String brokerageFuncStatus;
|
||||
|
||||
@ApiModelProperty(value = "分销模式")
|
||||
@ApiModelProperty(value = "分销模式:1-指定分销,2-人人分销,3-满额分销")
|
||||
@NotNull(message = "分销模式 不能为空")
|
||||
private String storeBrokerageStatus;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RetailShopRequest {
|
||||
@Range(min = 0, max = 100, message = "二级返佣比例在0-100中选择")
|
||||
private Integer storeBrokerageTwo;
|
||||
|
||||
@ApiModelProperty(value = "分销关系绑定")
|
||||
@ApiModelProperty(value = "分销关系绑定:0-所有用户,1-新用户")
|
||||
@NotNull(message = "分销关系绑定 不能为空")
|
||||
private String brokerageBindind;
|
||||
|
||||
@@ -64,8 +64,8 @@ public class RetailShopRequest {
|
||||
@Min(value = 0, message = "冻结时间最少为0天")
|
||||
private Integer extractTime;
|
||||
|
||||
@ApiModelProperty(value = "人人分销满足金额")
|
||||
@NotNull(message = "人人分销满足金额 不能为空")
|
||||
@DecimalMin(value = "0", message = "人人分销满足金额最小为0")
|
||||
private BigDecimal storeBrokeragePrice;
|
||||
// @ApiModelProperty(value = "满额分销满足金额")
|
||||
// @NotNull(message = "满额分销满足金额 不能为空")
|
||||
// @DecimalMin(value = "0", message = "满额分销满足金额最小为0")
|
||||
// private BigDecimal storeBrokeragePrice;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,6 @@ public class RetailShopStairUserRequest {
|
||||
@Range(min = 0, max = 3, message = "请选择正确的用户类型")
|
||||
private Integer type;
|
||||
|
||||
// 推广订单中的参数,公用对象
|
||||
@ApiModelProperty()
|
||||
private String orderPriceId;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
@Min(value = 1, message = "用户id不能为空")
|
||||
private Integer uid;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zbkj.crmeb.store.request;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 复制商品请求对象
|
||||
* +----------------------------------------------------------------------
|
||||
* | 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="StoreCopyProductRequest对象", description="复制商品请求对象")
|
||||
public class StoreCopyProductRequest {
|
||||
|
||||
@ApiModelProperty(value = "复制商品地址")
|
||||
@NotBlank(message = "复制商品地址 不能为空")
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.zbkj.crmeb.store.request;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
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)
|
||||
@ApiModel(value="StoreOrderEditPriceRequest对象", description="订单改价请求对象")
|
||||
public class StoreOrderEditPriceRequest {
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "订单号")
|
||||
@NotBlank(message = "订单号不能为空")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "订单金额")
|
||||
@DecimalMin(value = "0.00", message = "订单金额不能少于0.00")
|
||||
@NotNull(message = "订单金额不能为空")
|
||||
private BigDecimal price;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zbkj.crmeb.store.request;
|
||||
|
||||
/**
|
||||
* @author stivepeim
|
||||
* @title: StoreProductRelationRequest
|
||||
* @projectName crmeb
|
||||
* @description: TODO
|
||||
* @date 2020/5/2811:35
|
||||
*/
|
||||
public class StoreProductRelationRequest {
|
||||
}
|
||||
@@ -26,4 +26,19 @@ package com.zbkj.crmeb.store.service;
|
||||
void deleteByUser();
|
||||
|
||||
void orderPaySuccessAfter();
|
||||
|
||||
/**
|
||||
* 自动取消未支付订单
|
||||
*/
|
||||
void autoCancel();
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
*/
|
||||
void orderReceiving();
|
||||
|
||||
/**
|
||||
* 订单自动完成
|
||||
*/
|
||||
void autoComplete();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.store.request.RetailShopRequest;
|
||||
import com.zbkj.crmeb.store.request.RetailShopStairUserRequest;
|
||||
import com.zbkj.crmeb.store.response.RetailShopStatisticsResponse;
|
||||
import com.zbkj.crmeb.store.response.RetailShopUserResponse;
|
||||
import com.zbkj.crmeb.user.model.User;
|
||||
import com.zbkj.crmeb.user.response.SpreadUserResponse;
|
||||
import com.zbkj.crmeb.user.response.UserResponse;
|
||||
|
||||
import java.util.List;
|
||||
@@ -28,13 +28,13 @@ import java.util.List;
|
||||
public interface RetailShopService extends IService<User> {
|
||||
|
||||
/**
|
||||
* 获取分销列表
|
||||
* @param keywords
|
||||
* @param dateLimit
|
||||
* @param pageRequest
|
||||
* 分销员列表
|
||||
* @param keywords 搜索参数
|
||||
* @param dateLimit 时间参数
|
||||
* @param pageRequest 分页参数
|
||||
* @return
|
||||
*/
|
||||
CommonPage<RetailShopUserResponse> getList(String keywords, String dateLimit, PageParamRequest pageRequest);
|
||||
CommonPage<SpreadUserResponse> getSpreadPeopleList(String keywords, String dateLimit, PageParamRequest pageRequest);
|
||||
|
||||
/**
|
||||
* 获取分销头部数据
|
||||
|
||||
@@ -27,10 +27,10 @@ public interface StoreCartService extends IService<StoreCart> {
|
||||
/**
|
||||
* 根据有效标识符获取出数据
|
||||
* @param pageParamRequest 分页参数
|
||||
* @param cart 购物车参数
|
||||
* @param isValid 是否失效
|
||||
* @return 购物车列表
|
||||
*/
|
||||
List<StoreCartResponse> getList(PageParamRequest pageParamRequest, StoreCart cart, boolean isValid);
|
||||
List<StoreCartResponse> getList(PageParamRequest pageParamRequest, boolean isValid);
|
||||
|
||||
/**
|
||||
* 根据用户id和购物车ids查询购物车集合
|
||||
@@ -93,7 +93,7 @@ public interface StoreCartService extends IService<StoreCart> {
|
||||
* @param productId 商品id
|
||||
* @return 跟新结果
|
||||
*/
|
||||
boolean productStatusNotEnable(Integer productId);
|
||||
Boolean productStatusNotEnable(Integer productId);
|
||||
|
||||
/**
|
||||
* 购物车重选提交
|
||||
@@ -101,4 +101,10 @@ public interface StoreCartService extends IService<StoreCart> {
|
||||
* @return 提交结果
|
||||
*/
|
||||
boolean resetCart(CartResetRequest resetRequest);
|
||||
|
||||
/**
|
||||
* 对应sku购物车生效
|
||||
* @param skuIdList skuIdList
|
||||
*/
|
||||
Boolean productStatusNoEnable(List<Integer> skuIdList);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface StoreOrderInfoService extends IService<StoreOrderInfo> {
|
||||
|
||||
HashMap<Integer, List<StoreOrderInfoVo>> getMapInId(List<Integer> orderIdList);
|
||||
|
||||
public List<StoreOrderInfoVo> getOrderListByOrderId(Integer orderId);
|
||||
List<StoreOrderInfoVo> getOrderListByOrderId(Integer orderId);
|
||||
|
||||
/**
|
||||
* 批量添加订单详情
|
||||
|
||||
@@ -6,10 +6,7 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.crmeb.express.vo.ExpressSheetVo;
|
||||
import com.zbkj.crmeb.express.vo.LogisticsResultVo;
|
||||
import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
import com.zbkj.crmeb.store.request.RetailShopStairUserRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreOrderRefundRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreOrderSearchRequest;
|
||||
import com.zbkj.crmeb.store.request.StoreOrderSendRequest;
|
||||
import com.zbkj.crmeb.store.request.*;
|
||||
import com.zbkj.crmeb.store.response.*;
|
||||
import com.zbkj.crmeb.system.request.SystemWriteOffOrderSearchRequest;
|
||||
import com.zbkj.crmeb.system.response.SystemWriteOffOrderResponse;
|
||||
@@ -143,11 +140,10 @@ public interface StoreOrderService extends IService<StoreOrder> {
|
||||
|
||||
/**
|
||||
* 更改订单价格
|
||||
* @param orderId 订单id wx开头
|
||||
* @param price 待更改价格
|
||||
* @param request 订单改价对象
|
||||
* @return 更改结果
|
||||
*/
|
||||
boolean editPrice(String orderId,BigDecimal price);
|
||||
boolean editPrice(StoreOrderEditPriceRequest request);
|
||||
|
||||
/**
|
||||
* 确认付款
|
||||
@@ -214,4 +210,27 @@ public interface StoreOrderService extends IService<StoreOrder> {
|
||||
* @param orderNo 订单编号
|
||||
*/
|
||||
Boolean updatePaid(String orderNo);
|
||||
|
||||
Map<String, StoreOrder> getMapInOrderNo(List<String> orderNoList);
|
||||
|
||||
/**
|
||||
* 获取推广订单总金额
|
||||
* @param orderNoList 订单编号列表
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getSpreadOrderTotalPriceByOrderList(List<String> orderNoList);
|
||||
|
||||
/**
|
||||
* 获取所有收货订单id集合
|
||||
* @return
|
||||
*/
|
||||
List<StoreOrder> findIdAndUidListByReceipt();
|
||||
|
||||
/**
|
||||
* 根据用户uid查询所有已支付订单
|
||||
* @param userId 用户uid
|
||||
* @param pageParamRequest 分页参数
|
||||
* @return
|
||||
*/
|
||||
List<StoreOrder> findPaidListByUid(Integer userId, PageParamRequest pageParamRequest);
|
||||
}
|
||||
|
||||
@@ -36,4 +36,11 @@ public interface StoreOrderStatusService extends IService<StoreOrderStatus> {
|
||||
* @return 订单状态结果
|
||||
*/
|
||||
List<StoreOrderStatus> getByEntity(StoreOrderStatus storeOrderStatus);
|
||||
|
||||
/**
|
||||
* 根据订单id获取最后一条记录
|
||||
* @param orderId 订单id
|
||||
* @return
|
||||
*/
|
||||
StoreOrderStatus getLastByOrderId(Integer orderId);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,21 @@ import com.zbkj.crmeb.store.model.StoreOrder;
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface StoreOrderTaskService {
|
||||
public interface StoreOrderTaskService {
|
||||
|
||||
Boolean cancelByUser(StoreOrder storeOrder);
|
||||
Boolean cancelByUser(StoreOrder storeOrder);
|
||||
|
||||
Boolean refundApply(StoreOrder storeOrder);
|
||||
Boolean complete(StoreOrder storeOrder);
|
||||
|
||||
Boolean complete(StoreOrder storeOrder);
|
||||
Boolean takeByUser(StoreOrder storeOrder);
|
||||
|
||||
Boolean takeByUser(StoreOrder storeOrder);
|
||||
Boolean deleteByUser(StoreOrder storeOrder);
|
||||
|
||||
Boolean deleteByUser(StoreOrder storeOrder);
|
||||
Boolean refundOrder(StoreOrder storeOrder);
|
||||
|
||||
Boolean refundOrder(StoreOrder storeOrder);
|
||||
Boolean paySuccessAfter(StoreOrder storeOrder);
|
||||
|
||||
Boolean paySuccessAfter(StoreOrder storeOrder);
|
||||
}
|
||||
Boolean autoCancel(StoreOrder storeOrder);
|
||||
|
||||
Boolean orderReceiving(Integer orderId);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,14 @@ public interface StoreProductReplyService extends IService<StoreProductReply> {
|
||||
*/
|
||||
List<StoreProductReply> isReply(String unique,String replayType, Integer orderId);
|
||||
|
||||
/**
|
||||
* 查询是否已经回复
|
||||
* @param unique skuId
|
||||
* @param orderId 订单id
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean isReply(String unique, Integer orderId);
|
||||
|
||||
/**
|
||||
* 获取商品评论列表
|
||||
* @param productId 商品ID
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user