--升级兼容pc端

This commit is contained in:
xuwenbo
2021-05-11 14:06:16 +08:00
parent 82c08ddcc6
commit 3d5f79411d
12 changed files with 36 additions and 26 deletions

View File

@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -83,7 +84,7 @@ public class StoreCombinationController {
@ApiOperation(value = "拼团产品列表",notes = "拼团产品列表")
public ApiResult<CombinationQueryVo> getList(@RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){
return ApiResult.ok(storeCombinationService.getList(page, limit));
return ApiResult.resultPage(storeCombinationService.getList(page, limit),limit);
}
/**

View File

@ -42,6 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@ -76,7 +77,8 @@ public class StoreSeckillController {
if (StrUtil.isBlank(time) || !NumberUtil.isNumber(time)){
throw new YshopException("参数错误");
}
return ApiResult.ok(yxStoreSeckillService.getList(page, limit, Integer.valueOf(time)));
return ApiResult.resultPage(yxStoreSeckillService.getList(page, limit, Integer.valueOf(time)),limit);
}

View File

@ -97,9 +97,10 @@ public class ShoperController {
@AuthCheck
@GetMapping("/admin/order/list")
@ApiOperation(value = "订单列表",notes = "订单列表")
public ApiResult<List<YxStoreOrderQueryVo>> orderList(ShoperQueryParam queryParam) {
return ApiResult.ok(storeOrderService.orderList(null, queryParam.getStatus(),
queryParam.getPage(), queryParam.getLimit()));
public ApiResult<Object> orderList(ShoperQueryParam queryParam) {
Map<String, Object> map = storeOrderService.orderList(null, queryParam.getStatus(),
queryParam.getPage(), queryParam.getLimit());
return ApiResult.ok(map.get("list"));
}
/**

View File

@ -64,10 +64,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -171,6 +168,7 @@ public class StoreOrderController {
orderDTO.setOrderId(orderId);
map.put("status",OrderLogEnum.CREATE_ORDER_SUCCESS.getValue());
map.put("result",orderDTO);
map.put("createTime",order.getCreateTime());
//开始处理支付
//处理金额为0的情况
@ -239,16 +237,17 @@ public class StoreOrderController {
@AuthCheck
@GetMapping("/order/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "商品状态,默认为0未支付 1待发货 2待收货 3待评价 4已完成 5退款中 6已退款 7退款", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "type", value = "商品状态,-1全部 默认为0未支付 1待发货 2待收货 3待评价 4已完成 5退款中 6已退款 7退款", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int")
})
@ApiOperation(value = "订单列表",notes = "订单列表")
public ApiResult<List<YxStoreOrderQueryVo>> orderList(@RequestParam(value = "type",defaultValue = "0") int type,
public ApiResult<Object> orderList(@RequestParam(value = "type",defaultValue = "0") int type,
@RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(storeOrderService.orderList(uid,type, page,limit));
Map<String, Object> map = storeOrderService.orderList(uid, type, page, limit);
return ApiResult.resultPage((Integer) map.get("total"),(Integer) map.get("totalPage"),map.get("list"));
}

View File

@ -221,11 +221,12 @@ public class OrderSupplyService {
}else if(AppFromEnum.PC.getValue().equals(from)){ //扫码支付
map.put("status","WECHAT_PC_PAY");
WxPayNativeOrderResult wxPayNativeOrderResult = (WxPayNativeOrderResult)weixinPayService
.unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"APP商品购买");
.unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"pc商品购买");
jsConfig.put("codeUrl",wxPayNativeOrderResult.getCodeUrl());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
map.put("payMsg","订单创建成功");
return map;
}
else{//公众号
map.put("status","WECHAT_PAY");

View File

@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
/**
@ -60,7 +61,7 @@ public class ArticleController {
@ApiOperation(value = "文章列表",notes = "文章列表")
public ApiResult<List<YxArticleQueryVo>> getYxArticlePageList(@RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){
return ApiResult.ok(articleService.getList(page,limit));
return ApiResult.resultPage(articleService.getList(page,limit),limit);
}
}

View File

@ -43,10 +43,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName UserBillController
@ -186,7 +183,7 @@ public class UserBillController {
newType = Integer.valueOf(type);
}
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(userBillService.getUserBillList(page,limit,uid,newType));
return ApiResult.resultPage(Collections.singletonList(userBillService.getUserBillList(page,limit,uid,newType)),limit);
}

View File

@ -178,7 +178,8 @@ public class ApiResult<T> implements Serializable {
return result(ApiCode.FAIL,map);
}
public static <T> ApiResult<T> resultPage(List<T> list, int limit){
public static <T> ApiResult<T> resultPage(T t, int limit){
List<Object> list = (List<Object>) t;
int count = list.size() / limit;
if (list.size() == 0) {
return (ApiResult<T>) ApiResult.builder()

View File

@ -18,6 +18,7 @@ import java.util.stream.Stream;
@AllArgsConstructor
public enum OrderStatusEnum {
STATUS__1(-1,"全部订单"),
STATUS_0(0,"未支付"),
STATUS_1(1,"待发货"),
STATUS_2(2,"待收货"),

View File

@ -164,7 +164,7 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder>{
* @param limit limit
* @return list
*/
List<YxStoreOrderQueryVo> orderList(Long uid,int type,int page,int limit);
Map<String,Object> orderList(Long uid,int type,int page,int limit);
/**
* 获取某个用户的订单统计数据

View File

@ -1099,7 +1099,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
* @return list
*/
@Override
public List<YxStoreOrderQueryVo> orderList(Long uid, int type, int page, int limit) {
public Map<String,Object> orderList(Long uid, int type, int page, int limit) {
LambdaQueryWrapper<YxStoreOrder> wrapper= new LambdaQueryWrapper<>();
if(uid != null) {
wrapper.eq(YxStoreOrder::getUid,uid);
@ -1107,6 +1107,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
wrapper.orderByDesc(YxStoreOrder::getId);
switch (OrderStatusEnum.toType(type)){
case STATUS__1:
break;
//未支付
case STATUS_0:
wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_0.getValue())
@ -1159,10 +1161,13 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
Page<YxStoreOrder> pageModel = new Page<>(page, limit);
IPage<YxStoreOrder> pageList = yxStoreOrderMapper.selectPage(pageModel,wrapper);
List<YxStoreOrderQueryVo> list = generator.convert(pageList.getRecords(),YxStoreOrderQueryVo.class);
return list.stream()
Map<String,Object> map = new HashMap<>();
map.put("list",list.stream()
.map(this::handleOrder)
.collect(Collectors.toList());
.collect(Collectors.toList()));
map.put("total",pageList.getTotal());
map.put("totalPage",pageList.getPages());
return map;
}

View File

@ -7,7 +7,7 @@
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.mp.service;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -135,6 +135,7 @@ public class WeixinPayService {
orderRequest.setTradeType("APP");
}else if(AppFromEnum.PC.getValue().equals(from)){
orderRequest.setTradeType("NATIVE");
orderRequest.setProductId( UUID.fastUUID().toString());
} else{
orderRequest.setTradeType("JSAPI");
if(AppFromEnum.ROUNTINE.getValue().equals(from)){