Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product

pull/2/head
TianYu 2023-05-18 14:58:37 +08:00
commit abbe8ea262
33 changed files with 627 additions and 59 deletions

View File

@ -46,4 +46,6 @@ public class OrderPayRequest {
@Schema(description = "下单时小程序的场景值")
private Integer scene;
@Schema(description = "openid")
private String openid;
}

View File

@ -21,7 +21,7 @@ import java.util.Map;
* @version: V1.0.0
*/
@Slf4j
@RequestMapping("notify/ali")
@RequestMapping("notify/ali/")
@RestController
@Tag(name = "支付宝支付回调 - 订单支付")
public class AliPayNotifyController {

View File

@ -0,0 +1,76 @@
package cn.iocoder.yudao.module.shop.controller.app.qrcode;
import cn.iocoder.yudao.framework.common.enums.Constants;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.shop.service.qrcode.QrCodeService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Slf4j
@RestController
@RequestMapping("/qrcode")
@Tag(name = "用户APP - 二维码服务")
public class QrCodeController {
@Autowired
private QrCodeService qrCodeService;
/**
*
* @return CommonResult
*/
@Operation(summary="获取二维码")
@RequestMapping(value = "/get", method = RequestMethod.POST)
public CommonResult<Map<String, Object>> get(@RequestBody JSONObject data) {
return CommonResult.success(qrCodeService.get(data));
}
/**
* base64
* @return CommonResult
*/
@Operation(summary="远程图片转base64")
@RequestMapping(value = "/base64", method = RequestMethod.POST)
public CommonResult<Map<String, Object>> get(@RequestBody String url) {
return CommonResult.success(qrCodeService.base64(url));
}
/**
* base64
* @return CommonResult
*/
@Operation(summary="将字符串 转base64")
@RequestMapping(value = "/str2base64", method = RequestMethod.POST)
public CommonResult<Map<String, Object>> getQrcodeByString(
@RequestParam String text,
@RequestParam int width,
@RequestParam int height) {
if((width < 50 || height < 50) && (width > 500 || height > 500) && text.length() >= 999){
throw new ServiceException(Constants.RESULT_QRCODE_PRAMERROR);
}
return CommonResult.success(qrCodeService.base64String(text, width,height));
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.shop.dal.dataobject.express;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("eb_express")
@Schema( description="快递公司表")
public class ExpressDO implements Serializable {
private static final long serialVersionUID=1L;
@Schema( description= "快递公司id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Integer id;
@Schema( description= "快递公司简称")
private String code;
@Schema( description= "快递公司全称")
private String name;
@Schema( description= "是否需要月结账号")
private Boolean partnerId;
@Schema( description= "是否需要月结密码")
private Boolean partnerKey;
@Schema( description= "是否需要取件网店")
private Boolean net;
@Schema( description= "账号")
private String account;
@Schema( description= "密码")
private String password;
@Schema( description= "网点名称")
private String netName;
@Schema( description= "排序")
private Integer sort;
@Schema( description= "是否显示")
private Boolean isShow;
@Schema( description= "是否可用")
private Boolean status;
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.module.shop.dal.mysql.express;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ExpressMapper extends BaseMapper<ExpressDO> {
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.shop.service.express;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* ExpressService
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Service
@Validated
public interface ExpressService {
/**
*
* @param code
* @return ExpressDO
*/
ExpressDO getByCode(String code);
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.shop.service.express.impl;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import cn.iocoder.yudao.module.shop.dal.mysql.express.ExpressMapper;
import cn.iocoder.yudao.module.shop.service.express.ExpressService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class ExpressServiceImpl implements ExpressService {
@Resource
private ExpressMapper dao;
/**
*
* @param code
*/
@Override
public ExpressDO getByCode(String code) {
LambdaQueryWrapper<ExpressDO> lqw = new LambdaQueryWrapper<>();
lqw.eq(ExpressDO::getCode, code);
ExpressDO expressDO = dao.selectOne(lqw);
return expressDO;
}
}

View File

@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.Constants;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserBillDTO;
@ -22,12 +24,17 @@ import cn.iocoder.yudao.module.shop.service.product.StoreProductService;
import cn.iocoder.yudao.module.shop.utils.OrderUtil;
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.WxPayJsResultVo;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.service.WxPayService;
import lombok.Data;
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 org.springframework.util.Assert;
import java.math.BigDecimal;
import java.util.HashMap;
@ -86,6 +93,12 @@ public class OrderPayServiceImpl implements OrderPayService {
@Autowired
private ApiConfigApi apiConfigApi;
@Autowired
private WxPayOneAutoConfiguration wxPayOneAutoConfiguration;
@Autowired
private WxPayProperties payProperties;
/**
*
@ -104,7 +117,7 @@ public class OrderPayServiceImpl implements OrderPayService {
// billList.add(userBill);
// 更新用户下单数量
// user.setPayCount(user.getPayCount() + 1);
// user.setPayCount(user.getPayCount() + 1);
Boolean execute = transactionTemplate.execute(e -> {
@ -135,6 +148,7 @@ public class OrderPayServiceImpl implements OrderPayService {
/**
*
*
* @param storeOrder
* @return Boolean Boolean
*/
@ -191,7 +205,7 @@ public class OrderPayServiceImpl implements OrderPayService {
storeOrder.setIsChannel(3);
}
if (orderPayRequest.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
switch (orderPayRequest.getPayChannel()){
switch (orderPayRequest.getPayChannel()) {
case PayConstants.PAY_CHANNEL_WE_CHAT_H5:// H5
storeOrder.setIsChannel(2);
break;
@ -229,7 +243,7 @@ public class OrderPayServiceImpl implements OrderPayService {
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
// 预下单
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip);
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid());
response.setStatus(true);
WxPayJsResultVo vo = new WxPayJsResultVo();
vo.setAppId(unifiedorder.get("appId"));
@ -266,11 +280,12 @@ public class OrderPayServiceImpl implements OrderPayService {
/**
*
*
* @param storeOrder
* @param ip ip
* @param ip ip
* @return
*/
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip) {
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip,String openid) {
// 获取用户openId
// 根据订单支付类型来判断获取公众号openId还是小程序openId
@ -314,6 +329,25 @@ public class OrderPayServiceImpl implements OrderPayService {
// if (storeOrder.getIsChannel() == 2) {
// map.put("mweb_url", responseVo.getMWebUrl());
// }
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
Assert.notNull(wxPayService, "获取微信支付配置失败!");
WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request();
int sum = storeOrder.getPayPrice().multiply(new BigDecimal("100")).intValue();
wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum));
wxPayRequest.setDescription("会员充值");
wxPayRequest.setOutTradeNo(storeOrder.getOrderId());
wxPayRequest.setNotifyUrl(payProperties.getNotifyUrl());
wxPayRequest.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(openid));
wxPayRequest.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(ip));
wxPayRequest.setAppid(payProperties.getAppId());
wxPayRequest.setMchid(payProperties.getMchId());
try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
} catch (Exception e) {
e.getMessage();
}
return map;
}
}

View File

@ -13,8 +13,10 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.pay.properties.AliPayProperties;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
@ -31,6 +33,7 @@ import cn.iocoder.yudao.module.shop.request.order.StoreOrderSendRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderUpdatePriceRequest;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import cn.iocoder.yudao.module.shop.response.order.*;
import cn.iocoder.yudao.module.shop.service.express.ExpressService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderRefundService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
@ -43,12 +46,12 @@ import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
import cn.iocoder.yudao.module.shop.vo.product.MyRecord;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
@ -69,7 +72,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -126,6 +128,15 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
@Autowired
private AliPayProperties aliPayProperties;
@Autowired
private ExpressService expressService;
@Autowired
private ApiConfigApi apiConfigApi;
// @Autowired
// private OnePassService onePassService;
/**
* PC
*
@ -429,7 +440,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
StoreOrder info = getInfoException(orderNo);
if (info.getType().equals(1)) {// 视频号订单
// TODO 快递信息
// Express express = expressService.getByName(info.getDeliveryName());
// ExpressDO express = expressService.getByName(info.getDeliveryName());
// if (ObjectUtil.isNotNull(express)) {
// info.setDeliveryCode(express.getCode());
// } else {
@ -1461,22 +1472,22 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private void express(StoreOrderSendRequest request, StoreOrder storeOrder) {
// 校验快递发货参数
validateExpressSend(request);
// TODO 快递公司信息
// Express express = expressService.getByCode(request.getExpressCode());
// if (request.getExpressRecordType().equals("1")) { // 正常发货
// deliverGoods(request, storeOrder);
// }
// 快递公司信息
ExpressDO express = expressService.getByCode(request.getExpressCode());
if (request.getExpressRecordType().equals("1")) { // 正常发货
deliverGoods(request, storeOrder);
}
// if (request.getExpressRecordType().equals("2")) { // 电子面单
// request.setExpressName(express.getName());
// expressDump(request, storeOrder, express);
// }
//
// storeOrder.setDeliveryCode(express.getCode());
// storeOrder.setDeliveryName(express.getName());
// storeOrder.setStatus(1);
// storeOrder.setDeliveryType("express");
String message = Constants.ORDER_LOG_MESSAGE_EXPRESS.replace("{deliveryName}", request.getExpressName()).replace("{deliveryCode}", storeOrder.getDeliveryId());
storeOrder.setDeliveryCode(express.getCode());
storeOrder.setDeliveryName(express.getName());
storeOrder.setStatus(1);
storeOrder.setDeliveryType("express");
String message = Constants.ORDER_LOG_MESSAGE_EXPRESS.replace("{deliveryName}", express.getName()).replace("{deliveryCode}", storeOrder.getDeliveryId());
Boolean execute = transactionTemplate.execute(i -> {
updateById(storeOrder);
@ -1490,6 +1501,56 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
sendGoodsNotify(storeOrder);
}
// /**
// * 电子面单
// * @param request
// * @param storeOrder
// * @param express
// */
// private void expressDump(StoreOrderSendRequest request, StoreOrder storeOrder, ExpressDO express) {
// String configExportOpen = apiConfigApi.getConfigKey("config_export_open").toString();
// if (!configExportOpen.equals("1")) {// 电子面单未开启
// throw new ServiceException("请先开启电子面单");
// }
// MyRecord record = new MyRecord();
// record.set("com", express.getCode());// 快递公司编码
// record.set("to_name", storeOrder.getRealName());// 收件人
// record.set("to_tel", storeOrder.getUserPhone());// 收件人电话
// record.set("to_addr", storeOrder.getUserAddress());// 收件人详细地址
// record.set("from_name", request.getToName());// 寄件人
// record.set("from_tel", request.getToTel());// 寄件人电话
// record.set("from_addr", request.getToAddr());// 寄件人详细地址
// record.set("temp_id", request.getExpressTempId());// 电子面单模板ID
// String siid = apiConfigApi.getConfigKey("config_export_siid").toString();
// record.set("siid", siid);// 云打印机编号
// record.set("count", storeOrder.getTotalNum());// 商品数量
//
// //获取购买商品名称
// List<Integer> orderIdList = new ArrayList<>();
// orderIdList.add(storeOrder.getId());
// HashMap<Integer, List<StoreOrderInfoOldVo>> orderInfoMap = StoreOrderInfoService.getMapInId(orderIdList);
// if (orderInfoMap.isEmpty() || !orderInfoMap.containsKey(storeOrder.getId())) {
// throw new ServiceException("没有找到购买的商品信息");
// }
// List<String> productNameList = new ArrayList<>();
// for (StoreOrderInfoOldVo storeOrderInfoVo : orderInfoMap.get(storeOrder.getId())) {
// productNameList.add(storeOrderInfoVo.getInfo().getProductName());
// }
//
// record.set("cargo", String.join(",", productNameList));// 物品名称
// if (express.getPartnerId()) {
// record.set("partner_id", express.getAccount());// 电子面单月结账号(部分快递公司必选)
// }
// if (express.getPartnerKey()) {
// record.set("partner_key", express.getPassword());// 电子面单密码(部分快递公司必选)
// }
// if (express.getNet()) {
// record.set("net", express.getNetName());// 收件网点名称(部分快递公司必选)
// }
//
// MyRecord myRecord = onePassService.expressDump(record);
// storeOrder.setDeliveryId(myRecord.getStr("kuaidinum"));
// }
/**
*
*/
@ -1500,7 +1561,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
}
if (StrUtil.isBlank(request.getExpressCode())) throw new ServiceException("请选择快递公司");
if (StrUtil.isBlank(request.getExpressRecordType())) throw new ServiceException("请选择发货记录类型");
if (StrUtil.isBlank(request.getExpressTempId())) throw new ServiceException("请选择电子面单");
// if (StrUtil.isBlank(request.getExpressTempId())) throw new ServiceException("请选择电子面单");
if (StrUtil.isBlank(request.getToName())) throw new ServiceException("请填写寄件人姓名");
if (StrUtil.isBlank(request.getToTel())) throw new ServiceException("请填写寄件人电话");
if (StrUtil.isBlank(request.getToAddr())) throw new ServiceException("请填写寄件人地址");

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.shop.service.qrcode;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* QrCodeService
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public interface QrCodeService {
/**
*
* @return CommonResult
*/
Map<String, Object> get(JSONObject data);
/**
* base64
* @param url
*/
Map<String, Object> base64(String url);
/**
* base64
* @param text
* @param width
* @param height
*/
Map<String, Object> base64String(String text,int width, int height);
}

View File

@ -0,0 +1,88 @@
package cn.iocoder.yudao.module.shop.service.qrcode;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.util.Base64Utils;
import java.util.HashMap;
import java.util.Map;
/**
* QrCodeServiceImpl
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Service
public class QrCodeServiceImpl implements QrCodeService {
/**
*
* @return Object
*/
@Override
public Map<String, Object> get(JSONObject data) {
Map<String, Object> map = new HashMap<>();
StringBuilder scene = new StringBuilder();
String page = "";
try{
if(null != data){
Map<Object, Object> dataMap = JSONObject.toJavaObject(data, Map.class);
for (Map.Entry<Object, Object> m : dataMap.entrySet()) {
if(m.getKey().equals("path")){
//前端路由, 不需要拼参数
page = m.getValue().toString();
continue;
}
if (scene.length() > 0) {
scene.append(",");
}
scene.append(m.getKey()).append(":").append(m.getValue());
}
}
}catch (Exception e){
throw new ServiceException("url参数错误 " + e.getMessage());
}
map.put("code", "");
return map;
}
@Override
public Map<String, Object> base64(String url) {
byte[] bytes = HttpUtil.downloadBytes(url);
String base64Image = Base64Utils.encodeToString(bytes);
Map<String, Object> map = new HashMap<>();
map.put("code", base64Image);
return map;
}
/**
* QRcode
* @param text
* @return QRcode base64
*/
@Override
public Map<String, Object> base64String(String text,int width, int height) {
String base64Image = null;
try {
base64Image = Base64Utils.encodeToString(QrCodeUtil.generatePng(text,width,height));
}catch (Exception e){
throw new ServiceException("生成二维码异常");
}
Map<String, Object> map = new HashMap<>();
map.put("code", base64Image);
return map;
}
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.shop.support.pay;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
@ -61,12 +60,6 @@ public class WxPayStrategy implements IPayStrategy{
return response;
}
public static void main(String[] args) {
String article="MEMBER_11111";
article=article.replace("MEMBER","TUIKUAN");
System.out.println(article);
}
@Override
public void refund(RechargeOrderDO orderDO) {
WxPayRefundV3Request wxPayRefundV3Request = new WxPayRefundV3Request();

View File

@ -23,6 +23,8 @@ public interface ErrorCodeConstants {
ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1004003005, "未绑定账号,需要进行绑定");
ErrorCode AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1004003006, "获得手机号失败");
ErrorCode USER_PHONE_EXISTS = new ErrorCode(1004003007, "手机号已经存在");
// ========== 用户收件地址 1004004000 ==========
ErrorCode ADDRESS_NOT_EXISTS = new ErrorCode(1004004000, "用户收件地址不存在");

View File

@ -16,7 +16,7 @@ public class PromoterBaseVO {
@Schema(description = "组织id", required = true, example = "18443")
@NotNull(message = "组织id不能为空")
private String orgId;
private String deptId;
@Schema(description = "推广员名称", required = true, example = "5841")
@NotEmpty(message = "推广员名称不能为空")

View File

@ -18,7 +18,7 @@ public class PromoterExcelVO {
private Long id;
@ExcelProperty("组织id")
private String orgId;
private String deptId;
@ExcelProperty("会员id")
private Long userId;

View File

@ -10,7 +10,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
public class PromoterExportReqVO {
@Schema(description = "组织id", example = "18443")
private String orgId;
private String deptId;
@Schema(description = "会员id", example = "5841")
private Long userId;

View File

@ -1,10 +1,15 @@
package cn.iocoder.yudao.module.member.controller.admin.promoter.vo;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 推广员分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ -12,9 +17,20 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
public class PromoterPageReqVO extends PageParam {
@Schema(description = "组织id", example = "18443")
private String orgId;
private String deptId;
@Schema(description = "会员id", example = "5841")
private Long userId;
@Schema(description = "推广员名称", example = "5841")
private String nickname;
@Schema(description = "推广员手机号", example = "15601691300")
private String mobile;
/**
*
* <p>
* {@link CommonStatusEnum}
*/
@Schema(description = "帐号状态")
private Integer status;
}

View File

@ -5,9 +5,11 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoReqVO;
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoRespVO;
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobileReqVO;
import cn.iocoder.yudao.module.member.controller.app.user.vo.UserSpreadBannerVO;
import cn.iocoder.yudao.module.member.convert.user.UserConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.service.promoter.PromoterService;
@ -22,6 +24,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -32,6 +37,7 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_IS_EMP
@RequestMapping("/member/user")
@Validated
@Slf4j
public class AppUserController {
@Resource
@ -43,6 +49,7 @@ public class AppUserController {
@PutMapping("/update-nickname")
@Operation(summary = "修改用户昵称")
@PreAuthenticated
@TenantIgnore
public CommonResult<Boolean> updateUserNickname(@RequestParam("nickname") String nickname) {
userService.updateUserNickname(getLoginUserId(), nickname);
return success(true);
@ -51,6 +58,7 @@ public class AppUserController {
@PostMapping("/update-avatar")
@Operation(summary = "修改用户头像")
@PreAuthenticated
@TenantIgnore
public CommonResult<String> updateUserAvatar(@RequestParam("avatarFile") MultipartFile file) throws Exception {
if (file.isEmpty()) {
throw exception(FILE_IS_EMPTY);
@ -62,6 +70,7 @@ public class AppUserController {
@GetMapping("/get")
@Operation(summary = "获得基本信息")
@PreAuthenticated
@TenantIgnore
public CommonResult<AppUserInfoRespVO> getUserInfo() {
MemberUserDO user = userService.getUser(getLoginUserId());
AppUserInfoRespVO appUserInfoRespVO = UserConvert.INSTANCE.convert(user);
@ -76,6 +85,7 @@ public class AppUserController {
@PostMapping("/update-mobile")
@Operation(summary = "修改用户手机")
@PreAuthenticated
@TenantIgnore
public CommonResult<Boolean> updateMobile(@RequestBody @Valid AppUserUpdateMobileReqVO reqVO) {
userService.updateUserMobile(getLoginUserId(), reqVO);
return success(true);
@ -83,6 +93,7 @@ public class AppUserController {
@PostMapping("/update-user")
@Operation(summary = "修改用户信息")
@PreAuthenticated
@TenantIgnore
public CommonResult<Boolean> updateMobile(@RequestBody @Validated AppUserInfoReqVO req) {
req.setId(getLoginUserId());
MemberUserDO userDO = new MemberUserDO();
@ -92,6 +103,19 @@ public class AppUserController {
userService.updateById(userDO);
return success(true);
}
/**
*
*/
@Operation(summary = "推广海报图")
@RequestMapping(value = "/spread/banner", method = RequestMethod.GET)
public CommonResult<List<UserSpreadBannerVO>> getSpreadBannerList() {
List<UserSpreadBannerVO> list = new ArrayList<>();
UserSpreadBannerVO userSpreadBannerVO = new UserSpreadBannerVO();
userSpreadBannerVO.setId(1);
userSpreadBannerVO.setPic("http://192.168.1.147:48080/admin-api/infra/file/4/get/431efea27162d536d35f7b3c0b844ede98a6ba58f4fd72ac7181e7ee5ebae77a.jpg");
userSpreadBannerVO.setTitle("推广背景图");
list.add(userSpreadBannerVO);
return CommonResult.success(list);
}
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.member.controller.app.user.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="用户推广海报")
public class UserSpreadBannerVO implements Serializable {
private static final long serialVersionUID=1L;
@Schema(description = "id")
private Integer id;
@Schema(description = "名称")
private String title;
@Schema(description = "背景图")
private String pic;
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.member.dal.dataobject.promoter;
import lombok.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
@ -32,10 +34,12 @@ public class PromoterDO implements Serializable {
/**
* id
*/
private Long orgId;
private Long deptId;
/**
* id
*/
private Long userId;
private LocalDateTime createTime;
}

View File

@ -21,14 +21,13 @@ public interface PromoterMapper extends BaseMapperX<PromoterDO> {
default PageResult<PromoterDO> selectPage(PromoterPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PromoterDO>()
.eqIfPresent(PromoterDO::getOrgId, reqVO.getOrgId())
.eqIfPresent(PromoterDO::getUserId, reqVO.getUserId())
.eqIfPresent(PromoterDO::getDeptId, reqVO.getDeptId())
.orderByDesc(PromoterDO::getId));
}
IPage<PromoterRespVO> findListPage(IPage<PromoterRespVO> page, @Param("data") PromoterPageReqVO data);
default List<PromoterDO> selectList(PromoterExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PromoterDO>()
.eqIfPresent(PromoterDO::getOrgId, reqVO.getOrgId())
.eqIfPresent(PromoterDO::getDeptId, reqVO.getDeptId())
.eqIfPresent(PromoterDO::getUserId, reqVO.getUserId())
.orderByDesc(PromoterDO::getId));
}

View File

@ -1,10 +1,12 @@
package cn.iocoder.yudao.module.member.service.promoter;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@ -17,8 +19,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.Validator;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.*;
import cn.iocoder.yudao.module.member.controller.admin.promoter.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.promoter.PromoterDO;
@ -75,18 +79,28 @@ public class PromoterServiceImpl implements PromoterService {
throw new ServiceException(PROMOTER_EXISTS);
}
promoter.setUserId(memberUserDO.getId());
promoter.setCreateTime(LocalDateTime.now());
promoterMapper.insert(promoter);
// 返回
return promoter.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updatePromoter(PromoterUpdateReqVO updateReqVO) {
// 校验存在
validatePromoterExists(updateReqVO.getId());
PromoterDO promoterDO = validatePromoterExists(updateReqVO.getId());
// 更新
PromoterDO updateObj = PromoterConvert.INSTANCE.convert(updateReqVO);
promoterMapper.updateById(updateObj);
MemberUserDO memberUserDO = memberUserService.getUserByMobile(updateReqVO.getMobile());
if(memberUserDO!=null&&!promoterDO.getUserId().equals(memberUserDO.getId())){
throw new ServiceException(ErrorCodeConstants.USER_PHONE_EXISTS);
}else {
memberUserDO.setMobile(updateReqVO.getMobile());
memberUserDO.setNickname(updateReqVO.getNickname());
memberUserService.updateById(memberUserDO);
}
}
@Override
@ -97,10 +111,12 @@ public class PromoterServiceImpl implements PromoterService {
promoterMapper.deleteById(id);
}
private void validatePromoterExists(Long id) {
if (promoterMapper.selectById(id) == null) {
private PromoterDO validatePromoterExists(Long id) {
PromoterDO promoterDO = promoterMapper.selectById(id);
if (promoterDO == null) {
throw exception(PROMOTER_NOT_EXISTS);
}
return promoterDO;
}
@Override
@ -127,6 +143,13 @@ public class PromoterServiceImpl implements PromoterService {
@Override
public PageResult<PromoterRespVO> getPromoterPage(PromoterPageReqVO pageReqVO) {
Page<PromoterRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
if(StrUtil.isNotBlank(pageReqVO.getDeptId())){
DeptRespDTO deptRespDTO = deptApi.getDept(Long.parseLong(pageReqVO.getDeptId()));
if(deptRespDTO!=null){
pageReqVO.setDeptId(deptRespDTO.getParentOrganizationIds());
}
}
promoterMapper.findListPage(page,pageReqVO);
return new PageResult<>(page.getRecords(), page.getTotal());
}
@ -174,6 +197,7 @@ public class PromoterServiceImpl implements PromoterService {
PromoterDO promoter = new PromoterDO();
promoter.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId());
promoter.setUserId(memberUserDO.getId());
promoter.setCreateTime(LocalDateTime.now());
Long count = promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId,memberUserDO.getId()));
if(count>0){
respVO.getFailureUsernames().put(importUser.getNickName(), "已经是推广员");
@ -184,7 +208,7 @@ public class PromoterServiceImpl implements PromoterService {
respVO.getFailureUsernames().put(importUser.getNickName(), "组织不存在");
return;
}
promoter.setOrgId(deptRespDTO.getId());
promoter.setDeptId(deptRespDTO.getId());
promoterMapper.insert(promoter);
respVO.getCreateUsernames().add(importUser.getNickName());
return;

View File

@ -10,9 +10,23 @@
-->
<select id="findListPage" resultType="cn.iocoder.yudao.module.member.controller.admin.promoter.vo.PromoterRespVO">
select a.id,a.user_id,a.org_id,b.nickname,b.status,b.mobile,c.parent_organization_name as 'orgName' from member_promoter a
select a.id,a.user_id,a.dept_id,b.nickname,b.status,b.mobile,c.parent_organization_name as 'orgName' from member_promoter a
left join member_user b on a.user_id = b.id
left join system_dept c on c.id=a.org_id
left join system_dept c on c.id=a.dept_id
<where>
<if test="data.deptId!=null and data.deptId!=''">
and c.parent_organization_ids like CONCAT(#{data.deptId},'%')
</if>
<if test="data.status!=null">
and b.status =#{data.status}
</if>
<if test="data.nickname!=null and data.nickname!=''">
and b.nickname like CONCAT('%',#{data.nickname},'%')
</if>
<if test="data.mobile!=null and data.mobile!=''">
and b.mobile like CONCAT('%',#{data.mobile},'%')
</if>
</where>
</select>
</mapper>

View File

@ -19,5 +19,15 @@ public class DeptSimpleRespVO {
@Schema(description = "父部门 ID", required = true, example = "1024")
private Long parentId;
/**
*
*/
private String parentOrganizationIds;
/**
*
*/
private String parentOrganizationName;
}

View File

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -30,6 +31,7 @@ public class AppTenantController {
@GetMapping("/get")
@Operation(summary = "获得租户")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PermitAll
public CommonResult<TenantRespVO> getTenant(@RequestParam("id") Long id) {
TenantDO tenant = tenantService.getTenant(id);
return success(TenantConvert.INSTANCE.convert(tenant));

View File

@ -1,7 +1,5 @@
server:
port: 48080
servlet:
context-path: /cyyywl-api
--- #################### 数据库相关配置 ####################

View File

@ -1,5 +1,7 @@
server:
port: 48080
servlet:
context-path: /cyywl-api
--- #################### 数据库相关配置 ####################

View File

@ -1,7 +1,7 @@
server:
port: 48080
servlet:
context-path: /admin-api
context-path: /
--- #################### 数据库相关配置 ####################

View File

@ -108,8 +108,6 @@ yudao:
permit-all_urls:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/notice/wxpay/**
- /app-api/tenant/get
- /admin-api/system/tenant/get-id-by-name
websocket:
enable: true # websocket的开关
path: /websocket/message # 路径
@ -180,6 +178,7 @@ yudao:
- infra_job_log
- infra_job_log
- infra_data_source_config
- infra_api_access_log
- jimu_dict
- jimu_dict_item
- jimu_report
@ -217,6 +216,8 @@ yudao:
- cy_recharge_order_info
- cy_refund_fee_record
- market_banner
- eb_express
- eb_store_order_status
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m

View File

@ -66,7 +66,7 @@
</springProfile>
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,default">
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/>
<appender-ref ref="GRPC"/>

View File

@ -5,8 +5,8 @@ ENV = 'development'
VUE_APP_TITLE = 创盈商户管理系统
# 芋道管理系统/开发环境
#VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/admin-api'
VUE_APP_BASE_API = 'http://192.168.1.147:48080'
VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/cyywl-api'
#VUE_APP_BASE_API = 'http://192.168.1.147:48080'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@ -9,7 +9,7 @@ VUE_APP_BASE_API = 'https://cmx.bskies.cc:8000/admin-api'
#VUE_APP_BASE_API = 'http://192.168.2.71'
# 根据服务器或域名修改
PUBLIC_PATH = 'https://cmx.bskies.cc:8000/cy-admin/'
PUBLIC_PATH = 'http://192.168.2.71/'
# 二级部署路径
VUE_APP_APP_NAME ='/cy-admin/'

View File

@ -3,7 +3,7 @@
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="所属组织" prop="orgId">
<el-form-item label="所属组织" prop="deptId">
<treeselect style="width: 240px;" v-model="queryParams.deptId" :options="deptOptions" :show-count="true"
:clearable="false"
placeholder="请选择所属组织" :normalizer="normalizer"/>
@ -75,7 +75,7 @@
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="所属组织" prop="orgId">
<el-form-item label="所属组织" prop="deptId">
<treeselect style="width: 240px;" v-model="form.deptId" :options="deptOptions" :show-count="true"
:clearable="false"
placeholder="请选择所属组织" :normalizer="normalizer"/>
@ -243,14 +243,14 @@ export default {
queryParams: {
pageNo: 1,
pageSize: 10,
orgId: null,
deptId: null,
userId: null,
},
//
form: {},
//
rules: {
orgId: [{
deptId: [{
required: true,
message: '请选择所属组织',
trigger: 'blur'
@ -339,7 +339,7 @@ export default {
reset() {
this.form = {
id: undefined,
orgId: undefined,
deptId: undefined,
userId: undefined,
};
this.resetForm('form');