1.余额支付

2.支付参数整理
This commit is contained in:
HH 2022-05-12 14:44:42 +08:00
parent 2c5da04cc1
commit 6e9a7e361c
30 changed files with 565 additions and 135 deletions

View File

@ -7,6 +7,7 @@ import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.enums.BusinessType;
import com.ghy.common.utils.ShiroUtils;
import com.ghy.common.utils.poi.ExcelUtil;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.Goods;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsService;
@ -73,7 +74,9 @@ public class GoodsController extends BaseController {
@GetMapping("/add")
public String add(ModelMap mmap) {
Long parentId = ShiroUtils.getSysUser().getParentId();
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(parentId));
DeptGoodsCategory category = new DeptGoodsCategory();
category.setDeptId(parentId);
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(category));
return PREFIX + "/add";
}
@ -97,7 +100,9 @@ public class GoodsController extends BaseController {
@GetMapping("/edit/{goodsId}")
public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap) {
Long parentId = ShiroUtils.getSysUser().getParentId();
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(parentId));
DeptGoodsCategory category = new DeptGoodsCategory();
category.setDeptId(parentId);
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(category));
mmap.put("goods", goodsService.selectById(goodsId));
return PREFIX + "/edit";
}

View File

@ -1,12 +1,13 @@
package com.ghy.web.controller.goods;
import com.ghy.common.annotation.Log;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.domain.Ztree;
import com.ghy.common.enums.BusinessType;
import com.ghy.common.utils.ShiroUtils;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsCategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -21,15 +22,12 @@ public class GoodsDeptCategoryController extends BaseController {
private static final String PREFIX = "goods/deptcategory";
@Resource
GoodsCategoryService goodsCategoryService;
@Resource
DeptGoodsCategoryService deptGoodsCategoryService;
@RequiresPermissions("goods:deptcategory:view")
@GetMapping()
public String goodsCategory() {
public String DeptGoodsCategory() {
return PREFIX + "/deptcategory";
}
@ -43,19 +41,21 @@ public class GoodsDeptCategoryController extends BaseController {
/**
* 商品类别表
*/
@RequiresPermissions("goods:goods:list")
@RequiresPermissions("goods:deptcategory:list")
@PostMapping("/list")
@ResponseBody
public List<GoodsCategory> list(GoodsCategory category) {
return goodsCategoryService.selectGoodsCategoryList(category);
public List<DeptGoodsCategory> list(DeptGoodsCategory category) {
Long parentId = ShiroUtils.getSysUser().getParentId();
category.setDeptId(parentId);
return deptGoodsCategoryService.list(category);
}
@GetMapping("/tree")
@ResponseBody
public List<Ztree> goodsDeptCategoryTree() {
// Long parentId = ShiroUtils.getSysUser().getParentId();
// List<Ztree> ztrees = goodsDeptCategoryService.tree(parentId);
return goodsCategoryService.selectCategoryTree(null);
Long parentId = ShiroUtils.getSysUser().getParentId();
return deptGoodsCategoryService.tree(parentId);
}
@PostMapping("/app/list")
@ -64,4 +64,18 @@ public class GoodsDeptCategoryController extends BaseController {
return AjaxResult.success(deptGoodsCategoryService.appList(deptGoodsCategory.getDeptId()));
}
/**
* 删除子公司商品类别接口
*/
@RequiresPermissions("goods:deptcategory:remove")
@Log(title = "子公司商品类别管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
try {
return toAjax(deptGoodsCategoryService.delete(ids));
} catch (Exception e) {
return error(e.getMessage());
}
}
}

View File

@ -2,6 +2,7 @@ package com.ghy.web.controller.pay;
import com.ghy.common.adapay.AdapayService;
import com.ghy.common.adapay.callback.PayCallback;
import com.ghy.common.adapay.model.PayParam;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.order.domain.OrderMaster;
@ -42,8 +43,9 @@ public class AlipayController extends BaseController {
Map<String, Object> map;
try {
// TODO 订单里需要补充支付金额tittle简要描述分账信息description
map = adapayService.alipayQrPay(payCallback, orderMaster.getCode(), "orderMaster.get支付金额",
"orderMaster.getTittle()", "orderMaster.get简要描述", "orderMaster.getDivMember", "orderMaster.getDescription");
PayParam payParam = new PayParam(orderMaster.getCode(),
"orderMaster.get支付金额", "orderMaster.getTittle()", "orderMaster.get商品描述信息");
map = adapayService.alipayQrPay(payParam, payCallback, null, null, null);
} catch (BaseAdaPayException e) {
logger.error("获取微信用户信息失败", e);
return AjaxResult.error();

View File

@ -3,7 +3,8 @@ package com.ghy.web.controller.pay;
import com.alibaba.fastjson.JSONObject;
import com.ghy.common.adapay.AdapayService;
import com.ghy.common.adapay.callback.PayCallback;
import com.ghy.common.adapay.callback.model.WxLiteExpend;
import com.ghy.common.adapay.model.PayParam;
import com.ghy.common.adapay.model.WxpayExpend;
import com.ghy.common.config.WxConfig;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
@ -56,13 +57,14 @@ public class WxPayController extends BaseController {
}
String openId = wxUser.getString("openid");
//调用adapay微信公众号支付.
WxLiteExpend expend = new WxLiteExpend();
WxpayExpend expend = new WxpayExpend();
expend.setOpenId(openId);
Map<String, Object> map;
try {
// TODO 订单里需要补充支付金额tittle简要描述分账信息description
map = adapayService.wxPubPay(payCallback, expend, orderMaster.getCode(), "orderMaster.get支付金额",
"orderMaster.getTittle()", "orderMaster.get简要描述", "orderMaster.getDivMember", "orderMaster.getDescription");
PayParam payParam = new PayParam(orderMaster.getCode(),
"orderMaster.get支付金额", "orderMaster.getTittle()", "orderMaster.get商品描述信息");
map = adapayService.wxLitePay(payParam, payCallback, expend, null, null);
} catch (BaseAdaPayException e) {
logger.error("获取微信用户信息失败", e);
return AjaxResult.error();
@ -85,20 +87,18 @@ public class WxPayController extends BaseController {
logger.info("code is " + code);
//测试时前端不带订单号.
// String orderId = request.getParameter("orderId");
// 查询回订单信息如果订单不存在则退出.
// TODO 查询回订单信息如果订单不存在则退出.
try {
JSONObject wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret());
String openId = wxUser.getString("openid");
logger.info("open id is " + openId);
//调用adapay微信公众号支付.
WxLiteExpend expend = new WxLiteExpend();
WxpayExpend expend = new WxpayExpend();
expend.setOpenId(openId);
Map<String, Object> map = adapayService.wxPubPay(payCallback, expend, "wxPay123456" + Math.ceil(Math.random() * 100), "1.00",
"测试商品", "测试商品detail", null, "description");
//拼接消息给前端.前端通过JSAPI调用微信支付
map.forEach((key, value) -> {
logger.info("key is " + key + ", value is " + value);
});
Map<String, Object> map;
// TODO 订单里需要补充支付金额tittle简要描述分账信息description
PayParam payParam = new PayParam("订单号", "支付金额", "商品标题", "商品描述信息");
map = adapayService.wxPubPay(payParam, payCallback, expend, null, null);
return AjaxResult.success(map);
} catch (Exception e) {
e.printStackTrace();

View File

@ -1,7 +1,7 @@
package com.ghy.web.core;
import com.ghy.common.adapay.callback.PayCallback;
import com.ghy.common.adapay.callback.model.PayReply;
import com.ghy.common.adapay.model.PayReply;
import com.ghy.order.service.OrderDetailService;
import com.ghy.order.service.OrderMasterService;
import org.springframework.context.annotation.Bean;

View File

@ -0,0 +1,158 @@
package com.ghy;
import com.alibaba.fastjson.JSON;
import com.ghy.common.adapay.AdapayService;
import com.ghy.common.adapay.model.DivMember;
import com.ghy.common.adapay.model.PayParam;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.Goods;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.mapper.GoodsMapper;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsCategoryService;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@SpringBootTest
@RunWith(SpringRunner.class)
public class TestApplication {
@Resource
private AdapayService adapayService;
@Resource
private GoodsMapper goodsMapper;
@Resource
private GoodsCategoryService goodsCategoryService;
@Resource
private DeptGoodsCategoryService deptGoodsCategoryService;
@Test
public void testGoodsCategoryService() {
GoodsCategory goodsCategory = new GoodsCategory();
goodsCategory.setGoodsCategoryCode("FRUIT");
goodsCategory.setGoodsCategoryName("水果");
goodsCategory.setLevel(1);
goodsCategory.setType(1);
goodsCategoryService.insertGoodsCategory(goodsCategory);
}
@Test
public void testDeptGoodsCategoryService() {
// DeptGoodsCategory category = new DeptGoodsCategory();
// category.setDeptId(1L);
// category.setGoodsCategoryId(1L);
// category.setCategorySort(1);
// category.setOneRate("0.10");
// category.setTwoRate("0.10");
// category.setThreeRate("0.10");
// deptGoodsCategoryService.add(category);
// category.setGoodsCategoryId(2L);
// category.setCategorySort(2);
// deptGoodsCategoryService.add(category);
// category.setGoodsCategoryId(3L);
// category.setCategorySort(3);
// deptGoodsCategoryService.add(category);
List<DeptGoodsCategory> list = deptGoodsCategoryService.list(null);
list.forEach(System.out::println);
}
@Test
public void addGoods() {
for (int i = 1; i < 11; i++) {
Goods goods = new Goods();
goods.setGoodsCode("GOODS0000" + i);
goods.setGoodsName("神秘商品" + i);
goods.setGoodsPrice(BigDecimal.valueOf(i));
goods.setDiscountsPrice(BigDecimal.valueOf(i));
goods.setGroupPrice(BigDecimal.valueOf(i));
goods.setGoodsSort(i);
goods.setDeptId(1L);
goods.setStatus(0);
goods.setDeptGoodsCategoryId(1L);
goods.setGoodsNumber(i * 100);
System.out.println(goods);
goodsMapper.insertGoods(goods);
}
}
/**
* 转账
*/
@Test
public void balancePay() throws BaseAdaPayException {
String orderNo = "TEST_ORDER_" + System.currentTimeMillis();
System.out.println("orderNo = " + orderNo);
Map<String, Object> map = adapayService.balancePay(orderNo, "0", "HH",
"10.00", "商品标题", "商品描述", null, null);
System.out.println(JSON.toJSONString(map));
}
/**
* 支付宝正扫支付
*/
@Test
public void alipayQr() throws BaseAdaPayException {
DivMember gqz = new DivMember("0", "10.00", false);
DivMember hh = new DivMember("HH", "10.00", true);
String orderNo = "TEST_ORDER_" + System.currentTimeMillis();
System.out.println("orderNo = " + orderNo);
PayParam payParam = new PayParam(orderNo, "20.00", "测试商品", "测试商品描述信息");
Map<String, Object> map = adapayService.alipayQrPay(payParam, reply -> System.out.println(JSON.toJSONString(reply)),
null, null, Arrays.asList(gqz, hh));
System.out.println(JSON.toJSONString(map));
}
/**
* 创建实名用户
*/
@Test
public void createMember() throws BaseAdaPayException {
Map<String, Object> member = adapayService.createMember("LBW", "18788888888", "卢本伟",
"450321199608081017", "广西省桂林市", "velkhana@qq.com", null, null);
System.out.println(JSON.toJSONString(member));
}
/**
* 创建结算账户
*/
@Test
public void createSettleAccount() throws BaseAdaPayException {
Map<String, Object> map = adapayService.createSettleAccount("HH", "6217921009538441", "黄皓", "2",
"450321199608081017", "18777338398", null, null, null);
System.out.println(JSON.toJSONString(map));
}
/**
* 提现
*/
@Test
public void drawCash() throws BaseAdaPayException {
Map<String, Object> map = adapayService.drawCash(reply -> System.out.println(JSON.toJSONString(reply)),
"HH_DRAW_CASH0002", "T1", "198.00", "HH", null, null);
System.out.println(JSON.toJSONString(map));
}
/**
* 退款
*/
@Test
public void refund() throws BaseAdaPayException {
Map<String, Object> map = adapayService.refund(reply -> System.out.println(JSON.toJSONString(reply)),
"002112022051210564510370658738275037184", "REFUND002112022051210564510370658738275037184",
"20.00");
System.out.println(JSON.toJSONString(map));
}
}

View File

@ -1,13 +1,13 @@
package com.ghy.common.adapay;
import com.alibaba.fastjson.JSONObject;
import com.ghy.common.adapay.callback.DrawCashCallback;
import com.ghy.common.adapay.callback.PayCallback;
import com.ghy.common.adapay.callback.RefundCallback;
import com.ghy.common.adapay.callback.mapping.DrawCashReplyMapping;
import com.ghy.common.adapay.callback.mapping.PayReplyMapping;
import com.ghy.common.adapay.callback.mapping.RefundReplyMapping;
import com.ghy.common.adapay.callback.model.Expend;
import com.ghy.common.adapay.callback.model.WxLiteExpend;
import com.ghy.common.adapay.model.*;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.*;
import lombok.Setter;
@ -15,9 +15,11 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@ -32,6 +34,41 @@ public class AdapayService {
@Resource
private AdapayProperties adapayProperties;
/**
* 创建余额支付请求
* 商户利用该接口进行余额支付支持同一商户下的商户-用户用户-商户用户-用户间的账户余额支付
*
* @param orderNo [必填]请求订单号只能为英文数字或者下划线的一种或多种组合保证在app_id下唯一
* @param outMemberId [必填]出账用户的member_id 若为商户本身时请传入0
* @param inMemberId [必填]入账用户的member_id 若为商户本身时请传入0
* @param transAmt [必填]交易金额必须大于0人民币为元保留两位小数点"0.10""100.05"
* @param goodsTitle [必填]商品名称
* @param goodsDesc [必填]商品描述
* @param payMode 支付模式delay- 延时分账模式值为 delay div_members 字段必须为空
* 值为空时并且div_mermbers不为空时表示实时分账
* 值为空时并且div_mermbers也为空时表示不分账
* @param divMembers 分账对象信息列表最多仅支持7个分账方
* @return 成功时同步返回交易结果的 JSON
*/
public Map<String, Object> balancePay(@NotNull String orderNo, @NotNull String outMemberId, @NotNull String inMemberId,
@NotNull String transAmt, @NotNull String goodsTitle, @NotNull String goodsDesc,
String payMode, Collection<DivMember> divMembers) throws BaseAdaPayException {
Map<String, Object> balanceParam = new HashMap<>(10);
balanceParam.put("app_id", adapayProperties.getAppId());
balanceParam.put("adapay_func_code", "settle_accounts.balancePay");
balanceParam.put("order_no", orderNo);
balanceParam.put("out_member_id", outMemberId);
balanceParam.put("in_member_id", inMemberId);
balanceParam.put("trans_amt", transAmt);
balanceParam.put("goods_title", goodsTitle);
balanceParam.put("goods_desc", goodsDesc);
balanceParam.put("pay_mode", payMode);
if (!CollectionUtils.isEmpty(divMembers)) {
balanceParam.put("div_members", divMembers);
}
return AdapayCommon.requestAdapay(balanceParam);
}
/**
* 创建结算账户对象 https://docs.adapay.tech/api/trade.html#settle-account-create
* 创建结算账户对象是为一个已创建用户对象创建结算账户用于对用户分账金额的结算目前仅支持绑定银行卡结算账户
@ -60,6 +97,7 @@ public class AdapayService {
case "1":
Assert.isTrue(StringUtils.isNoneBlank(bankCode, provCode, areaCode),
"[bankCode, provCode, areaCode] cannot be empty !");
break;
case "2":
Assert.hasText(cardId, "cardId is blank !");
accountInfo.put("cert_type", "00");
@ -153,54 +191,47 @@ public class AdapayService {
/**
* 支付宝正扫支付
*/
public Map<String, Object> alipayQrPay(PayCallback callback, String orderNo, String payAmt,
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
return pay(callback, PayChannelEnum.ALIPAY_QR.getCode(), null, orderNo, payAmt, goodsTittle, goodsDesc, divMembers, description);
public Map<String, Object> alipayQrPay(PayParam payParam, PayCallback callback, AlipayExpend expend, DeviceInfo deviceInfo,
Collection<DivMember> divMembers) throws BaseAdaPayException {
return pay("alipay_qr", payParam, callback, expend, deviceInfo, divMembers);
}
/**
* 微信公众号支付
*/
public Map<String, Object> wxPubPay(PayCallback callback, WxLiteExpend expend, String orderNo, String payAmt,
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
return pay(callback, PayChannelEnum.WX_PUB.getCode(), expend, orderNo, payAmt, goodsTittle, goodsDesc, divMembers, description);
public Map<String, Object> wxPubPay(PayParam payParam, PayCallback callback, WxpayExpend expend, DeviceInfo deviceInfo,
Collection<DivMember> divMembers) throws BaseAdaPayException {
return pay("wx_pub", payParam, callback, expend, deviceInfo, divMembers);
}
/**
* 微信小程序支付
*/
public Map<String, Object> wxLitePay(PayCallback callback, WxLiteExpend expend, String orderNo, String payAmt,
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
return pay(callback, PayChannelEnum.WX_LITE.getCode(), expend, orderNo, payAmt, goodsTittle, goodsDesc, divMembers, description);
public Map<String, Object> wxLitePay(PayParam payParam, PayCallback callback, WxpayExpend expend, DeviceInfo deviceInfo,
Collection<DivMember> divMembers) throws BaseAdaPayException {
return pay("wx_lite", payParam, callback, expend, deviceInfo, divMembers);
}
/**
* @param callback [必填项]处理支付结果的回调接口
* @param orderNo [必填项]订单号
* @param payAmt [必填项]交易金额必须大于0保留两位小数点"0.10""100.05"
* @param goodsTittle [必填项]商品名称
* @param goodsDesc [必填项]商品描述信息微信小程序和微信公众号该字段最大长度42个字符
* @param payChannel [必填项]支付渠道详见 https://docs.adapay.tech/api/appendix.html#id2
* @param expend 支付渠道额外参数条件可输入详见 https://docs.adapay.tech/api/appendix.html#expend
* @param divMembers 分账对象信息列表最多仅支持7个分账方json 数组形式详见 https://docs.adapay.tech/api/appendix.html#divmembers
* @param description 订单附加说明
* @param payParam [必填项]支付参数
* @param callback [必填项]处理支付结果的回调接口
* @param expend 支付渠道额外参数 https://docs.adapay.tech/api/appendix.html#expend
* @param deviceInfo 前端设备信息 https://docs.adapay.tech/api/appendix.html#deviceinfo
* @param divMembers 分账对象信息列表 https://docs.adapay.tech/api/appendix.html#divmembers
* @return 同步返回一个 支付对象详见 https://docs.adapay.tech/api/trade.html#id2
*/
public Map<String, Object> pay(PayCallback callback, String payChannel, Expend expend, String orderNo, String payAmt,
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
Map<String, Object> paymentParams = new HashMap<>(16);
public Map<String, Object> pay(String payChannel, PayParam payParam, PayCallback callback, Expend expend,
DeviceInfo deviceInfo, Collection<DivMember> divMembers) throws BaseAdaPayException {
JSONObject paymentParams = payParam.toJSONObject();
paymentParams.put("app_id", adapayProperties.getAppId());
paymentParams.put("notify_url", adapayProperties.getNotifyUrl());
paymentParams.put("order_no", orderNo);
paymentParams.put("pay_channel", payChannel);
paymentParams.put("pay_amt", payAmt);
paymentParams.put("goods_title", goodsTittle);
paymentParams.put("goods_desc", goodsDesc);
paymentParams.put("div_members", divMembers);
paymentParams.put("description", description);
paymentParams.put("device_info", deviceInfo);
paymentParams.put("expend", expend);
PayReplyMapping.putCallback(orderNo, callback);
logger.info("paymentParams=" + paymentParams);
PayReplyMapping.putCallback(payParam.getOrderNo(), callback);
logger.debug("paymentParams: {}", paymentParams.toJSONString());
return Payment.create(paymentParams);
}

View File

@ -1,6 +1,6 @@
package com.ghy.common.adapay.callback;
import com.ghy.common.adapay.callback.model.DrawCashReply;
import com.ghy.common.adapay.model.DrawCashReply;
/**
* 处理提现结果的接口

View File

@ -1,6 +1,6 @@
package com.ghy.common.adapay.callback;
import com.ghy.common.adapay.callback.model.PayReply;
import com.ghy.common.adapay.model.PayReply;
/**
* 处理支付结果的回调接口

View File

@ -1,6 +1,6 @@
package com.ghy.common.adapay.callback;
import com.ghy.common.adapay.callback.model.RefundReply;
import com.ghy.common.adapay.model.RefundReply;
/**
* 处理退款结果的回调接口

View File

@ -3,7 +3,7 @@ package com.ghy.common.adapay.callback.mapping;
import com.alibaba.fastjson.JSON;
import com.ghy.common.adapay.callback.DrawCashCallback;
import com.ghy.common.adapay.callback.Event;
import com.ghy.common.adapay.callback.model.DrawCashReply;
import com.ghy.common.adapay.model.DrawCashReply;
import org.springframework.util.Assert;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -3,7 +3,7 @@ package com.ghy.common.adapay.callback.mapping;
import com.alibaba.fastjson.JSON;
import com.ghy.common.adapay.callback.Event;
import com.ghy.common.adapay.callback.PayCallback;
import com.ghy.common.adapay.callback.model.PayReply;
import com.ghy.common.adapay.model.PayReply;
import org.springframework.util.Assert;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -3,7 +3,7 @@ package com.ghy.common.adapay.callback.mapping;
import com.alibaba.fastjson.JSON;
import com.ghy.common.adapay.callback.Event;
import com.ghy.common.adapay.callback.RefundCallback;
import com.ghy.common.adapay.callback.model.RefundReply;
import com.ghy.common.adapay.model.RefundReply;
import org.springframework.util.Assert;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AlipayQrExpend extends Expend {
public class AlipayExpend extends Expend {
/**
* 优惠信息
@ -20,11 +20,32 @@ public class AlipayQrExpend extends Expend {
private PromotionDetail promotionDetail;
/**
* 花呗分期数
* 花呗分期数 String(2)
* 支付金额大于等于 100 元时可不指定分期数用户可自由选择分期数
* 支付金额小于 100 元时必须指定分期数否则不支持花呗分期支付
* 指定分期数后用户不能更分期数分期数目前只支持 3612花呗分期的手续费由用户自己承担
*/
@JSONField(name = "hb_fq_num")
private PromotionDetail hbFqNum;
private String hbFqNum;
/**
* 买家的支付宝用户 id
* pay_channel = alipay_pub alipay_lite 时必填
*/
@JSONField(name = "buyer_id")
private String buyerId;
/**
* 买家支付宝账号
*/
@JSONField(name = "buyer_logon_id")
private String buyerLogonId;
/**
* 扫码设备读出的条形码或者二维码信息
* pay_channel = alipay_scan 时必填
*/
@JSONField(name = "auth_code")
private String authCode;
}

View File

@ -0,0 +1,60 @@
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
/**
* 前端设备信息 https://docs.adapay.tech/api/appendix.html#deviceinfo
*
* @author HH 2022/5/12
*/
@Data
public class DeviceInfo {
/**
* 设备类型1 :手机 2 :平板 3:手表 4:PC
*/
@JSONField(name = "device_type")
private String deviceType;
/**
* [必填]交易设备所在的公网 IP
*/
@JSONField(name = "device_ip")
private String deviceIp;
/**
* 终端设备号收单机构为商户终端分配的唯一编号当pay_channel的值为alipay_scan或wx_scan时必填
*/
@JSONField(name = "device_id")
private String deviceId;
/**
* 交易设备 MAC
*/
@JSONField(name = "device_mac")
private String deviceMac;
/**
* 交易设备 imei
*/
@JSONField(name = "device_imei")
private String deviceImei;
/**
* 交易设备 IMSI
*/
@JSONField(name = "device_imsi")
private String deviceImsi;
/**
* 交易设备 ICCID
*/
@JSONField(name = "device_iccId")
private String deviceIccId;
/**
* 交易设备 WIFI MAC
*/
@JSONField(name = "deviceWifiMac")
private String device_wifi_mac;
/**
* 交易设备 GPS
*/
@JSONField(name = "promotion_detail")
private String promotionDetail;
}

View File

@ -0,0 +1,47 @@
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 分账对象信息
*
* @author HH 2022/5/12
*/
@Data
public class DivMember {
/**
* 分账用户 Member 对象的 id若是商户本身时传入"0"
*/
@JSONField(name = "member_id")
private String memberId;
/**
* 分账金额精确到分 "0.50""1.00"
* 分账总金额必须等于主交易金额金额不能为 "0.00"
*/
private String amount;
/**
* 是否手续费承担方N-Y-手续费承担方有且只能有一个
*/
@JSONField(name = "fee_flag")
private String feeFlag;
/**
* 构造方法
*
* @param memberId 分账用户 Member 对象的 id若是商户本身时传入"0"
* @param amount 分账金额精确到分 "0.50""1.00" 分账总金额必须等于主交易金额金额不能为 "0.00"
* @param feeFlag 是否手续费承担方N-Y-手续费承担方有且只能有一个
*/
public DivMember(@NotNull String memberId, @NotNull String amount, boolean feeFlag) {
this.memberId = memberId;
this.amount = amount;
this.feeFlag = feeFlag ? "Y" : "N";
}
}

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

View File

@ -1,7 +1,8 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
/**
* 所有支付渠道扩展参数的父类
* https://docs.adapay.tech/api/appendix.html#expend
*
* @author HH 2022/3/31
*/

View File

@ -0,0 +1,83 @@
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
/**
* 支付参数
*
* @author HH 2022/5/12
*/
@Data
public class PayParam {
/**
* 请求订单号只能为英文数字或者下划线的一种或多种组合保证在app_id下唯一
*/
@JSONField(name = "order_no")
private String orderNo;
/**
* 交易金额必须大于0保留两位小数点如0.10100.05等
*/
@JSONField(name = "pay_amt")
private String payAmt;
/**
* 支付模式delay- 延时分账模式值为 delay div_members 字段必须为空
* 值为空时并且div_members不为空时表示实时分账
* 值为空时并且div_members也为空时表示不分账
*/
@JSONField(name = "pay_mode")
private String payMode;
/**
* 商品标题
*/
@JSONField(name = "goods_title")
private String goodsTittle;
/**
* 商品描述信息微信小程序和微信公众号该字段最大长度42个字符
*/
@JSONField(name = "goods_desc")
private String goodsDesc;
/**
* 订单附加说明 最大长度128个字符
*/
private String description;
/**
* 订单失效时间输入格式yyyyMMddHHmmss最长失效时间为微信支付宝反扫类3分钟非反扫类2小时
* 云闪付1天值为空时默认最长时效时间
*/
@JSONField(name = "time_expire")
private String timeExpire;
/**
* 手续费收取模式O-商户手续费账户扣取手续费I-交易金额中扣取手续费值为空时默认值为I
* 若为O时分账对象列表中不支持传入手续费承担方
*/
@JSONField(name = "fee_mode")
private String feeMode;
/**
* 包含所有必填参数的构造器其它参数按需set
*
* @param orderNo [必填项]请求订单号只能为英文数字或者下划线的一种或多种组合保证在app_id下唯一
* @param payAmt [必填项]交易金额必须大于0保留两位小数点"0.10""100.05"
* @param goodsTittle [必填项]商品名称
* @param goodsDesc [必填项]商品描述信息微信小程序和微信公众号该字段最大长度42个字符
*/
public PayParam(String orderNo, String payAmt, String goodsTittle, String goodsDesc) {
boolean noneBlank = StringUtils.isNoneBlank(orderNo, payAmt, goodsTittle, goodsDesc);
Assert.isTrue(noneBlank, "PayParam [orderNo, payChannel, payAmt, goodsTittle, goodsDesc] cannot be empty!");
this.orderNo = orderNo;
this.payAmt = payAmt;
this.goodsTittle = goodsTittle;
this.goodsDesc = goodsDesc;
}
public JSONObject toJSONObject() {
String jsonString = JSON.toJSONString(this);
return JSON.parseObject(jsonString);
}
}

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.ghy.common.adapay.callback.model;
package com.ghy.common.adapay.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@ -11,13 +11,20 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxLiteExpend extends Expend {
public class WxpayExpend extends Expend {
/**
* [必填]微信用户关注商家公众号的 openid
* 微信用户关注商家公众号的 openid
* pay_channel = wx_lite wx_pub 时必填
*/
@JSONField(name = "open_id")
private String openId;
/**
* 扫码设备读出的条形码或者二维码信息
* pay_channel = wx_scan 时必填
*/
@JSONField(name = "auth_code")
private String authCode;
/**
* 当前微信小程序的 appid
*/

View File

@ -1,8 +1,8 @@
package com.ghy.goods.domain;
import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@ -11,7 +11,8 @@ import java.util.List;
* 分公司使用类目
*/
@Data
public class DeptGoodsCategory extends BaseEntity {
@EqualsAndHashCode(callSuper = true)
public class DeptGoodsCategory extends GoodsCategory {
@Excel(name = "序列", cellType = Excel.ColumnType.NUMERIC)
private Long deptGoodsCategoryId;
@ -19,18 +20,6 @@ public class DeptGoodsCategory extends BaseEntity {
@Excel(name = "分公司id", cellType = Excel.ColumnType.NUMERIC)
private Long deptId;
@Excel(name = "类别id", cellType = Excel.ColumnType.NUMERIC)
private Long goodsCategoryId;
@Excel(name = "类别编码", cellType = Excel.ColumnType.STRING)
private String goodsCategoryCode;
@Excel(name = "类别名称", cellType = Excel.ColumnType.STRING)
private String goodsCategoryName;
@Excel(name = "类别类型. 1.服务类 2.商品类", cellType = Excel.ColumnType.STRING)
private Integer type;
@Excel(name = "排序", cellType = Excel.ColumnType.STRING)
private Integer categorySort;
@Excel(name = "一级分销扣点比例", cellType = Excel.ColumnType.STRING)
private String oneRate;

View File

@ -28,7 +28,7 @@ public interface DeptGoodsCategoryMapper {
* @param category 商品入参
* @return 商品集合
*/
List<DeptGoodsCategory> selectDeptGoodsCategoryList(DeptGoodsCategory category);
List<DeptGoodsCategory> selectList(DeptGoodsCategory category);
/**

View File

@ -16,9 +16,9 @@ public interface DeptGoodsCategoryService {
/**
* 用deptId查询出该公司的所有类目
*
* @param deptId 公司ID
* @param category 查询条件
*/
List<DeptGoodsCategory> list(Long deptId);
List<DeptGoodsCategory> list(DeptGoodsCategory category);
/**
* 新增一条分公司类目
@ -56,4 +56,6 @@ public interface DeptGoodsCategoryService {
* @return 父子层级的list
*/
List<DeptGoodsCategory> appList(Long deptId);
int delete(String ids);
}

View File

@ -1,18 +1,18 @@
package com.ghy.goods.service.impl;
import com.ghy.common.core.domain.Ztree;
import com.ghy.common.core.text.Convert;
import com.ghy.common.utils.StringUtils;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.mapper.DeptGoodsCategoryMapper;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* @author clunt
@ -22,30 +22,12 @@ import java.util.stream.Collectors;
@Service
public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
@Resource
private GoodsCategoryService goodsCategoryService;
@Resource
private DeptGoodsCategoryMapper deptGoodsCategoryMapper;
@Override
public List<DeptGoodsCategory> list(Long deptId) {
DeptGoodsCategory query = new DeptGoodsCategory();
query.setDeptId(deptId);
List<DeptGoodsCategory> result = deptGoodsCategoryMapper.selectDeptGoodsCategoryList(query);
if (result.isEmpty())
return result;
Set<Long> goodsCategoryIdSet = result.stream().map(DeptGoodsCategory::getGoodsCategoryId).filter(Objects::nonNull).collect(Collectors.toSet());
List<GoodsCategory> goodsCategoryList = goodsCategoryService.selectByIds(goodsCategoryIdSet);
Map<Long, GoodsCategory> goodsCategoryMap = goodsCategoryList.stream().collect(Collectors.toMap(GoodsCategory::getGoodsCategoryId, x -> x));
result.forEach(x -> {
GoodsCategory goodsCategory = goodsCategoryMap.get(x.getGoodsCategoryId());
if (goodsCategory != null) {
x.setGoodsCategoryName(goodsCategory.getGoodsCategoryName());
x.setGoodsCategoryCode(goodsCategory.getGoodsCategoryCode());
x.setType(goodsCategory.getType());
}
});
return result;
public List<DeptGoodsCategory> list(DeptGoodsCategory category) {
return deptGoodsCategoryMapper.selectList(category);
}
@Override
@ -100,6 +82,12 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
return goodsCategoryList;
}
@Override
public int delete(String ids) {
Long[] array = Convert.toLongArray(ids);
return delete(Arrays.asList(array));
}
private void fillChild(List<DeptGoodsCategory> goodsCategoryList) {
List<DeptGoodsCategory> childList;
for (DeptGoodsCategory deptGoodsCategory : goodsCategoryList) {

View File

@ -30,11 +30,13 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
@Override
public int insertGoodsCategory(GoodsCategory goodsCategory) {
setLevel(goodsCategory);
return goodsCategoryMapper.insertCategoryGoods(goodsCategory);
}
@Override
public int updateGoodsCategory(GoodsCategory goodsCategory) {
setLevel(goodsCategory);
return goodsCategoryMapper.updateGoodsCategory(goodsCategory);
}
@ -106,7 +108,7 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
*/
public List<Ztree> initZtree(List<GoodsCategory> goodsCategoryList, List<String> roleDeptList) {
List<Ztree> ztrees = new ArrayList<Ztree>();
List<Ztree> ztrees = new ArrayList<>();
for (GoodsCategory goodsCategory : goodsCategoryList) {
if (UserConstants.CATEGORY_NORMAL.equals(goodsCategory.getStatus())) {
Ztree ztree = new Ztree();
@ -121,5 +123,13 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
return ztrees;
}
private void setLevel(GoodsCategory goodsCategory) {
Long parentId = goodsCategory.getParentCategoryId();
GoodsCategory parent;
if (parentId == null || (parent = goodsCategoryMapper.selectById(parentId)) == null) {
goodsCategory.setLevel(1);
} else {
goodsCategory.setLevel(parent.getLevel() + 1);
}
}
}

View File

@ -8,6 +8,9 @@
<result property="goodsCategoryId" column="goods_category_id"/>
<result property="goodsCategoryName" column="goods_category_name"/>
<result property="parentCategoryId" column="parent_category_id" />
<result property="level" column="level" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="categorySort" column="category_sort"/>
<result property="oneRate" column="one_rate"/>
<result property="twoRate" column="two_rate"/>
@ -25,11 +28,15 @@
FROM dept_goods_category
</sql>
<sql id="selectJoin">
SELECT dgc.dept_goods_category_id, dgc.dept_id, dgc.goods_category_id, dgc.category_sort,
dgc.one_rate, dgc.two_rate, dgc.three_rate, dgc.create_by, dgc.create_time, dgc.remark,
gc.goods_category_name, gc.level, gc.parent_category_id, gc.type, gc.status
FROM dept_goods_category dgc LEFT JOIN goods_category gc ON dgc.goods_category_id = gc.goods_category_id
</sql>
<select id="appList" parameterType="com.ghy.goods.domain.DeptGoodsCategory" resultMap="DeptGoodsCategoryResult">
SELECT dgc.dept_goods_category_id, dgc.dept_id, dgc.goods_category_id, gc.goods_category_name, gc.parent_category_id, dgc.category_sort,
dgc.one_rate, dgc.two_rate, dgc.three_rate, dgc.create_by, dgc.create_time, dgc.remark
FROM dept_goods_category dgc
LEFT JOIN goods_category gc on gc.goods_category_id = dgc.goods_category_id
<include refid="selectJoin"/>
<where>
dgc.dept_id = #{deptId}
<if test="goodsCategoryId == null ">
@ -45,7 +52,6 @@
<update id="updateDeptGoodsCategory" parameterType="com.ghy.goods.domain.DeptGoodsCategory">
UPDATE dept_goods_category
<set>
<if test="deptId != null and goodsCategoryCode != ''">dept_id = #{deptId},</if>
<if test="goodsCategoryId != null">goods_category_id = #{goodsCategoryId},</if>
<if test="categorySort != null">category_sort = #{categorySort},</if>
<if test="oneRate != null and oneRate != ''">one_rate = #{oneRate},</if>
@ -76,7 +82,7 @@
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and goodsCategoryCode != ''">#{deptId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="goodsCategoryId != null">#{goodsCategoryId},</if>
<if test="categorySort != null">#{categorySort},</if>
<if test="oneRate != null and oneRate != ''">#{oneRate},</if>
@ -87,11 +93,17 @@
)
</insert>
<select id="selectDeptGoodsCategoryList" parameterType="com.ghy.goods.domain.DeptGoodsCategory" resultMap="DeptGoodsCategoryResult">
<include refid="selectDeptGoodsCategory" />
<select id="selectList" parameterType="com.ghy.goods.domain.DeptGoodsCategory" resultMap="DeptGoodsCategoryResult">
<include refid="selectJoin"/>
<where>
<if test="deptId != null">
AND dept_id = #{deptId}
AND dgc.dept_id = #{deptId}
</if>
<if test="goodsCategoryName != null and goodsCategoryName != ''">
AND gc.goods_category_name LIKE concat('%', #{goodsCategoryName}, '%')
</if>
<if test="status != null and status != ''">
AND gc.status LIKE concat('%', #{status}, '%')
</if>
</where>
</select>

View File

@ -19,7 +19,7 @@
<sql id="selectGoodsCategory">
SELECT goods_category_id, goods_category_code, goods_category_name, parent_category_id,
level, type, status, create_by, create_time, remark
level, type, status, create_by, create_time, remark, category_sort
FROM goods_category
</sql>
@ -84,12 +84,12 @@
)
</insert>
<select id="selectByGoodsCategoryName" parameterType="long" resultMap="GoodsCategoryResult">
<select id="selectByGoodsCategoryName" parameterType="String" resultMap="GoodsCategoryResult">
<include refid="selectGoodsCategory"/>
WHERE goods_category_name = #{goodsCategoryName} LIMIT 1
</select>
<select id="selectByGoodsCategoryCode" parameterType="long" resultMap="GoodsCategoryResult">
<select id="selectByGoodsCategoryCode" parameterType="String" resultMap="GoodsCategoryResult">
<include refid="selectGoodsCategory"/>
WHERE goods_category_code = #{goodsCategoryCode} LIMIT 1
</select>