记得上下班打卡 | git大法好,push需谨慎

Commit 33abfb67 authored by 胡佳晨's avatar 胡佳晨

提交 资金接口

parent c4fac190
...@@ -9,10 +9,11 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -9,10 +9,11 @@ import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid; import javax.validation.Valid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
public interface IGoblinStoreMoneyService { public interface IGoblinStoreMoneyService {
ResponseDto<BigDecimal> money(); ResponseDto<HashMap<String,String>> money(String spuId);
ResponseDto<PageInfo<GoblinOrderLogVo>> getSpuList(String spuName, String st, String et, int page); ResponseDto<PageInfo<GoblinOrderLogVo>> getSpuList(String spuName, String st, String et, int page);
......
...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
@ApiSupport(order = 149102) @ApiSupport(order = 149102)
...@@ -29,9 +30,12 @@ public class GoblinStoreMoneyController { ...@@ -29,9 +30,12 @@ public class GoblinStoreMoneyController {
@GetMapping("money") @GetMapping("money")
@ApiOperation("商品资金总收入") @ApiOperation("商品资金总收入")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "spuId", value = "spuId"),
})
@ApiResponse(code = 200, message = "接口返回对象参数") @ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<BigDecimal> money() { public ResponseDto<HashMap<String,String>> money(@RequestParam(value = "spuId", required = false) String spuId) {
return goblinStoreMoneyService.money(); return goblinStoreMoneyService.money(spuId);
} }
@GetMapping("spu/list") @GetMapping("spu/list")
......
package com.liquidnet.service.goblin.service.impl.manage; package com.liquidnet.service.goblin.service.impl.manage;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil; import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinOrderLogVo; import com.liquidnet.service.goblin.dto.vo.GoblinOrderLogVo;
...@@ -24,14 +25,18 @@ public class GoblinStoreMoneyServiceImpl implements IGoblinStoreMoneyService { ...@@ -24,14 +25,18 @@ public class GoblinStoreMoneyServiceImpl implements IGoblinStoreMoneyService {
GoblinMongoUtils mongoUtils; GoblinMongoUtils mongoUtils;
@Override @Override
public ResponseDto<BigDecimal> money() { public ResponseDto<HashMap<String,String>> money(String spuId) {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo vo = redisUtils.getStoreInfoVoByUid(uid); GoblinStoreInfoVo vo = redisUtils.getStoreInfoVoByUid(uid);
if (vo == null) { if (vo == null) {
return ResponseDto.failure("店铺不存在"); return ResponseDto.failure("店铺不存在");
} }
BigDecimal price = mongoUtils.storeMoney(vo.getStoreId()); String data = mongoUtils.storeMoney(vo.getStoreId(), spuId);
return ResponseDto.success(price); String[] array = data.split(",");
HashMap<String,String> map = CollectionUtil.mapStringString();
map.put("name",array[0]);
map.put("price",array[1]);
return ResponseDto.success(map);
} }
@Override @Override
......
...@@ -504,7 +504,7 @@ public class GoblinMongoUtils { ...@@ -504,7 +504,7 @@ public class GoblinMongoUtils {
} }
//修改 订单退款数据 //修改 订单退款数据
public UpdateResult updateGoblinBackOrderVo(String backOrderId,GoblinBackOrderVo data) { public UpdateResult updateGoblinBackOrderVo(String backOrderId, GoblinBackOrderVo data) {
BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data)); BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinBackOrderVo.class.getSimpleName()).updateOne( return mongoTemplate.getCollection(GoblinBackOrderVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("backOrderId").is(backOrderId)).getQueryObject(), Query.query(Criteria.where("backOrderId").is(backOrderId)).getQueryObject(),
...@@ -517,19 +517,41 @@ public class GoblinMongoUtils { ...@@ -517,19 +517,41 @@ public class GoblinMongoUtils {
} }
//店铺总收入 //店铺总收入
public BigDecimal storeMoney(String storeId) { public String storeMoney(String storeId, String spuId) {
String spuName = "店铺总收入";
Criteria criteria = Criteria.where("status").in(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_28.getValue()).and("storeId").is(storeId); Criteria criteria = Criteria.where("status").in(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_28.getValue()).and("storeId").is(storeId);
Aggregation aggregation ;
Aggregation aggregation = Aggregation.newAggregation( if (spuId != null) {
criteria = criteria.and("spuId").is(spuId);
Query query = Query.query(Criteria.where("spuId").is(spuId));
query.fields().include("name");
GoblinGoodsInfoVo spuIdAndName = mongoTemplate.findOne(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
if (spuIdAndName == null) {
return "," + BigDecimal.ZERO;
} else {
spuName = spuIdAndName.getName();
}
aggregation = Aggregation.newAggregation(
Aggregation.match(criteria),
Aggregation.group("spuId")
.first("spuId").as("spuId")
.first("skuPriceActual").as("skuPriceActual")
.sum("skuPriceActualBig").as("skuPriceActualBig"));
}else{
aggregation = Aggregation.newAggregation(
Aggregation.match(criteria), Aggregation.match(criteria),
Aggregation.group("storeId") Aggregation.group("storeId")
.first("storeId").as("storeId") .first("storeId").as("storeId")
.first("skuPriceActual").as("skuPriceActual") .first("skuPriceActual").as("skuPriceActual")
.sum("skuPriceActualBig").as("skuPriceActualBig") .sum("skuPriceActualBig").as("skuPriceActualBig"));
); }
AggregationResults<GoblinOrderLogVo> outputType = mongoTemplate.aggregate(aggregation, GoblinOrderLogVo.class.getSimpleName(), GoblinOrderLogVo.class); AggregationResults<GoblinOrderLogVo> outputType = mongoTemplate.aggregate(aggregation, GoblinOrderLogVo.class.getSimpleName(), GoblinOrderLogVo.class);
List<GoblinOrderLogVo> dataList = new ArrayList(outputType.getMappedResults()); List<GoblinOrderLogVo> dataList = new ArrayList(outputType.getMappedResults());
return dataList.get(0).getSkuPriceActualBig(); if (dataList.size() > 0) {
return spuName + "," + dataList.get(0).getSkuPriceActualBig();
} else {
return "," + BigDecimal.ZERO;
}
} }
//资金列表 //资金列表
...@@ -541,7 +563,7 @@ public class GoblinMongoUtils { ...@@ -541,7 +563,7 @@ public class GoblinMongoUtils {
Criteria criteria = Criteria.where("status").in(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_28.getValue()).and("storeId").is(storeId); Criteria criteria = Criteria.where("status").in(GoblinStatusConst.Status.ORDER_LOG_STATUS_11.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_22.getValue(), GoblinStatusConst.Status.ORDER_LOG_STATUS_28.getValue()).and("storeId").is(storeId);
if (spuName != null) { if (spuName != null) {
//根据spu名称查询spuId //根据spu名称查询spuId
Query query = Query.query(Criteria.where("name").regex(".*?"+spuName+".*").and("storeId").is(storeId)); Query query = Query.query(Criteria.where("name").regex(".*?" + spuName + ".*").and("storeId").is(storeId));
query.fields().include("spuId").include("name"); query.fields().include("spuId").include("name");
spuIdAndName = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); spuIdAndName = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
criteria = criteria.and("spuId").in(spuIdAndName.stream().map(GoblinGoodsInfoVo::getSpuId).collect(Collectors.toList())); criteria = criteria.and("spuId").in(spuIdAndName.stream().map(GoblinGoodsInfoVo::getSpuId).collect(Collectors.toList()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment