新增加app支付、邀请码等
This commit is contained in:
@ -22,6 +22,7 @@ import co.yixiang.modules.order.web.param.YxStoreOrderQueryParam;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
@ -91,6 +92,8 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
||||
|
||||
WxPayMwebOrderResult wxH5Pay(String orderId) throws WxPayException;
|
||||
|
||||
WxPayAppOrderResult appPay(String orderId) throws WxPayException;
|
||||
|
||||
String aliPay(String orderId) throws Exception;
|
||||
|
||||
void delCacheOrderInfo(int uid, String key);
|
||||
|
@ -73,6 +73,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
@ -1001,6 +1002,34 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
return payUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信APP支付
|
||||
* @param orderId
|
||||
* @return
|
||||
* @throws WxPayException
|
||||
*/
|
||||
@Override
|
||||
public WxPayAppOrderResult appPay(String orderId) throws WxPayException {
|
||||
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,0);
|
||||
if(ObjectUtil.isNull(orderInfo)) throw new ErrorRequestException("订单不存在");
|
||||
if(orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) throw new ErrorRequestException("该订单已支付");
|
||||
|
||||
if(orderInfo.getPayPrice().doubleValue() <= 0) throw new ErrorRequestException("该支付无需支付");
|
||||
|
||||
YxUser wechatUser = userService.getById(orderInfo.getUid());
|
||||
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
|
||||
|
||||
if(StrUtil.isNotEmpty(orderInfo.getExtendOrderId())){
|
||||
orderId = orderInfo.getExtendOrderId();
|
||||
}
|
||||
|
||||
BigDecimal bigDecimal = new BigDecimal(100);
|
||||
|
||||
return payService.appPay(orderId,"app商品购买",
|
||||
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),
|
||||
BillDetailEnum.TYPE_3.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信H5支付
|
||||
* @param orderId
|
||||
|
@ -46,6 +46,7 @@ import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
@ -283,7 +284,21 @@ public class StoreOrderController extends BaseController {
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map,"订单创建成功");
|
||||
}else{
|
||||
}else if(param.getFrom().equals("app")){//app支付
|
||||
map.put("status","WECHAT_APP_PAY");
|
||||
WxPayAppOrderResult wxPayAppOrderResult = storeOrderService
|
||||
.appPay(orderId);
|
||||
jsConfig.put("appid",wxPayAppOrderResult.getAppId());
|
||||
jsConfig.put("partnerid",wxPayAppOrderResult.getPartnerId());
|
||||
jsConfig.put("prepayid",wxPayAppOrderResult.getPrepayId());
|
||||
jsConfig.put("package",wxPayAppOrderResult.getPackageValue());
|
||||
jsConfig.put("noncestr",wxPayAppOrderResult.getNonceStr());
|
||||
jsConfig.put("timestamp",wxPayAppOrderResult.getTimeStamp());
|
||||
jsConfig.put("sign",wxPayAppOrderResult.getSign());
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map,"订单创建成功");
|
||||
} else{//公众号
|
||||
map.put("status","WECHAT_PAY");
|
||||
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
|
||||
.wxPay(orderId);
|
||||
@ -365,6 +380,20 @@ public class StoreOrderController extends BaseController {
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map,"订单创建成功");
|
||||
}else if(param.getFrom().equals("app")){//app支付
|
||||
map.put("status","WECHAT_APP_PAY");
|
||||
WxPayAppOrderResult wxPayAppOrderResult = storeOrderService
|
||||
.appPay(orderId);
|
||||
jsConfig.put("appid",wxPayAppOrderResult.getAppId());
|
||||
jsConfig.put("partnerid",wxPayAppOrderResult.getPartnerId());
|
||||
jsConfig.put("prepayid",wxPayAppOrderResult.getPrepayId());
|
||||
jsConfig.put("package",wxPayAppOrderResult.getPackageValue());
|
||||
jsConfig.put("noncestr",wxPayAppOrderResult.getNonceStr());
|
||||
jsConfig.put("timestamp",wxPayAppOrderResult.getTimeStamp());
|
||||
jsConfig.put("sign",wxPayAppOrderResult.getSign());
|
||||
orderDTO.setJsConfig(jsConfig);
|
||||
map.put("result",orderDTO);
|
||||
return ApiResult.ok(map,"订单创建成功");
|
||||
}else{
|
||||
map.put("status","WECHAT_PAY");
|
||||
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
|
||||
|
@ -34,8 +34,10 @@ import co.yixiang.modules.security.security.TokenProvider;
|
||||
import co.yixiang.modules.security.security.vo.AuthUser;
|
||||
import co.yixiang.modules.security.security.vo.JwtUser;
|
||||
import co.yixiang.modules.security.service.OnlineUserService;
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxWechatUser;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.service.YxWechatUserService;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
@ -100,10 +102,11 @@ public class AuthController {
|
||||
private final YxWechatUserService wechatUserService;
|
||||
private final WxMaService wxMaService;
|
||||
private final NotifyService notifyService;
|
||||
private final YxSystemAttachmentService systemAttachmentService;
|
||||
|
||||
|
||||
@Log("H5用户登录")
|
||||
@ApiOperation("H5登录授权")
|
||||
@Log("H5/APP用户登录")
|
||||
@ApiOperation("H5/APP登录授权")
|
||||
@AnonymousAccess
|
||||
@PostMapping(value = "/login")
|
||||
public ApiResult<Map<String, String>> login(@Validated @RequestBody AuthUser authUser,
|
||||
@ -477,7 +480,7 @@ public class AuthController {
|
||||
|
||||
@AnonymousAccess
|
||||
@PostMapping("/register")
|
||||
@ApiOperation(value = "H5注册新用户", notes = "H5注册新用户")
|
||||
@ApiOperation(value = "H5/APP注册新用户", notes = "H5/APP5注册新用户")
|
||||
public ApiResult<String> register(@Validated @RequestBody RegParam param) {
|
||||
|
||||
Object codeObj = redisUtils.get("code_" + param.getAccount());
|
||||
@ -501,7 +504,11 @@ public class AuthController {
|
||||
user.setPassword(passwordEncoder.encode(param.getPassword()));
|
||||
user.setPwd(passwordEncoder.encode(param.getPassword()));
|
||||
user.setPhone(param.getAccount());
|
||||
user.setUserType(AppFromEnum.H5.getValue());
|
||||
if (StrUtil.isNotBlank(param.getInviteCode())){
|
||||
user.setUserType(AppFromEnum.APP.getValue());
|
||||
}else{
|
||||
user.setUserType(AppFromEnum.H5.getValue());
|
||||
}
|
||||
user.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
user.setLastTime(OrderUtil.getSecondTimestampTwo());
|
||||
user.setNickname(param.getAccount());
|
||||
@ -512,6 +519,13 @@ public class AuthController {
|
||||
|
||||
userService.save(user);
|
||||
|
||||
//设置推广关系
|
||||
if (StrUtil.isNotBlank(param.getInviteCode())) {
|
||||
YxSystemAttachment systemAttachment = systemAttachmentService.getByCode(param.getInviteCode());
|
||||
userService.setSpread(systemAttachment.getUid(),
|
||||
user.getUid());
|
||||
}
|
||||
|
||||
return ApiResult.ok("注册成功");
|
||||
}
|
||||
|
||||
|
@ -22,4 +22,6 @@ public class RegParam {
|
||||
|
||||
//todo
|
||||
private Integer spread;
|
||||
|
||||
private String inviteCode;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public class AuthUser {
|
||||
|
||||
private String spread;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{username=" + username + ", password= ******}";
|
||||
|
@ -83,6 +83,8 @@ public class IndexController {
|
||||
//滚动
|
||||
map.put("roll",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS));
|
||||
|
||||
map.put("mapKey",RedisUtil.get("tengxun_map_key"));
|
||||
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -120,8 +121,9 @@ public class StoreProductController extends BaseController {
|
||||
@GetMapping("/product/detail/{id}")
|
||||
@ApiOperation(value = "普通商品详情",notes = "普通商品详情")
|
||||
public ApiResult<ProductDTO> detail(@PathVariable Integer id,
|
||||
@RequestParam(value = "") String latitude,
|
||||
@RequestParam(value = "") String longitude){
|
||||
@RequestParam(value = "",required=false) String latitude,
|
||||
@RequestParam(value = "",required=false) String longitude,
|
||||
@RequestParam(value = "",required=false) String from){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
|
||||
ProductDTO productDTO = storeProductService.goodsDetail(id,0,uid,latitude,longitude);
|
||||
@ -141,49 +143,61 @@ public class StoreProductController extends BaseController {
|
||||
if(!userType.equals(AppFromEnum.ROUNTINE.getValue())) {
|
||||
userType = AppFromEnum.H5.getValue();
|
||||
}
|
||||
String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+ File.separator;
|
||||
String qrcodeUrl = "";
|
||||
String routineQrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
//下载图片
|
||||
siteUrl = siteUrl+"/product/";
|
||||
QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
from = "app";
|
||||
//app类型
|
||||
if(StrUtil.isNotBlank(from) && AppFromEnum.APP.getValue().equals(from)){
|
||||
String name = id+"_"+uid + "_"+from+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String inviteCode = OrderUtil.createShareCode();
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
systemAttachmentService.newAttachmentAdd(name, "", "","",uid,inviteCode);
|
||||
}else{
|
||||
QrCodeUtil.generate(siteUrl+"/detail/"+id+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
inviteCode = attachment.getInviteCode();
|
||||
}
|
||||
|
||||
productDTO.getStoreInfo().setCodeBase(inviteCode);
|
||||
}else {
|
||||
String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg";
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+ File.separator;
|
||||
String qrcodeUrl = "";
|
||||
String routineQrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
//下载图片
|
||||
siteUrl = siteUrl+"/product/";
|
||||
QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}else{
|
||||
QrCodeUtil.generate(siteUrl+"/detail/"+id+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
}
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
routineQrcodeUrl = apiUrl + "/api/file/qrcode/"+name;
|
||||
qrcodeUrl = fileDir+name;
|
||||
routineQrcodeUrl = apiUrl + "/api/file/qrcode/"+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
routineQrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir();
|
||||
}
|
||||
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
routineQrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir();
|
||||
}
|
||||
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
productDTO.getStoreInfo().setCodeBase(routineQrcodeUrl);
|
||||
}else{
|
||||
try {
|
||||
String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl));
|
||||
productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
productDTO.getStoreInfo().setCodeBase(routineQrcodeUrl);
|
||||
}else{
|
||||
try {
|
||||
String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl));
|
||||
productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ApiResult.ok(productDTO);
|
||||
}
|
||||
|
||||
|
@ -53,4 +53,8 @@ public class YxSystemAttachment extends BaseEntity {
|
||||
@ApiModelProperty(value = "图片上传模块类型 1 后台上传 2 用户生成")
|
||||
private Integer moduleType;
|
||||
|
||||
private Integer uid;
|
||||
|
||||
private String inviteCode;
|
||||
|
||||
}
|
||||
|
@ -28,8 +28,12 @@ public interface YxSystemAttachmentService extends BaseService<YxSystemAttachmen
|
||||
|
||||
YxSystemAttachment getInfo(String name);
|
||||
|
||||
YxSystemAttachment getByCode(String code);
|
||||
|
||||
void attachmentAdd(String name,String attSize,String attDir,String sattDir);
|
||||
|
||||
void newAttachmentAdd(String name,String attSize,String attDir,String sattDir,int uid,String code);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
@ -29,7 +29,7 @@ public interface YxUserLevelService extends BaseService<YxUserLevel> {
|
||||
|
||||
void setUserLevel(int uid,int levelId);
|
||||
|
||||
void setLevelComplete(int uid);
|
||||
boolean setLevelComplete(int uid);
|
||||
|
||||
UserLevelInfoDTO getUserLevelInfo(int id);
|
||||
|
||||
|
@ -47,7 +47,14 @@ public class YxSystemAttachmentServiceImpl extends BaseServiceImpl<YxSystemAttac
|
||||
@Override
|
||||
public YxSystemAttachment getInfo(String name) {
|
||||
QueryWrapper<YxSystemAttachment> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name",name);
|
||||
wrapper.eq("name",name).last("limit 1");
|
||||
return yxSystemAttachmentMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxSystemAttachment getByCode(String code) {
|
||||
QueryWrapper<YxSystemAttachment> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("invite_code",code).last("limit 1");
|
||||
return yxSystemAttachmentMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@ -66,6 +73,23 @@ public class YxSystemAttachmentServiceImpl extends BaseServiceImpl<YxSystemAttac
|
||||
yxSystemAttachmentMapper.insert(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newAttachmentAdd(String name, String attSize, String attDir, String sattDir, int uid, String code) {
|
||||
YxSystemAttachment attachment = new YxSystemAttachment();
|
||||
attachment.setName(name);
|
||||
attachment.setAttSize(attSize);
|
||||
attachment.setAttDir(attDir);
|
||||
attachment.setAttType("image/jpeg");
|
||||
attachment.setSattDir(sattDir);
|
||||
attachment.setTime(OrderUtil.getSecondTimestampTwo());
|
||||
attachment.setImageType(1);
|
||||
attachment.setModuleType(2);
|
||||
attachment.setPid(1);
|
||||
attachment.setUid(uid);
|
||||
attachment.setInviteCode(code);
|
||||
yxSystemAttachmentMapper.insert(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxSystemAttachmentQueryVo getYxSystemAttachmentById(Serializable id) throws Exception{
|
||||
return yxSystemAttachmentMapper.getYxSystemAttachmentById(id);
|
||||
|
@ -115,14 +115,14 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public void setLevelComplete(int uid) {
|
||||
public boolean setLevelComplete(int uid) {
|
||||
YxUserQueryVo userQueryVo = userService.getYxUserById(uid);
|
||||
if(ObjectUtil.isNull(userQueryVo)) return;
|
||||
if(ObjectUtil.isNull(userQueryVo)) return false;
|
||||
|
||||
int levelId = getUserLevel(uid,9);
|
||||
|
||||
int nextLevelId = systemUserLevelService.getNextLevelId(levelId);
|
||||
if(nextLevelId == 0) return;
|
||||
if(nextLevelId == 0) return false;
|
||||
|
||||
//QueryWrapper<YxSystemUserTask> wrapper = new QueryWrapper<>();
|
||||
//wrapper.eq("level_id",nextLevelId).eq("is_show",1);
|
||||
@ -131,9 +131,13 @@ public class YxUserLevelServiceImpl extends BaseServiceImpl<YxUserLevelMapper, Y
|
||||
int finishCount = systemUserTaskService.getTaskComplete(nextLevelId,uid);
|
||||
if(finishCount == 3){
|
||||
setUserLevel(uid,nextLevelId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@ import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.param.PromParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserBillQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -124,7 +125,7 @@ public class UserBillController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/spread/banner")
|
||||
@ApiOperation(value = "分销二维码海报生成",notes = "分销二维码海报生成")
|
||||
public ApiResult<Object> spreadBanner(){
|
||||
public ApiResult<Object> spreadBanner(@RequestParam(value = "",required=false) String from){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
YxUserQueryVo userInfo = yxUserService.getYxUserById(uid);
|
||||
String siteUrl = systemConfigService.getData("site_url");
|
||||
@ -136,89 +137,147 @@ public class UserBillController extends BaseController {
|
||||
return ApiResult.fail("未配置api地址");
|
||||
}
|
||||
|
||||
String userType = userInfo.getUserType();
|
||||
if(!userType.equals(AppFromEnum.ROUNTINE.getValue())) {
|
||||
userType = AppFromEnum.H5.getValue();
|
||||
}
|
||||
|
||||
String name = uid + "_"+userType+"_user_wap.jpg";
|
||||
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+File.separator;
|
||||
String qrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
//判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
siteUrl = siteUrl+"/distribution/";
|
||||
}
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
QrCodeUtil.generate(siteUrl+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
}
|
||||
|
||||
|
||||
String spreadPicName = uid + "_"+userType+"_user_spread.jpg";
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
String spreadUrl = "";
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("fx.jpg");
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("simsunb.ttf");
|
||||
File newFile = new File("fx.jpg");
|
||||
File newFileT = new File("simsunb.ttf");
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(stream, newFile);
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
//app类型
|
||||
if(StrUtil.isNotBlank(from) && AppFromEnum.APP.getValue().equals(from)){
|
||||
String spreadPicName = uid + "_"+from+"_user_spread.jpg";
|
||||
String fileDir = path+"qrcode"+File.separator;
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("fx.jpg");
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("simsunb.ttf");
|
||||
File newFile = new File("fx.jpg");
|
||||
File newFileT = new File("simsunb.ttf");
|
||||
try {
|
||||
|
||||
// Font font = new Font(newFileT.getAbsolutePath(), Font.BOLD, 20);
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
Font f= font.deriveFont(Font.PLAIN,20);
|
||||
//font.
|
||||
ImgUtil.pressText(//
|
||||
newFile,
|
||||
FileUtil.file(spreadPicPath),
|
||||
userInfo.getNickname()+"邀您加入",
|
||||
Color.BLACK,
|
||||
f, //字体
|
||||
50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
ImgUtil.pressImage(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片
|
||||
-150, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
systemAttachmentService.attachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName);
|
||||
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
|
||||
} catch (Exception e) {
|
||||
FileUtils.copyInputStreamToFile(stream, newFile);
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
try {
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
Font f= font.deriveFont(Font.PLAIN,20);
|
||||
ImgUtil.pressText(//
|
||||
newFile,
|
||||
FileUtil.file(spreadPicPath),
|
||||
userInfo.getNickname()+"邀您加入",
|
||||
Color.BLACK,
|
||||
f, //字体
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
String inviteCode = OrderUtil.createShareCode();
|
||||
ImgUtil.pressText(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
"邀您码:"+ inviteCode,
|
||||
Color.RED,
|
||||
f, //字体
|
||||
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
systemAttachmentService.newAttachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName,uid,inviteCode);
|
||||
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
}
|
||||
}
|
||||
else{//其他
|
||||
String userType = userInfo.getUserType();
|
||||
if(!userType.equals(AppFromEnum.ROUNTINE.getValue())) {
|
||||
userType = AppFromEnum.H5.getValue();
|
||||
}
|
||||
|
||||
String name = uid + "_"+userType+"_user_wap.jpg";
|
||||
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+File.separator;
|
||||
String qrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
//判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题
|
||||
if(userType.equals(AppFromEnum.ROUNTINE.getValue())){
|
||||
siteUrl = siteUrl+"/distribution/";
|
||||
}
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
QrCodeUtil.generate(siteUrl+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
}
|
||||
|
||||
String spreadPicName = uid + "_"+userType+"_user_spread.jpg";
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("fx.jpg");
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("simsunb.ttf");
|
||||
File newFile = new File("fx.jpg");
|
||||
File newFileT = new File("simsunb.ttf");
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(stream, newFile);
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
try {
|
||||
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
Font f= font.deriveFont(Font.PLAIN,20);
|
||||
//font.
|
||||
ImgUtil.pressText(//
|
||||
newFile,
|
||||
FileUtil.file(spreadPicPath),
|
||||
userInfo.getNickname()+"邀您加入",
|
||||
Color.BLACK,
|
||||
f, //字体
|
||||
50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
ImgUtil.pressImage(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片
|
||||
-150, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
systemAttachmentService.attachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName);
|
||||
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,8 +70,13 @@ public class UserLevelController extends BaseController {
|
||||
@ApiOperation(value = "检测用户是否可以成为会员",notes = "检测用户是否可以成为会员")
|
||||
public ApiResult<Object> detection(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
userLevelService.setLevelComplete(uid);
|
||||
return ApiResult.ok("ok");
|
||||
boolean res = userLevelService.setLevelComplete(uid);
|
||||
if(res){
|
||||
return ApiResult.ok("升级成功!");
|
||||
}else{
|
||||
return ApiResult.fail("还不符合升级条件哦!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class WechatController extends BaseController {
|
||||
map.put("appId",jsapiSignature.getAppId());
|
||||
map.put("jsApiList",new String[]{"updateAppMessageShareData","openLocation","scanQRCode",
|
||||
"chooseWXPay","updateAppMessageShareData","updateTimelineShareData",
|
||||
"openAddress","editAddress"});
|
||||
"openAddress","editAddress","getLocation"});
|
||||
map.put("nonceStr",jsapiSignature.getNonceStr());
|
||||
map.put("signature",jsapiSignature.getSignature());
|
||||
map.put("timestamp",jsapiSignature.getTimestamp());
|
||||
|
@ -34,6 +34,11 @@ public interface ShopConstants {
|
||||
*/
|
||||
String YSHOP_WEIXIN_MINI_PAY_SERVICE = "yshop_weixin_mini_pay_service";
|
||||
|
||||
/**
|
||||
* 微信支付app service
|
||||
*/
|
||||
String YSHOP_WEIXIN_APP_PAY_SERVICE = "yshop_weixin_app_pay_service";
|
||||
|
||||
/**
|
||||
* 微信公众号service
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@ public enum AppFromEnum {
|
||||
WEIXIN_H5("weixinh5","weixinh5"),
|
||||
H5("h5","H5"),
|
||||
WECHAT("wechat","公众号"),
|
||||
APP("app","APP"),
|
||||
ROUNTINE("routine","小程序");
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import javax.xml.crypto.Data;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @ClassName OrderUtil
|
||||
@ -16,6 +17,30 @@ import java.util.Date;
|
||||
**/
|
||||
public class OrderUtil {
|
||||
|
||||
/**
|
||||
* 生成邀请码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String createShareCode() {
|
||||
int maxNum = 36;
|
||||
int i;
|
||||
int count = 0;
|
||||
char[] str = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
|
||||
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
StringBuffer pwd = new StringBuffer("");
|
||||
Random r = new Random();
|
||||
while (count < 10) {
|
||||
i = Math.abs(r.nextInt(maxNum));
|
||||
if (i >= 0 && i < str.length) {
|
||||
pwd.append(str[i]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return pwd.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取俩个数之间的随机数
|
||||
* @param min
|
||||
|
@ -56,7 +56,7 @@ public class WxPayConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取WxAppPayService
|
||||
* 获取小程序WxAppPayService
|
||||
* @return
|
||||
*/
|
||||
public static WxPayService getWxAppPayService() {
|
||||
@ -79,6 +79,30 @@ public class WxPayConfiguration {
|
||||
return wxPayService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APPPayService
|
||||
* @return
|
||||
*/
|
||||
public static WxPayService getAppPayService() {
|
||||
WxPayService wxPayService = payServices.get(ShopConstants.YSHOP_WEIXIN_APP_PAY_SERVICE);
|
||||
if(wxPayService == null || RedisUtil.get(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE) == null) {
|
||||
WxPayConfig payConfig = new WxPayConfig();
|
||||
payConfig.setAppId(RedisUtil.get("wx_native_app_appId"));
|
||||
payConfig.setMchId(RedisUtil.get("wxpay_mchId"));
|
||||
payConfig.setMchKey(RedisUtil.get("wxpay_mchKey"));
|
||||
payConfig.setKeyPath(RedisUtil.get("wxpay_keyPath"));
|
||||
// 可以指定是否使用沙箱环境
|
||||
payConfig.setUseSandboxEnv(false);
|
||||
wxPayService = new WxPayServiceImpl();
|
||||
wxPayService.setConfig(payConfig);
|
||||
payServices.put(ShopConstants.YSHOP_WEIXIN_APP_PAY_SERVICE, wxPayService);
|
||||
|
||||
//增加标识
|
||||
RedisUtil.set(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE,"yshop");
|
||||
}
|
||||
return wxPayService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除WxPayService
|
||||
*/
|
||||
@ -86,6 +110,7 @@ public class WxPayConfiguration {
|
||||
RedisUtil.del(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
||||
payServices.remove(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
||||
payServices.remove(ShopConstants.YSHOP_WEIXIN_MINI_PAY_SERVICE);
|
||||
payServices.remove(ShopConstants.YSHOP_WEIXIN_APP_PAY_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.mp.config.WxPayConfiguration;
|
||||
import co.yixiang.mp.handler.RedisHandler;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||
@ -97,6 +98,38 @@ public class YxPayService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信app支付
|
||||
*
|
||||
* @param orderId
|
||||
* @param body
|
||||
* @param totalFee
|
||||
* @return
|
||||
* @throws WxPayException
|
||||
*/
|
||||
public WxPayAppOrderResult appPay(String orderId, String body,
|
||||
Integer totalFee, String attach) throws WxPayException {
|
||||
|
||||
String apiUrl = redisHandler.getVal("api_url");
|
||||
if (StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
|
||||
|
||||
WxPayService wxPayService = WxPayConfiguration.getAppPayService();
|
||||
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||
|
||||
orderRequest.setTradeType("APP");
|
||||
orderRequest.setBody(body);
|
||||
orderRequest.setOutTradeNo(orderId);
|
||||
orderRequest.setTotalFee(totalFee);
|
||||
orderRequest.setSpbillCreateIp("127.0.0.1");
|
||||
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
|
||||
orderRequest.setAttach(attach);
|
||||
|
||||
WxPayAppOrderResult appOrderResult = wxPayService.createOrder(orderRequest);
|
||||
|
||||
return appOrderResult;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退款
|
||||
|
Reference in New Issue
Block a user