|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.core.redis.RedisLockEntity;
|
|
@@ -15,6 +16,7 @@ import com.zhongzheng.common.utils.AES;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.polyv.PolyvUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
|
import com.zhongzheng.modules.course.vo.CourseChapterVo;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
@@ -29,6 +31,7 @@ import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlan;
|
|
@@ -374,111 +377,118 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
|
|
|
public Boolean pushOfficialInfo(ClassGradeUserQueryBo bo){
|
|
|
ClassGradeUserVo userVo = this.baseMapper.selectUser(bo);
|
|
|
if(Validator.isEmpty(userVo)){
|
|
|
- throw new CustomException("用户不存在");
|
|
|
+ // throw new CustomException("用户不存在");
|
|
|
+ System.out.println("用户不存在");
|
|
|
+ return false;
|
|
|
}
|
|
|
- if(Validator.isEmpty(userVo.getInterfacePushId())||userVo.getInterfacePushId().equals(1L)){
|
|
|
- throw new CustomException("没开通信息推送");
|
|
|
+ if(Validator.isEmpty(userVo.getInterfacePushId())||!userVo.getInterfacePushId().equals(1L)){
|
|
|
+ // throw new CustomException("没开通信息推送");
|
|
|
+ System.out.println("没开通信息推送");
|
|
|
+ return false;
|
|
|
}
|
|
|
- if(Validator.isEmpty(userVo.getInterfacePushId())||userVo.getInterfacePushId().equals(1L)){
|
|
|
- throw new CustomException("没开通信息推送");
|
|
|
- }
|
|
|
- if(Validator.isEmpty(userVo.getClassName())){
|
|
|
- throw new CustomException("没配置班号");
|
|
|
+ if(Validator.isEmpty(userVo.getOfficialName())){
|
|
|
+ // throw new CustomException("没配置班号");
|
|
|
+ System.out.println("没配置班号");
|
|
|
+ return false;
|
|
|
}
|
|
|
if(Validator.isEmpty(userVo.getClassStatus())||userVo.getClassStatus()!=1){
|
|
|
- throw new CustomException("未开班");
|
|
|
+ // throw new CustomException("未开班");
|
|
|
+ System.out.println("未开班");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ OrderGoodsQueryBo goodsQueryBo = new OrderGoodsQueryBo();
|
|
|
+ goodsQueryBo.setUserId(bo.getUserId());
|
|
|
+ goodsQueryBo.setGradeId(userVo.getGradeId());
|
|
|
+ OrderGoodsVo orderGoods = iOrderGoodsService.gradeGoods(goodsQueryBo);
|
|
|
+ if(Validator.isEmpty(orderGoods)){
|
|
|
+ // throw new CustomException("班级商品不存在");
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("zh",OFFICIALPUSH_INFOACCOUNT);
|
|
|
- params.put("bh",userVo.getClassName());
|
|
|
+ params.put("bh",userVo.getOfficialName());
|
|
|
params.put("xm",userVo.getRealName());
|
|
|
params.put("sfz",userVo.getIdCard());
|
|
|
params.put("dh",userVo.getTelPhone());
|
|
|
- params.put("bmrq","2022-11-11");
|
|
|
+ params.put("bmrq",DateUtils.timestampToDate(orderGoods.getCreateTime()));
|
|
|
String dataTxt = params.get("zh")+params.get("bh")+params.get("xm")+params.get("sfz")+params.get("dh")+params.get("bmrq");
|
|
|
System.out.println(dataTxt);
|
|
|
String encrypted = dataSign(dataTxt,OFFICIALPUSH_TOKEN);
|
|
|
- System.out.println(encrypted);
|
|
|
params.put("SignMsg",encrypted);
|
|
|
String respone = "";
|
|
|
try{
|
|
|
respone = HttpUtils.postFormBody(OFFICIALPUSH_INFOPATH,params);
|
|
|
- System.out.println(respone);
|
|
|
+ String[] split = respone.split("\\|");
|
|
|
+ if (split.length < 2) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(split[0].equals("OK")){
|
|
|
+ //推送成功
|
|
|
+ LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
+ objectLambdaUpdateWrapper.eq(ClassGradeUser::getId, userVo.getId());
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatus, 1);
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusMsg, respone);
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusTime,DateUtils.getNowTime());
|
|
|
+ this.update(null, objectLambdaUpdateWrapper);
|
|
|
+ return true;
|
|
|
+ }else {
|
|
|
+ //推送失败
|
|
|
+ LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
+ objectLambdaUpdateWrapper.eq(ClassGradeUser::getId, userVo.getId());
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusMsg, respone);
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
|
|
|
+ objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusTime,DateUtils.getNowTime());
|
|
|
+ this.update(null, objectLambdaUpdateWrapper);
|
|
|
+ throw new CustomException("推送失败:"+respone);
|
|
|
+ }
|
|
|
}catch (IOException e){
|
|
|
throw new CustomException("请求错误");
|
|
|
}
|
|
|
- ClassGradeUserOfficialBo officialBo = new ClassGradeUserOfficialBo();
|
|
|
- officialBo.setZh("peixunjigou");
|
|
|
- officialBo.setBh(userVo.getClassName());
|
|
|
- officialBo.setSfz(userVo.getIdCard());
|
|
|
- officialBo.setXm(userVo.getRealName());
|
|
|
- officialBo.setDh(userVo.getTelPhone());
|
|
|
- officialBo.setBmrq("2022-2-15");
|
|
|
-
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- public String dataSign(String SourceMsg,String PKey)
|
|
|
- {
|
|
|
- try{
|
|
|
- String TempPKey;
|
|
|
- TempPKey = getMD5(PKey,"gb2312");
|
|
|
- TempPKey = SourceMsg + TempPKey;
|
|
|
- TempPKey = getMD5(TempPKey,"gb2312");
|
|
|
- return TempPKey;
|
|
|
- }catch (NoSuchAlgorithmException e){
|
|
|
- throw new CustomException("数据错误");
|
|
|
- }catch (UnsupportedEncodingException exception){
|
|
|
- throw new CustomException("数据错误");
|
|
|
- }catch (Exception exception2){
|
|
|
- throw new CustomException("数据错误");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static String MD5Encode(String origin) {
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
+ public static String EncoderByMd5(String str) {
|
|
|
+ String result = "";
|
|
|
+ MessageDigest md5 = null;
|
|
|
try {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- md.update(origin.getBytes("utf8"));
|
|
|
- byte[] result = md.digest();
|
|
|
- for (int i = 0; i < result.length; i++) {
|
|
|
- //int val = result[i] & 0xff;
|
|
|
- //sb.append(Integer.toHexString(val));
|
|
|
- int val = (result[i] & 0x000000ff) | 0xffffff00;
|
|
|
- sb.append(Integer.toHexString(val).substring(6));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
+ md5 = MessageDigest.getInstance("MD5");
|
|
|
+ // 这句是关键
|
|
|
+ md5.update(str.getBytes("gb2312"));
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ byte b[] = md5.digest();
|
|
|
+ int i;
|
|
|
+ StringBuffer buf = new StringBuffer("");
|
|
|
+ for (int offset = 0; offset < b.length; offset++) {
|
|
|
+ i = b[offset];
|
|
|
+ if (i < 0)
|
|
|
+ i += 256;
|
|
|
+ if (i < 16)
|
|
|
+ buf.append("0");
|
|
|
+ buf.append(Integer.toHexString(i));
|
|
|
}
|
|
|
+ result = buf.toString();
|
|
|
|
|
|
- return sb.toString();
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
- public String getMD5(String str, String encoding) throws Exception {
|
|
|
-
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
-
|
|
|
- md.update(str.getBytes(encoding));
|
|
|
-
|
|
|
- byte[] result = md.digest();
|
|
|
-
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
-
|
|
|
- for (int i = 0; i < result.length; i++) {
|
|
|
-
|
|
|
- int val = result[i] & 0xff;
|
|
|
-
|
|
|
- sb.append(Integer.toHexString(val));
|
|
|
+ public String dataSign(String SourceMsg,String PKey)
|
|
|
+ {
|
|
|
+ String TempPKey;
|
|
|
+ TempPKey = EncoderByMd5(PKey);
|
|
|
+ TempPKey = SourceMsg + TempPKey;
|
|
|
+ TempPKey = EncoderByMd5(TempPKey);
|
|
|
+ return TempPKey;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public List<ClassPeriodStudentExportVo> exportPo(ClassGradeUserQueryBo bo) {
|