| | |
| | | package com.ruoyi.member.service.impl.member; |
| | | import com.google.common.collect.Lists; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.member.domain.dto.*; |
| | | import com.ruoyi.member.domain.pojo.member.IntegralRecord; |
| | | import com.ruoyi.member.domain.pojo.member.MemberArchive; |
| | | import com.ruoyi.member.domain.pojo.member.MemberTotal; |
| | | import com.ruoyi.member.domain.vo.MerMemberTotalVo; |
| | | import com.ruoyi.member.domain.vo.*; |
| | | import com.ruoyi.member.mapper.member.MemberMapper; |
| | | import com.ruoyi.member.service.member.IntegralRecordService; |
| | |
| | | import com.ruoyi.system.api.domain.poji.config.SysTag; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysFile; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.*; |
| | | import com.ruoyi.system.api.model.AppMiniLoginDto; |
| | | import com.ruoyi.system.api.model.AppMiniLoginVo; |
| | | import com.ruoyi.system.api.service.RemoteConfigService; |
| | | import com.ruoyi.system.api.service.RemoteOrderService; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import com.ruoyi.system.api.service.RemoteUserService; |
| | | import com.ruoyi.system.api.service.*; |
| | | import io.jsonwebtoken.lang.Assert; |
| | | import lombok.extern.log4j.Log4j2; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.FileCopyUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Nullable; |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | @Resource |
| | | private MemberArchiveService memberArchiveService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteOrderService remoteOrderService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Resource |
| | | private RemoteFileService remoteFileService; |
| | | |
| | | |
| | | /** |
| | | * @description: TODO |
| | | * @author jqs34 |
| | |
| | | if (oldMember != null && oldMember.getBindingFlag() == 0) { |
| | | oldMember.setRelationShopId(merMemberAddDto.getShopId()); |
| | | oldMember.setBindingFlag(1); |
| | | oldMember.setBindingType(8); |
| | | this.updateById(oldMember); |
| | | return oldMember.getUserId(); |
| | | } |
| | |
| | | //1.手动领取2.全部用户3.会员用户4非会员用户5自定义 |
| | | return memberMapper.listIdBySendType(sendType,shopId); |
| | | } |
| | | |
| | | |
| | | public List<Long> listIdBySendType2(Long shopId) { |
| | | //1.手动领取2.全部用户3.会员用户4非会员用户5自定义 |
| | | return memberMapper.listIdBySendType2(shopId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param userIds |
| | |
| | | List<Member> mobileList = memberMapper.listTodayBirthday(); |
| | | if(mobileList!=null&&!mobileList.isEmpty()){ |
| | | log.info("生日祝福发送短信---"+mobileList.toString()); |
| | | for(Member member : mobileList){ |
| | | for (Member member : mobileList) { |
| | | try { |
| | | String msg = "{\"name\":\"" + (StringUtils.isEmpty(member.getRealName()) ? member.getNickName() : member.getRealName()) + "\"}"; |
| | | MsgUtils.sendMsg(member.getMobile(),null, msg); |
| | | MsgUtils.sendMsg(member.getMobile(), null, msg); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动添加用户积分 |
| | | * |
| | | * @param integral |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R addIntegralRecord(Integer integral, Long userId, String orderId) { |
| | | Member member = this.getByUserId(userId); |
| | | MemberTotal memberTotal = memberTotalService.getById(member.getMemberId()); |
| | | IntegralRecord integralRecord = new IntegralRecord(); |
| | | integralRecord.setDelFlag(0); |
| | | integralRecord.setUserId(userId); |
| | | integralRecord.setChangeType(6); |
| | | integralRecord.setChangeIntegral(integral); |
| | | integralRecord.setSurpIntegral(memberTotal.getUseableIntegral() + integral); |
| | | integralRecord.setCreateTime(new Date()); |
| | | integralRecord.setOrderId(orderId); |
| | | integralRecord.setChangeReason("抽奖活动获得"); |
| | | integralRecordService.save(integralRecord); |
| | | memberTotal.setTotalIntegral(memberTotal.getTotalIntegral() + integral); |
| | | memberTotal.setUseableIntegral(memberTotal.getUseableIntegral() + integral); |
| | | memberTotal.setPlSuggestFlag(1); |
| | | memberTotalService.saveOrUpdate(memberTotal); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String getWeiXinQrCode(String scene, String path) { |
| | | try { |
| | | File file = wxMaService.getQrcodeService().createWxaCodeUnlimit(scene, path); |
| | | FileInputStream input = new FileInputStream(file); |
| | | MultipartFile multipartFile = new MyMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input)); |
| | | |
| | | SysFile sysFile = remoteFileService.upload(multipartFile).getData(); |
| | | return sysFile.getUrl(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public class MyMultipartFile implements MultipartFile { |
| | | private final String name; |
| | | private final byte[] content; |
| | | private String originalFilename; |
| | | @Nullable |
| | | private String contentType; |
| | | |
| | | |
| | | public MyMultipartFile(String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) { |
| | | Assert.hasLength(name, "Name must not be null"); |
| | | this.name = name; |
| | | this.originalFilename = originalFilename != null ? originalFilename : ""; |
| | | this.contentType = contentType; |
| | | this.content = content != null ? content : new byte[0]; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | public String getOriginalFilename() { |
| | | return this.originalFilename; |
| | | } |
| | | |
| | | @Nullable |
| | | public String getContentType() { |
| | | return this.contentType; |
| | | } |
| | | |
| | | public boolean isEmpty() { |
| | | return this.content.length == 0; |
| | | } |
| | | |
| | | public long getSize() { |
| | | return (long) this.content.length; |
| | | } |
| | | |
| | | public byte[] getBytes() throws IOException { |
| | | return this.content; |
| | | } |
| | | |
| | | public InputStream getInputStream() throws IOException { |
| | | return new ByteArrayInputStream(this.content); |
| | | } |
| | | |
| | | public void transferTo(File dest) throws IOException, IllegalStateException { |
| | | FileCopyUtils.copy(this.content, dest); |
| | | } |
| | | } |
| | | |
| | | } |