|
|
@@ -1,12 +1,15 @@
|
|
|
package com.fs.app.controller.store;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.app.controller.AppBaseController;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
+import com.fs.hisStore.config.StoreConfig;
|
|
|
import com.fs.hisStore.param.FsStoreScanPaymentStatParam;
|
|
|
import com.fs.hisStore.service.IFsStorePaymentScrmService;
|
|
|
import com.fs.hisStore.vo.FsStoreScanPaymentStatDetailsVo;
|
|
|
import com.fs.hisStore.vo.FsStoreScanPaymentStatVo;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -15,7 +18,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Api("扫码流水统计接口")
|
|
|
@RestController
|
|
|
@@ -24,6 +31,9 @@ public class FsStoreScanPaymentStatController extends AppBaseController {
|
|
|
@Autowired
|
|
|
private IFsStorePaymentScrmService paymentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+
|
|
|
/**
|
|
|
* 扫码支付统计接口
|
|
|
*/
|
|
|
@@ -40,4 +50,40 @@ public class FsStoreScanPaymentStatController extends AppBaseController {
|
|
|
}
|
|
|
return R.ok().put("data",scanPaymentStat);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 扫码码立减金额查询
|
|
|
+ */
|
|
|
+ @ApiOperation("扫码码立减金额查询")
|
|
|
+ @GetMapping("/getScanCodeDiscountAmount")
|
|
|
+ public R getScanCodeDiscountAmount() {
|
|
|
+ final String STORE_CONFIG_KEY = "store.config";
|
|
|
+ final BigDecimal DEFAULT_DISCOUNT_AMOUNT = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ try {
|
|
|
+ String jsonConfig = configService.selectConfigByKey(STORE_CONFIG_KEY);
|
|
|
+ StoreConfig storeConfig = JSONUtil.toBean(jsonConfig, StoreConfig.class);
|
|
|
+
|
|
|
+ BigDecimal discountAmount = DEFAULT_DISCOUNT_AMOUNT;
|
|
|
+ if (isValidDiscountConfig(storeConfig)) {
|
|
|
+ discountAmount = storeConfig.getScanCodeDiscountAmount();
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok().put("data", Collections.singletonMap("scanCodeDiscountAmount", discountAmount));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("查询立减金额失败,请稍后重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证立减配置是否有效
|
|
|
+ * @param config 店铺配置对象
|
|
|
+ * @return 配置是否有效
|
|
|
+ */
|
|
|
+ private boolean isValidDiscountConfig(StoreConfig config) {
|
|
|
+ return config != null
|
|
|
+ && Boolean.TRUE.equals(config.getScanCodeDiscountEnabled())
|
|
|
+ && config.getScanCodeDiscountAmount() != null
|
|
|
+ && config.getScanCodeDiscountAmount().compareTo(BigDecimal.ZERO) > 0;
|
|
|
+ }
|
|
|
}
|