Merge branch 'feature/mall_product'

pull/2/head^2
tangqian 2023-05-26 14:39:17 +08:00
commit 9894119ba8
3 changed files with 33 additions and 26 deletions

View File

@ -49,4 +49,6 @@ public class WxPayJsResultVo {
@Schema(description = "拉起收银台的ticket", required = true) @Schema(description = "拉起收银台的ticket", required = true)
private String ticket; private String ticket;
@Schema(description = "", required = true)
private String packageValue;
} }

View File

@ -52,7 +52,7 @@ public class StoreProductController {
* @param request * @param request
* @param pageParamRequest * @param pageParamRequest
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:list')") @PreAuthorize("@ss.hasPermission('admin:product:list')")
@Operation(summary = "分页列表") //配合swagger使用 @Operation(summary = "分页列表") //配合swagger使用
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
public CommonResult<PageInfo<StoreProductResponse>> getList(@Validated StoreProductSearchRequest request, public CommonResult<PageInfo<StoreProductResponse>> getList(@Validated StoreProductSearchRequest request,
@ -64,7 +64,7 @@ public class StoreProductController {
* *
* @param request * @param request
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:save')") @PreAuthorize("@ss.hasPermission('admin:product:save')")
@Operation(summary = "新增商品") @Operation(summary = "新增商品")
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
public CommonResult<Boolean> save(@RequestBody @Validated StoreProductAddRequest request) { public CommonResult<Boolean> save(@RequestBody @Validated StoreProductAddRequest request) {
@ -79,7 +79,7 @@ public class StoreProductController {
* *
* @param id Integer * @param id Integer
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:delete')") @PreAuthorize("@ss.hasPermission('admin:product:delete')")
@Operation(summary = "删除") @Operation(summary = "删除")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
public CommonResult<Boolean> delete(@RequestBody @PathVariable Integer id, @RequestParam(value = "type", required = false, defaultValue = "recycle")String type) { public CommonResult<Boolean> delete(@RequestBody @PathVariable Integer id, @RequestParam(value = "type", required = false, defaultValue = "recycle")String type) {
@ -99,7 +99,7 @@ public class StoreProductController {
* *
* @param id Integer * @param id Integer
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:restore')") @PreAuthorize("@ss.hasPermission('admin:product:restore')")
@Operation(summary = "恢复商品") @Operation(summary = "恢复商品")
@RequestMapping(value = "/restore/{id}", method = RequestMethod.GET) @RequestMapping(value = "/restore/{id}", method = RequestMethod.GET)
public CommonResult<Boolean> restore(@RequestBody @PathVariable Integer id) { public CommonResult<Boolean> restore(@RequestBody @PathVariable Integer id) {
@ -114,7 +114,7 @@ public class StoreProductController {
* *
* @param storeProductRequest * @param storeProductRequest
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:update')") @PreAuthorize("@ss.hasPermission('admin:product:update')")
@Operation(summary = "商品修改") @Operation(summary = "商品修改")
@RequestMapping(value = "/update", method = RequestMethod.POST) @RequestMapping(value = "/update", method = RequestMethod.POST)
public CommonResult<Boolean> update(@RequestBody @Validated StoreProductAddRequest storeProductRequest) { public CommonResult<Boolean> update(@RequestBody @Validated StoreProductAddRequest storeProductRequest) {
@ -129,7 +129,7 @@ public class StoreProductController {
* *
* @param id id * @param id id
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:info')") @PreAuthorize("@ss.hasPermission('admin:product:info')")
@Operation(summary = "商品详情") @Operation(summary = "商品详情")
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET) @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
public CommonResult<StoreProductInfoResponse> info(@PathVariable Integer id) { public CommonResult<StoreProductInfoResponse> info(@PathVariable Integer id) {
@ -139,7 +139,7 @@ public class StoreProductController {
/** /**
* tabs * tabs
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:tabs:headers')") @PreAuthorize("@ss.hasPermission('admin:product:tabs:headers')")
@Operation(summary = "商品表头数量") @Operation(summary = "商品表头数量")
@RequestMapping(value = "/tabs/headers", method = RequestMethod.GET) @RequestMapping(value = "/tabs/headers", method = RequestMethod.GET)
public CommonResult<List<StoreProductTabsHeader>> getTabsHeader() { public CommonResult<List<StoreProductTabsHeader>> getTabsHeader() {
@ -149,7 +149,7 @@ public class StoreProductController {
/** /**
* *
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:up')") @PreAuthorize("@ss.hasPermission('admin:product:up')")
@Operation(summary = "上架") @Operation(summary = "上架")
@RequestMapping(value = "/putOnShell/{id}", method = RequestMethod.GET) @RequestMapping(value = "/putOnShell/{id}", method = RequestMethod.GET)
public CommonResult<Boolean> putOn(@PathVariable Integer id) { public CommonResult<Boolean> putOn(@PathVariable Integer id) {
@ -163,7 +163,7 @@ public class StoreProductController {
/** /**
* *
*/ */
// @PreAuthorize("@ss.hasPermission('admin:product:down')") @PreAuthorize("@ss.hasPermission('admin:product:down')")
@Operation(summary = "下架") @Operation(summary = "下架")
@RequestMapping(value = "/offShell/{id}", method = RequestMethod.GET) @RequestMapping(value = "/offShell/{id}", method = RequestMethod.GET)
public CommonResult<Boolean> offShell(@PathVariable Integer id) { public CommonResult<Boolean> offShell(@PathVariable Integer id) {

View File

@ -245,25 +245,29 @@ public class OrderPayServiceImpl implements OrderPayService {
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息 // 微信支付,调用微信预下单,返回拉起微信支付需要的信息
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) { if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
// 预下单 // 预下单
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid()); WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid());
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = wxPayUnifiedOrderV3Result.getPayInfo(TradeTypeEnum.JSAPI, payProperties.getAppId(), payProperties.getMchId(), wxPayService.getConfig().getPrivateKey());
response.setStatus(true); response.setStatus(true);
WxPayJsResultVo vo = new WxPayJsResultVo(); WxPayJsResultVo vo = new WxPayJsResultVo();
vo.setAppId(unifiedorder.get("appId"));
vo.setNonceStr(unifiedorder.get("nonceStr")); vo.setAppId(/*unifiedorder.get("appId")*/jsapiResult.getAppId());
vo.setPackages(unifiedorder.get("package")); vo.setNonceStr(/*unifiedorder.get("nonceStr")*/jsapiResult.getNonceStr());
vo.setSignType(unifiedorder.get("signType")); // vo.setPackages(unifiedorder.get("package"));
vo.setTimeStamp(unifiedorder.get("timeStamp")); vo.setPackageValue(jsapiResult.getPackageValue());
vo.setPaySign(unifiedorder.get("paySign")); vo.setSignType(/*unifiedorder.get("signType")*/jsapiResult.getSignType());
vo.setTimeStamp(/*unifiedorder.get("timeStamp")*/jsapiResult.getTimeStamp());
vo.setPaySign(/*unifiedorder.get("paySign")*/jsapiResult.getPaySign());
if (storeOrder.getIsChannel() == 2) { if (storeOrder.getIsChannel() == 2) {
vo.setMwebUrl(unifiedorder.get("mweb_url")); vo.setMwebUrl(wxPayUnifiedOrderV3Result.getH5Url());
response.setPayType(PayConstants.PAY_CHANNEL_WE_CHAT_H5); response.setPayType(PayConstants.PAY_CHANNEL_WE_CHAT_H5);
} }
if (storeOrder.getIsChannel() == 4 || storeOrder.getIsChannel() == 5) { // if (storeOrder.getIsChannel() == 4 || storeOrder.getIsChannel() == 5) {
vo.setPartnerid(unifiedorder.get("partnerid")); // vo.setPartnerid(unifiedorder.get("partnerid"));
} // }
// 更新商户订单号 // 更新商户订单号
storeOrder.setOutTradeNo(unifiedorder.get("outTradeNo")); // storeOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
storeOrderService.updateById(storeOrder); // storeOrderService.updateById(storeOrder);
response.setJsConfig(vo); response.setJsConfig(vo);
return response; return response;
} }
@ -287,7 +291,7 @@ public class OrderPayServiceImpl implements OrderPayService {
* @param ip ip * @param ip ip
* @return * @return
*/ */
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip,String openid) { private WxPayUnifiedOrderV3Result unifiedorder(StoreOrder storeOrder, String ip,String openid) {
// 获取用户openId // 获取用户openId
// 根据订单支付类型来判断获取公众号openId还是小程序openId // 根据订单支付类型来判断获取公众号openId还是小程序openId
@ -316,7 +320,7 @@ public class OrderPayServiceImpl implements OrderPayService {
// 预下单(统一下单) // 预下单(统一下单)
//CreateOrderResponseVo responseVo = wechatNewService.payUnifiedorder(unifiedorderVo); //CreateOrderResponseVo responseVo = wechatNewService.payUnifiedorder(unifiedorderVo);
// 组装前端预下单参数 // 组装前端预下单参数
Map<String, String> map = new HashMap<>(); // Map<String, String> map = new HashMap<>();
// map.put("appId", unifiedorderVo.getAppid()); // map.put("appId", unifiedorderVo.getAppid());
// map.put("nonceStr", unifiedorderVo.getAppid()); // map.put("nonceStr", unifiedorderVo.getAppid());
// map.put("package", "prepay_id=".concat(responseVo.getPrepayId())); // map.put("package", "prepay_id=".concat(responseVo.getPrepayId()));
@ -348,11 +352,12 @@ public class OrderPayServiceImpl implements OrderPayService {
wxPayRequest.setTimeExpire(formatLocalDateTime(LocalDateTime.now().plusMinutes(30), "yyyyMMddHHmmss")); wxPayRequest.setTimeExpire(formatLocalDateTime(LocalDateTime.now().plusMinutes(30), "yyyyMMddHHmmss"));
try { try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest); WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url()); // map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
return wxPayUnifiedOrderV3Result;
} catch (Exception e) { } catch (Exception e) {
e.getMessage(); e.getMessage();
} }
return map; return null;
} }
public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) { public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) {
return localDateTime.format(DateTimeFormatter.ofPattern(pattern)); return localDateTime.format(DateTimeFormatter.ofPattern(pattern));