| | |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.mall.dto.ApiRechargeWalletDto; |
| | | import cc.mrbird.febs.mall.dto.RechargeWalletMessageSendDto; |
| | | import cc.mrbird.febs.mall.dto.WxPowerDto; |
| | | import cc.mrbird.febs.mall.dto.WxUpCodeDto; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | |
| | | import cc.mrbird.febs.pay.model.*; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.WechatConfigure; |
| | | import cc.mrbird.febs.pay.util.WechatEventUtil; |
| | | import cc.mrbird.febs.pay.util.WeixinServiceUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.text.StrFormatter; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.spring.SpringUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.dynamic.datasource.toolkit.Base64; |
| | | import com.baomidou.mybatisplus.extension.exceptions.ApiException; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | |
| | | |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.net.*; |
| | | import java.nio.charset.Charset; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | private MallMemberWithdrawMapper mallMemberWithdrawMapper; |
| | | private final IMallMoneyFlowService mallMoneyFlowService; |
| | | @Autowired |
| | | WechatEventUtil wechatEventUtil; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | | @Autowired |
| | | private MallGoodsMapper mallGoodsMapper; |
| | | @Autowired |
| | | private MallTeamLeaderMapper mallTeamLeaderMapper; |
| | | |
| | | private final SpringContextHolder springContextHolder; |
| | | |
| | |
| | | BrandWCPayRequestData payData; |
| | | String productNames = "小程序充值"; |
| | | MallMember mallMember = mallMemberMapper.selectById(apiRechargeWalletDto.getMemberId()); |
| | | String rechargeNo = "CZ_"+MallUtils.getOrderNum(); |
| | | String rechargeNo = apiRechargeWalletDto.getRechargeNo(); |
| | | Long agentApplyId = apiRechargeWalletDto.getAgentApplyId() == null ? 0L : apiRechargeWalletDto.getAgentApplyId(); |
| | | Boolean debug = xcxProperties.getDebug(); |
| | | String attrStr = "{'rechargeNo':"+rechargeNo+",'memberId':"+mallMember.getId()+"}"; |
| | | String attrStr = "{'rechargeNo':"+rechargeNo |
| | | +",'memberId':"+mallMember.getId() |
| | | +",'agentApplyId':"+agentApplyId |
| | | +",'type':"+apiRechargeWalletDto.getType()+"}"; |
| | | if (debug) { |
| | | payData = weixinServiceUtil.createRechargeWallet("[测试]" + productNames, rechargeNo, |
| | | 1, mallMember.getOpenId(), attrStr); |
| | |
| | | payData = weixinServiceUtil.createRechargeWallet(productNames, rechargeNo, |
| | | unit.multiply(money).intValue(),mallMember.getOpenId(), attrStr); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | mallMember.getId(), |
| | | money, |
| | | MoneyFlowTypeEnum.RECHARGE.getValue(), |
| | | rechargeNo, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | "余额充值",1); |
| | | return payData; |
| | | } |
| | | |
| | |
| | | // } |
| | | return new FebsResponse().success(); |
| | | } |
| | | @Override |
| | | public FebsResponse getUpCode(WxUpCodeDto wxUpCodeDto) { |
| | | String qRcode = null; |
| | | if(ObjectUtil.isEmpty(wxUpCodeDto.getInviteId())){ |
| | | return new FebsResponse().fail().message("邀请码不存在"); |
| | | } |
| | | String inviteId = wxUpCodeDto.getInviteId(); |
| | | MallMember mallMember = mallMemberMapper.selectInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isEmpty(mallMember)){ |
| | | return new FebsResponse().fail().message("邀请码不存在"); |
| | | } |
| | | String sessionKey = mallMember.getSessionKey(); |
| | | if(ObjectUtil.isEmpty(sessionKey)){ |
| | | String ticket = wechatEventUtil.getTicket(inviteId); |
| | | if(StrUtil.isEmpty(ticket)){ |
| | | return new FebsResponse().fail().message("临时带参二维码ticket失败"); |
| | | } |
| | | qRcode = wechatEventUtil.getQRcode(ticket); |
| | | mallMember.setSessionKey(qRcode); |
| | | mallMemberMapper.updateById(mallMember); |
| | | }else{ |
| | | qRcode = sessionKey; |
| | | } |
| | | |
| | | return new FebsResponse().success().data(qRcode); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse getPower(WxPowerDto wxPowerDto) { |
| | | if(ObjectUtil.isEmpty(wxPowerDto.getUrl())){ |
| | | return new FebsResponse().fail().message("获取权限失败"); |
| | | } |
| | | Map<String, Object> ticket = wechatEventUtil.ticket(wxPowerDto.getUrl()); |
| | | return new FebsResponse().success().data(ticket); |
| | | } |
| | | |
| | | @Override |
| | | public BrandWCPayRequestData startPayment(MallOrderInfo mallOrderInfo) throws Exception { |
| | |
| | | orderStateMsgVo.setTemplate_id(info.getTemplateId());//订阅消息模板id |
| | | orderStateMsgVo.setPage(info.getPage()); |
| | | Map<String, WxTemplateData> m = new HashMap<>(4); |
| | | m.put("thing4.DATA", new WxTemplateData(info.getAddressArea())); |
| | | m.put("phone_number14.DATA", new WxTemplateData(info.getLeaderPhone())); |
| | | m.put("thing3.DATA", new WxTemplateData(info.getGoodsName())); |
| | | m.put("thing5.DATA", new WxTemplateData(info.getDetailAddress())); |
| | | m.put("thing15.DATA", new WxTemplateData(info.getRemark())); |
| | | m.put("thing19", new WxTemplateData(info.getAddressArea())); |
| | | m.put("phone_number18", new WxTemplateData(info.getLeaderPhone())); |
| | | m.put("thing3", new WxTemplateData(info.getGoodsName())); |
| | | m.put("thing15", new WxTemplateData(info.getRemark())); |
| | | orderStateMsgVo.setData(m); |
| | | String s = JSONUtil.toJsonStr(orderStateMsgVo); |
| | | log.info(s); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getTemplateId() { |
| | | List<String> wxTemplates = new ArrayList<>(); |
| | | public List<HashMap<String, String>> getTemplateId() { |
| | | List<HashMap<String, String>> wxTemplates = new ArrayList<>(); |
| | | List<DataDictionaryCustom> wxTemplateList = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.WX_TEMPLATE_ID_THREE.getType()); |
| | | if(CollUtil.isNotEmpty(wxTemplateList)){ |
| | | for(DataDictionaryCustom dic : wxTemplateList){ |
| | | wxTemplates.add(dic.getValue()); |
| | | HashMap<String, String> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("name",dic.getCode()); |
| | | objectObjectHashMap.put("value",dic.getValue()); |
| | | wxTemplates.add(objectObjectHashMap); |
| | | } |
| | | } |
| | | return wxTemplates; |
| | | } |
| | | |
| | | @Autowired |
| | | private MallGoodsMapper mallGoodsMapper; |
| | | @Autowired |
| | | private MallTeamLeaderMapper mallTeamLeaderMapper; |
| | | |
| | | @Override |
| | | public FebsResponse generateQrCode(WxGenerateQrCodeDto wxGenerateQrCodeDto) { |
| | |
| | | * @return |
| | | */ |
| | | //图片上传路径 |
| | | public static final String IMG_UPLOAD_PATH="/mnt/sdc/webresource/groupbuy/wxcode"; |
| | | public static final String IMG_UPLOAD_PATH="/mnt/sdc/webresource/qianayi/wxcode"; |
| | | public String generateAcode(String scene,String path,String imgName,String width, Integer type){ |
| | | String urlPrefix="https://hwfile.csxuncong.com/groupbuy/wxcode"; |
| | | String urlPrefix="https://hwfile.csxuncong.com/qianayi/wxcode"; |
| | | String imgPath=IMG_UPLOAD_PATH+imgName; |
| | | if(!FileUtil.exist(imgPath)){ |
| | | |