1
0
Quellcode durchsuchen

中网小程序微信国际(香港)支付api模块提交

hyq vor 6 Jahren
Ursprung
Commit
782cf9d520
100 geänderte Dateien mit 7839 neuen und 0 gelöschten Zeilen
  1. 59 0
      kmall-api/pom.xml
  2. 17 0
      kmall-api/src/main/java/com/kmall/api/annotation/IgnoreAuth.java
  3. 19 0
      kmall-api/src/main/java/com/kmall/api/annotation/LoginUser.java
  4. 194 0
      kmall-api/src/main/java/com/kmall/api/api/ApiAddressController.java
  5. 210 0
      kmall-api/src/main/java/com/kmall/api/api/ApiAuthController.java
  6. 77 0
      kmall-api/src/main/java/com/kmall/api/api/ApiBrandController.java
  7. 721 0
      kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java
  8. 88 0
      kmall-api/src/main/java/com/kmall/api/api/ApiCatalogController.java
  9. 84 0
      kmall-api/src/main/java/com/kmall/api/api/ApiCollectController.java
  10. 145 0
      kmall-api/src/main/java/com/kmall/api/api/ApiCommentController.java
  11. 246 0
      kmall-api/src/main/java/com/kmall/api/api/ApiCouponController.java
  12. 41 0
      kmall-api/src/main/java/com/kmall/api/api/ApiFeedbackController.java
  13. 162 0
      kmall-api/src/main/java/com/kmall/api/api/ApiFootprintController.java
  14. 60 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsActivityController.java
  15. 638 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsController.java
  16. 41 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsCrashController.java
  17. 173 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupController.java
  18. 339 0
      kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupOpenController.java
  19. 59 0
      kmall-api/src/main/java/com/kmall/api/api/ApiHelpIssueController.java
  20. 168 0
      kmall-api/src/main/java/com/kmall/api/api/ApiIndexController.java
  21. 473 0
      kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java
  22. 390 0
      kmall-api/src/main/java/com/kmall/api/api/ApiPayController.java
  23. 150 0
      kmall-api/src/main/java/com/kmall/api/api/ApiRegionController.java
  24. 38 0
      kmall-api/src/main/java/com/kmall/api/api/ApiRegisterController.java
  25. 118 0
      kmall-api/src/main/java/com/kmall/api/api/ApiSearchController.java
  26. 63 0
      kmall-api/src/main/java/com/kmall/api/api/ApiSmsController.java
  27. 71 0
      kmall-api/src/main/java/com/kmall/api/api/ApiTopicController.java
  28. 52 0
      kmall-api/src/main/java/com/kmall/api/api/ApiUploadController.java
  29. 119 0
      kmall-api/src/main/java/com/kmall/api/api/ApiUserController.java
  30. 322 0
      kmall-api/src/main/java/com/kmall/api/api/pingan/ApiPayPinganController.java
  31. 149 0
      kmall-api/src/main/java/com/kmall/api/api/pingan/mpconfig/ApiPinganMpconfigController.java
  32. 289 0
      kmall-api/src/main/java/com/kmall/api/api/wxGlobal/ApiWxGlobalPayController.java
  33. 119 0
      kmall-api/src/main/java/com/kmall/api/cache/UserTokenCache.java
  34. 44 0
      kmall-api/src/main/java/com/kmall/api/config/SwaggerConfig.java
  35. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiAdMapper.java
  36. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiAdPositionMapper.java
  37. 13 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiAddressMapper.java
  38. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiAttributeCategoryMapper.java
  39. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiAttributeMapper.java
  40. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiBrandMapper.java
  41. 30 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCartMapper.java
  42. 21 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCategoryMapper.java
  43. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiChannelMapper.java
  44. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCollectMapper.java
  45. 26 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCommentMapper.java
  46. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCommentPictureMapper.java
  47. 32 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiCouponMapper.java
  48. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiFeedbackMapper.java
  49. 18 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiFootprintMapper.java
  50. 19 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiFreightMapper.java
  51. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsActivityMapper.java
  52. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsCrashMapper.java
  53. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGalleryMapper.java
  54. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupMapper.java
  55. 19 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupOpenDetailMapper.java
  56. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupOpenMapper.java
  57. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsIssueMapper.java
  58. 24 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsMapper.java
  59. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsSpecificationMapper.java
  60. 16 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiHelpIssueMapper.java
  61. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiHelpTypeMapper.java
  62. 18 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiKeywordsMapper.java
  63. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiMerchMapper.java
  64. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiMerchUserMapper.java
  65. 11 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiMngChangeMapper.java
  66. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderBuyerPayCheckMapper.java
  67. 11 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderExceptionRecordMapper.java
  68. 21 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderGoodsMapper.java
  69. 49 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderMapper.java
  70. 23 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderProcessRecordMapper.java
  71. 13 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiOrderRefundMapper.java
  72. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiPayerChildOrderRealMapper.java
  73. 20 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiPinganPayOrderMapper.java
  74. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiPinganResponseMapper.java
  75. 42 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiProductMapper.java
  76. 18 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiProductStoreRelaMapper.java
  77. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiRelatedGoodsMapper.java
  78. 16 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiSearchHistoryMapper.java
  79. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiSpecificationMapper.java
  80. 10 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiStoreGoodsGalleryMapper.java
  81. 19 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMapper.java
  82. 10 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMngChangeMapper.java
  83. 9 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMngMapper.java
  84. 9 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiSysExceptionRecordMapper.java
  85. 10 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiSysParamMapper.java
  86. 16 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiSysPrinterMapper.java
  87. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiTopicCategoryMapper.java
  88. 15 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiTopicMapper.java
  89. 10 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiUserCollectionMapper.java
  90. 22 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiUserCouponMapper.java
  91. 17 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiUserLevelMapper.java
  92. 44 0
      kmall-api/src/main/java/com/kmall/api/dao/ApiUserMapper.java
  93. 152 0
      kmall-api/src/main/java/com/kmall/api/dto/GeometryMarker.java
  94. 125 0
      kmall-api/src/main/java/com/kmall/api/dto/GoodsActivityVo.java
  95. 48 0
      kmall-api/src/main/java/com/kmall/api/dto/IdCardMsgVo.java
  96. 48 0
      kmall-api/src/main/java/com/kmall/api/dto/SendMsgVo.java
  97. 64 0
      kmall-api/src/main/java/com/kmall/api/entity/AdPositionVo.java
  98. 135 0
      kmall-api/src/main/java/com/kmall/api/entity/AdVo.java
  99. 246 0
      kmall-api/src/main/java/com/kmall/api/entity/AddressVo.java
  100. 45 0
      kmall-api/src/main/java/com/kmall/api/entity/AttributeCategoryVo.java

+ 59 - 0
kmall-api/pom.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>kmall-pt-global</artifactId>
+        <groupId>com.kmall</groupId>
+        <version>3.1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>kmall-api</artifactId>
+    <packaging>jar</packaging>
+    <description>API接口模块</description>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>com.kmall</groupId>
+            <artifactId>kmall-common</artifactId>
+            <version>${kmall-version}</version>
+        </dependency>
+
+        <!--swagger 依赖-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.18.1</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>8</source>
+                    <target>8</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/annotation/IgnoreAuth.java

@@ -0,0 +1,17 @@
+package com.kmall.api.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 忽略Token验证
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:44
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface IgnoreAuth {
+
+}

+ 19 - 0
kmall-api/src/main/java/com/kmall/api/annotation/LoginUser.java

@@ -0,0 +1,19 @@
+package com.kmall.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 登录用户信息
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 20:39
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface LoginUser {
+
+}

+ 194 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiAddressController.java

@@ -0,0 +1,194 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.StoreVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiAddressService;
+import com.kmall.api.service.ApiStoreService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.CommonUtil;
+import com.kmall.common.utils.PhoneFormatCheckUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/address")
+public class ApiAddressController extends ApiBaseAction {
+    @Autowired
+    private ApiAddressService addressService;
+    @Autowired
+    private ApiStoreService apiStoreService;
+
+    /**
+     * 获取用户的收货地址
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser) {
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        List<AddressVo> addressEntities = addressService.queryList(param);
+        return toResponsSuccess(addressEntities);
+    }
+
+    /**
+     * 获取收货地址的详情
+     */
+    @IgnoreAuth
+    @GetMapping("detail")
+    public Object detail(Long id) {
+        AddressVo entity = addressService.queryObject(id);
+        return toResponsSuccess(entity);
+    }
+
+    /**
+     * 添加或更新收货地址
+     */
+    @PostMapping("save")
+    public Object save(@LoginUser UserVo loginUser) {
+        JSONObject addressJson = this.getJsonRequest();
+        AddressVo entity = new AddressVo();
+        if (null != addressJson) {
+            if (!PhoneFormatCheckUtils.isPhoneLegal(addressJson.getString("telNumber"))) {
+                return toResponsFail("手机号格式有误!");
+            }
+            entity.setId(addressJson.getLong("id"));
+            entity.setUserId(loginUser.getId());
+            entity.setUserName(addressJson.getString("userName"));
+            entity.setPostalCode(addressJson.getString("postalCode"));
+            entity.setProvinceName(addressJson.getString("provinceName"));
+            entity.setCityName(addressJson.getString("cityName"));
+            entity.setCountyName(addressJson.getString("countyName"));
+            entity.setDetailInfo(addressJson.getString("detailInfo"));
+            entity.setNationalCode(addressJson.getString("nationalCode"));
+            entity.setTelNumber(addressJson.getString("telNumber"));
+            entity.setLatitude(addressJson.getBigDecimal("latitude"));
+            entity.setLongitude(addressJson.getBigDecimal("longitude"));
+            if (null != addressJson.getBoolean("isDefault")
+                    && addressJson.getBoolean("isDefault").equals(true)) {
+                entity.setIsDefault(1);
+            } else {
+                entity.setIsDefault(0);
+            }
+        }
+        // 更新默认
+        if (entity.getIsDefault() == 1) {
+            Map params = new HashMap();
+            params.put("user_id", entity.getUserId());
+            params.put("is_default", 1);
+            List<AddressVo> addressVoList = addressService.queryList(params);
+            if (null != addressVoList) {
+                for (AddressVo addressVo : addressVoList) {
+                    if (null != entity.getId() && addressVo.getId().equals(entity.getId())) {
+                        continue;
+                    } else {
+                        addressVo.setIsDefault(0);
+                        addressService.update(addressVo);
+                    }
+                }
+            }
+        }
+        if (null != entity.getId() && entity.getId() > 0) {
+            addressService.update(entity);
+            return toResponsSuccess(entity);
+        } else {
+            addressService.save(entity);
+            return toResponsSuccess(entity);
+        }
+    }
+
+    /**
+     * 同步微信小程序的地址
+     */
+    @PostMapping("syncAddress")
+    public Object syncAddress(@LoginUser UserVo loginUser) {
+        JSONObject addressJson = this.getJsonRequest();
+        AddressVo entity = new AddressVo();
+        if (null != addressJson) {
+            if (!PhoneFormatCheckUtils.isPhoneLegal(addressJson.getString("telNumber"))) {
+                return toResponsFail("手机号格式有误!");
+            }
+            entity.setUserId(loginUser.getId());
+            entity.setUserName(addressJson.getString("userName"));
+            entity.setPostalCode(addressJson.getString("postalCode"));
+            entity.setProvinceName(addressJson.getString("provinceName"));
+            entity.setCityName(addressJson.getString("cityName"));
+            entity.setCountyName(addressJson.getString("countyName"));
+            entity.setDetailInfo(addressJson.getString("detailInfo"));
+            entity.setNationalCode(addressJson.getString("nationalCode"));
+            entity.setTelNumber(addressJson.getString("telNumber"));
+            entity.setLatitude(addressJson.getBigDecimal("latitude"));
+            entity.setLongitude(addressJson.getBigDecimal("longitude"));
+            if (null != addressJson.getBoolean("isDefault")
+                    && addressJson.getBoolean("isDefault").equals(true)) {
+                entity.setIsDefault(1);
+            } else {
+                entity.setIsDefault(0);
+            }
+        }
+        //
+        Map params = new HashMap();
+        params.put("user_id", entity.getUserId());
+        List<AddressVo> addressVoList = addressService.queryList(params);
+        if (null != addressVoList) {
+            for (AddressVo addressVo : addressVoList) {
+                if (null != entity.getDetailInfo() && addressVo.getDetailInfo().equals(entity.getDetailInfo())) {
+                    return toResponsSuccess(addressVo);
+                }
+            }
+        }
+        addressService.save(entity);
+        return toResponsSuccess(entity);
+    }
+
+    /**
+     * 删除指定的收货地址
+     */
+    @IgnoreAuth
+    @PostMapping("delete")
+    public Object delete() {
+        JSONObject jsonParam = this.getJsonRequest();
+        addressService.delete(jsonParam.getIntValue("id"));
+        return toResponsSuccess("");
+    }
+
+    /**
+     * 校验选中的地址,门店是否可以配送
+     */
+    @PostMapping("checkStore")
+    public Object checkStore() {
+        JSONObject jsonParam = this.getJsonRequest();
+        Long storeId = jsonParam.getLong("storeId");
+        AddressVo addressVo = jsonParam.getObject("checkedAddress", AddressVo.class);
+        if (null == addressVo || null == addressVo.getLatitude() || null == addressVo.getLongitude()) {
+            return toResponsFail("当前地址距离门店过远,无法配送,抱歉!");
+        }
+        StoreVo storeVo = apiStoreService.queryObject(storeId);
+        if (null == storeVo || null == storeVo.getLatitude() || null == storeVo.getLongitude()) {
+            return toResponsFail("当前门店暂时无法配送,抱歉!");
+        }
+        double distance = CommonUtil.getDistance(storeVo.getLatitude().doubleValue(), storeVo.getLongitude().doubleValue(),
+                addressVo.getLatitude().doubleValue(), addressVo.getLongitude().doubleValue());
+//        if (storeVo.getCoverRadius().compareTo(new BigDecimal(distance)) < 0) {
+//            return toResponsFail("当前地址距离门店过远,无法配送,抱歉!");
+//        }
+        //
+        storeVo.setDistance(new BigDecimal(distance));
+        return toResponsSuccess(storeVo);
+    }
+}

+ 210 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiAuthController.java

@@ -0,0 +1,210 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.ApiMerchUserService;
+import com.kmall.api.service.ApiStoreService;
+import com.kmall.api.service.ApiUserService;
+import com.kmall.api.service.TokenService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiUserUtils;
+import com.kmall.api.util.CommonUtil;
+import com.qiniu.util.StringUtils;
+import org.apache.commons.collections.MapUtils;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API登录授权
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:31
+ */
+@RestController
+@RequestMapping("/api/auth")
+public class ApiAuthController extends ApiBaseAction {
+    private Logger logger = Logger.getLogger(getClass());
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private TokenService tokenService;
+    @Autowired
+    private ApiStoreService apiStoreService;
+    @Autowired
+    private ApiMerchUserService apiMerchUserService;
+
+    /**
+     * 登录
+     */
+    @IgnoreAuth
+    @PostMapping("login_by_weixin")
+    public Object loginByWeixin() {
+        Map<String, Object> resultObj = new HashMap();
+        JSONObject jsonParam = this.getJsonRequest();
+        FullUserInfo fullUserInfo = null;
+        Long storeId = jsonParam.getLong("storeId");
+        String merchSn = (String)jsonParam.get("merchSn");
+        String code = "";
+        if (!StringUtils.isNullOrEmpty(jsonParam.getString("code"))) {
+            code = jsonParam.getString("code");
+        }
+        if (null != jsonParam.get("userInfo")) {
+            fullUserInfo = jsonParam.getObject("userInfo", FullUserInfo.class);
+        }
+        UserInfo userInfo = fullUserInfo.getUserInfo();
+        if(userInfo == null){
+            return toResponsFail("登录失败");
+        }
+        //获取openid
+        String requestUrl = ApiUserUtils.getWebAccess(code);//通过自定义工具类组合出小程序需要的登录凭证 code
+        logger.info("》》》组合token为:" + requestUrl);
+        JSONObject sessionData = CommonUtil.httpsRequest(requestUrl, "GET", null);
+
+        if (null == sessionData) {
+            return toResponsFail("登录失败");
+        }
+        String openId = sessionData.getString("openid");
+        if (StringUtils.isNullOrEmpty(openId)) {
+            return toResponsFail("登录失败");
+        }
+        //验证用户信息完整性
+        String sha1 = CommonUtil.getSha1(fullUserInfo.getRawData() + sessionData.getString("session_key"));
+        if (!fullUserInfo.getSignature().equals(sha1)) {
+            return toResponsFail("登录失败");
+        }
+        Date nowTime = new Date();
+        UserVo userVo = userService.queryByOpenId(openId);
+        userInfo.setNickName(filterEmoji(userInfo.getNickName()));;
+        if (null == userVo) {
+            userVo = new UserVo();
+            userVo.setPassword(openId);
+            userVo.setRegister_time(nowTime);
+            userVo.setRegister_ip(this.getClientIp());
+            userVo.setLast_login_ip(userVo.getRegister_ip());
+            userVo.setLast_login_time(userVo.getRegister_time());
+            userVo.setWeixin_openid(sessionData.getString("openid"));
+            userVo.setAvatar(userInfo.getAvatarUrl());
+            userVo.setGender(userInfo.getGender()); // //性别 0:未知、1:男、2:女
+            userVo.setNickname(userInfo.getNickName());
+            userVo.setUser_level_id(1);
+            userService.save(userVo);
+
+        } else {
+            userVo.setLast_login_ip(this.getClientIp());
+            userVo.setLast_login_time(nowTime);
+            userVo.setAvatar(userInfo.getAvatarUrl());
+            userVo.setGender(userInfo.getGender()); // //性别 0:未知、1:男、2:女
+            userService.update(userVo);
+        }
+        Map<String, Object> tokenMap = tokenService.createAndUpdateToken(userVo.getWeixin_openid(), storeId,userVo.getId(),merchSn);
+        String token = MapUtils.getString(tokenMap, "token");
+
+        if (null == userInfo || StringUtils.isNullOrEmpty(token)) {
+            return toResponsFail("登录失败");
+        }
+
+        resultObj.put("token", token);
+        resultObj.put("userInfo", userInfo);
+        resultObj.put("userId", userVo.getId());
+        return toResponsSuccess(resultObj);
+    }
+    /**
+     * 将emoji表情替换成空串
+     * @param source
+     * @return 过滤后的字符串
+     **/
+    public static String filterEmoji(String source) {
+        if (source != null && source.length() > 0) {
+            return source.replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", "");
+        } else {
+            return source;
+        }
+    }
+
+
+
+    /**
+     * 根据经纬度选择门店
+     */
+    @GetMapping("nearbyList")
+    @IgnoreAuth
+    public Object nearbyList(@RequestParam BigDecimal latitude, @RequestParam BigDecimal longitude) {
+        Map param = new HashMap();
+        param.put("latitude", latitude);
+        param.put("longitude", longitude);
+        List<StoreVo> storeVoList = apiStoreService.queryNearbyList(param);
+        if (null != storeVoList && storeVoList.size() > 0 && null != getOpenId()) {
+            tokenService.createAndUpdateToken(getOpenId(), storeVoList.get(0).getId(),getUserId(),storeVoList.get(0).getMerchSn());
+        }
+        return toResponsSuccess(storeVoList);
+    }
+
+    /**
+     * 根据城市获取门店
+     */
+    @GetMapping("storeListByCity")
+    @IgnoreAuth
+    public Object storeListByCity(@RequestParam String provinceName, @RequestParam String cityName, @RequestParam String countyName) {
+        Map param = new HashMap();
+        param.put("province_name", provinceName);
+        param.put("city_name", cityName);
+        param.put("county_name", countyName);
+
+        List<StoreVo> storeVoList = apiStoreService.queryList(param);
+        return toResponsSuccess(storeVoList);
+    }
+
+    /**
+     * 选择门店Id
+     */
+    @PostMapping("chooseStoreId")
+    public Object chooseStoreId() {
+        JSONObject jsonParam = this.getJsonRequest();
+        String openId = getOpenId();
+        Long storeId = jsonParam.getLong("storeId");
+        String merchSn = (String)jsonParam.get("merchSn");
+        //
+        Map<String, Object> resultObj = new HashMap();
+        Map<String, Object> tokenMap = tokenService.createAndUpdateToken(openId, storeId,getUserId(),merchSn);
+        String token = MapUtils.getString(tokenMap, "token");
+        resultObj.put("token", token);
+        return toResponsSuccess(resultObj);
+    }
+
+    @IgnoreAuth
+    @PostMapping("updateLoginUser")
+    public Object updateLoginUser() {
+        JSONObject jsonParam = this.getJsonRequest();
+        Long storeId = jsonParam.getLong("storeId");
+        Long userId = jsonParam.getLong("userId");
+        String merchSn = (String)jsonParam.get("merchSn");
+        Date nowTime = new Date();
+        UserVo userVo = userService.queryObject(userId);
+        if (null != userVo) {
+            MerchUserVo merchUser = apiMerchUserService.queryObjectByStoreId(storeId,userId);
+            MerchUserVo merchUserVo = new MerchUserVo();
+            merchUserVo.setStoreId(Integer.parseInt(String.valueOf(storeId)));
+            merchUserVo.setMerchSn(merchSn);
+            merchUserVo.setUserId(Integer.parseInt(String.valueOf(userId)));
+            if(merchUser != null) {;
+                merchUserVo.setModTime(new Date());
+                merchUserVo.setId(merchUser.getId());
+                apiMerchUserService.update(merchUserVo);
+            }else{
+                merchUserVo.setCreateTime(new Date());
+                merchUserVo.setModTime(new Date());
+                apiMerchUserService.save(merchUserVo);
+            }
+        }
+        return toResponsSuccess("1");
+    }
+}

+ 77 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiBrandController.java

@@ -0,0 +1,77 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.entity.BrandVo;
+import com.kmall.api.service.ApiBrandService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.Query;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/brand")
+public class ApiBrandController extends ApiBaseAction {
+    @Autowired
+    private ApiBrandService brandService;
+
+    /**
+     * 品牌首页
+     */
+    @IgnoreAuth
+    @GetMapping("index")
+    public Object index() {
+        Map param = new HashMap();
+        List<BrandVo> entityList = brandService.queryList(param);
+        return toResponsSuccess(entityList);
+    }
+
+    /**
+     * 分页获取品牌
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(@RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        //查询列表数据
+        Map params = new HashMap();
+        params.put("fields", "id, name, floor_price, app_list_pic_url");
+        params.put("page", page);
+        params.put("limit", size);
+        params.put("sidx", "id");
+        params.put("order", "asc");
+
+        Query query = new Query(params);
+        List<BrandVo> brandEntityList = brandService.queryList(query);
+        int total = brandService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(brandEntityList, total, query.getLimit(), query.getPage());
+        //
+        return toResponsSuccess(pageUtil);
+    }
+
+    /**
+     * 品牌详情
+     */
+    @IgnoreAuth
+    @GetMapping("detail")
+    public Object detail(@RequestParam Integer id) {
+        Map<String, Object> resultObj = new HashMap();
+        //查询列表数据
+        BrandVo entity = brandService.queryObject(id);
+        //
+        resultObj.put("brand", entity);
+        return toResponsSuccess(resultObj);
+    }
+}

+ 721 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java

@@ -0,0 +1,721 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.MapUtils;
+import com.qiniu.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/cart")
+public class ApiCartController extends ApiBaseAction {
+    @Autowired
+    private ApiCartService cartService;
+    @Autowired
+    private ApiGoodsService goodsService;
+    @Autowired
+    private ApiProductService productService;
+    @Autowired
+    private ApiAddressService addressService;
+    @Autowired
+    private ApiCouponService apiCouponService;
+    @Autowired
+    private ApiUserCouponService apiUserCouponService;
+    @Autowired
+    private ApiOrderGoodsService apiOrderGoodsService;
+    @Autowired
+    private ApiUserService apiUserService;
+
+    @Autowired
+    private ApiFreightService apiFreightService;
+
+    /**
+     * 获取购物车中的数据
+     */
+    @GetMapping("getCartMoney")
+    public Object getCartMoney(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        //查询列表数据
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        Long storeId = getStoreId();
+        param.put("store_id", storeId);
+        List<CartVo> cartList = cartService.queryList(param);
+        //获取购物车统计信息
+        Integer goodsCount = 0;
+        BigDecimal goodsAmount = new BigDecimal(0.00);
+        Integer checkedGoodsCount = 0;
+        BigDecimal checkedGoodsAmount = new BigDecimal(0.00);
+        for (CartVo cartItem : cartList) {
+            goodsCount += cartItem.getNumber();
+            goodsAmount = goodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            if (null != cartItem.getChecked() && 1 == cartItem.getChecked()) {
+                checkedGoodsCount += cartItem.getNumber();
+                checkedGoodsAmount = checkedGoodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            }
+        }
+
+        resultObj.put("cartList", cartList);
+        //
+        Map<String, Object> cartTotal = new HashMap();
+        cartTotal.put("goodsCount", goodsCount);
+        cartTotal.put("goodsAmount", goodsAmount);
+        cartTotal.put("checkedGoodsCount", checkedGoodsCount);
+        cartTotal.put("checkedGoodsAmount", checkedGoodsAmount);
+        //
+        resultObj.put("cartTotal", cartTotal);
+        return resultObj;
+    }
+
+    /**
+     * 获取购物车中的数据
+     */
+    @GetMapping("getCart")
+    public Object getCart() {
+        UserVo loginUser = new UserVo();
+        loginUser.setId(getUserId());
+        Map<String, Object> resultObj = new HashMap();
+        //查询列表数据
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        Long storeId = getStoreId();
+        param.put("store_id", storeId);
+        param.put("merchSn", getMerchSn());
+        List<CartVo> cartList = cartService.queryList(param);
+
+        List<CartVo> validCartList = cartService.queryValidCartList(param);
+        //获取购物车统计信息
+        Integer goodsCount = 0;
+        BigDecimal goodsAmount = new BigDecimal(0.00);
+        Integer checkedGoodsCount = 0;
+        BigDecimal checkedGoodsAmount = new BigDecimal(0.00);
+        List<CartVo> cart00List = new ArrayList<>();
+        List<CartVo> cart02List = new ArrayList<>();
+        List<CartVo> cart10List = new ArrayList<>();
+        List<CartVo> cart11List = new ArrayList<>();
+        for (CartVo cartItem : cartList) {
+            goodsCount += cartItem.getNumber();
+            goodsAmount = goodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            if (null != cartItem.getChecked() && 1 == cartItem.getChecked()) {
+                checkedGoodsCount += cartItem.getNumber();
+                checkedGoodsAmount = checkedGoodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            }
+            if(org.apache.commons.lang.StringUtils.isNotEmpty(cartItem.getGoodsBizType())){
+                cartItem.setGoodsBizTypeName(Dict.orderBizType.valueOf("item_"+ cartItem.getGoodsBizType()).getItemName());
+            }else{
+                cartItem.setGoodsBizTypeName("");
+            }
+
+            if(Dict.orderBizType.item_00.getItem().equalsIgnoreCase(cartItem.getGoodsBizType())){
+                CartVo cartVo00= cartItem;
+                cart00List.add(cartVo00);
+            }
+            if(Dict.orderBizType.item_02.getItem().equalsIgnoreCase(cartItem.getGoodsBizType())){
+                CartVo cartVo02= cartItem;
+                cart02List.add(cartVo02);
+            }
+            if(Dict.orderBizType.item_10.getItem().equalsIgnoreCase(cartItem.getGoodsBizType())){
+                CartVo cartVo10= cartItem;
+                cart10List.add(cartVo10);
+            }
+            if(Dict.orderBizType.item_11.getItem().equalsIgnoreCase(cartItem.getGoodsBizType())){
+                CartVo cartVo11= cartItem;
+                cart11List.add(cartVo11);
+            }
+
+        }
+        // 获取优惠信息提示 邮费
+        CouponVo shippingCoupon = apiCouponService.matchShippingSign(loginUser.getId(), checkedGoodsAmount);
+
+        // 获取优惠信息提示 满减
+        CouponVo fullSubCoupon = apiCouponService.matchFullSubSign(loginUser.getId(), checkedGoodsAmount);
+
+        List<CouponVo> couponInfoList = new ArrayList();
+        if (null != shippingCoupon) {
+            couponInfoList.add(shippingCoupon);
+        }
+        if (null != fullSubCoupon) {
+            couponInfoList.add(fullSubCoupon);
+        }
+
+        resultObj.put("couponInfoList", couponInfoList);
+
+        resultObj.put("cart00List", cart00List);//{'cartList':{'type': '保税备货','data':{}}}
+        resultObj.put("cart02List", cart02List);
+        resultObj.put("cart10List", cart10List);
+        resultObj.put("cart11List", cart11List);
+        resultObj.put("cartList", cartList);
+        resultObj.put("validCartList", validCartList);
+        //
+        Map<String, Object> cartTotal = new HashMap();
+        cartTotal.put("goodsCount", goodsCount);
+        cartTotal.put("goodsAmount", goodsAmount);
+        cartTotal.put("checkedGoodsCount", checkedGoodsCount);
+        cartTotal.put("checkedGoodsAmount", checkedGoodsAmount);
+        //
+        resultObj.put("cartTotal", cartTotal);
+        return resultObj;
+    }
+
+    /**
+     * 获取购物车中的数据,底部显示
+     */
+    @GetMapping("getFootCart")
+    public Object getFootCart(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        //查询列表数据
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        Long storeId = getStoreId();
+        param.put("store_id", storeId);
+        List<CartVo> cartList = cartService.queryList(param);
+        //获取购物车统计信息
+        Integer goodsCount = 0;
+        BigDecimal goodsAmount = new BigDecimal(0.00);
+        Integer checkedGoodsCount = 0;
+        BigDecimal checkedGoodsAmount = new BigDecimal(0.00);
+        for (CartVo cartItem : cartList) {
+            goodsCount += 1;
+            goodsAmount = goodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            if (null != cartItem.getChecked() && 1 == cartItem.getChecked()) {
+                checkedGoodsCount += cartItem.getNumber();
+                checkedGoodsAmount = checkedGoodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            }
+        }
+        //
+        resultObj.put("goodsCount", goodsCount);
+        resultObj.put("goodsAmount", goodsAmount);
+        resultObj.put("checkedGoodsCount", checkedGoodsCount);
+        resultObj.put("checkedGoodsAmount", checkedGoodsAmount);
+        //
+        return toResponsSuccess(resultObj);
+    }
+
+
+    /**
+     * 获取购物车信息,所有对购物车的增删改操作,都要重新返回购物车的信息
+     */
+    @GetMapping("index")
+    public Object index() {
+        return toResponsSuccess(getCart());
+    }
+
+    /**
+     * 添加商品到购物车
+     */
+    @PostMapping("add")
+    public Object add(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        Long goodsId = jsonParam.getLong("goodsId");
+        Long productId = jsonParam.getLong("productId");
+        Integer number = jsonParam.getInteger("number");
+        //判断商品是否可以购买
+        GoodsVo goodsInfo = goodsService.queryObject(goodsId);
+        if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
+            return toResponsFail("商品已下架");
+        }
+        Long storeId = getStoreId();
+        //取得规格的信息,判断规格库存
+        /*ProductVo productInfo = productService.queryObjectByStoreId(productId, storeId);
+        if (null == productInfo) {
+            return toResponsFail("商品已下架");
+        }
+        if(productInfo.getStock_num() <= 0){
+            return toResponsFail("库存不足");
+        }*/
+        ProductVo productInfo = productService.queryByStoreId(productId, storeId);
+        if (null == productInfo) {
+            return toResponsFail("商品已下架");
+        }
+        if(productInfo.getStock_num() == null || number > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
+            return toResponsFail("该商品库存不足");
+        }
+        if (null == productInfo.getRetail_price()) {
+            productInfo.setRetail_price(goodsInfo.getRetail_price());
+            productInfo.setMarket_price(goodsInfo.getMarket_price());
+        }
+        //判断购物车中是否存在此规格商品
+        Map cartParam = new HashMap();
+        cartParam.put("goods_id", goodsId);
+        cartParam.put("product_id", productId);
+        cartParam.put("user_id", loginUser.getId());
+        cartParam.put("store_id", storeId);
+        List<CartVo> cartInfoList = cartService.queryList(cartParam);
+        CartVo cartInfo = null != cartInfoList && cartInfoList.size() > 0 ? cartInfoList.get(0) : null;
+        if (null == cartInfo) {//添加规格名和值
+            cartInfo = new CartVo();
+
+            cartInfo.setGoods_id(goodsId);
+            cartInfo.setProduct_id(productId);
+            cartInfo.setGoods_sn(productInfo.getGoods_sn());
+            cartInfo.setGoods_name(goodsInfo.getName());
+            cartInfo.setList_pic_url(goodsInfo.getList_pic_url());
+            cartInfo.setNumber(number);
+            cartInfo.setStore_id(storeId);
+            cartInfo.setUser_id(loginUser.getId());
+            cartInfo.setRetail_price(productInfo.getRetail_price());
+            cartInfo.setMarket_price(productInfo.getMarket_price());
+            cartInfo.setGoods_specification_name_value(productInfo.getGoods_specification_name_value());
+            cartInfo.setGoods_specification_ids(productInfo.getGoods_specification_ids());
+            cartInfo.setChecked(1);
+            cartInfo.setGoodsBizType(goodsInfo.getGoodsBizType());//业务类型
+            cartInfo.setStockNum(productInfo.getStock_num());
+            cartInfo.setMerchSn(goodsInfo.getMerchSn());
+            cartService.save(cartInfo);
+        } else {
+            if(number + cartInfo.getNumber() > productInfo.getStock_num()){
+                return toResponsFail("商品选购数量(含购物车已加购数量)已超过库存");
+            }
+            cartInfo.setNumber(cartInfo.getNumber() + number);
+            cartInfo.setGoodsBizType(goodsInfo.getGoodsBizType());//业务类型
+            cartInfo.setStockNum(productInfo.getStock_num());
+            cartService.update(cartInfo);
+        }
+        return toResponsSuccess(getCart());
+    }
+
+    /**
+     * 添加商品到购物车
+     */
+    @PostMapping("addByGoodsId")
+    public Object addByGoodsId(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        Long goodsId = jsonParam.getLong("goodsId");
+        //判断商品是否可以购买
+        GoodsVo goodsInfo = goodsService.queryObject(goodsId);
+        if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
+            return toResponsFail("商品已下架");
+        }
+        Long storeId = getStoreId();
+        Map resultObj = cartService.addByGoodsId(getUserId(), goodsId, storeId);
+        if (0 != MapUtils.getInteger("errno", resultObj)) {
+            return toResponsObject(MapUtils.getInteger("errno", resultObj), MapUtils.getString("errmsg", resultObj), "");
+        }
+        return toResponsSuccess(getCart());
+    }
+
+    /**
+     * 根据订单号添加商品到购物车
+     */
+    @GetMapping("addByOrder")
+    public Object addByOrder(@LoginUser UserVo loginUser, Long orderId) {
+        JSONObject jsonParam = getJsonRequest();
+        //
+        Map params = new HashMap();
+        params.put("order_id", orderId);
+        List<OrderGoodsVo> orderGoodsVos = apiOrderGoodsService.queryList(params);
+        for (OrderGoodsVo goodsVo : orderGoodsVos) {
+            //判断商品是否可以购买
+            GoodsVo goodsInfo = goodsService.queryObject(goodsVo.getGoods_id());
+            if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
+                return toResponsFail("商品已下架");
+            }
+        }
+        Long storeId = getStoreId();
+        for (OrderGoodsVo goodsVo : orderGoodsVos) {
+            ProductVo productInfo = productService.queryByStoreId(goodsVo.getProduct_id(), storeId);
+            if (null == productInfo) {
+                return toResponsFail("商品已下架");
+            }
+            if(productInfo.getStock_num() == null || goodsVo.getNumber() > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
+                return toResponsFail("该商品库存不足");
+            }
+            CartVo cartInfo = new CartVo();
+            cartInfo.setGoods_id(goodsVo.getGoods_id());
+            cartInfo.setProduct_id(goodsVo.getProduct_id());
+            cartInfo.setGoods_sn(goodsVo.getGoods_sn());
+            cartInfo.setGoods_name(goodsVo.getGoods_name());
+            cartInfo.setList_pic_url(goodsVo.getList_pic_url());
+            cartInfo.setNumber(goodsVo.getNumber());
+            cartInfo.setStore_id(storeId);
+            cartInfo.setUser_id(getUserId());
+            cartInfo.setRetail_price(goodsVo.getRetail_price());
+            cartInfo.setMarket_price(goodsVo.getMarket_price());
+            cartInfo.setGoods_specification_name_value(goodsVo.getGoods_specification_name_value());
+            cartInfo.setGoods_specification_ids(goodsVo.getGoods_specification_ids());
+            cartInfo.setChecked(1);
+            cartInfo.setGoodsBizType(goodsVo.getOrderBizType());
+            cartInfo.setStockNum(productInfo.getStock_num());
+            cartInfo.setMerchSn(goodsVo.getMerchSn());
+
+            Map map = new HashMap();
+            map.put("user_id", getUserId());
+            map.put("store_id", getStoreId());
+            map.put("goods_id",goodsVo.getGoods_id());
+            map.put("product_id",goodsVo.getProduct_id());
+            map.put("number",goodsVo.getNumber());
+            List<CartVo> list= cartService.queryList(map);
+            if(list != null && list.size() > 0){
+                for (CartVo vo:list) {
+                    cartInfo.setId(vo.getId());
+                    cartService.update(cartInfo);
+                }
+            }else{
+                cartService.save(cartInfo);
+            }
+
+        }
+        return toResponsSuccess("添加成功");
+    }
+
+
+    /**
+     * 减少商品到购物车
+     */
+    @PostMapping("minus")
+    public Object minus(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        Integer goodsId = jsonParam.getInteger("goodsId");
+        Integer productId = jsonParam.getInteger("productId");
+        Integer number = jsonParam.getInteger("number");
+        //判断购物车中是否存在此规格商品
+        Map cartParam = new HashMap();
+        cartParam.put("goods_id", goodsId);
+        cartParam.put("product_id", productId);
+        Long storeId = getStoreId();
+        cartParam.put("store_id", storeId);
+        cartParam.put("user_id", loginUser.getId());
+        List<CartVo> cartInfoList = cartService.queryList(cartParam);
+        CartVo cartInfo = null != cartInfoList && cartInfoList.size() > 0 ? cartInfoList.get(0) : null;
+        int cart_num = 0;
+        if (null != cartInfo) {
+            if (cartInfo.getNumber() > number) {
+                cartInfo.setNumber(cartInfo.getNumber() - number);
+                cartService.update(cartInfo);
+                cart_num = cartInfo.getNumber();
+            } else if (cartInfo.getNumber() == 1) {
+                cartService.delete(cartInfo.getId());
+                cart_num = 0;
+            }
+        }
+        return toResponsSuccess(cart_num);
+    }
+
+    /**
+     * 更新指定的购物车信息
+     */
+    @PostMapping("update")
+    public Object update(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        Long goodsId = jsonParam.getLong("goodsId");
+        Long storeId = getStoreId();
+        Long productId = jsonParam.getLong("productId");
+        Integer number = jsonParam.getInteger("number");
+        Integer id = jsonParam.getInteger("id");
+        boolean isAdd = true;
+        //取得规格的信息,判断规格库存
+        ProductVo productInfo = productService.queryByStoreId(productId, storeId);
+        if (null == productInfo) {
+            return this.toResponsObject(400, "商品已下架", getCart());
+        }
+        if(productInfo.getStock_num() == null || number > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
+            return this.toResponsObject(400, "该商品库存不足", getCart());
+        }
+        String msg = "";
+//        if (productInfo.getStock_num() < number) {
+//            msg = "库存不足,仅剩余" + productInfo.getStock_num();
+//            number = productInfo.getStock_num();
+////            return this.toResponsObject(400, "库存不足,仅剩余" + productInfo.getStock_num(), "");
+//        }
+        //判断是否已经存在product_id购物车商品
+        CartVo cartInfo = cartService.queryObject(id);
+        //只是更新number
+        if (cartInfo.getProduct_id().equals(productId)) {
+            cartInfo.setNumber(number);
+            cartInfo.setStockNum(productInfo.getStock_num());
+            cartService.update(cartInfo);
+            return toResponsObject(0, msg, getCart());
+        }
+
+        Map cartParam = new HashMap();
+        cartParam.put("goodsId", goodsId);
+        cartParam.put("productId", productId);
+        cartParam.put("store_id", storeId);
+        List<CartVo> cartInfoList = cartService.queryList(cartParam);
+        CartVo newcartInfo = null != cartInfoList && cartInfoList.size() > 0 ? cartInfoList.get(0) : null;
+        if (null == newcartInfo) {
+            cartInfo.setProduct_id(productId);
+            cartInfo.setGoods_sn(productInfo.getGoods_sn());
+            cartInfo.setNumber(number);
+            cartInfo.setRetail_price(productInfo.getRetail_price());
+            cartInfo.setMarket_price(productInfo.getRetail_price());
+            cartInfo.setGoods_specification_name_value(productInfo.getGoods_specification_name_value());
+            cartInfo.setGoods_specification_ids(productInfo.getGoods_specification_ids());
+            cartService.update(cartInfo);
+        } else {
+            //添加规格名和值
+            cartInfo.setProduct_id(productId);
+            cartInfo.setGoods_sn(productInfo.getGoods_sn());
+            cartInfo.setNumber(number);
+            cartInfo.setRetail_price(productInfo.getRetail_price());
+            cartInfo.setMarket_price(productInfo.getRetail_price());
+            cartInfo.setGoods_specification_name_value(productInfo.getGoods_specification_name_value());
+            cartInfo.setGoods_specification_ids(productInfo.getGoods_specification_ids());
+            cartService.update(cartInfo);
+        }
+        return toResponsObject(0, msg, getCart());
+    }
+
+    /**
+     * 是否选择商品,如果已经选择,则取消选择,批量操作
+     */
+    @PostMapping("checked")
+    public Object checked(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        String productIds = jsonParam.getString("productIds");
+        Integer isChecked = jsonParam.getInteger("isChecked");
+        String goodsBizType = jsonParam.getString("goodsBizType");
+        String[] productIdArray = null;
+        if(StringUtils.isNullOrEmpty(goodsBizType)) {
+            if (StringUtils.isNullOrEmpty(productIds)) {//点击全选时
+                return this.toResponsFail("删除出错");
+            }
+            productIdArray = productIds.split(",");
+        }else{
+            //根据业务类型查询购物车
+            List<CartVo> cartVoList = cartService.queryCartByGoodsBizType(goodsBizType);
+            productIdArray = new String[cartVoList.size()];
+            for (int i = 0;i< cartVoList.size();i++){
+                productIdArray[i] =cartVoList.get(i).getProduct_id()+"";
+            }
+        }
+        cartService.updateCheck(productIdArray, isChecked, loginUser.getId(), getStoreId());
+        return toResponsSuccess(getCart());
+    }
+
+    //删除选中的购物车商品,批量删除
+    @PostMapping("delete")
+    public Object delete(@LoginUser UserVo loginUser) {
+        JSONObject jsonObject = getJsonRequest();
+        Long cartId = jsonObject.getLong("cartId");
+        if (null == cartId) {
+            return toResponsFail("删除出错");
+        }
+        cartService.delete(cartId);
+        return toResponsSuccess(getCart());
+    }
+
+    //  获取购物车商品的总件件数
+    @GetMapping("goodscount")
+    public Object goodscount(@LoginUser UserVo loginUser) {
+        if (null == loginUser || null == loginUser.getId()) {
+            return toResponsFail("未登录");
+        }
+        Map<String, Object> resultObj = new HashMap();
+        //查询列表数据
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("store_id", getStoreId());
+        List<CartVo> cartList = cartService.queryList(param);
+        //获取购物车统计信息
+        Integer goodsCount = 0;
+        for (CartVo cartItem : cartList) {
+            goodsCount += cartItem.getNumber();
+        }
+        resultObj.put("cartList", cartList);
+        //
+        Map<String, Object> cartTotal = new HashMap();
+        cartTotal.put("goodsCount", goodsCount);
+        //
+        resultObj.put("cartTotal", cartTotal);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 订单提交前的检验和填写相关订单信息
+     */
+    @GetMapping("checkout")
+    public Object checkout(@LoginUser UserVo loginUser, Long userCouponId,String merchSn) {
+        Map<String, Object> resultObj = new HashMap();
+        //选择的收货地址
+        Map param = new HashMap();
+        param.put("is_default", 1);
+        param.put("user_id", loginUser.getId());
+        List<AddressVo> addressEntityList = addressService.queryList(param);
+
+        //获取要购买的商品
+        Map<String, Object> cartData = (Map<String, Object>) this.getCartMoney(loginUser);
+
+        List<CartVo> checkedGoodsList = new ArrayList();
+        for (CartVo cartEntity : (List<CartVo>) cartData.get("cartList")) {
+            if (cartEntity.getChecked() == 1) {
+                checkedGoodsList.add(cartEntity);
+            }
+        }
+        //计算订单的费用
+        //商品总价
+        BigDecimal goodsTotalPrice = (BigDecimal) ((HashMap) cartData.get("cartTotal")).get("checkedGoodsAmount");
+
+        //获取可用的优惠券信息 抵用券
+        List<UserCouponVo> enableCouponList = apiUserCouponService.matchUserCouponList(loginUser.getId(),merchSn,goodsTotalPrice);
+        UserCouponVo checkedCoupon = null;
+        BigDecimal couponPrice = new BigDecimal(0.00);  //使用优惠券减免的金额
+        if (null != enableCouponList && enableCouponList.size() > 0) {
+            if (null != userCouponId) {
+                for (UserCouponVo couponVo : enableCouponList) {
+                    if (null != userCouponId && userCouponId.equals(couponVo.getId())) {
+                        couponPrice = couponVo.getType_money();
+                        checkedCoupon = couponVo;
+                    }
+                }
+            }
+        }
+        // 根据收货地址计算运费
+//        BigDecimal freightPrice = apiCouponService.matchShipping(loginUser.getId(), goodsTotalPrice);
+        BigDecimal freightPrice00 = new BigDecimal("00");
+        BigDecimal freightPrice02 = new BigDecimal("00");
+        BigDecimal freightPrice10 = new BigDecimal("00");
+        BigDecimal freightPrice11 = new BigDecimal("00");
+        //查询运费模板
+        for (CartVo vo: checkedGoodsList) {
+            if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_00.getItem())){
+                FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
+                freightPrice00 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice00;
+            }
+            if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem())){
+                FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
+                freightPrice02 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice02;
+            }
+            if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())){
+                FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
+                freightPrice10 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice10;
+            }
+            if(vo.getGoodsBizType().equalsIgnoreCase(Dict.orderBizType.item_11.getItem())){
+                FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(vo.getGoods_id());
+                freightPrice11 = freightEntity!=null ? freightEntity.getDefaultFreight() : freightPrice11;
+            }
+
+        }
+        // 计算优惠券 todo 暂时不计算全场金额满减
+        BigDecimal fullCutCouponDec = Constant.ZERO;
+        Long fullCutCouponId = 0L;
+        /*CouponVo fullSubCoupon = apiCouponService.matchFullSub(loginUser.getId(), goodsTotalPrice);
+        if (null != fullSubCoupon && null != fullSubCoupon.getId()) {
+            // 满减
+            fullCutCouponDec = fullSubCoupon.getType_money();
+            fullCutCouponId = fullSubCoupon.getId();
+        }*/
+        resultObj.put("fullCutCouponDec", fullCutCouponDec);
+        resultObj.put("fullCutCouponId", fullCutCouponId);
+        //订单的总价
+        BigDecimal orderTotalPrice = goodsTotalPrice.add(freightPrice00).add(freightPrice02).add(freightPrice10).add(freightPrice11);
+
+        //
+        BigDecimal actualPrice = orderTotalPrice.subtract(fullCutCouponDec).subtract(couponPrice);  //减去其它支付的金额后,要实际支付的金额
+
+        resultObj.put("freightPrice00", freightPrice00);
+        resultObj.put("freightPrice02", freightPrice02);
+        resultObj.put("freightPrice10", freightPrice10);
+        resultObj.put("freightPrice11", freightPrice11);
+        resultObj.put("checkedCoupon", checkedCoupon);
+        resultObj.put("couponList", enableCouponList);
+
+        resultObj.put("couponPrice", couponPrice);
+        resultObj.put("checkedGoodsList", checkedGoodsList);
+        resultObj.put("goodsTotalPrice", goodsTotalPrice);
+        resultObj.put("orderTotalPrice", orderTotalPrice);
+        resultObj.put("actualPrice", actualPrice);
+        if (null != addressEntityList && addressEntityList.size() > 0) {
+            resultObj.put("addressVo", addressEntityList.get(0));
+        } else { // 没有默认地址,选择一个
+            param = new HashMap();
+            param.put("user_id", loginUser.getId());
+            addressEntityList = addressService.queryList(param);
+            if (null != addressEntityList && addressEntityList.size() > 0) {
+                resultObj.put("addressVo", addressEntityList.get(0));
+            }
+        }
+        UserVo userVo = apiUserService.queryObject(loginUser.getId());
+        if(userVo != null){
+            resultObj.put("idNo", userVo.getIdNo());
+            resultObj.put("userName", userVo.getUsername());
+        }
+
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 选择优惠券列表
+     */
+    @GetMapping("checkedCouponList")
+    public Object checkedCouponList(@LoginUser UserVo loginUser) {
+        //查询列表数据
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        Long storeId = getStoreId();
+        param.put("store_id", storeId);
+        List<CartVo> cartList = cartService.queryList(param);
+        //获取购物车统计信息
+        BigDecimal checkedGoodsAmount = new BigDecimal(0.00);
+        for (CartVo cartItem : cartList) {
+            if (null != cartItem.getChecked() && 1 == cartItem.getChecked()) {
+                checkedGoodsAmount = checkedGoodsAmount.add(cartItem.getRetail_price().multiply(new BigDecimal(cartItem.getNumber())));
+            }
+        }
+        // 匹配优惠券
+        List<UserCouponVo> couponVos = apiUserCouponService.signUserCouponList(loginUser.getId(),getMerchSn(),checkedGoodsAmount);
+        return toResponsSuccess(couponVos);
+    }
+
+//    select checked from mall_cart where goods_biz_type ='00'
+
+    @PostMapping("getCheckedDataByType")
+    public Object getCheckedDataByType() {
+
+        JSONObject jsonParam = getJsonRequest();
+        String goodsBizType = jsonParam.getString("goodsBizType");
+        List<CartVo> cartVoList = cartService.queryCartByGoodsBizType(goodsBizType);
+        for (int i=0;i<cartVoList.size();i++){
+            if(cartVoList.get(i).getChecked()==0){//未选中
+                Map map=new HashMap();
+                map.put("isChecked",false);
+                return toResponsSuccess(map);
+            }
+        }
+        Map map=new HashMap();
+        map.put("isChecked",true);
+        return toResponsSuccess(map);
+    }
+
+    /**
+     * 清空购物车失效商品
+     * @return
+     */
+    @GetMapping("deleteValidCart")
+    public Object deleteValidCart() {
+        try{
+            Map param = new HashMap();
+            param.put("user_id", getUserId());
+            Long storeId = getStoreId();
+            param.put("store_id", storeId);
+            List<CartVo> list = cartService.queryValidCartList(param);
+            for (CartVo cart: list) {
+                cartService.delete(cart.getId());
+            }
+            return toResponsSuccess(getCart());
+        }catch (Exception e){
+            return toResponsFail("清空失败");
+        }
+    }
+
+}

+ 88 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiCatalogController.java

@@ -0,0 +1,88 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.CategoryVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiCategoryService;
+import com.kmall.api.util.ApiBaseAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/catalog")
+public class ApiCatalogController extends ApiBaseAction {
+    @Autowired
+    private ApiCategoryService categoryService;
+
+    /**
+     * 获取分类栏目数据
+     */
+    @IgnoreAuth
+    @GetMapping("index")
+    public Object index(@LoginUser UserVo loginUser, Integer id,
+                        @RequestParam(value = "page", defaultValue = "1") Integer page,
+                        @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        Map<String, Object> resultObj = new HashMap();
+        Map params = new HashMap();
+        params.put("page", page);
+        params.put("limit", size);
+        params.put("sidx", "sort_order");
+        params.put("order", "asc");
+        params.put("parent_id", 0);
+        params.put("store_id", getStoreId());
+        //查询列表数据
+        List<CategoryVo> data = categoryService.queryList(params);
+        //
+        CategoryVo currentCategory = null;
+        if (null != id) {
+            currentCategory = categoryService.queryObject(id);
+        }
+        if (null == currentCategory && data.size() > 0) {
+            currentCategory = data.get(0);
+        }
+
+        //获取子分类数据
+        if (null != currentCategory && null != currentCategory.getId()) {
+            params.put("parent_id", currentCategory.getId());
+            currentCategory.setSubCategoryList(categoryService.queryListByParentId(params));
+        }
+
+        resultObj.put("categoryList", data);
+        resultObj.put("currentCategory", currentCategory);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("current")
+    public Object current(@LoginUser UserVo loginUser, Integer id) {
+        Map<String, Object> resultObj = new HashMap();
+        Map params = new HashMap();
+        params.put("parent_id", 0);
+        CategoryVo currentCategory = null;
+        if (null != id) {
+            currentCategory = categoryService.queryObject(id);
+        }
+        //获取子分类数据
+        if (null != currentCategory && null != currentCategory.getId()) {
+            params.put("parent_id", currentCategory.getId());
+            currentCategory.setSubCategoryList(categoryService.queryList(params));
+        }
+        resultObj.put("currentCategory", currentCategory);
+        return toResponsSuccess(resultObj);
+    }
+}

+ 84 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiCollectController.java

@@ -0,0 +1,84 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.CollectVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiCollectService;
+import com.kmall.api.util.ApiBaseAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/collect")
+public class ApiCollectController extends ApiBaseAction {
+    @Autowired
+    private ApiCollectService collectService;
+
+    /**
+     * 获取用户收藏
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, Integer typeId) {
+
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("type_id", typeId);
+        param.put("store_id", getStoreId());
+        List<CollectVo> collectEntities = collectService.queryList(param);
+
+        return toResponsSuccess(collectEntities);
+    }
+
+    /**
+     * 获取用户收藏
+     */
+    @PostMapping("addordelete")
+    public Object addordelete(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        Integer typeId = jsonParam.getInteger("typeId");
+        Integer valueId = jsonParam.getInteger("valueId");
+
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("type_id", typeId);
+        param.put("value_id", valueId);
+        List<CollectVo> collectEntities = collectService.queryList(param);
+        //
+        Integer collectRes = null;
+        String handleType = "add";
+        if (null == collectEntities || collectEntities.size() < 1) {
+            CollectVo collectEntity = new CollectVo();
+            collectEntity.setAdd_time(System.currentTimeMillis() / 1000);
+            collectEntity.setType_id(typeId);
+            collectEntity.setValue_id(valueId);
+            collectEntity.setIs_attention(0);
+            collectEntity.setUser_id(loginUser.getId());
+            //添加收藏
+            collectRes = collectService.save(collectEntity);
+        } else {
+            //取消收藏
+            collectRes = collectService.delete(collectEntities.get(0).getId());
+            handleType = "delete";
+        }
+
+        if (collectRes > 0) {
+            Map data = new HashMap();
+            data.put("type", handleType);
+            return toResponsSuccess(data);
+        }
+        return toResponsFail("操作失败");
+    }
+}

+ 145 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiCommentController.java

@@ -0,0 +1,145 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.Query;
+import com.kmall.common.utils.enums.CouponTypeEnum;
+import com.qiniu.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/comment")
+public class ApiCommentController extends ApiBaseAction {
+    @Autowired
+    private ApiCommentService commentService;
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private ApiCommentPictureService commentPictureService;
+    @Autowired
+    private ApiCouponService apiCouponService;
+    @Autowired
+    private ApiUserCouponService apiUserCouponService;
+
+    /**
+     * 发表评论
+     */
+    @PostMapping("post")
+    public Object post(@LoginUser UserVo loginUser) {
+        Map resultObj = new HashMap();
+        //
+        JSONObject jsonParam = getJsonRequest();
+        Integer typeId = jsonParam.getInteger("typeId");
+        Long orderId = jsonParam.getLong("orderId");
+        Long insertId = commentService.save(jsonParam, loginUser.getId());
+        // 是否领取优惠券
+        if (null != insertId && insertId > 0 && typeId == 0) {
+            // 当前是否评价过
+            Map param = new HashMap();
+            param.put("user_id", loginUser.getId());
+            param.put("orderId", orderId);
+            Integer hasComment = commentService.queryTotal(param);
+            if (hasComment == 1) {
+                Map couponParam = new HashMap();
+                couponParam.put("send_type", CouponTypeEnum.COUPONTYPE6.getIndex());
+                CouponVo newCouponConfig = apiCouponService.queryMaxUserEnableCoupon(couponParam);
+                if (null != newCouponConfig) {
+                    UserCouponVo userCouponVo = apiCouponService.takeCoupon(newCouponConfig, loginUser.getId(), "", 0L, 0);
+                    resultObj.put("coupon", userCouponVo);
+                }
+            }
+        }
+        if (null != insertId && insertId > 0) {
+            return toResponsObject(0, "评论添加成功", resultObj);
+        } else {
+            return toResponsFail("评论保存失败");
+        }
+    }
+
+    /**
+     */
+    @GetMapping("count")
+    public Object count(@LoginUser UserVo loginUser, Integer typeId, Integer valueId, Integer orderId) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        Map param = new HashMap();
+        param.put("type_id", typeId);
+        param.put("value_id", valueId);
+        param.put("orderId", orderId);
+        Integer allCount = commentService.queryTotal(param);
+        Integer hasPicCount = commentService.queryhasPicTotal(param);
+        //
+        resultObj.put("allCount", allCount);
+        resultObj.put("hasPicCount", hasPicCount);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * @param typeId
+     * @param valueId
+     * @param showType 选择评论的类型 0 全部, 1 只显示图片
+     * @param page
+     * @param size
+     * @return
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(Integer typeId, Integer valueId, Integer orderId, Integer showType,
+                       @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "size", defaultValue = "10") Integer size,
+                       String sort, String order) {
+        Map<String, Object> resultObj = new HashMap();
+        List<CommentVo> commentList = new ArrayList();
+        Map param = new HashMap();
+        param.put("type_id", typeId);
+        param.put("value_id", valueId);
+        param.put("orderId", orderId);
+        param.put("page", page);
+        param.put("limit", size);
+        if (StringUtils.isNullOrEmpty(sort)) {
+            param.put("order", "desc");
+        } else {
+            param.put("order", sort);
+        }
+        if (StringUtils.isNullOrEmpty(order)) {
+            param.put("sidx", "id");
+        } else {
+            param.put("sidx", order);
+        }
+        if (null != showType && showType == 1) {
+            param.put("hasPic", 1);
+        }
+        //查询列表数据
+        Query query = new Query(param);
+        commentList = commentService.queryList(query);
+        int total = commentService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(commentList, total, query.getLimit(), query.getPage());
+        //
+        for (CommentVo commentItem : commentList) {
+            commentItem.setContent(commentItem.getContent());
+//            commentItem.setContent(BaseStr64.decode(commentItem.getContent()));
+            commentItem.setUser_info(userService.queryObject(commentItem.getUserId()));
+
+            Map paramPicture = new HashMap();
+            paramPicture.put("comment_id", commentItem.getId());
+            List<CommentPictureVo> commentPictureEntities = commentPictureService.queryList(paramPicture);
+            commentItem.setPic_list(commentPictureEntities);
+        }
+        return toResponsSuccess(pageUtil);
+    }
+}

+ 246 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiCouponController.java

@@ -0,0 +1,246 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.CouponVo;
+import com.kmall.api.entity.SmsLogVo;
+import com.kmall.api.entity.UserCouponVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiCouponService;
+import com.kmall.api.service.ApiUserCouponService;
+import com.kmall.api.service.ApiUserService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.entity.SysSmsLogEntity;
+import com.kmall.common.service.SysSmsLogService;
+import com.kmall.common.utils.enums.CouponTypeEnum;
+import com.qiniu.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.*;
+
+/**
+ * API优惠券管理
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:31
+ */
+@RestController
+@RequestMapping("/api/coupon")
+public class ApiCouponController extends ApiBaseAction {
+    @Autowired
+    private ApiUserService apiUserService;
+    @Autowired
+    private ApiCouponService apiCouponService;
+    @Autowired
+    private ApiUserCouponService apiUserCouponService;
+    @Autowired
+    private SysSmsLogService sysSmsLogService;
+
+    /**
+     * 是否有可以参加的活动
+     *
+     * @return
+     */
+    @GetMapping("enableActivity")
+    public Object enableActivity() {
+        Map resultObj = new HashMap();
+        Map param = new HashMap();
+        param.put("user_id", getUserId());
+        // 需要点击领取的优惠券
+        Integer[] send_types = new Integer[]{CouponTypeEnum.COUPONTYPE1.getIndex()};
+        param.put("send_types", send_types);
+        param.put("unObtain", true);// 未领取
+        resultObj.put("takeCoupon", "");
+        List<CouponVo> couponVos = apiCouponService.queryUserCoupons(param);
+        if (null != couponVos && couponVos.size() > 0) {
+            apiCouponService.takeCoupon(couponVos.get(0), getUserId(), "", 0L, 1);
+            resultObj.put("takeCoupon", couponVos.get(0));
+            return toResponsSuccess(resultObj);
+        }
+//        // 已经发放,但是没有提醒的
+//        param = new HashMap();
+//        send_types = new Integer[]{0, 2, 4, 5, 6};
+//        param.put("user_id", loginUser.getId());
+//        param.put("send_types", send_types);
+//        param.put("show_state", 0); // 是否需要显示 0:未显示 1:已显示
+//        param.put("unUsed", true);
+//        param.put("enabled", true);
+//        List<UserCouponVo> userCouponVos = apiUserCouponService.queryList(param);
+//        if (null != userCouponVos && userCouponVos.size() > 0) {
+//            UserCouponVo userCouponVo = userCouponVos.get(0);
+//            userCouponVo.setShow_state(1);
+//            apiUserCouponService.update(userCouponVo);
+//            // 返回优惠券
+//            CouponVo couponVo = apiCouponService.queryObject(userCouponVo.getCoupon_id());
+//            resultObj.put("showCoupon", couponVo);
+//            return toResponsSuccess(couponVo);
+//        }
+        // 无需领取的优惠券
+//        param = new HashMap();
+//        param.put("user_id", loginUser.getId());
+//        send_types = new Integer[]{3, 7};
+//        param.put("send_types", send_types);
+//        param.put("filterCouponIds", couponIds);
+//        CouponVo couponVo = apiCouponService.queryMaxUserEnableCoupon(param);
+//        if (null != couponVo) {
+//            resultObj.put("showCoupon", couponVo);
+//            return toResponsSuccess(resultObj);
+//        }
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 获取优惠券列表
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser) {
+
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("enabled", true);
+        param.put("unUsed", true);
+        param.put("merchSn", getMerchSn());
+        List<UserCouponVo> couponVos = apiUserCouponService.queryList(param);
+        return toResponsSuccess(couponVos);
+    }
+
+    /**
+     * 兑换优惠券
+     */
+    @PostMapping("exchange")
+    public Object exchange(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        String coupon_number = jsonParam.getString("coupon_number");
+        if (StringUtils.isNullOrEmpty(coupon_number)) {
+            return toResponsFail("当前优惠码无效");
+        }
+        //
+        Map param = new HashMap();
+        param.put("coupon_number", coupon_number);
+        param.put("merchSn", getMerchSn());
+        List<UserCouponVo> couponVos = apiUserCouponService.queryList(param);
+        UserCouponVo userCouponVo = null;
+        if (null == couponVos || couponVos.size() == 0) {
+            return toResponsFail("当前优惠码无效");
+        }
+        userCouponVo = couponVos.get(0);
+        if (null != userCouponVo.getUser_id() && !userCouponVo.getUser_id().equals(0L)) {
+            return toResponsFail("当前优惠码已经兑换");
+        }
+        CouponVo couponVo = apiCouponService.queryObject(userCouponVo.getCoupon_id());
+        if (null == couponVo || null == couponVo.getUse_end_date() || couponVo.getUse_end_date().before(new Date())) {
+            return toResponsFail("当前优惠码已经过期");
+        }
+        userCouponVo.setUser_id(loginUser.getId());
+        userCouponVo.setAdd_time(new Date());
+        apiUserCouponService.update(userCouponVo);
+        return toResponsSuccess(userCouponVo);
+    }
+
+    /**
+     *   手机号绑定
+     */
+    @PostMapping("newuser")
+    public Object newuser(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        //
+        String phone = jsonParam.getString("phone");
+        String smscode = jsonParam.getString("smscode");
+        List<UserVo> userVoList = apiUserService.queryByMobile(phone);
+        if(userVoList != null && userVoList.size() > 0){
+            return toResponsFail("该手机号已绑定");
+        }
+        // 校验短信码
+        SysSmsLogEntity smsLogVo = sysSmsLogService.querySmsCodeByUserId(loginUser.getId());
+        if (null != smsLogVo && !smsLogVo.getSmsCode().equals(smscode) || smsLogVo.getSendStatus() == 0) {
+            return toResponsFail("短信验证码错误");
+        }
+        // 更新手机号码
+        if (!StringUtils.isNullOrEmpty(phone)) {
+            if (!phone.equals(loginUser.getMobile())) {
+                loginUser.setMobile(phone);
+                apiUserService.update(loginUser);
+            }
+        }
+        /*// 判断是否是新用户
+        if (!StringUtils.isNullOrEmpty(loginUser.getMobile())) {
+            return toResponsFail("当前优惠券只能新用户领取");
+        } else {
+            loginUser.setMobile(phone);
+            apiUserService.update(loginUser);
+        }*/
+        // 是否领取过了
+        Map params = new HashMap();
+        params.put("user_id", loginUser.getId());
+        params.put("send_type", 4);
+        List<CouponVo> couponVos = apiCouponService.queryUserCoupons(params);
+        if (null != couponVos && couponVos.size() > 0) {
+            return toResponsFail("已经领取过,不能重复领取");
+        }
+        // 领取
+        Map couponParam = new HashMap();
+        couponParam.put("send_type", CouponTypeEnum.COUPONTYPE4.getIndex());
+        CouponVo newCouponConfig = apiCouponService.queryMaxUserEnableCoupon(couponParam);
+        if (null != newCouponConfig) {
+            UserCouponVo userCouponVo = apiCouponService.takeCoupon(newCouponConfig, loginUser.getId(), "", 0L, 1);
+            return toResponsSuccess(userCouponVo);
+        } else {
+            return toResponsFail("领取失败");
+        }
+    }
+    /**
+     *  校验是否领取
+     */
+    @GetMapping("checkActivit")
+    public Object checkActivit(@LoginUser UserVo loginUser) {
+        // 是否领取过了
+        Map params = new HashMap();
+        params.put("user_id", loginUser.getId());
+        params.put("send_type", 4);
+        List<CouponVo> couponVos = apiCouponService.queryUserCoupons(params);
+        if (null != couponVos && couponVos.size() > 0) {
+            return toResponsObject(2, "已经领取过,不能重复领取", couponVos);
+        }
+
+        return toResponsSuccess(couponVos);
+    }
+
+    /**
+     *   转发领取红包
+     */
+    @GetMapping("transActivit")
+    public Object transActivit(@LoginUser UserVo loginUser, String sourceKey, Long referrer) {
+        // 是否领取过了
+        Map params = new HashMap();
+        params.put("user_id", loginUser.getId());
+        params.put("send_type", 2);
+        params.put("source_key", sourceKey);
+        List<CouponVo> couponVos = apiCouponService.queryUserCoupons(params);
+        if (null != couponVos && couponVos.size() > 0) {
+            return toResponsObject(2, "已经领取过", couponVos);
+        }
+        // 领取
+        Map couponParam = new HashMap();
+        couponParam.put("send_type", CouponTypeEnum.COUPONTYPE2.getIndex());
+        CouponVo newCouponConfig = apiCouponService.queryMaxUserEnableCoupon(couponParam);
+        if (null != newCouponConfig) {
+            UserCouponVo userCouponVo = apiCouponService.takeCoupon(newCouponConfig, loginUser.getId(), sourceKey, referrer, 1);
+            List<UserCouponVo> userCouponVos = new ArrayList();
+            userCouponVos.add(userCouponVo);
+            //
+            params = new HashMap();
+            params.put("user_id", loginUser.getId());
+            params.put("send_type", 2);
+            params.put("source_key", sourceKey);
+            couponVos = apiCouponService.queryUserCoupons(params);
+            return toResponsSuccess(couponVos);
+        } else {
+            return toResponsFail("领取失败");
+        }
+    }
+}

+ 41 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiFeedbackController.java

@@ -0,0 +1,41 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.FeedbackVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiFeedbackService;
+import com.kmall.api.util.ApiBaseAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiFeedbackController <br>
+ */
+@RestController
+@RequestMapping("/api/feedback")
+public class ApiFeedbackController extends ApiBaseAction {
+    @Autowired
+    private ApiFeedbackService feedbackService;
+
+    /**
+     * 添加或更新收货地址
+     */
+    @PostMapping("save")
+    public Object save(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+        FeedbackVo feedback = jsonParam.getObject("feedback", FeedbackVo.class);
+        feedback.setUserId(loginUser.getId());
+        feedback.setUserName(loginUser.getNickname());
+        feedback.setAddTime(new Date());
+        feedback.setStatus(1);
+        feedbackService.save(feedback);
+        return toResponsSuccess("感谢你的反馈");
+    }
+}

+ 162 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiFootprintController.java

@@ -0,0 +1,162 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.FootprintVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiFootprintService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.DateUtils;
+import com.kmall.common.utils.Query;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/footprint")
+public class ApiFootprintController extends ApiBaseAction {
+    @Autowired
+    private ApiFootprintService footprintService;
+
+    /**
+     */
+    @PostMapping("delete")
+    public Object delete(@LoginUser UserVo loginUser, Integer footprintId) {
+        //删除当天的同一个商品的足迹
+        FootprintVo footprintEntity = footprintService.queryObject(footprintId);
+        //
+        Map param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("goods_id", footprintEntity.getGoods_id());
+        footprintService.deleteByParam(param);
+        //
+        return toResponsMsgSuccess("删除成功");
+    }
+
+    /**
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser,
+                       @RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        Map resultObj = new HashMap();
+
+        Long storeId = getStoreId();
+        //查询列表数据
+        Map params = new HashMap();
+        params.put("page", page);
+        params.put("limit", size);
+        params.put("sidx", "f.id");
+        params.put("user_id", loginUser.getId());
+        params.put("store_id", storeId);
+        params.put("maxFoot", true);
+        params.put("order", "desc");
+        Query query = new Query(params);
+        List<FootprintVo> footprintVos = footprintService.queryList(query);
+        int total = footprintService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(footprintVos, total, query.getLimit(), query.getPage());
+        //
+        Map<String, List<FootprintVo>> footPrintMap = new TreeMap<String, List<FootprintVo>>(new Comparator<String>() {
+            /*
+             * int compare(Object o1, Object o2) 返回一个基本类型的整型,
+             * 返回负数表示:o1 小于o2,
+             * 返回0 表示:o1和o2相等,
+             * 返回正数表示:o1大于o2。
+             */
+            public int compare(String o1, String o2) {
+
+                //指定排序器按照降序排列
+                return o2.compareTo(o1);
+            }
+        });
+
+        if (null != footprintVos && footprintVos.size() > 0) {
+            for (FootprintVo footprintVo : footprintVos) {
+                String addTime = DateUtils.timeToStr(footprintVo.getAdd_time(), DateUtils.DATE_PATTERN);
+                List<FootprintVo> tmpList = footPrintMap.get(addTime);
+                if (null == footPrintMap.get(addTime)) {
+                    tmpList = new ArrayList();
+                }
+                tmpList.add(footprintVo);
+                footPrintMap.put(addTime, tmpList);
+            }
+            List<FootprintVo>[] footprintVoList = new List[footPrintMap.size()];
+            int i = 0;
+            for (Map.Entry<String, List<FootprintVo>> entry : footPrintMap.entrySet()) {
+                footprintVoList[i] = entry.getValue();
+                i++;
+            }
+            resultObj.put("count", pageUtil.getCount());
+            resultObj.put("totalPages", pageUtil.getTotalPages());
+            resultObj.put("numsPerPage", pageUtil.getNumsPerPage());
+            resultObj.put("currentPage", pageUtil.getCurrentPage());
+            resultObj.put("data", footprintVoList);
+        }
+
+        return this.toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 猜你喜欢
+     */
+    @GetMapping("glist")
+    public Object glist(@LoginUser UserVo loginUser,String storeId) {
+        Map resultObj = new HashMap();
+
+        //查询列表数据
+        Map params = new HashMap();
+        params.put("sidx", "f.id");
+        params.put("user_id", loginUser.getId());
+        params.put("maxFoot", true);
+        params.put("order", "desc");
+        params.put("bizType", true);
+        params.put("store_id", storeId);
+        List<FootprintVo> footprintVos = footprintService.queryList(params);
+        List<FootprintVo> list = new ArrayList();
+        if (null != footprintVos) {
+            for (FootprintVo vo : footprintVos) {
+                boolean has = false;
+                for (FootprintVo voInner : list) {
+                    if (vo.getGoods_id().equals(voInner.getGoods_id())) {
+                        has = true;
+                        break;
+                    }
+                }
+                if (!has) {
+                    list.add(vo);
+                }
+                if (list.size() > 10) {
+                    break;
+                }
+            }
+        }
+        resultObj.put("list", list);
+        return this.toResponsSuccess(resultObj);
+    }
+
+
+    /**
+     */
+    @GetMapping("sharelist")
+    public Object sharelist(@LoginUser UserVo loginUser,
+                            @RequestParam(value = "page", defaultValue = "1") Integer page,
+                            @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        Map resultObj = new HashMap();
+
+        //查询列表数据
+        Map params = new HashMap();
+        params.put("sidx", "f.id");
+        params.put("order", "desc");
+        params.put("referrer", loginUser.getId());
+        List<FootprintVo> footprintVos = footprintService.shareList(params);
+        //
+        resultObj.put("data", footprintVos);
+        return this.toResponsSuccess(resultObj);
+    }
+}

+ 60 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsActivityController.java

@@ -0,0 +1,60 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.dto.GoodsActivityVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiGoodsActivityService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.Query;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiGoodsActivityController <br>
+ */
+@RestController
+@RequestMapping("/api/activity")
+public class ApiGoodsActivityController extends ApiBaseAction {
+    @Autowired
+    private ApiGoodsActivityService apiGoodsActivityService;
+
+    /**
+     * 团购
+     *
+     * @param loginUser
+     * @param page
+     * @param size
+     * @param type      2团购
+     * @return
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, @RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size, Integer type) {
+        Map param = new HashMap();
+        param.put("page", page);
+        param.put("limit", size);
+        param.put("type", type);
+        // 多余,防止报错
+        param.put("sidx", "id");
+        param.put("order", "desc");
+        param.put("store_id", getStoreId());
+        //查询列表数据
+        Query query = new Query(param);
+        List<GoodsActivityVo> topicEntities = apiGoodsActivityService.queryList(query);
+        int total = apiGoodsActivityService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(topicEntities, total, query.getLimit(), query.getPage());
+        return toResponsSuccess(pageUtil);
+    }
+}

+ 638 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsController.java

@@ -0,0 +1,638 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.DateUtils;
+import com.kmall.common.utils.Query;
+import com.kmall.common.utils.enums.CouponTypeEnum;
+import com.qiniu.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/goods")
+public class ApiGoodsController extends ApiBaseAction {
+    @Autowired
+    private ApiGoodsService goodsService;
+    @Autowired
+    private ApiGoodsSpecificationService goodsSpecificationService;
+    @Autowired
+    private ApiProductService productService;
+    @Autowired
+    private ApiGoodsGalleryService goodsGalleryService;
+    @Autowired
+    private ApiGoodsIssueService goodsIssueService;
+    @Autowired
+    private ApiAttributeService attributeService;
+    @Autowired
+    private ApiCommentService commentService;
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private ApiCommentPictureService commentPictureService;
+    @Autowired
+    private ApiCollectService collectService;
+    @Autowired
+    private ApiFootprintService footprintService;
+    @Autowired
+    private ApiCategoryService categoryService;
+    @Autowired
+    private ApiSearchHistoryService searchHistoryService;
+    @Autowired
+    private ApiRelatedGoodsService relatedGoodsService;
+    @Autowired
+    private ApiCouponService apiCouponService;
+    @Autowired
+    private ApiUserCouponService apiUserCouponService;
+    @Autowired
+    private ApiCartService cartService;
+    @Autowired
+    private ApiAdService apiAdService;
+    @Autowired
+    private ApiBrandService apiBrandService;
+
+    @Autowired
+    private ApiFreightService apiFreightService;
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        //
+        Map param = new HashMap();
+        List<GoodsVo> goodsList = goodsService.queryList(param);
+        //
+        return toResponsSuccess(goodsList);
+    }
+
+    /**
+     * 获取sku信息,用于购物车编辑时选择规格
+     */
+    @IgnoreAuth
+    @GetMapping("sku")
+    public Object sku(@LoginUser UserVo loginUser, Long goodsId) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        GoodsVo goodsVo = goodsService.queryObject(goodsId);
+        //
+        List<Map> goodsSpecificationEntityList = goodsSpecificationService.queryByGoodsIdGroupByNames(goodsId);
+        //
+        Map param = new HashMap();
+        param.put("goods_id", goodsId);
+        param.put("store_id", getStoreId());
+        List<ProductVo> productEntityList = productService.queryList(param);
+
+        CartVo cartVo = cartService.queryObjectByGoodsIdAndUserId(goodsId,getUserId());
+        if(cartVo == null){
+            resultObj.put("cartNumber", 0);
+        }else{
+            resultObj.put("cartNumber", cartVo.getNumber());
+        }
+        resultObj.put("goodsVo", goodsVo);
+        resultObj.put("specificationList", goodsSpecificationEntityList);
+        resultObj.put("productList", productEntityList);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 商品画廊数据
+     */
+    @IgnoreAuth
+    @GetMapping("goodsGallery")
+    public Object goodsGallery(Integer goods_id) {
+        Map param = new HashMap();
+        param.put("goods_id", goods_id);
+        List<GoodsGalleryVo> gallery = goodsGalleryService.queryList(param);
+        return toResponsSuccess(gallery);
+    }
+
+    /**
+     * 商品详情页数据
+     * */
+    @GetMapping("detail")
+    public Object detail(Long id, Long referrer,String merchSn) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        Long userId = getUserId();
+        Long storeId = getStoreId();
+        GoodsVo info = goodsService.queryObjectByStoreId(id, storeId);
+        if(info == null){
+            return toResponsFail("此商品不存在");
+        }
+        BrandVo brand = apiBrandService.queryObject(info.getBrand_id());
+        resultObj.put("brand", brand);
+
+        Map param = new HashMap();
+        param.put("goods_id", id);
+        param.put("store_id", getStoreId());
+        List<Map> specificationList = goodsSpecificationService.queryByGoodsIdGroupByNames(id);
+        //
+        List<ProductVo> productEntityList = productService.queryList(param);
+        //
+        List<GoodsGalleryVo> gallery = goodsGalleryService.queryList(param);
+        resultObj.put("gallery", gallery);
+
+        Map ngaParam = new HashMap();
+        ngaParam.put("fields", "nga.value, na.name");
+        ngaParam.put("sidx", "nga.id");
+        ngaParam.put("order", "asc");
+        ngaParam.put("goods_id", id);
+        List<AttributeVo> attribute = attributeService.queryList(ngaParam);
+        //
+        Map issueParam = new HashMap();
+        issueParam.put("merch_sn", merchSn);
+        List<GoodsIssueVo> issue = goodsIssueService.queryList(issueParam);
+        //
+        param.put("value_id", id);
+        param.put("type_id", 0);
+        Integer commentCount = commentService.queryTotal(param);
+        List<CommentVo> hotComment = commentService.queryList(param);
+        Map commentInfo = new HashMap();
+        if (null != hotComment && hotComment.size() > 0) {
+            UserVo commentUser = userService.queryObject(hotComment.get(0).getUserId());
+            commentInfo.put("content", hotComment.get(0).getContent());
+            commentInfo.put("add_time", DateUtils.timeToStr(hotComment.get(0).getAddTime(), DateUtils.PATTERN_YYYY_MM_DD_HH_MM));
+            commentInfo.put("nickname", commentUser.getNickname());
+            commentInfo.put("avatar", commentUser.getAvatar());
+            Map paramPicture = new HashMap();
+            paramPicture.put("comment_id", hotComment.get(0).getId());
+            List<CommentPictureVo> commentPictureEntities = commentPictureService.queryList(paramPicture);
+            commentInfo.put("pic_list", commentPictureEntities);
+        }
+        Map comment = new HashMap();
+        comment.put("count", commentCount);
+        comment.put("data", commentInfo);
+        //当前用户是否收藏
+        Map collectParam = new HashMap();
+        collectParam.put("user_id", getUserId());
+        collectParam.put("value_id", id);
+        collectParam.put("type_id", 0);
+        Integer userHasCollect = collectService.queryTotal(collectParam);
+        if (userHasCollect > 0) {
+            userHasCollect = 1;
+        }
+        //记录用户的足迹
+        FootprintVo footprintEntity = new FootprintVo();
+        footprintEntity.setAdd_time(System.currentTimeMillis() / 1000);
+        footprintEntity.setGoods_brief(info.getGoods_brief());
+        footprintEntity.setList_pic_url(info.getList_pic_url());
+        footprintEntity.setGoods_id(info.getId());
+        footprintEntity.setName(info.getName());
+        footprintEntity.setRetail_price(info.getRetail_price());
+        footprintEntity.setUser_id(userId);
+        if (null != referrer) {
+            footprintEntity.setReferrer(referrer);
+        } else {
+            footprintEntity.setReferrer(0L);
+        }
+        footprintService.save(footprintEntity);
+
+        Map cartMap= new HashMap();
+        cartMap.put("user_id",userId);
+        cartMap.put("goods_id",info.getId());
+        List<CartVo> cartVoList = cartService.queryList(cartMap);
+
+        FreightEntity freightEntity = apiFreightService.queryObjectByGoodsId(info.getId());
+        //
+        resultObj.put("info", info);
+
+        resultObj.put("attribute", attribute);
+        resultObj.put("userHasCollect", userHasCollect);
+        resultObj.put("issue", issue);
+        resultObj.put("comment", comment);
+        resultObj.put("specificationList", specificationList);
+        resultObj.put("productList", productEntityList);
+        resultObj.put("stockNum", productEntityList.size()!=0? productEntityList.get(0).getStock_num():0);
+        resultObj.put("cartNumber", cartVoList.size()!=0? cartVoList.get(0).getNumber():0);
+        resultObj.put("defaultFreight", freightEntity != null? freightEntity.getDefaultFreight() :0);
+
+        return toResponsSuccess(resultObj);
+    }
+
+    /*
+     *  用户转发获取优惠券
+     */
+    @IgnoreAuth
+    @GetMapping("transferCoupon")
+    public Object transferCoupon(@LoginUser UserVo loginUser, Long goods_id, Integer send_type, Long referrer) {
+        Map<String, Object> resultObj = new HashMap();
+        // 记录推荐人是否可以领取红包,用户登录时校验
+        Long userId = getUserId();
+        try {
+            // 是否已经有可用的转发红包
+            Map params = new HashMap();
+            params.put("user_id", userId);
+            params.put("send_type", send_type);
+            params.put("unUsed", true);
+            List<CouponVo> enabledCouponVos = apiCouponService.queryUserCoupons(params);
+            if ((null == enabledCouponVos || enabledCouponVos.size() == 0)
+                    && null != referrer && null != userId) {
+                // 获取优惠信息提示
+                Map couponParam = new HashMap();
+                couponParam.put("enabled", true);
+                Integer[] send_types = new Integer[]{CouponTypeEnum.COUPONTYPE2.getIndex()};
+                couponParam.put("send_types", send_types);
+                List<CouponVo> couponVos = apiCouponService.queryList(couponParam);
+                if (null != couponVos && couponVos.size() > 0) {
+                    CouponVo couponVo = couponVos.get(0);
+                    Map footprintParam = new HashMap();
+                    footprintParam.put("goods_id", goods_id);
+                    footprintParam.put("referrer", referrer);
+                    Integer footprintNum = footprintService.queryTotal(footprintParam);
+                    if (null != footprintNum && null != couponVo.getMin_transmit_num()
+                            && footprintNum > couponVo.getMin_transmit_num()) {
+                        apiCouponService.takeCoupon(couponVo, userId, "", 0L, 1);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsSuccess("");
+    }
+
+    /**
+     *  获取分类下的商品
+     */
+    @IgnoreAuth
+    @GetMapping("category")
+    public Object category(@LoginUser UserVo loginUser, Integer id) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        CategoryVo currentCategory = categoryService.queryObject(id);
+        //
+        CategoryVo parentCategory = categoryService.queryObject(currentCategory.getParent_id());
+        Map params = new HashMap();
+        params.put("parent_id", currentCategory.getParent_id());
+        List<CategoryVo> brotherCategory = categoryService.queryList(params);
+        //
+        resultObj.put("currentCategory", currentCategory);
+        resultObj.put("parentCategory", parentCategory);
+        resultObj.put("brotherCategory", brotherCategory);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     *   获取商品列表
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, Integer categoryId,
+                       Integer brandId, String keyword, Integer isNew, Integer isHot,String goodsBizType,
+                       @RequestParam(value = "page", defaultValue = "1") Integer
+                               page, @RequestParam(value = "size", defaultValue = "10") Integer size,
+                       String sort, String order) {
+        Map params = new HashMap();
+        try{
+            keyword = new String(keyword.getBytes("iso-8859-1"),"utf-8");
+        }catch (Exception e){
+            logger.error("error:", e);
+        }
+        params.put("brand_id", brandId);
+        params.put("keyword", keyword);
+        params.put("is_new", isNew);
+        params.put("is_hot", isHot);
+        params.put("page", page);
+        params.put("limit", size);
+        params.put("order", sort);
+        params.put("sidx", order);
+        params.put("goodsBizType", goodsBizType);
+        params.put("store_id", getStoreId());
+        params.put("notGoodsBizType", true);
+        //
+        if (null != sort && sort.equals("price")) {
+            params.put("sidx", "a.retail_price");
+            params.put("order", order);
+        } else {
+            params.put("sidx", "a.id");
+            params.put("order", "desc");
+        }
+        //添加到搜索历史
+        if (!StringUtils.isNullOrEmpty(keyword)) {
+            SearchHistoryVo searchHistoryVo = new SearchHistoryVo();
+            searchHistoryVo.setAdd_time(System.currentTimeMillis() / 1000);
+            searchHistoryVo.setKeyword(keyword);
+            searchHistoryVo.setUser_id(null != loginUser ? loginUser.getId().toString() : "");
+            searchHistoryVo.setFrom("");
+            searchHistoryService.save(searchHistoryVo);
+        }
+        //筛选的分类
+        List<CategoryVo> filterCategory = new ArrayList();
+        CategoryVo rootCategory = new CategoryVo();
+        rootCategory.setId(0);
+        rootCategory.setName("全部");
+        rootCategory.setChecked(false);
+        filterCategory.add(rootCategory);
+        //
+        params.put("fields", "a.category_id");
+        params.put("limit", 1);
+        List<GoodsVo> goodsVoList = goodsService.queryList(params);
+        params.put("limit", size);
+        params.remove("fields");
+        if (null != goodsVoList && goodsVoList.size() > 0) {
+            List<Integer> categoryIds = new ArrayList();
+            for (GoodsVo goodsVo : goodsVoList) {
+                if (null != goodsVo && null != goodsVo.getCategory_id()) {
+                    categoryIds.add(goodsVo.getCategory_id());
+                }
+            }
+            //查找二级分类的parent_id
+            Map categoryParam = new HashMap();
+            categoryParam.put("ids", categoryIds);
+            categoryParam.put("fields", "parent_id");
+            List<CategoryVo> parentCategoryList = categoryService.queryList(categoryParam);
+            //
+            List<Integer> parentIds = new ArrayList();
+            for (CategoryVo categoryEntity : parentCategoryList) {
+                parentIds.add(categoryEntity.getParent_id());
+            }
+            //一级分类
+            categoryParam = new HashMap();
+            categoryParam.put("fields", "id,name");
+            categoryParam.put("order", "asc");
+            categoryParam.put("sidx", "sort_order");
+            categoryParam.put("ids", parentIds);
+            List<CategoryVo> parentCategory = categoryService.queryList(categoryParam);
+            if (null != parentCategory) {
+                filterCategory.addAll(parentCategory);
+            }
+        }
+        //查询列表数据
+        params.put("fields", "distinct a.id, a.name, a.list_pic_url, psr1.market_price, psr1.retail_price, a.goods_brief");
+        params.put("category_parent_id", categoryId);
+        Query query = new Query(params);
+        List<GoodsVo> goodsList = goodsService.queryList(query);
+        int total = goodsService.queryTotal(query);
+        ApiPageUtils goodsData = new ApiPageUtils(goodsList, total, query.getLimit(), query.getPage());
+        //搜索到的商品
+        for (CategoryVo categoryEntity : filterCategory) {
+            if (null != categoryId && categoryEntity.getId() == 0 || categoryEntity.getId() == categoryId) {
+                categoryEntity.setChecked(true);
+            } else {
+                categoryEntity.setChecked(false);
+            }
+        }
+        goodsData.setFilterCategory(filterCategory);
+        return toResponsSuccess(goodsData);
+    }
+
+    /**
+     *   获取疯狂折扣商品列表
+     */
+    @IgnoreAuth
+    @GetMapping("hotGoodsList")
+    public Object hotGoodsList(@LoginUser UserVo loginUser, Integer categoryId,
+                               String sort, String order) {
+        Map reusltObj = new HashMap();
+        //
+        Long store_id = getStoreId();
+        Map params = new HashMap();
+        //筛选的分类
+        List<CategoryVo> filterCategory = new ArrayList();
+        CategoryVo rootCategory = new CategoryVo();
+        rootCategory.setId(0);
+        rootCategory.setName("全部");
+        rootCategory.setChecked(false);
+        filterCategory.add(rootCategory);
+        //
+        params.put("fields", "a.category_id");
+        params.put("is_hot", "1");
+        params.put("store_id", store_id);
+
+        List<GoodsVo> categoryEntityList = goodsService.queryList(params);
+        params.remove("fields");
+        if (null != categoryEntityList && categoryEntityList.size() > 0) {
+            List<Integer> categoryIds = new ArrayList();
+            for (GoodsVo goodsVo : categoryEntityList) {
+                if (null == goodsVo || null == goodsVo.getCategory_id()) {
+                    continue;
+                }
+                categoryIds.add(goodsVo.getCategory_id());
+            }
+            //查找二级分类的parent_id
+            Map categoryParam = new HashMap();
+            categoryParam.put("ids", categoryIds);
+            categoryParam.put("fields", "parent_id");
+            List<CategoryVo> parentCategoryList = categoryService.queryList(categoryParam);
+            //
+            List<Integer> parentIds = new ArrayList();
+            for (CategoryVo categoryEntity : parentCategoryList) {
+                parentIds.add(categoryEntity.getParent_id());
+            }
+            //一级分类
+            categoryParam = new HashMap();
+            categoryParam.put("fields", "id,name");
+            categoryParam.put("order", "asc");
+            categoryParam.put("sidx", "sort_order");
+            categoryParam.put("ids", parentIds);
+            List<CategoryVo> parentCategory = categoryService.queryList(categoryParam);
+            if (null != parentCategory) {
+                filterCategory.addAll(parentCategory);
+            }
+        }
+        params.put("category_parent_id", categoryId);
+        params.put("fields", "a.id,a.name,a.goods_brief,a.list_pic_url,psr1.retail_price," +
+                "psr1.market_price,b.id as product_id");
+        params.put("is_hot", "1");
+        params.put("is_delete", 0);
+        params.put("store_id", store_id);
+        if (!StringUtils.isNullOrEmpty(sort) && !StringUtils.isNullOrEmpty(order)) {
+            if (sort.equals("price")) {
+                params.put("sidx", "a.retail_price");
+                params.put("order", order);
+            }
+        }
+        List<GoodsVo> hotGoods = goodsService.queryHotGoodsList(params);
+
+        reusltObj.put("filterCategory", filterCategory);
+        reusltObj.put("goodsList", hotGoods);
+
+        return toResponsSuccess(reusltObj);
+    }
+
+    /**
+     *   新品首发
+     */
+    @IgnoreAuth
+    @GetMapping("new")
+    public Object newAction(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        Map bannerInfo = new HashMap();
+        bannerInfo.put("url", "");
+        bannerInfo.put("name", "坚持初心,为你寻觅世间好物");
+        bannerInfo.put("img_url", "http://yanxuan.nosdn.127.net/8976116db321744084774643a933c5ce.png");
+        resultObj.put("bannerInfo", bannerInfo);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     *   人气推荐
+     */
+    @IgnoreAuth
+    @GetMapping("hot")
+    public Object hot(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        Map param = new HashMap();
+        param.put("ad_position_id", 4);
+        List<AdVo> adVoList = apiAdService.queryList(param);
+        if (null != adVoList && adVoList.size() > 0) {
+            Map bannerInfo = new HashMap();
+            bannerInfo.put("url", "");
+            bannerInfo.put("name", adVoList.get(0).getName());
+            bannerInfo.put("img_url", adVoList.get(0).getImageUrl());
+            resultObj.put("bannerInfo", bannerInfo);
+        } else {
+            Map bannerInfo = new HashMap();
+            bannerInfo.put("url", "");
+            bannerInfo.put("name", "大家都在商城选好物");
+            bannerInfo.put("img_url", "https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180807/1057182334dfb2.png");
+            resultObj.put("bannerInfo", bannerInfo);
+        }
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     *   商品详情页的大家都在看的商品
+     */
+    @IgnoreAuth
+    @GetMapping("related")
+    public Object related(@LoginUser UserVo loginUser, Long id) {
+        Map<String, Object> resultObj = new HashMap();
+        Map param = new HashMap();
+        param.put("goods_id", id);
+        param.put("fields", "related_goods_id");
+        List<RelatedGoodsVo> relatedGoodsEntityList = relatedGoodsService.queryList(param);
+
+        List<Integer> relatedGoodsIds = new ArrayList();
+        for (RelatedGoodsVo relatedGoodsEntity : relatedGoodsEntityList) {
+            relatedGoodsIds.add(relatedGoodsEntity.getRelated_goods_id());
+        }
+        List<Integer> relatedGoods = new ArrayList();
+        if (null == relatedGoodsIds || relatedGoods.size() < 1) {
+            //查找同分类下的商品
+            GoodsVo goodsCategory = goodsService.queryObject(id);
+            if (null != goodsCategory) {
+                Map paramRelated = new HashMap();
+                paramRelated.put("store_id", getStoreId());
+                paramRelated.put("notGoodsBizType", true);
+                paramRelated.put("fields", "a.id, a.name, a.list_pic_url, psr1.retail_price,b.id as product_id");
+                paramRelated.put("category_id", goodsCategory.getCategory_id());
+                relatedGoods = goodsService.queryList(paramRelated);
+            }
+        } else {
+            Map paramRelated = new HashMap();
+            paramRelated.put("store_id", getStoreId());
+            paramRelated.put("notGoodsBizType", true);
+            paramRelated.put("goods_ids", relatedGoodsIds);
+            paramRelated.put("fields", "a.id, a.name, a.list_pic_url, psr1.retail_price,b.id as product_id");
+            relatedGoods = goodsService.queryList(paramRelated);
+        }
+        resultObj.put("goodsList", relatedGoods);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 在售的商品总数
+     */
+    @IgnoreAuth
+    @GetMapping("count")
+    public Object count(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        Map param = new HashMap();
+        param.put("storeId", getStoreId());
+        param.put("notGoodsBizType", true);
+        param.put("is_delete", 0);
+        param.put("is_on_sale", 1);
+        Integer goodsCount = goodsService.queryTotal(param);
+        resultObj.put("goodsCount", goodsCount);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     *   获取商品列表
+     */
+    @IgnoreAuth
+    @GetMapping("productlist")
+    public Object productlist(@LoginUser UserVo loginUser, Integer categoryId,
+                              Integer isNew, Integer discount,String goodsBizType,
+                              @RequestParam(value = "page", defaultValue = "1") Integer
+                                      page, @RequestParam(value = "size", defaultValue = "10") Integer size,
+                              String sort, String order) {
+        Map params = new HashMap();
+        params.put("is_new", isNew);
+        params.put("page", page);
+        params.put("limit", size);
+        params.put("order", sort);
+        params.put("sidx", order);
+        params.put("store_id", getStoreId());
+        //
+        if (null != sort && sort.equals("price")) {
+            params.put("sidx", "retail_price");
+            params.put("order", order);
+        } else if (null != sort && sort.equals("sell")) {
+            params.put("sidx", "psr1.sell_volume");
+            params.put("order", order);
+        } else {
+            params.put("sidx", "id");
+            params.put("order", "desc");
+        }
+        // 0不限 1特价 2团购
+        if (null != discount && discount == 1) {
+            params.put("is_hot", 1);
+        } else if (null != discount && discount == 2) {
+            params.put("is_group", true);
+        }
+        params.put("goodsBizType", goodsBizType);
+        CategoryVo categoryVo = categoryService.queryObject(categoryId);
+        if(categoryVo != null){
+            if(categoryVo.getSort_order()!= null && categoryVo.getSort_order()== 0){
+            }else{
+                params.put("category_parent_id", categoryId);
+            }
+        }
+        //查询列表数据
+        Query query = new Query(params);
+        List<GoodsVo> goodsList = goodsService.queryCatalogProductList(query);
+        int total = goodsService.queryTotal(query);
+
+        // 当前购物车中
+        List<CartVo> cartList = new ArrayList();
+        if (null != getUserId()) {
+            Long storeId = getStoreId();
+            //查询列表数据
+            Map cartParam = new HashMap();
+            cartParam.put("user_id", getUserId());
+            cartParam.put("store_id", storeId);
+            cartList = cartService.queryList(cartParam);
+        }
+        if (null != cartList && cartList.size() > 0 && null != goodsList && goodsList.size() > 0) {
+            for (GoodsVo goodsVo : goodsList) {
+                for (CartVo cartVo : cartList) {
+                    if (goodsVo.getId().equals(cartVo.getGoods_id())) {
+                        goodsVo.setCart_num(cartVo.getNumber());
+                    }
+                }
+            }
+        }
+        ApiPageUtils goodsData = new ApiPageUtils(goodsList, total, query.getLimit(), query.getPage());
+        return toResponsSuccess(goodsData);
+    }
+}

+ 41 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsCrashController.java

@@ -0,0 +1,41 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.GoodsCrashVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiGoodsCrashService;
+import com.kmall.api.util.ApiBaseAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API搭配减价管理
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:31
+ */
+@RestController
+@RequestMapping("/api/goodscrash")
+public class ApiGoodsCrashController extends ApiBaseAction {
+    @Autowired
+    private ApiGoodsCrashService apiGoodsCrashService;
+
+    /**
+     * 获取优惠券列表
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, Long goodsId) {
+
+        Map param = new HashMap();
+        param.put("goods_id", goodsId);
+        List<GoodsCrashVo> crashVos = apiGoodsCrashService.queryList(param);
+        return toResponsSuccess(crashVos);
+    }
+}

+ 173 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupController.java

@@ -0,0 +1,173 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.DateUtils;
+import com.kmall.common.utils.Query;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/group")
+public class ApiGoodsGroupController extends ApiBaseAction {
+    @Autowired
+    protected ApiGoodsGroupOpenService apiGoodsGroupOpenService;
+    @Autowired
+    private ApiGoodsGroupService apiGoodsGroupService;
+    @Autowired
+    private ApiGoodsService apiGoodsService;
+    @Autowired
+    private ApiGoodsSpecificationService apiGoodsSpecificationService;
+    @Autowired
+    private ApiProductService apiProductService;
+    @Autowired
+    private ApiGoodsGalleryService apiGoodsGalleryService;
+    @Autowired
+    private ApiGoodsIssueService goodsIssueService;
+    @Autowired
+    private ApiAttributeService attributeService;
+    @Autowired
+    private ApiCommentService commentService;
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private ApiCommentPictureService commentPictureService;
+    @Autowired
+    private ApiCollectService collectService;
+    @Autowired
+    private ApiFootprintService footprintService;
+
+    /**
+     * 团购列表
+     *
+     * @param loginUser
+     * @param page
+     * @param size
+     * @return
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, @RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        Map param = new HashMap();
+        param.put("page", page);
+        param.put("limit", size);
+//        param.put("sidx", "end_time");
+//        param.put("order", "desc");
+        param.put("end_time", new Date());
+        param.put("storeId", getStoreId());
+        //查询列表数据
+        Query query = new Query(param);
+        List<GoodsGroupVo> groupVos = apiGoodsGroupService.queryList(query);
+        int total = apiGoodsGroupService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(groupVos, total, query.getLimit(), query.getPage());
+        return toResponsSuccess(pageUtil);
+    }
+
+    /**
+     * 团购商品详情页数据
+     */
+    @GetMapping("info")
+    public Object info(Long id, Long referrer) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        Long userId = getUserId();
+        Long storeId = getStoreId();
+        GoodsGroupVo groupVo = apiGoodsGroupService.queryObjectByStoreId(id, storeId);
+        GoodsVo info = apiGoodsService.queryObjectByStoreId(groupVo.getGoods_id(), storeId);
+        Map param = new HashMap();
+        param.put("goods_id", groupVo.getGoods_id());
+        param.put("store_id", storeId);
+        //
+        List<Map> specificationList = apiGoodsSpecificationService.queryByGoodsIdGroupByNames(groupVo.getGoods_id());
+        //
+        List<ProductVo> productEntityList = apiProductService.queryList(param);
+        //
+        List<GoodsGalleryVo> gallery = apiGoodsGalleryService.queryList(param);
+        Map ngaParam = new HashMap();
+        ngaParam.put("fields", "nga.value, na.name");
+        ngaParam.put("sidx", "nga.id");
+        ngaParam.put("order", "asc");
+        ngaParam.put("goods_id", groupVo.getGoods_id());
+        List<AttributeVo> attribute = attributeService.queryList(ngaParam);
+        //
+        Map issueParam = new HashMap();
+//        issueParam.put("goods_id", groupVo.getGoods_id());
+        List<GoodsIssueVo> issue = goodsIssueService.queryList(issueParam);
+        //
+        param.put("value_id", groupVo.getGoods_id());
+        param.put("type_id", 0);
+        Integer commentCount = commentService.queryTotal(param);
+        List<CommentVo> hotComment = commentService.queryList(param);
+        Map commentInfo = new HashMap();
+        if (null != hotComment && hotComment.size() > 0) {
+            UserVo commentUser = userService.queryObject(hotComment.get(0).getUserId());
+            commentInfo.put("content", hotComment.get(0).getContent());
+            commentInfo.put("add_time", DateUtils.timeToStr(hotComment.get(0).getAddTime(), DateUtils.DATE_PATTERN));
+            commentInfo.put("nickname", commentUser.getNickname());
+            commentInfo.put("avatar", commentUser.getAvatar());
+            Map paramPicture = new HashMap();
+            paramPicture.put("comment_id", hotComment.get(0).getId());
+            List<CommentPictureVo> commentPictureEntities = commentPictureService.queryList(paramPicture);
+            commentInfo.put("pic_list", commentPictureEntities);
+        }
+        Map comment = new HashMap();
+        comment.put("count", commentCount);
+        comment.put("data", commentInfo);
+        //当前用户是否收藏
+        Map collectParam = new HashMap();
+        collectParam.put("user_id", getUserId());
+        collectParam.put("value_id", id);
+        collectParam.put("type_id", 2);
+        Integer userHasCollect = collectService.queryTotal(collectParam);
+        if (userHasCollect > 0) {
+            userHasCollect = 1;
+        }
+        //记录用户的足迹
+        FootprintVo footprintEntity = new FootprintVo();
+        footprintEntity.setAdd_time(System.currentTimeMillis() / 1000);
+        footprintEntity.setGoods_brief(info.getGoods_brief());
+        footprintEntity.setList_pic_url(info.getList_pic_url());
+        footprintEntity.setGoods_id(info.getId());
+        footprintEntity.setName(info.getName());
+        footprintEntity.setRetail_price(info.getRetail_price());
+        footprintEntity.setUser_id(userId);
+        if (null != referrer) {
+            footprintEntity.setReferrer(referrer);
+        } else {
+            footprintEntity.setReferrer(0L);
+        }
+        footprintService.save(footprintEntity);
+        //
+        info.setGoodsBizType(StringUtils.isEmpty(info.getGoodsBizType())?"": Dict.orderBizType.valueOf("item_"+ info.getGoodsBizType()).getItemName());
+        resultObj.put("groupVo", groupVo);
+        resultObj.put("info", info);
+        resultObj.put("gallery", gallery);
+        resultObj.put("attribute", attribute);
+        resultObj.put("userHasCollect", userHasCollect);
+        resultObj.put("issue", issue);
+        resultObj.put("comment", comment);
+        resultObj.put("specificationList", specificationList);
+        resultObj.put("productList", productEntityList);
+        return toResponsSuccess(resultObj);
+    }
+}

+ 339 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiGoodsGroupOpenController.java

@@ -0,0 +1,339 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.DateUtils;
+import org.apache.commons.collections.MapUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/groupopen")
+public class ApiGoodsGroupOpenController extends ApiBaseAction {
+    @Autowired
+    private ApiGoodsGroupOpenService apiGoodsGroupOpenService;
+    @Autowired
+    private ApiGoodsGroupService apiGoodsGroupService;
+    @Autowired
+    private ApiGoodsService apiGoodsService;
+    @Autowired
+    private ApiGoodsSpecificationService apiGoodsSpecificationService;
+    @Autowired
+    private ApiProductService apiProductService;
+    @Autowired
+    private ApiGoodsGalleryService apiGoodsGalleryService;
+    @Autowired
+    private ApiGoodsIssueService goodsIssueService;
+    @Autowired
+    private ApiAttributeService attributeService;
+    @Autowired
+    private ApiCommentService commentService;
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private ApiCommentPictureService commentPictureService;
+    @Autowired
+    private ApiCollectService collectService;
+    @Autowired
+    private ApiFootprintService footprintService;
+    @Autowired
+    private ApiAddressService apiAddressService;
+    @Autowired
+    private ApiGoodsGroupOpenDetailService apiGoodsGroupOpenDetailService;
+
+    /**
+     * 已经开团列表
+     *
+     * @param type    参团状态 0待付款 1拼团中 2拼团成功 3拼团失败
+     * @param groupId 团购Id
+     * @return
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(Integer type, Integer groupId) {
+        Map param = new HashMap();
+        param.put("sidx", "open_time");
+        param.put("order", "desc");
+        param.put("group_id", groupId);
+        param.put("attend_status", type);
+        param.put("end_time", new Date());
+        //查询列表数据
+        List<GoodsGroupOpenVo> list = apiGoodsGroupOpenService.queryList(param);
+        return toResponsSuccess(list);
+    }
+
+    /**
+     * 正在拼团的人
+     *
+     * @param openId 开团Id
+     * @return
+     */
+    @IgnoreAuth
+    @GetMapping("attendList")
+    public Object attendList(Long openId) {
+        Map param = new HashMap();
+        param.put("open_id", openId);
+        param.put("attend_statuss", new Integer[]{1, 2, 3});
+        //查询列表数据
+        List<GoodsGroupOpenDetailVo> list = apiGoodsGroupOpenDetailService.queryList(param);
+        //
+        GoodsGroupOpenVo openVo = apiGoodsGroupOpenService.queryObject(openId);
+        if (null != list && list.size() > 0) {
+            for (GoodsGroupOpenDetailVo detailVo : list) {
+                if (openVo.getUser_id().equals(detailVo.getUser_id())) {
+                    detailVo.setGroup_head(1);
+                }
+            }
+            Collections.sort(list, new Comparator<GoodsGroupOpenDetailVo>() {
+                @Override
+                public int compare(GoodsGroupOpenDetailVo o1, GoodsGroupOpenDetailVo o2) {
+                    return o2.getGroup_head().compareTo(o1.getGroup_head());
+                }
+            });
+        }
+        return toResponsSuccess(list);
+    }
+
+    /**
+     * 已经开团列表
+     *
+     * @param loginUser
+     * @return
+     */
+    @GetMapping("myList")
+    public Object myList(@LoginUser UserVo loginUser) {
+        Map param = new HashMap();
+        param.put("sidx", "open_time");
+        param.put("order", "desc");
+        param.put("user_id", getUserId());
+        //查询列表数据
+        List<GoodsGroupOpenDetailVo> list = apiGoodsGroupOpenDetailService.queryList(param);
+        return toResponsSuccess(list);
+    }
+
+    /**
+     * 团购商品详情页数据
+     */
+    @GetMapping("groupInfo")
+    public Object groupInfo(Long id, Long referrer) {
+        Map<String, Object> resultObj = new HashMap();
+        //
+        Long userId = getUserId();
+        Long storeId = getStoreId();
+        GoodsGroupVo groupVo = apiGoodsGroupService.queryObjectByStoreId(id, storeId);
+        GoodsVo info = apiGoodsService.queryObjectByStoreId(groupVo.getGoods_id(), storeId);
+        Map param = new HashMap();
+        param.put("goods_id", groupVo.getGoods_id());
+        param.put("store_id", getStoreId());
+        //
+        List<Map> specificationList = apiGoodsSpecificationService.queryByGoodsIdGroupByNames(groupVo.getGoods_id());
+        //
+        List<ProductVo> productEntityList = apiProductService.queryList(param);
+        //
+        List<GoodsGalleryVo> gallery = apiGoodsGalleryService.queryList(param);
+        Map ngaParam = new HashMap();
+        ngaParam.put("fields", "nga.value, na.name");
+        ngaParam.put("sidx", "nga.id");
+        ngaParam.put("order", "asc");
+        ngaParam.put("goods_id", groupVo.getGoods_id());
+        List<AttributeVo> attribute = attributeService.queryList(ngaParam);
+        //
+        Map issueParam = new HashMap();
+//        issueParam.put("goods_id", groupVo.getGoods_id());
+        List<GoodsIssueVo> issue = goodsIssueService.queryList(issueParam);
+        //
+        param.put("value_id", groupVo.getGoods_id());
+        param.put("type_id", 0);
+        Integer commentCount = commentService.queryTotal(param);
+        List<CommentVo> hotComment = commentService.queryList(param);
+        Map commentInfo = new HashMap();
+        if (null != hotComment && hotComment.size() > 0) {
+            UserVo commentUser = userService.queryObject(hotComment.get(0).getUserId());
+            commentInfo.put("content", hotComment.get(0).getContent());
+            commentInfo.put("add_time", DateUtils.timeToStr(hotComment.get(0).getAddTime(), DateUtils.DATE_PATTERN));
+            commentInfo.put("nickname", commentUser.getNickname());
+            commentInfo.put("avatar", commentUser.getAvatar());
+            Map paramPicture = new HashMap();
+            paramPicture.put("comment_id", hotComment.get(0).getId());
+            List<CommentPictureVo> commentPictureEntities = commentPictureService.queryList(paramPicture);
+            commentInfo.put("pic_list", commentPictureEntities);
+        }
+        Map comment = new HashMap();
+        comment.put("count", commentCount);
+        comment.put("data", commentInfo);
+        //当前用户是否收藏
+        Map collectParam = new HashMap();
+        collectParam.put("user_id", getUserId());
+        collectParam.put("value_id", id);
+        collectParam.put("type_id", 2);
+        Integer userHasCollect = collectService.queryTotal(collectParam);
+        if (userHasCollect > 0) {
+            userHasCollect = 1;
+        }
+        //记录用户的足迹
+        FootprintVo footprintEntity = new FootprintVo();
+        footprintEntity.setAdd_time(System.currentTimeMillis() / 1000);
+        footprintEntity.setGoods_brief(info.getGoods_brief());
+        footprintEntity.setList_pic_url(info.getList_pic_url());
+        footprintEntity.setGoods_id(info.getId());
+        footprintEntity.setName(info.getName());
+        footprintEntity.setRetail_price(info.getRetail_price());
+        footprintEntity.setUser_id(userId);
+        if (null != referrer) {
+            footprintEntity.setReferrer(referrer);
+        } else {
+            footprintEntity.setReferrer(0L);
+        }
+        footprintService.save(footprintEntity);
+        // 是否已经有开团了
+        Map openParam = new HashMap();
+        openParam.put("group_id", id);
+        openParam.put("attend_status", 1);
+        List<GoodsGroupOpenVo> groupOpenVos = apiGoodsGroupOpenService.queryList(openParam);
+        //
+        resultObj.put("groupVo", groupVo);
+        resultObj.put("info", info);
+        resultObj.put("gallery", gallery);
+        resultObj.put("attribute", attribute);
+        resultObj.put("userHasCollect", userHasCollect);
+        resultObj.put("issue", issue);
+        resultObj.put("comment", comment);
+        resultObj.put("specificationList", specificationList);
+        resultObj.put("productList", productEntityList);
+        resultObj.put("groupOpenVos", groupOpenVos);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 获取团单详情
+     */
+    @GetMapping("info")
+    public Object info(Long openId) {
+        GoodsGroupOpenVo openVo = apiGoodsGroupOpenService.queryObject(openId);
+        return toResponsSuccess(openVo);
+    }
+
+    /**
+     * 团购商品详情页数据
+     */
+    @GetMapping("groupOpenDetail")
+    public Object groupOpenDetail(Long detailId) {
+        // 团购明细
+        GoodsGroupOpenDetailVo openDetailVo = apiGoodsGroupOpenDetailService.queryObject(detailId);
+
+        return toResponsSuccess(openDetailVo);
+    }
+
+    /**
+     * 开团
+     */
+    @PostMapping("openGroup")
+    public Object openGroup() {
+        Map resultObj = null;
+        JSONObject jsonParam = getJsonRequest();
+        Long groupId = jsonParam.getLong("groupId");
+        Long productId = jsonParam.getLong("productId");
+        String postscript = jsonParam.getString("postscript");
+        Integer number = jsonParam.getInteger("number");
+        Long addressId = jsonParam.getLong("addressId");
+        String delivery_remark = jsonParam.getString("delivery_remark");
+        try {
+            if (com.kmall.common.utils.StringUtils.isNullOrEmpty(delivery_remark)) {
+                delivery_remark = "尽快送达";
+            }
+            resultObj = apiGoodsGroupOpenService.openGroup(groupId, productId, postscript,
+                    number, getUserId(), addressId, getStoreId(), delivery_remark);
+            if (null != resultObj) {
+                return toResponsObject(MapUtils.getInteger(resultObj, "errno"), MapUtils.getString(resultObj, "errmsg"), resultObj.get("data"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("开团失败");
+    }
+
+    /**
+     * 已经存在团购,参团
+     */
+    @PostMapping("attendGroup")
+    public Object attendGroup() {
+        Map resultObj = null;
+        JSONObject jsonParam = getJsonRequest();
+        Long openId = jsonParam.getLong("openId");
+        Long productId = jsonParam.getLong("productId");
+        String postscript = jsonParam.getString("postscript");
+        Integer number = jsonParam.getInteger("number");
+        Long addressId = jsonParam.getLong("addressId");
+        String delivery_remark = jsonParam.getString("delivery_remark");
+        try {
+            if (com.kmall.common.utils.StringUtils.isNullOrEmpty(delivery_remark)) {
+                delivery_remark = "尽快送达";
+            }
+            resultObj = apiGoodsGroupOpenService.attendGroup(openId, productId, postscript,
+                    number, getUserId(), addressId, delivery_remark);
+            if (null != resultObj) {
+                return toResponsObject(MapUtils.getInteger(resultObj, "errno"), MapUtils.getString(resultObj, "errmsg"), resultObj.get("data"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("参团失败");
+    }
+
+    /**
+     * 团购订单提交
+     */
+    @GetMapping("groupcheck")
+    public Object groupcheck(@LoginUser UserVo loginUser, Long groupId, Long productId, Integer number) {
+        Map<String, Object> resultObj = new HashMap();
+        // 默认全国包邮
+        BigDecimal freightPrice = Constant.ZERO;
+        Long storeId = getStoreId();
+        //
+        GoodsGroupVo groupVo = apiGoodsGroupService.queryObjectByStoreId(groupId, storeId);
+
+        GoodsVo goodsVo = apiGoodsService.queryObjectByStoreId(groupVo.getGoods_id(), storeId);
+
+        ProductVo productVo = apiProductService.queryObjectByStoreId(productId, getStoreId());
+        //计算订单的费用
+        BigDecimal orderPrice = groupVo.getRetail_min_price().multiply(new BigDecimal(number));
+
+        //获取可用的优惠券信息
+        Map usercouponMap = new HashMap();
+        usercouponMap.put("user_id", loginUser.getId());
+
+        resultObj.put("freightPrice", freightPrice);
+        resultObj.put("goodsPrice", groupVo.getRetail_min_price());
+        resultObj.put("orderPrice", orderPrice);
+        resultObj.put("actualPrice", orderPrice);
+        resultObj.put("number", number);
+        //
+        resultObj.put("productVo", productVo);
+        resultObj.put("goodsVo", goodsVo);
+        // 地址
+        Map<String, Object> map = new HashMap();
+        map.put("is_default", 1);
+        map.put("user_id", loginUser.getId());
+        List<AddressVo> list = apiAddressService.queryList(map);
+        if (null != list && list.size() > 0) {
+            resultObj.put("addressVo", list.get(0));
+        }
+        return toResponsSuccess(resultObj);
+    }
+}

+ 59 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiHelpIssueController.java

@@ -0,0 +1,59 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.entity.HelpIssueVo;
+import com.kmall.api.entity.HelpTypeVo;
+import com.kmall.api.service.ApiHelpIssueService;
+import com.kmall.api.service.ApiHelpTypeService;
+import com.kmall.api.util.ApiBaseAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Controller
+ *
+ * @author Scott
+ * @email
+ * @date 2017-12-02 10:04:20
+ */
+@RestController
+@RequestMapping("api/helpissue")
+public class ApiHelpIssueController extends ApiBaseAction {
+    @Autowired
+    private ApiHelpIssueService helpIssueService;
+    @Autowired
+    private ApiHelpTypeService helpTypeService;
+
+    /**
+     * 查看帮助类型列表
+     */
+    @GetMapping("/typeList")
+    @IgnoreAuth
+    public Object typeList() {
+
+        List<HelpTypeVo> list = helpTypeService.queryList(new HashMap());
+
+        return toResponsSuccess(list);
+    }
+
+    /**
+     * 查看问题列表
+     */
+    @GetMapping("/issueList")
+    @IgnoreAuth
+    public Object issueList(Long type_id,String merchSn) {
+
+        Map params = new HashMap();
+        params.put("type_id", type_id);
+        params.put("merchSn",merchSn);
+        List<HelpIssueVo> helpIssueList = helpIssueService.queryList(params);
+
+        return toResponsSuccess(helpIssueList);
+    }
+}

+ 168 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiIndexController.java

@@ -0,0 +1,168 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.dto.IdCardMsgVo;
+import com.kmall.api.dto.SendMsgVo;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.IdCardUtil;
+import com.kmall.common.utils.RRException;
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpUtils;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/index")
+public class ApiIndexController extends ApiBaseAction {
+    protected Logger log = Logger.getLogger(ApiIndexController.class);
+    @Autowired
+    private ApiAdService apiAdService;
+    @Autowired
+    private ApiChannelService channelService;
+    @Autowired
+    private ApiGoodsService goodsService;
+    @Autowired
+    private ApiCartService cartService;
+    @Autowired
+    private ApiOrderService apiOrderService;
+    @Autowired
+    private ApiUserService apiUserService;
+
+    /**
+     * app首页
+     */
+    @IgnoreAuth
+    @GetMapping("index")
+    public Object index() {
+        Map<String, Object> resultObj = new HashMap();
+        // init
+        Long userId = getUserId();
+        Long storeId = getStoreId();
+        //
+        Map param = new HashMap();
+//        param.put("ad_position_ids", new Integer[]{1, 2, 3});
+        param.put("ad_position_ids", new Integer[]{1});//用户注册
+        param.put("storeId",storeId);
+        List<AdVo> adVos = apiAdService.queryList(param);
+        //
+        List<AdVo> banner = new ArrayList();
+        if (null != adVos && adVos.size() > 0) {
+            for (AdVo adVo : adVos) {
+                if (adVo.getAdPositionId() == 1) {
+                    banner.add(adVo);
+                } else if (adVo.getAdPositionId() == 2) {
+                    resultObj.put("groupBanner", adVo);
+                }
+            }
+        }
+        resultObj.put("banner", banner);
+        //
+        param = new HashMap();
+        param.put("sidx", "sort_order ");
+        param.put("order", "asc ");
+        List<ChannelVo> channel = channelService.queryList(param);
+        resultObj.put("channel", channel);
+        // 超级折扣,需要门店过滤
+        param = new HashMap();
+        param.put("fields", "distinct a.id,a.name,a.goods_brief,a.list_pic_url,psr1.retail_price,psr1.market_price,b.id as product_id,psr1.stock_num");
+        param.put("is_hot", "1");
+        param.put("offset", 0);
+        param.put("limit", 3);
+        param.put("is_delete", 0);
+        param.put("store_id", storeId);
+        List<GoodsVo> hotGoods = goodsService.queryHotGoodsList(param);
+        resultObj.put("hotGoodsList", hotGoods);
+        // 当前购物车中
+        List<CartVo> cartList = new ArrayList();
+        if (null != userId) {
+            //查询列表数据
+            Map cartParam = new HashMap();
+            cartParam.put("user_id", userId);
+            cartParam.put("store_id", storeId);
+            cartList = cartService.queryList(cartParam);
+        }
+        if (null != cartList && cartList.size() > 0 && null != hotGoods && hotGoods.size() > 0) {
+            for (GoodsVo goodsVo : hotGoods) {
+                for (CartVo cartVo : cartList) {
+                    if (goodsVo.getId().equals(cartVo.getGoods_id())) {
+                        goodsVo.setCart_num(cartVo.getNumber());
+                    }
+                }
+            }
+        }
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 个人中心主页,是否是骑手
+     */
+    @GetMapping("ucenterIndex")
+    public Object ucenterIndex() {
+        Map resultObj = new HashMap();
+        Long userId = getUserId();
+        // 统计个人中心订单数据
+        Map params = new HashMap();
+        params.put("user_id", userId);
+        Map countMap = apiOrderService.queryUcenterMap(params);
+        resultObj.put("countMap", countMap);
+        return toResponsSuccess(resultObj);
+    }
+
+    @PostMapping("idCardRealName")
+    public Object idCardRealName(@LoginUser UserVo loginUser) {
+        JSONObject jsonParam = getJsonRequest();
+
+        Long userId = getUserId();
+        String idNo = jsonParam.getString("idNo");
+        String username = jsonParam.getString("userName");
+        UserVo user = apiUserService.queryObjectByIdNoAndName(idNo, username);
+        UserVo userVo = new UserVo();
+        userVo.setUsername(username);
+        userVo.setIdNo(idNo);
+        userVo.setId(userId);
+        try {
+            if(user != null){
+                if(loginUser.getId() != user.getId()){
+                    return toResponsFail("该身份证信息已被绑定");
+                }
+            }
+            //实名认证身份证信息
+            String result = IdCardUtil.checkIdCard(idNo, username);
+            logger.info("idcard check result:"+result);
+            IdCardMsgVo vo = JSON.parseObject(result,IdCardMsgVo.class);
+            if(vo.getRespCode().equalsIgnoreCase("0000")){
+                apiUserService.update(userVo);
+                return toResponsMsgSuccess("实名绑定成功");
+            }else{
+                return toResponsFail(vo.getRespMessage());
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return toResponsFail("系统异常");
+        }
+    }
+    public static void main(String[] args) {
+
+    }
+
+}

+ 473 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java

@@ -0,0 +1,473 @@
+package com.kmall.api.api;
+
+import com.alibaba.druid.util.StringUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.service.express.kdn.ApiKdniaoService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.service.print.ticket.PrintTicketPropertiesBuilder;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.Query;
+import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.WechatUtil;
+import org.apache.commons.collections.MapUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/order")
+public class ApiOrderController extends ApiBaseAction {
+    @Autowired
+    private ApiOrderService orderService;
+    @Autowired
+    private ApiOrderGoodsService orderGoodsService;
+    @Autowired
+    private ApiKD100Service apiKD100Service;
+    @Autowired
+    private ApiKdniaoService apiKdniaoService;
+    @Autowired
+    private ApiAddressService apiAddressService;
+    @Autowired
+    private ApiCommentService apiCommentService;
+    @Autowired
+    private ApiOrderProcessRecordService orderProcessRecordService;
+    @Autowired
+    private ApiOrderRefundService apiOrderRefundService;
+    @Autowired
+    private ApiStoreService apiStoreService;
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        //
+        return toResponsSuccess("");
+    }
+
+    /**
+     * 获取订单列表
+     */
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser,
+                       @RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size,
+                       Integer evaluate_status, Integer order_status) {
+        //
+        Map params = new HashMap();
+        params.put("user_id", loginUser.getId());
+        params.put("page", page);
+        params.put("order_status", order_status);
+        params.put("evaluate_status", evaluate_status);
+        params.put("limit", size);
+        params.put("sidx", "add_time");
+        params.put("order", "desc");
+        params.put("size", "desc");
+        if(order_status != null) {
+            if (order_status == Integer.parseInt(Dict.orderStatus.item_401.getItem())) {
+                params.put("pay_status", Dict.payStatus.item_4.getItem());
+            }
+        }
+        //查询列表数据
+        Query query = new Query(params);
+        List<OrderVo> orderEntityList = orderService.queryList(query);
+        int total = orderService.queryTotal(query);
+        //
+        for (OrderVo item : orderEntityList) {
+            Map orderGoodsParam = new HashMap();
+            orderGoodsParam.put("order_id", item.getId());
+            if(item.getRefundStatus() !=null){
+                if(item.getRefundStatus().equalsIgnoreCase(Dict.RefundStatus.item_1.getItem()) ||
+                        item.getRefundStatus().equalsIgnoreCase(Dict.RefundStatus.item_2.getItem())){
+                    item.setIsRefundStatus(true);
+                }else{
+                    item.setIsRefundStatus(false);
+                }
+            }else{
+                item.setIsRefundStatus(false);
+            }
+
+            //订单的商品
+            List<OrderGoodsVo> goodsList = orderGoodsService.queryList(orderGoodsParam);
+            Integer goodsCount = 0;
+            for (OrderGoodsVo orderGoodsEntity : goodsList) {
+                goodsCount += orderGoodsEntity.getNumber();
+                item.setGoodsCount(goodsCount);
+            }
+            item.setGoodsList(goodsList);
+        }
+        ApiPageUtils pageUtil = new ApiPageUtils(orderEntityList, total, query.getLimit(), query.getPage());
+        return toResponsSuccess(pageUtil);
+    }
+
+    /**
+     * 获取订单详情
+     */
+    @GetMapping("detail")
+    public Object detail(@LoginUser UserVo loginUser, Long orderId) {
+        Map resultObj = new HashMap();
+        //
+        OrderVo orderInfo = orderService.queryObject(orderId);
+        if (null == orderInfo) {
+            return toResponsObject(400, "订单不存在", "");
+        }
+        Map orderGoodsParam = new HashMap();
+        orderGoodsParam.put("order_id", orderId);
+        //订单的商品
+        List<OrderGoodsVo> orderGoods = orderGoodsService.queryList(orderGoodsParam);
+
+        //订单可操作的选择,删除,支付,收货,评论,退换货
+        Map handleOption = orderInfo.getHandleOption();
+        resultObj.put("orderInfo", orderInfo);
+        resultObj.put("orderGoods", orderGoods);
+        resultObj.put("handleOption", handleOption);
+
+        //查询物流轨迹
+        List<Map> mapList = new ArrayList<>();
+        OrderProcessRecordEntity entity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+        if (entity != null) {
+            if((orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem()) ||
+                    orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem()))){
+                Map map = new HashMap();
+                map.put("AcceptStation", PrintTicketPropertiesBuilder.instance().getAddress()
+                        + "送达" + apiStoreService.queryObject(orderInfo.getStore_id()).getStoreAddress()
+                        + ";交易完成,用户已提走");
+                mapList.add(map);
+            }else{
+                if (!StringUtils.isEmpty(orderInfo.getShipping_code()) && !StringUtils.isEmpty(orderInfo.getShipping_no()) &&entity.getShipmentStartTime()!=null) {
+                    JSONObject Traces = apiKdniaoService.getOrderTracesByJson(orderInfo.getShipping_code(), orderInfo.getShipping_no());
+                    if (Traces != null) {
+                        mapList = (List<Map>) Traces.get("Traces");
+                        String State = (String) Traces.get("State"); //物流状态:2-在途中,3-签收,4-问题件
+                        if (Dict.logisticsStatus.item_0.getItem().equalsIgnoreCase(State)) {
+                            Map noDataMap = new HashMap();
+                            noDataMap.put("AcceptTime", "");
+                            noDataMap.put("AcceptStation", Traces.get("Reason"));
+                            mapList.add(noDataMap);
+                        }
+                    }
+                }
+            }
+            if (Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsCustomsSend()) && entity.getShipmentStartTime() != null) {
+                Map map = new HashMap();
+                map.put("AcceptTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getShipmentStartTime()));
+                map.put("AcceptStation", "订单已出库");
+                mapList.add(map);
+            }
+            if (Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsCustomsSend())) {
+                Map map = new HashMap();
+                map.put("AcceptTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getCustomsSuccTime()));
+                map.put("AcceptStation", "订单清关完成,等待仓库发货");
+                mapList.add(map);
+            }
+            if (Dict.isSend.item_0.getItem().equalsIgnoreCase(entity.getIsCustomsSend())) {
+                Map map = new HashMap();
+                map.put("AcceptTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getCustomsSuccTime()));
+                map.put("AcceptStation", "订单清关失败");
+                mapList.add(map);
+            }
+            if (Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsPaymentSend())) {
+                Map map = new HashMap();
+                map.put("AcceptTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getPaySuccTime()));
+                map.put("AcceptStation", "订单支付成功");
+                mapList.add(map);
+            }
+            if (Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsAddOrderSend())) {
+                Map map = new HashMap();
+                map.put("AcceptTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getAddOrderSuccTime()));
+                map.put("AcceptStation", "客户下单成功");
+                mapList.add(map);
+            }
+        }
+        resultObj.put("wuliu", mapList != null && mapList.size() > 0 ? mapList.get(0) : null);
+
+        if(orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_401.getItem()) || orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_402.getItem()) ) {
+            MallOrderRefund refundInfo = apiOrderRefundService.queryObjectByOrderId(String.valueOf(orderInfo.getId()));
+            resultObj.put("refundInfo", refundInfo);
+        }
+
+        return toResponsSuccess(resultObj);
+    }
+
+    @GetMapping("detailList")
+    public Object detailList(@LoginUser UserVo loginUser, Long[] orderIds,Integer status) {
+        List<Long> orderIdList=new ArrayList<>();
+        for(int i=0;i<orderIds.length;i++){
+            orderIdList.add(orderIds[i]);
+        }
+        Map resultObj = new HashMap();
+
+        List<OrderVo> orderVoList = orderService.queryObjectByIdList(orderIdList);
+        BigDecimal actualPrice = Constant.ZERO;
+
+        for (OrderVo orderInfo:orderVoList) {
+            if (null == orderInfo) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单不存在", "");
+            }
+            actualPrice = actualPrice.add(orderInfo.getActual_price());
+            if (status == 0) {
+                OrderVo orderVo = new OrderVo();
+                orderVo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_0.getItem()));
+                orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_0.getItem()));
+                orderVo.setId(orderInfo.getId());
+                orderService.update(orderVo);
+            }
+        }
+        //订单的商品
+        List<OrderGoodsVo> orderGoods = orderGoodsService.queryListByIds(orderIdList);
+        resultObj.put("actualPrice", actualPrice);
+        resultObj.put("orderGoods", orderGoods);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 获取订单列表
+     */
+    @PostMapping("submit")
+    public Object submit(@LoginUser UserVo loginUser) {
+        Map resultObj = null;
+        try {
+            resultObj = orderService.submit(getJsonRequest(), loginUser, getStoreId());
+            if (null != resultObj) {
+                return toResponsObject(MapUtils.getInteger(resultObj, "errno"), MapUtils.getString(resultObj, "errmsg"), resultObj.get("data"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("提交失败");
+    }
+
+    /**
+     * 取消订单
+     */
+    @GetMapping("cancelOrder")
+    public Object cancelOrder(@LoginUser UserVo loginUser, Long orderId) {
+        try {
+            OrderVo orderVo = orderService.queryObject(orderId);
+            if (orderVo.getOrder_status() == 300) {
+                return toResponsFail("已发货,不能取消");
+            } else if (orderVo.getOrder_status() == 301) {
+                return toResponsFail("已收货,不能取消");
+            } else if (orderVo.getOrder_status() == 101 || orderVo.getOrder_status() == 401 || orderVo.getOrder_status() == 402) {
+                return toResponsFail("当前订单不能取消");
+            }
+            // 需要退款
+            if (orderVo.getPay_status() == 2) {
+                WechatRefundApiResult result = WechatUtil.wxRefund(orderVo.getMerchOrderSn().toString(),
+                        orderVo.getActual_price().doubleValue(), orderVo.getActual_price().doubleValue());
+                if (result.getResult_code().equals(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                    if (orderVo.getOrder_status() == 201) {
+                        orderVo.setOrder_status(401);
+                    } else if (orderVo.getOrder_status() == 300) {
+                        orderVo.setOrder_status(402);
+                    }
+                    orderVo.setPay_status(4);
+                    orderService.cancelOrder(orderVo);
+                    return toResponsMsgSuccess("取消成功");
+                } else {
+                    return toResponsFail("取消失败");
+                }
+            } else {
+                orderVo.setOrder_status(101);
+                orderService.cancelOrder(orderVo);
+                return toResponsSuccess("取消成功");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("提交失败");
+    }
+
+    /**
+     * 确认收货
+     */
+    @GetMapping("confirmOrder")
+    public Object confirmOrder(@LoginUser UserVo loginUser, Long orderId) {
+        try {
+            if (null == orderId) {
+                JSONObject params = getJsonRequest();
+                orderId = params.getLong("orderId");
+            }
+            orderService.confirmOrder(orderId);
+            return toResponsSuccess("取消成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("提交失败");
+    }
+
+    /**
+     * 跟踪快递轨迹
+     */
+    @GetMapping("getLogistics")
+    public Object getLogistics(Long orderId) {
+        Map resultObj = new HashMap();
+        Map map = new HashMap();
+        OrderVo orderInfo = orderService.queryObject(orderId);
+        if (null == orderInfo) {
+            return toResponsObject(400, "订单不存在", "");
+        }
+        List<WuliuVo> wuliuList = new ArrayList<WuliuVo>();
+
+        OrderProcessRecordEntity entity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+        if(entity !=null){
+            if(orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())
+                    || orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem())){
+                WuliuVo vo = new WuliuVo();
+                vo.setAcceptStation(PrintTicketPropertiesBuilder.instance().getAddress()
+                        + "送达" + apiStoreService.queryObject(orderInfo.getStore_id()).getStoreAddress()
+                        + ";交易完成,用户已提走");
+                wuliuList.add(vo);
+            }else {
+                if (!StringUtils.isEmpty(orderInfo.getShipping_code()) && !StringUtils.isEmpty(orderInfo.getShipping_no()) && entity.getShipmentStartTime() != null) {
+                    // 快递
+                    JSONObject Traces = apiKdniaoService.getOrderTracesByJson(orderInfo.getShipping_code(), orderInfo.getShipping_no());
+                    List<Map> mapList = (List<Map>) Traces.get("Traces");
+                    if(mapList!=null&&mapList.size()>0) {
+                        for (int i = 0; i < mapList.size(); i++) {
+                            WuliuVo vo = new WuliuVo();
+                            vo.setAcceptTime((String) mapList.get(i).get("AcceptTime"));
+                            vo.setAcceptStation((String) mapList.get(i).get("AcceptStation"));
+                            wuliuList.add(vo);
+                        }
+                    }
+                    String State = (String) Traces.get("State"); //物流状态:2-在途中,3-签收,4-问题件
+                    String Reason = (String) Traces.get("Reason");
+                    if (Dict.logisticsStatus.item_0.getItem().equalsIgnoreCase(State)) {
+                        WuliuVo wuliuVo = new WuliuVo();
+                        wuliuVo.setAcceptStation(Reason);
+                        wuliuList.add(wuliuVo);
+                    }
+                    map.put("State", Traces.get("State")); //物流状态:2-在途中,3-签收,4-问题件
+                    map.put("Reason", Traces.get("Reason"));
+                }
+            }
+            if (Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsCustomsSend()) && entity.getShipmentStartTime() != null) {
+                WuliuVo wuliuVo = new WuliuVo();
+                wuliuVo.setAcceptStation("订单已出库");
+                wuliuVo.setAcceptTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getShipmentStartTime()));
+                wuliuList.add(wuliuVo);
+            }
+            if(Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsCustomsSend())){
+                WuliuVo wuliuVo = new WuliuVo();
+                wuliuVo.setAcceptStation("订单清关完成,等待仓库发货");
+                wuliuVo.setAcceptTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getCustomsSuccTime()));
+                wuliuList.add(wuliuVo);
+            }
+            if (Dict.isSend.item_0.getItem().equalsIgnoreCase(entity.getIsCustomsSend())) {
+                WuliuVo wuliuVo = new WuliuVo();
+                wuliuVo.setAcceptStation("订单清关失败");
+                wuliuList.add(wuliuVo);
+            }
+            if(Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsPaymentSend())){
+                WuliuVo wuliuVo = new WuliuVo();
+                wuliuVo.setAcceptStation("订单支付成功");
+                wuliuVo.setAcceptTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getPaySuccTime()));
+                wuliuList.add(wuliuVo);
+            }
+            if(Dict.isSend.item_1.getItem().equalsIgnoreCase(entity.getIsAddOrderSend())){
+                WuliuVo wuliuVo = new WuliuVo();
+                wuliuVo.setAcceptStation("订单下单成功");
+                wuliuVo.setAcceptTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(entity.getAddOrderSuccTime()));
+                wuliuList.add(wuliuVo);
+            }
+        }
+        map.put("TracesList",wuliuList);
+        map.put("LogisticCode", orderInfo.getShipping_no());
+        map.put("ShipperCode",  orderInfo.getShipping_code());
+        resultObj.put("wuliu", map);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     * 申请退款
+     * @param loginUser
+     * @return
+     */
+    @PostMapping("saveApplyRefund")
+    public Object saveApplyRefund(@LoginUser UserVo loginUser) {
+        try {
+            JSONObject json = getJsonRequest();
+            String orderId = json.getString("orderId");
+            String merchOrderSn = json.getString("merchOrderSn");
+            String refundReason = json.getString("refundReason");
+            List<OrderVo> list = orderService.queryObjectByMerchOrderSn(merchOrderSn);
+            OrderVo orderInfo = null;
+            if(list!=null && list.size()>0){
+                for (OrderVo vo: list) {
+                    if(Long.valueOf(orderId).equals(vo.getId())){
+                        orderInfo = vo;
+                    }
+                }
+            }
+            if (null == orderInfo) {
+                return toResponsObject(400, "订单不存在", "");
+            }
+            if (orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_401.getItem()) ||
+                    orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_402.getItem())) {
+                return toResponsObject(400, "订单已退款", "");
+            }
+            OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+            if(org.apache.commons.lang.StringUtils.isNotEmpty(processRecordEntity.getIsCustomsSend())) {
+                if (processRecordEntity.getIsCustomsSend().equalsIgnoreCase("2")) {
+                    return toResponsObject(400, "订单正在清关中,不能申请退款", "");
+                }
+                if (processRecordEntity.getIsCustomsSend().equalsIgnoreCase("1")) {
+                    return toResponsObject(400, "订单已清关完成,不能申请退款", "");
+                }
+            }
+            MallOrderRefund mallOrderRefund = apiOrderRefundService.queryObjectByOrderId(orderInfo.getId()+"");
+            MallOrderRefund orderRefund = new MallOrderRefund();
+            orderRefund.setOrderId(Integer.parseInt(orderId));
+            orderRefund.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_1.getItem()));
+            orderRefund.setRefundReason(refundReason);
+            orderRefund.setModTime(new Date());
+            if(list.size()>1){//多条订单
+                orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_2.getItem()));//部分退款
+            }else{
+                orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));//用户全额退款
+            }
+            orderRefund.setRefundMoney(orderInfo.getActual_price());
+
+            if(mallOrderRefund !=null){
+                if(mallOrderRefund.getRefundStatus() == Integer.parseInt(Dict.RefundStatus.item_2.getItem()) ){
+                    return toResponsFail("该订单已退款成功,请勿重复申请");
+                }
+                if(mallOrderRefund.getRefundStatus() == Integer.parseInt(Dict.RefundStatus.item_5.getItem()) ){
+                    return toResponsFail("该订单在退款处理中,请勿重复申请");
+                }
+                if(mallOrderRefund.getRefundStatus() == Integer.parseInt(Dict.RefundStatus.item_1.getItem()) ){
+                    return toResponsFail("该订单在退款申请中,请勿重复申请");
+                }
+                orderRefund.setId(mallOrderRefund.getId());
+                apiOrderRefundService.update(orderRefund);
+                if(mallOrderRefund.getRefundStatus() == Integer.parseInt(Dict.RefundStatus.item_4.getItem()) ||
+                        mallOrderRefund.getRefundStatus() == Integer.parseInt(Dict.RefundStatus.item_3.getItem())){
+                    return toResponsMsgSuccess("重新申请订单成功");
+                }
+            }else{
+                orderRefund.setCreateTime(new Date());
+                apiOrderRefundService.save(orderRefund);
+            }
+            return toResponsMsgSuccess("退款申请成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return toResponsFail("提交失败");
+    }
+}

+ 390 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiPayController.java

@@ -0,0 +1,390 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.dao.ApiOrderRefundMapper;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.service.pay.wxpay.WxPayPropertiesBuilder;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.CommonUtil;
+import com.kmall.common.utils.CharUtil;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.MapUtils;
+import com.kmall.common.utils.XmlUtil;
+import com.kmall.common.utils.wechat.AESUtil;
+import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.WechatRefundNotifyResult;
+import com.kmall.common.utils.wechat.WechatUtil;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/pay")
+public class ApiPayController extends ApiBaseAction {
+    private Logger logger = Logger.getLogger(ApiPayController.class);
+    @Autowired
+    private ApiOrderService orderService;
+    @Autowired
+    private ApiOrderGoodsService orderGoodsService;
+    @Autowired
+    private ApiPayService apiPayService;
+    @Autowired
+    private ApiOrderProcessRecordService orderProcessRecordService;
+    @Autowired
+    private ApiOrderExceptionRecordService apiOrderExceptionRecordService;
+
+    @Autowired
+    private ApiOrderRefundMapper mallOrderRefundMapper;
+
+    /**
+     */
+    @RequestMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        return toResponsSuccess("");
+    }
+
+    /**
+     * 获取支付的请求参数,用户生成订单, 商户订单号、预支付编号,且支付状态、订单状态均为支付中;
+     */
+    @GetMapping("pay_prepay")
+    public Object payPrepay(@LoginUser UserVo loginUser, Long[] orderIds,String isMergePay) {
+        List<Long> orderIdList=new ArrayList<>();
+        String merchOrderSn = "";
+        for(int i=0;i<orderIds.length;i++){
+            orderIdList.add(orderIds[i]);
+        }
+        BigDecimal actual_price = Constant.ZERO;
+        List<OrderVo> orderVoList = orderService.queryObjectByIdList(orderIdList);
+        List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
+
+        for (OrderVo orderInfo:orderVoList) {
+            if (orderInfo.getOrder_status() == 101) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单超时支付,已取消", "");
+            }
+            if (orderInfo.getPay_status() != 0 && orderInfo.getPay_status() != 1) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单已支付,请不要重复操作", "");
+            }
+            merchOrderSn = orderInfo.getMerchOrderSn();
+
+            //如此次是单笔支付,则判断下单时该商户订单是否是拆单订单,如果都满足,则更新商户订单号,生成新的预支付信息
+            if(Dict.isMergePay.item_0.getItem().equalsIgnoreCase(isMergePay)) {
+                if ("2".equalsIgnoreCase(orderInfo.getIsMergePay())) {//多笔订单单笔支付,则商户订单号,生成新的预支付信息
+//                    merchOrderSn = "EMATO" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
+                    merchOrderSn = "EMATO"+ CommonUtil.generateOrderNumber();
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                }
+            }
+
+            OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+            if(processRecordEntity != null){
+                OrderProcessRecordEntity entity = new OrderProcessRecordEntity();
+                entity.setOrderSn(orderInfo.getOrder_sn());
+                entity.setUserId(Integer.valueOf(loginUser.getId()+""));
+                entity.setPayStartTime(new Date());
+                entity.setId(processRecordEntity.getId());
+                processRecordEntityList.add(entity);
+            }
+            actual_price = actual_price.add(orderInfo.getActual_price());
+
+        }
+
+        String nonceStr = CharUtil.getRandomString(32);
+
+        //https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3
+        Map<Object, Object> resultObj = new HashMap();
+
+        try {
+            Map<Object, Object> parame = new TreeMap<>();
+            //parame.put("appid", ResourceUtil.getConfigByName("wx.appId"));
+            parame.put("appid", WxPayPropertiesBuilder.instance().getAppId());
+            //parame.put("mch_id", ResourceUtil.getConfigByName("wx.mchId"));// 商家账号。
+            parame.put("mch_id", WxPayPropertiesBuilder.instance().getMchId());// 商家账号。
+            String randomStr = CharUtil.getRandomNum(18).toUpperCase();
+            parame.put("nonce_str", randomStr);// 随机字符串
+            parame.put("out_trade_no", merchOrderSn);// 商户订单编号
+            parame.put("body", "中网跨境商城-支付");// 商品描述
+
+            //订单的商品
+//            List<OrderGoodsVo> orderGoods = orderGoodsService.queryListByIds(orderIdList);
+//            if (null != orderGoods) {
+//                String body = "商城-";
+//                for (OrderGoodsVo goodsVo : orderGoods) {
+//                    body = body + goodsVo.getGoods_name() + "、";
+//                }
+//                if (body.length() > 0) {
+//                    body = body.substring(0, body.length() - 1);
+//                }
+//                parame.put("body", body);// 商品描述
+//            }
+            //支付金额
+//            parame.put("total_fee", orderInfo.getActual_price().multiply(Constant.ONE_HUNDRED).intValue()));//todo 消费金额
+            parame.put("total_fee", actual_price.multiply(Constant.ONE_HUNDRED).intValue());// 消费金额
+            //parame.put("notify_url", ResourceUtil.getConfigByName("wx.notifyUrl"));// 回调地址
+            parame.put("notify_url", WxPayPropertiesBuilder.instance().getNotifyUrl());// 回调地址
+            //parame.put("trade_type", ResourceUtil.getConfigByName("wx.tradeType"));// 交易类型APP
+            parame.put("trade_type", WxPayPropertiesBuilder.instance().getTradeType());// 交易类型APP
+//            parame.put("spbill_create_ip", getClientIp());
+            //parame.put("spbill_create_ip", ResourceUtil.getConfigByName("spbillCreateIp"));
+            parame.put("spbill_create_ip", WxPayPropertiesBuilder.instance().getSpbillCreateIp());
+            parame.put("openid", loginUser.getWeixin_openid());
+//            parame.put("sign_type", "MD5");
+            //String sign = WechatUtil.arraySign(parame, ResourceUtil.getConfigByName("wx.paySignKey"));
+            String sign = WechatUtil.arraySign(parame, WxPayPropertiesBuilder.instance().getPaySignKey());
+            parame.put("sign", sign);// 数字签证
+
+            String xml = MapUtils.convertMap2Xml(parame);
+            logger.info("xml:" + xml);
+            //Map<String, Object> resultUn = XmlUtil.xmlStrToMap(WechatUtil.requestOnce(ResourceUtil.getConfigByName("wx.uniformorder"), xml));
+            Map<String, Object> resultUn = XmlUtil.xmlStrToMap(WechatUtil.requestOnce(WxPayPropertiesBuilder.instance().getUniformorder(), xml));
+            // 响应报文
+            String return_code = MapUtils.getString("return_code", resultUn);
+            String return_msg = MapUtils.getString("return_msg", resultUn);
+            //
+            if (return_code.equalsIgnoreCase("FAIL")) {
+//                updateFailProcessBatch(processRecordEntityList, "支付失败," +return_msg);//更新订单流转信息
+                addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败," +return_msg);//记录订单异常信息
+                return toResponsFail("支付失败," + return_msg);
+            } else if (return_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                // 返回数据
+                String result_code = MapUtils.getString("result_code", resultUn);
+                String err_code_des = MapUtils.getString("err_code_des", resultUn);
+                if (result_code.equalsIgnoreCase("FAIL")) {
+//                    updateFailProcessBatch(processRecordEntityList, "支付失败," +err_code_des);//更新订单流转信息
+                    addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(),"支付失败," +err_code_des);//记录订单异常信息
+                    return toResponsFail("支付失败," + err_code_des);
+                } else if (result_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                    apiPayService.payPrepay(resultObj, resultUn, nonceStr, orderVoList);
+                    orderProcessRecordService.updateBatch(processRecordEntityList);//更新订单流转信息
+                    return toResponsObject(0, "微信统一订单下单成功", resultObj);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+//            updateFailProcessBatch(processRecordEntityList, "下单失败,error=" + e.getMessage());//更新订单流转信息
+            return toResponsFail("下单失败,error=" + e.getMessage());
+        }
+        return toResponsFail("下单失败");
+    }
+
+//    /**
+//     * 更新订单支付失败流转信息
+//     * @param processRecordEntityList
+//     * @param return_msg
+//     */
+//    public void updateFailProcessBatch(List<OrderProcessRecordEntity> processRecordEntityList,String return_msg){
+//        for (OrderProcessRecordEntity orderProcessRecordEntity : processRecordEntityList) {
+//            orderProcessRecordEntity.setIsPaymentSend(Dict.isSend.item_0.getItem());
+//            orderProcessRecordEntity.setProcessContent(return_msg);
+//        }
+//        orderProcessRecordService.updateBatch(processRecordEntityList);
+//    }
+
+    /**
+     * 记录订单异常信息
+     * @param orderVoList
+     * @param exceptionStatus
+     * @param expContent
+     */
+    public void addOrderExceptionRecord(List<OrderVo> orderVoList,String exceptionStatus,String expContent){
+        for (OrderVo orderInfo: orderVoList) {
+            MallOrderExceptionRecord mallOrderExceptionRecord = new MallOrderExceptionRecord();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrder_sn());
+            mallOrderExceptionRecord.setExceptionStatus(exceptionStatus);
+            mallOrderExceptionRecord.setExceptionContent(expContent);
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            apiOrderExceptionRecordService.save(mallOrderExceptionRecord);
+        }
+    }
+
+    /**
+     * 微信订单回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/notify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void notify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("微信订单回调接口>>>>>>notify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            logger.error("reponseXml:" + reponseXml);
+            WechatRefundApiResult result = (WechatRefundApiResult) XmlUtil.xmlStrToBean(reponseXml, WechatRefundApiResult.class);
+            String result_code = result.getResult_code();
+            if (result_code.equalsIgnoreCase("FAIL")) {
+                String out_trade_no = result.getOut_trade_no();//订单编号
+                logger.error("订单" + out_trade_no + "支付失败");
+                response.getWriter().write(setXml("SUCCESS", "OK"));
+                response.getWriter().close();
+            } else if (result_code.equalsIgnoreCase(WechatUtil.WXTradeState.SUCCESS.getCode())) {
+                //验签
+                String time_end = result.getTime_end();
+                String out_trade_no = result.getOut_trade_no();//商户订单号
+                String transaction_id = result.getTransaction_id();//微信支付订单号
+                String total_fee = result.getTotal_fee();//订单编号
+                logger.error("订单" + out_trade_no + "支付成功");
+                // 业务处理
+                apiPayService.notify(out_trade_no,total_fee,transaction_id,time_end);
+                response.getWriter().write(setXml("SUCCESS", "OK"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+    /**
+     * 订单退款请求 todo 小程序用户暂不给退款
+     */
+    /*@GetMapping("refund")
+    public Object refund(@LoginUser UserVo loginUser, Long orderId) {
+        //
+        OrderVo orderInfo = orderService.queryObject(orderId);
+
+        if (null == orderInfo) {
+            return toResponsObject(400, "订单已取消", "");
+        }
+
+        if (orderInfo.getOrder_status() == 401 || orderInfo.getOrder_status() == 402) {
+            return toResponsObject(400, "订单已退款", "");
+        }
+
+        if (orderInfo.getPay_status() != 2) {
+            return toResponsObject(400, "订单未付款,不能退款", "");
+        }
+
+//        WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getId().toString(),
+//                orderInfo.getActual_price().doubleValue(), orderInfo.getActual_price().doubleValue());
+        WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getMerchOrderSn().toString(),
+                orderInfo.getActual_price().doubleValue(), orderInfo.getActual_price().doubleValue());
+        if (result.getResult_code().equals("SUCCESS")) {
+            apiPayService.refund(orderInfo,result,"");
+            return toResponsObject(400, "成功退款", "");
+        } else {
+            MallOrderRefund mallOrderRefund = mallOrderRefundMapper.queryObjectByOrderId(orderInfo.getId()+"");
+            MallOrderRefund orderRefund = new MallOrderRefund();
+            orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
+            orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActual_price().multiply(Constant.ONE_HUNDRED).doubleValue()));
+            orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_3.getItem()));
+            orderRefund.setModTime(new Date());
+            if(mallOrderRefund !=null){
+                orderRefund.setId(mallOrderRefund.getId());
+                mallOrderRefundMapper.update(orderRefund);
+            }
+
+            MallOrderExceptionRecord mallOrderExceptionRecord = new MallOrderExceptionRecord();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrder_sn());
+            mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_03.getItem());
+            mallOrderExceptionRecord.setExceptionContent("退款失败"+result.getErr_code_des());
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            apiOrderExceptionRecordService.save(mallOrderExceptionRecord);
+
+            return toResponsObject(400, "退款失败"+result.getErr_code_des(), "");
+        }
+    }*/
+
+
+    /**
+     * 微信订单退款回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/refundNotify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void refundNotify(HttpServletRequest request, HttpServletResponse response) {
+        logger.error("refundNotify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            logger.error("reponseXml:" + reponseXml);
+            WechatRefundNotifyResult result = (WechatRefundNotifyResult) XmlUtil.xmlStrToBean(reponseXml, WechatRefundNotifyResult.class);
+
+            if (result.getReturn_code().equalsIgnoreCase("FAIL")) {
+                logger.info("微信查询接口调用失败: "+result.getReturn_msg());
+                response.getWriter().write(setXml("SUCCESS", "OK"));
+                response.getWriter().close();
+            }else {
+                String req_info = result.getReq_info();//加密信息
+                String aesResult = AESUtil.decryptData(req_info);
+                System.out.println(aesResult);
+                WechatRefundApiResult refundApiResult = (WechatRefundApiResult) XmlUtil.xmlStrToBean(aesResult, WechatRefundApiResult.class);
+
+                logger.error("订单" + refundApiResult.getOut_trade_no() + "退款成功");
+                // 业务处理
+                apiPayService.refundNotify(refundApiResult);
+                response.getWriter().write(setXml("SUCCESS", "OK"));
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+
+
+    /**
+     * 订单退款请求
+     */
+    @IgnoreAuth
+    @GetMapping("test")
+    public Object test(Long orderId) {
+        OrderVo orderInfo = orderService.queryObject(orderId);
+        // 微信通知
+        orderService.notifyPaySuccess(orderInfo);
+        return null;
+    }
+
+    //返回微信服务
+    public static String setXml(String return_code, String return_msg) {
+        return "<xml><return_code><![CDATA[" + return_code + "]]></return_code><return_msg><![CDATA[" + return_msg + "]]></return_msg></xml>";
+    }
+
+    //模拟微信回调接口
+    public static String callbakcXml(String orderNum) {
+        return "<xml><appid><![CDATA[wx2421b1c4370ec43b]]></appid><attach><![CDATA[支付测试]]></attach><bank_type><![CDATA[CFT]]></bank_type><fee_type><![CDATA[CNY]]></fee_type> <is_subscribe><![CDATA[Y]]></is_subscribe><mch_id><![CDATA[10000100]]></mch_id><nonce_str><![CDATA[5d2b6c2a8db53831f7eda20af46e531c]]></nonce_str><openid><![CDATA[oUpF8uMEb4qRXf22hE3X68TekukE]]></openid> <out_trade_no><![CDATA[" + orderNum + "]]></out_trade_no>  <result_code><![CDATA[SUCCESS]]></result_code> <return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[B552ED6B279343CB493C5DD0D78AB241]]></sign><sub_mch_id><![CDATA[10000100]]></sub_mch_id> <time_end><![CDATA[20140903131540]]></time_end><total_fee>1</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[1004400740201409030005092168]]></transaction_id></xml>";
+    }
+}

+ 150 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiRegionController.java

@@ -0,0 +1,150 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.common.cache.RegionCacheUtil;
+import com.kmall.api.entity.RegionVo;
+import com.kmall.common.dao.SysRegionDao;
+import com.kmall.common.entity.SysRegionEntity;
+import com.kmall.api.service.ApiTopicService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.security.session.JedisSessionDAO;
+import com.kmall.common.service.SysRegionService;
+import com.kmall.common.utils.StringUtils;
+import com.kmall.common.utils.redis.JedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/region")
+public class ApiRegionController extends ApiBaseAction {
+    @Autowired
+    private ApiTopicService topicService;
+    @Autowired
+    private SysRegionService sysRegionService;
+    // session 在redis过期时间是30分钟30*60
+    private static int expireTime = 1800;
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(Integer parentId) {
+        List<SysRegionEntity> regionEntityList = new ArrayList();
+        Map<String,Object> queryListMap = new HashMap<>();
+        Map<String, Object> listMap = JedisUtil.getObjectMap("sysRegionEntityList");
+        if(listMap == null){
+            List<SysRegionEntity> sysRegionEntityList= sysRegionService.queryList(new HashMap<String, Object>());
+            queryListMap.put("sysRegionEntityList",sysRegionEntityList);
+            JedisUtil.setObjectMap("sysRegionEntityList", queryListMap, expireTime);
+            for (SysRegionEntity areaVo : sysRegionEntityList) {
+                if (null != areaVo.getParentId() && parentId.equals(areaVo.getParentId())) {
+                    regionEntityList.add(areaVo);
+                }
+            }
+        }else{
+            Map<byte[], byte[]> map = new HashMap<byte[], byte[]>();
+            for (Map.Entry<String, Object> e : listMap.entrySet()) {
+                List<Object> objectList =  (List<Object>)listMap.get(e.getKey());
+                for (Object o:objectList){
+                    SysRegionEntity sysRegionEntity = (SysRegionEntity)o;
+                    if (null != sysRegionEntity.getParentId() && parentId.equals(sysRegionEntity.getParentId())) {
+                        regionEntityList.add(sysRegionEntity);
+                    }
+                }
+            }
+        }
+        List<RegionVo> regionVoList = new ArrayList();
+        if (null != regionEntityList && regionEntityList.size() > 0) {
+            for (SysRegionEntity sysRegionEntity : regionEntityList) {
+                regionVoList.add(new RegionVo(sysRegionEntity));
+            }
+        }
+        return toResponsSuccess(regionVoList);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("provinceList")
+    public Object provinceList() {
+        List<SysRegionEntity> regionEntityList = RegionCacheUtil.getAllProvice();
+        List<RegionVo> regionVoList = new ArrayList();
+        if (null != regionEntityList && regionEntityList.size() > 0) {
+            for (SysRegionEntity sysRegionEntity : regionEntityList) {
+                regionVoList.add(new RegionVo(sysRegionEntity));
+            }
+        }
+        return toResponsSuccess(regionVoList);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("cityList")
+    public Object provinceList(String proviceName) {
+        List<SysRegionEntity> regionEntityList = RegionCacheUtil.getChildrenCity(proviceName);
+        List<RegionVo> regionVoList = new ArrayList();
+        if (null != regionEntityList && regionEntityList.size() > 0) {
+            for (SysRegionEntity sysRegionEntity : regionEntityList) {
+                regionVoList.add(new RegionVo(sysRegionEntity));
+            }
+        }
+        return toResponsSuccess(regionVoList);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("distinctList")
+    public Object distinctList(String proviceName, String cityName) {
+        List<SysRegionEntity> regionEntityList = RegionCacheUtil.getChildrenDistrict(proviceName, cityName);
+        List<RegionVo> regionVoList = new ArrayList();
+        if (null != regionEntityList && regionEntityList.size() > 0) {
+            for (SysRegionEntity sysRegionEntity : regionEntityList) {
+                regionVoList.add(new RegionVo(sysRegionEntity));
+            }
+        }
+        return toResponsSuccess(regionVoList);
+    }
+
+    @IgnoreAuth
+    @GetMapping("info")
+    public Object info(Integer regionId) {
+        SysRegionEntity regionEntity = RegionCacheUtil.getAreaByAreaId(regionId);
+        return toResponsSuccess(new RegionVo(regionEntity));
+    }
+
+    @IgnoreAuth
+    @GetMapping("regionIdsByNames")
+    public Object regionIdsByNames(String provinceName, String cityName, String districtName) {
+        Map resultObj = new HashMap();
+        Integer provinceId = 0;
+        Integer cityId = 0;
+        Integer districtId = 0;
+        if (null != provinceName) {
+            provinceId = RegionCacheUtil.getProvinceIdByName(provinceName);
+        }
+        if (null != provinceId && !StringUtils.isNullOrEmpty(cityName)) {
+            cityId = RegionCacheUtil.getCityIdByName(provinceId, cityName);
+        }
+        if (null != provinceId && null != cityId && !StringUtils.isNullOrEmpty(districtName)) {
+            districtId = RegionCacheUtil.getDistrictIdByName(provinceId, cityId, districtName);
+        }
+        resultObj.put("provinceId", provinceId);
+        resultObj.put("cityId", cityId);
+        resultObj.put("districtId", districtId);
+        return toResponsSuccess(resultObj);
+    }
+}

+ 38 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiRegisterController.java

@@ -0,0 +1,38 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.service.ApiUserService;
+import com.kmall.common.utils.R;
+import com.kmall.common.validator.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 注册
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-26 17:27
+ */
+@RestController
+@RequestMapping("/api/register")
+public class ApiRegisterController {
+    @Autowired
+    private ApiUserService userService;
+
+    /**
+     * 注册
+     */
+    @IgnoreAuth
+    @PostMapping("register")
+    public R register(String mobile, String password) {
+        Assert.isBlank(mobile, "手机号不能为空");
+        Assert.isBlank(password, "密码不能为空");
+
+        userService.save(mobile, password);
+
+        return R.ok();
+    }
+}

+ 118 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiSearchController.java

@@ -0,0 +1,118 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.KeywordsVo;
+import com.kmall.api.entity.SearchHistoryVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiKeywordsService;
+import com.kmall.api.service.ApiSearchHistoryService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.Query;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API登录授权
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:31
+ */
+@RestController
+@RequestMapping("/api/search")
+public class ApiSearchController extends ApiBaseAction {
+    @Autowired
+    private ApiKeywordsService keywordsService;
+    @Autowired
+    private ApiSearchHistoryService searchHistoryService;
+
+    /**
+     *   index
+     */
+    @GetMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        Map<String, Object> resultObj = new HashMap();
+        Map param = new HashMap();
+        param.put("is_default", 1);
+        param.put("page", 1);
+        param.put("limit", 1);
+        param.put("sidx", "id");
+        param.put("order", "asc");
+        List<KeywordsVo> keywordsEntityList = keywordsService.queryList(param);
+        //取出输入框默认的关键词
+        KeywordsVo defaultKeyword = null != keywordsEntityList && keywordsEntityList.size() > 0 ? keywordsEntityList.get(0) : null;
+        //取出热闹关键词
+        param = new HashMap();
+        param.put("fields", "distinct keyword,is_hot");
+        param.put("page", 1);
+        param.put("limit", 10);
+        param.put("sidx", "id");
+        param.put("order", "asc");
+        Query query = new Query(param);
+        List<Map> hotKeywordList = keywordsService.hotKeywordList(query);
+        //
+        param = new HashMap();
+        param.put("user_id", loginUser.getId());
+        param.put("fields", "distinct keyword");
+        param.put("page", 1);
+        param.put("limit", 10);
+        param.put("sidx", "id");
+        param.put("order", "asc");
+        List<SearchHistoryVo> historyVoList = searchHistoryService.queryList(param);
+        String[] historyKeywordList = new String[historyVoList.size()];
+        if (null != historyVoList) {
+            int i = 0;
+            for (SearchHistoryVo historyVo : historyVoList) {
+                historyKeywordList[i] = historyVo.getKeyword();
+                i++;
+            }
+        }
+        //
+        resultObj.put("defaultKeyword", defaultKeyword);
+        resultObj.put("historyKeywordList", historyKeywordList);
+        resultObj.put("hotKeywordList", hotKeywordList);
+        return toResponsSuccess(resultObj);
+    }
+
+    /**
+     *   helper
+     */
+    @IgnoreAuth
+    @GetMapping("helper")
+    public Object helper(@LoginUser UserVo loginUser, String keyword) {
+        Map param = new HashMap();
+        param.put("fields", "distinct keyword");
+        param.put("keyword", keyword);
+        param.put("limit", 10);
+        param.put("offset", 0);
+        List<KeywordsVo> keywords = keywordsService.queryList(param);
+        String[] keys = new String[keywords.size()];
+        if (null != keywords) {
+            int i = 0;
+            for (KeywordsVo keywordsVo : keywords) {
+                keys[i] = keywordsVo.getKeyword();
+                i++;
+            }
+        }
+        //
+        return toResponsSuccess(keys);
+    }
+
+    /**
+     *   clearhistory
+     */
+    @PostMapping("clearhistory")
+    public Object clearhistory(@LoginUser UserVo loginUser) {
+        searchHistoryService.deleteByUserId(loginUser.getId());
+        //
+        return toResponsSuccess("");
+    }
+}

+ 63 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiSmsController.java

@@ -0,0 +1,63 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.common.entity.SysSmsLogEntity;
+import com.kmall.common.service.SysSmsLogService;
+import com.kmall.common.utils.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * 名称:ApiController <br>
+ * 描述:Api<br>
+ *
+ * @author Scott
+ * @version 1.0
+ * @since 1.0.0
+ */
+@RestController
+@RequestMapping("api")
+public class ApiSmsController {
+    @Autowired
+    private SysSmsLogService smsLogService;
+
+    /**
+     * 安全起见,暴露的接口需要配置有效的请求IP
+     */
+    private static final String VALID_IP = "127.0.0.1";
+
+    /**
+     * 发送短信
+     * mobile:电话号码字符串,中间用英文逗号间隔
+     * content:内容字符串
+     * stime:追加发送时间,可为空,为空为及时发送
+     * <p>
+     * 示例:
+     * http://域名:端口/api/sendSms?mobile=13000000000,15209831990&content=发送的短信内容
+     */
+    @IgnoreAuth
+    @PostMapping("/sendSms")
+    public R sendSms(HttpServletRequest request, @RequestParam Map<String, String> params) {
+        SysSmsLogEntity smsLog = new SysSmsLogEntity();
+        String validIP = RequestUtil.getIpAddrByRequest(request);
+        if (VALID_IP.indexOf(validIP) < 0) {
+            throw new RRException("非法地址请求!");
+        }
+        //外部系统调用接口
+        smsLog.setUserId(1L);
+        smsLog.setMobile(params.get("mobile"));
+        smsLog.setContent(params.get("content"));
+        String stime = params.get("stime");
+        if (StringUtils.isNotEmpty(stime)) {
+            smsLog.setStime(DateUtils.strToDate(stime));
+        }
+        SysSmsLogEntity sysSmsLogEntity = smsLogService.sendSms(smsLog);
+        return R.ok().put("result", sysSmsLogEntity);
+    }
+}

+ 71 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiTopicController.java

@@ -0,0 +1,71 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.TopicVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiTopicService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.ApiPageUtils;
+import com.kmall.common.utils.Query;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/topic")
+public class ApiTopicController extends ApiBaseAction {
+    @Autowired
+    private ApiTopicService topicService;
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("list")
+    public Object list(@LoginUser UserVo loginUser, @RequestParam(value = "page", defaultValue = "1") Integer page,
+                       @RequestParam(value = "size", defaultValue = "10") Integer size) {
+        Map param = new HashMap();
+        param.put("page", page);
+        param.put("limit", size);
+        param.put("sidx", "id");
+        param.put("order", "desc");
+        param.put("fields", "id, title, price_info, scene_pic_url,subtitle");
+        //查询列表数据
+        Query query = new Query(param);
+        List<TopicVo> topicEntities = topicService.queryList(query);
+        int total = topicService.queryTotal(query);
+        ApiPageUtils pageUtil = new ApiPageUtils(topicEntities, total, query.getLimit(), query.getPage());
+        return toResponsSuccess(pageUtil);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("detail")
+    public Object detail(@LoginUser UserVo loginUser, Integer id) {
+        TopicVo topicEntity = topicService.queryObject(id);
+        return toResponsSuccess(topicEntity);
+    }
+
+    /**
+     */
+    @IgnoreAuth
+    @GetMapping("related")
+    public Object related(@LoginUser UserVo loginUser, Integer id) {
+        Map param = new HashMap();
+        param.put("limit", 4);
+        List<TopicVo> topicEntities = topicService.queryList(param);
+        return toResponsSuccess(topicEntities);
+    }
+}

+ 52 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiUploadController.java

@@ -0,0 +1,52 @@
+package com.kmall.api.api;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.common.fileserver.util.FileManager;
+import com.kmall.common.oss.OSSFactory;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.R;
+import com.kmall.common.utils.RRException;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-09-08 13:20<br>
+ * 描述: ApiUploadController <br>
+ */
+@RestController
+@RequestMapping("/api/upload")
+public class ApiUploadController extends ApiBaseAction {
+
+    /**
+     * 上传文件
+     */
+    @IgnoreAuth
+    @PostMapping("/upload")
+    public Object upload(@RequestParam("file") MultipartFile file) throws Exception {
+        if (file.isEmpty()) {
+            throw new RRException("上传文件不能为空");
+        }
+//        //上传文件
+//        String url = OSSFactory.build().upload(file);
+        //上传文件
+        String url = FileManager.upload(file);
+
+        /*//保存文件信息
+        SysOssEntity ossEntity = new SysOssEntity();
+        ossEntity.setUrl(url);
+        ossEntity.setCreateDate(new Date());
+        sysOssService.save(ossEntity);
+
+        R r = new R();
+        r.put("url", url);
+        r.put("link", url);
+        return r;*/
+        return toResponsSuccess(url);
+    }
+}

+ 119 - 0
kmall-api/src/main/java/com/kmall/api/api/ApiUserController.java

@@ -0,0 +1,119 @@
+package com.kmall.api.api;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.dto.SendMsgVo;
+import com.kmall.api.util.SendMsgUtil;
+import com.kmall.common.entity.SysSmsLogEntity;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.ApiUserService;
+import com.kmall.common.service.SysSmsLogService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.CharUtil;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 作者: @author Scott <br>
+ * 时间: 2017-08-11 08:32<br>
+ * 描述: ApiIndexController <br>
+ */
+@RestController
+@RequestMapping("/api/user")
+public class ApiUserController extends ApiBaseAction {
+    protected Logger log = Logger.getLogger(ApiUserController.class);
+    @Autowired
+    private ApiUserService userService;
+    @Autowired
+    private SysSmsLogService smsLogService;
+
+    /**
+     */
+    /*@IgnoreAuth
+    @GetMapping("info")
+    public Object info(String mobile) {
+        Map param = new HashMap();
+        param.put("mobile", mobile);
+        UserVo user = userService.queryByMobile(mobile);
+        user.setPassword("");
+        return user;
+    }*/
+
+    /**
+     * 发送短信
+     */
+    @PostMapping("smscode")
+    public Object smscode(@LoginUser UserVo loginUser) {
+        JSONObject jsonParams = getJsonRequest();
+        String sms_code = SendMsgUtil.createRandomVcode();
+        String phone = jsonParams.getString("phone");
+//        String msgContent = "【前海电商】手机验证码为:"+sms_code;
+        String msgContent = "【中网小程序】亲爱的亲,您的验证码是"+sms_code+"。有效期为5分钟,请尽快验证";
+
+        System.out.println("msgContent:"+msgContent);
+        // 一分钟之内不能重复发送短信
+        SysSmsLogEntity smsLogVo = smsLogService.querySmsCodeByUserId(loginUser.getId());
+        if (null != smsLogVo && (System.currentTimeMillis() - smsLogVo.getStime().getTime()) / 1000 < 1 * 60) {
+            return toResponsFail("短信已发送");
+        }
+
+        try{
+            //发送验证码到手机
+            String result = SendMsgUtil.sendMsg(phone,msgContent);
+            SendMsgVo vo = JSON.parseObject(result,SendMsgVo.class);
+
+            SysSmsLogEntity smsLog = new SysSmsLogEntity();
+            smsLog.setUserId(loginUser.getId());
+            smsLog.setMobile(phone);
+            smsLog.setContent(msgContent);
+            smsLog.setSmsCode(sms_code);
+            if(vo.getCode().equalsIgnoreCase("0")){
+                smsLog.setSendStatus(1);
+                smsLog.setSendId(vo.getSid());
+                smsLog.setReturnMsg(vo.getMsg());
+                smsLog.setMerchSn(getMerchSn());
+                smsLog.setStoreId(getStoreId().intValue());
+
+                SysSmsLogEntity sysSmsLogEntity = smsLogService.sendSms(smsLog);
+                if (null == sysSmsLogEntity) {
+                    return toResponsFail("短信记录失败");
+                } else {
+                    return toResponsSuccess("短信发送成功");
+                }
+            }else{
+                smsLog.setSendStatus(0);
+                smsLog.setReturnMsg(vo.getMsg());
+                smsLogService.sendSms(smsLog);
+                return toResponsFail("短信发送失败:"+vo.getMsg());
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return toResponsFail("短信发送失败");
+        }
+
+    }
+
+    /**
+     * 获取当前会员等级
+     *
+     * @return
+     */
+    @PostMapping("getCurUser")
+    public Object getUserLevel() {
+        Long userId = getUserId();
+        UserVo userInfo = userService.queryObject(userId);
+        String userLevel = userService.getUserLevel(userInfo);
+        userInfo.setUserLevel(userLevel);
+        return toResponsSuccess(userInfo);
+    }
+}

+ 322 - 0
kmall-api/src/main/java/com/kmall/api/api/pingan/ApiPayPinganController.java

@@ -0,0 +1,322 @@
+package com.kmall.api.api.pingan;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.OrderProcessRecordEntity;
+import com.kmall.api.entity.OrderVo;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.*;
+import com.kmall.api.service.pay.wxpay.WxPayPropertiesBuilder;
+import com.kmall.api.service.pingan.ApiPinganPayOrderService;
+import com.kmall.api.service.pingan.ApiPinganResponseService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.CommonUtil;
+import com.kmall.common.constant.Dict;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.MapUtils;
+import com.kmall.common.utils.RRException;
+import com.kmall.common.utils.StringUtils;
+import com.kmall.common.utils.pingan.PinganUtil;
+import com.kmall.common.utils.pingan.dto.PinganPayOrderDto;
+import com.kmall.common.utils.pingan.dto.PinganResponseDto;
+import com.kmall.common.utils.pingan.properties.PinganPayPropertiesBuilder;
+import com.kmall.common.utils.pingan.utils.InterfaceParams;
+import com.kmall.common.utils.pingan.utils.TLinx2Util;
+import com.kmall.common.utils.pingan.utils.TLinxAESCoder;
+import net.sf.json.JSONObject;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.util.*;
+
+@RestController
+@RequestMapping("api/pay/pingan")
+public class ApiPayPinganController extends ApiBaseAction {
+
+    private Logger logger = Logger.getLogger(ApiPayPinganController.class);
+
+    private static final String SUCCESS_CODE = "0";
+
+    @Autowired
+    private ApiOrderService orderService;
+
+    @Autowired
+    private ApiPayService payService;
+
+    @Autowired
+    private ApiPinganResponseService pinganResponseService;
+
+    @Autowired
+    private ApiPinganPayOrderService pinganPayOrderService;
+
+    @Autowired
+    private ApiOrderProcessRecordService orderProcessRecordService;
+
+    @Autowired
+    private ApiUserService userService;
+
+    @RequestMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        return toResponsSuccess("");
+    }
+
+
+    /**
+     * 平安下单接口
+     * @return
+     */
+    @GetMapping("payorder")
+    public Object payorder(@LoginUser UserVo loginUser, Long[] orderIds,String isMergePay) {
+        loginUser = userService.queryObject(loginUser.getId());
+
+        List<Long> orderIdList=new ArrayList<>();
+        String merchOrderSn = "";
+        for(int i=0;i<orderIds.length;i++){
+            orderIdList.add(orderIds[i]);
+        }
+        BigDecimal actual_price = Constant.ZERO;
+        List<OrderVo> orderVoList = orderService.queryObjectByIdList(orderIdList);
+        List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
+
+        for (OrderVo orderInfo : orderVoList) {
+            if (orderInfo.getOrder_status() == 101) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单超时支付,已取消", "");
+            }
+            if (orderInfo.getPay_status() != 0 && orderInfo.getPay_status() != 1) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单已支付,请不要重复操作", "");
+            }
+            merchOrderSn = orderInfo.getMerchOrderSn();
+
+            //如此次是单笔支付,则判断下单时该商户订单是否是拆单订单,如果都满足,则更新商户订单号,生成新的预支付信息
+            if(Dict.isMergePay.item_0.getItem().equalsIgnoreCase(isMergePay)) {
+                if ("2".equalsIgnoreCase(orderInfo.getIsMergePay())) {//多笔订单单笔支付,则商户订单号,生成新的预支付信息
+//                    merchOrderSn = "EMATO" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
+                    merchOrderSn = "EMATO"+ CommonUtil.generateOrderNumber();
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                } else {
+                    // 取消订单
+                   /*PinganResponseDto payCancel = PinganUtil.pinganPayCancel(null, orderInfo.getMerchOrderSn());
+                    if (payCancel == null) {
+                        logger.info("平安取消订单接口调用失败!");
+                        return toResponsFail("下单失败");
+                    }
+                    payCancel.setOutNo(orderInfo.getMerchOrderSn());
+                    payCancel.setCreateTime(new Date());
+                    pinganResponseService.save(payCancel);
+                    if (!SUCCESS_CODE.equals(payCancel.getErrcode()) && !"8002".equals(payCancel.getErrcode())) {
+                        return toResponsFail(payCancel.getMsg());
+                    }*/
+
+                    merchOrderSn = "EMATO"+ CommonUtil.generateOrderNumber();
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                }
+            }
+
+            OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+            if(processRecordEntity != null){
+                OrderProcessRecordEntity entity = new OrderProcessRecordEntity();
+                entity.setOrderSn(orderInfo.getOrder_sn());
+                entity.setUserId(Integer.valueOf(loginUser.getId().toString()));
+                entity.setPayStartTime(new Date());
+                entity.setId(processRecordEntity.getId());
+                processRecordEntityList.add(entity);
+            }
+            actual_price = actual_price.add(orderInfo.getActual_price());
+        }
+
+        try {
+            String timestamp = new Date().getTime() / 1000 + "";    // 时间
+
+            // 固定参数
+            TreeMap<String, String> postmap = new TreeMap<String, String>();    // 请求参数的map
+
+            postmap.put("open_id", PinganPayPropertiesBuilder.instance().getPayOpenId());
+            postmap.put("timestamp", timestamp);
+
+            TreeMap<String, String> param = new TreeMap<>();
+            param.put("out_no", merchOrderSn);
+            param.put("pmt_tag", "WeixinOL");
+            param.put("original_amount", actual_price.multiply(Constant.ONE_HUNDRED).intValue()+"");//分为单位
+            param.put("trade_amount", actual_price.multiply(Constant.ONE_HUNDRED).intValue()+"");//分为单位
+            param.put("sub_appid", WxPayPropertiesBuilder.instance().getAppId());
+            param.put("sub_openid", loginUser.getWeixin_openid());
+            param.put("trade_type", "JSAPI");
+            // 实名认证
+//            param.put("user_creid", loginUser.getIdNo());
+//            param.put("user_truename", loginUser.getUsername());
+
+            param.put("notify_url", PinganPayPropertiesBuilder.instance().getNotifyUrl());
+
+            //数据加密,加签
+            TLinx2Util.handleEncrypt(param, postmap);
+            TLinx2Util.handleSign(postmap);
+
+            //请求
+            String rspStr = TLinx2Util.handlePost(postmap, InterfaceParams.PAYORDER);
+            System.out.println("返回字符串=" + rspStr);
+
+            //解析数据,处理数据
+            return analysisResponse(rspStr, merchOrderSn, orderVoList);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+//            updateFailProcessBatch(processRecordEntityList, "下单失败,error=" + e.getMessage());//更新订单流转信息
+            return toResponsFail("下单失败,error=" + e.getMessage());
+        }
+    }
+
+
+    /**
+     * 更新订单支付失败流转信息
+     * @param processRecordEntityList
+     * @param return_msg
+     */
+    private void updateFailProcessBatch(List<OrderProcessRecordEntity> processRecordEntityList,String return_msg){
+        for (OrderProcessRecordEntity orderProcessRecordEntity : processRecordEntityList) {
+            orderProcessRecordEntity.setIsPaymentSend(Dict.isSend.item_0.getItem());
+            orderProcessRecordEntity.setProcessContent(return_msg);
+        }
+        orderProcessRecordService.updateBatch(processRecordEntityList);
+    }
+
+
+    /**
+     * 解析响应数据
+     * @param rspStr
+     * @return
+     */
+    private Object analysisResponse(String rspStr, String merchOrderSn, List<OrderVo> orderVoList) throws Exception {
+        JSONObject respObject = JSONObject.fromObject(rspStr);
+        logger.info("返回错误码:【" + MapUtils.getString("errcode", respObject) + "】");
+        logger.info("返回错误提示【" + MapUtils.getString("msg", respObject) + "】");
+        logger.info("平安支付下单返回数据:【" + MapUtils.getString("data", respObject) + "】");
+        logger.info("接口签名【" + MapUtils.getString("sign", respObject) + "】");
+
+        if (!respObject.isEmpty()) {
+            PinganResponseDto response = new PinganResponseDto();
+            response.setErrcode(MapUtils.getString("errcode", respObject));
+            response.setMsg(MapUtils.getString("msg", respObject));
+            response.setData(MapUtils.getString("data", respObject));
+            response.setSign(MapUtils.getString("sign", respObject));
+            if (StringUtils.isNotEmpty(MapUtils.getString("timestamp", respObject))) {
+                Long timestamp = Long.parseLong(MapUtils.getString("timestamp", respObject)) * 1000;
+                response.setTimestamp(new Date(timestamp));
+            }
+            response.setReqInterface(InterfaceParams.PAYORDER);
+            response.setCreateTime(new Date());
+            response.setOutNo(merchOrderSn);
+
+            if (SUCCESS_CODE.equals(response.getErrcode())) {
+                // 验签, 判断是否下单成功
+                if (TLinx2Util.verifySign(respObject)) {
+                    String dataJson = TLinxAESCoder.decrypt(response.getData(), PinganPayPropertiesBuilder.instance().getPayOpenKey());
+
+                    // 添加平安支付回执
+                    response.setDatajson(dataJson);
+                    pinganResponseService.save(response);
+
+                    // 参数解密,添加平安支付订单信息
+                    if (dataJson != null) {
+                        JSONObject dataObject = JSONObject.fromObject(dataJson);
+                        PinganPayOrderDto payorder = PinganUtil.buildPayOrderDto(dataObject);
+                        payorder.setCreateTime(new Date());
+                        pinganPayOrderService.save(payorder);
+
+                        String prepay_id = payorder.getTradeNo();
+                        for (OrderVo orderInfo : orderVoList) {
+                            orderInfo.setPay_id(prepay_id);
+                            orderInfo.setPay_status(Integer.parseInt(Dict.payStatus.item_1.getItem())); // 付款中
+                            orderInfo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_100.getItem()));
+                            orderInfo.setPayFlag(Dict.payFlag.item_pingan.getItem());
+                        }
+                        orderService.updateBatch(orderVoList);
+
+                        Map<String, Object> payParam = new HashMap<>();
+                        payParam.put("timeStamp", MapUtils.getString("timeStamp", dataObject));
+                        payParam.put("nonceStr", MapUtils.getString("nonceStr", dataObject));
+                        payParam.put("signType", MapUtils.getString("signType", dataObject));
+                        payParam.put("package", MapUtils.getString("package", dataObject));
+                        payParam.put("paySign", MapUtils.getString("paySign", dataObject));
+                        return toResponsSuccess(payParam);
+                    }
+                }
+            } else if ("8045".equals(response.getErrcode())) {
+                PinganPayOrderDto payOrderDto = pinganPayOrderService.queryByOutNo(merchOrderSn);
+                if (payOrderDto != null) {
+                    Map<String, Object> payParam = new HashMap<>();
+                    payParam.put("timeStamp", payOrderDto.getTimeStamp());
+                    payParam.put("nonceStr", payOrderDto.getNoncestr());
+                    payParam.put("signType", payOrderDto.getSigntype());
+                    payParam.put("package", payOrderDto.getPrepayId());
+                    payParam.put("paySign", payOrderDto.getPaysign());
+                    return toResponsSuccess(payParam);
+                }
+
+                pinganResponseService.save(response);
+                logger.debug("下单失败!" + response.getMsg());
+                return toResponsFail("下单失败!");
+            } else {
+                pinganResponseService.save(response);
+                logger.debug("下单失败!" + response.getMsg());
+                return toResponsFail("下单失败!");
+            }
+        }
+
+        return toResponsFail("下单失败!");
+    }
+
+
+    /**
+     * 平安订单回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/notify", method = RequestMethod.POST)
+    @ResponseBody
+    public String notify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("平安订单回调接口>>>>>>pingan notify start");
+        String openId = request.getParameter("open_id");
+        if (StringUtils.isNotEmpty(openId) && openId.equals(PinganPayPropertiesBuilder.instance().getPayOpenId())) {
+            String ordNo = request.getParameter("ord_no");
+            String timestamp = request.getParameter("timestamp");
+            String randStr = request.getParameter("rand_str");
+            String outNo = request.getParameter("out_no");
+            String status = request.getParameter("status");
+            String tradeResult = request.getParameter("trade_result");
+            String payTime = request.getParameter("pay_time");
+            String sign = request.getParameter("sign");
+
+            Map<String, Object> params = new TreeMap<>();
+            params.put("open_id", openId);
+            params.put("ord_no", ordNo);
+            params.put("timestamp", timestamp);
+            params.put("rand_str", randStr);
+            params.put("out_no", outNo);
+            params.put("status", status);
+            params.put("trade_result", tradeResult);
+            params.put("pay_time", payTime);
+            params.put("sign", sign);
+
+            PinganResponseDto responseDto = new PinganResponseDto();
+            responseDto.setOutNo(outNo);
+            responseDto.setReqInterface(InterfaceParams.NOTIFY);
+            responseDto.setDatajson(JSONObject.fromObject(params).toString());
+            responseDto.setCreateTime(new Date());
+            pinganResponseService.save(responseDto);
+
+            JSONObject result = JSONObject.fromObject(tradeResult);
+            payService.notify(result.getString("out_trade_no"), result.getString("total_fee"), result.getString("transaction_id"), result.getString("time_end"));
+            return "notify_success";
+        } else {
+            logger.info("平安订单回调接口openId不匹配");
+        }
+        logger.info("平安订单回调接口>>>>>>pingan notify end");
+        return "notify_fail";
+    }
+
+}

+ 149 - 0
kmall-api/src/main/java/com/kmall/api/api/pingan/mpconfig/ApiPinganMpconfigController.java

@@ -0,0 +1,149 @@
+package com.kmall.api.api.pingan.mpconfig;
+
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.api.entity.UserVo;
+import com.kmall.api.service.pay.wxpay.WxPayPropertiesBuilder;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.pingan.properties.PinganPayPropertiesBuilder;
+import com.kmall.common.utils.pingan.utils.InterfaceParams;
+import com.kmall.common.utils.pingan.utils.TLinx2Util;
+import com.kmall.common.utils.pingan.utils.TLinxAESCoder;
+import com.kmall.common.utils.pingan.utils.TLinxPluginUtil;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.RandomStringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@RestController
+@RequestMapping("api/pay/pingan/mpconfig")
+public class ApiPinganMpconfigController extends ApiBaseAction {
+
+    @RequestMapping("index")
+    public Object index(@LoginUser UserVo loginUser) {
+        return toResponsSuccess("");
+    }
+
+    /**
+     * Unicode转 汉字字符串
+     * @param str
+     * @return
+     */
+    private static String unicodeToString(String str) {
+        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
+        Matcher matcher = pattern.matcher(str);
+        char ch;
+        while (matcher.find()) {
+            String group = matcher.group(2);
+            ch = (char) Integer.parseInt(group, 16);
+            String group1 = matcher.group(1);
+            str = str.replace(group1, ch + "");
+        }
+        return str;
+    }
+
+    /**
+     * 平安商户支付配置
+     * @return
+     */
+    @GetMapping("add")
+    public Object add() {
+        String timestamp = new Date().getTime() / 1000 + "";    // 时间
+
+        try {
+            // 固定参数
+            TreeMap<String, String> postmap = new TreeMap<String, String>();    // 请求参数的map
+
+            postmap.put("open_id", PinganPayPropertiesBuilder.instance().getPayOpenId());
+            postmap.put("timestamp", timestamp);
+
+            TreeMap<String, String> datamap = new TreeMap<>();
+            datamap.put("pmt_tag", "WeixinOL");
+            datamap.put("sub_appid", WxPayPropertiesBuilder.instance().getAppId());
+
+            //数据加密,加签
+            TLinx2Util.handleEncrypt(datamap, postmap);
+            TLinx2Util.handleSign(postmap);
+
+            //请求
+            String rspStr = TLinx2Util.handlePost(postmap, InterfaceParams.MPCONFIGADD);
+            System.out.println("返回字符串=" + rspStr);
+
+            JSONObject respObject = JSONObject.fromObject(rspStr);
+
+            Object dataStr = respObject.get("data");
+            System.out.println("返回data字符串="+dataStr);
+
+            if (!rspStr.isEmpty() || (dataStr != null)) {
+                if (TLinx2Util.verifySign(respObject)) {    // 验签成功
+                    String respData = TLinxAESCoder.decrypt(dataStr.toString(), PinganPayPropertiesBuilder.instance().getPayOpenKey());
+                    System.out.println("==================响应data内容:" + respData);
+                    return toResponsSuccess("商户支付配置查询成功");
+                } else {
+                    System.out.println("=====验签失败=====");
+                }
+            } else {
+                System.out.println("=====没有返回data数据=====");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return toResponsFail("商户支付配置失败");
+    }
+
+    /**
+     * 平安商户支付配置
+     * @return
+     */
+    @GetMapping("query")
+    public Object query() {
+        String timestamp = new Date().getTime() / 1000 + "";    // 时间
+
+        try {
+            // 固定参数
+            TreeMap<String, String> postmap = new TreeMap<String, String>();    // 请求参数的map
+
+            postmap.put("open_id", PinganPayPropertiesBuilder.instance().getPayOpenId());
+            postmap.put("timestamp", timestamp);
+
+            TreeMap<String, String> datamap = new TreeMap<>();
+            datamap.put("pmt_tag", "WeixinOL");
+
+            //数据加密,加签
+            TLinx2Util.handleEncrypt(datamap, postmap);
+            TLinx2Util.handleSign(postmap);
+
+            //请求
+            String rspStr = TLinx2Util.handlePost(postmap, InterfaceParams.MPCONFIGQUERY);
+            System.out.println("返回字符串=" + rspStr);
+
+            JSONObject respObject = JSONObject.fromObject(rspStr);
+
+            Object dataStr = respObject.get("data");
+            System.out.println("返回data字符串="+dataStr);
+
+            if (!rspStr.isEmpty() || (dataStr != null)) {
+                if (TLinx2Util.verifySign(respObject)) {    // 验签成功
+                    String respData = TLinxAESCoder.decrypt(dataStr.toString(), PinganPayPropertiesBuilder.instance().getPayOpenKey());
+                    System.out.println("==================响应data内容:" + respData);
+                    return toResponsSuccess("商户支付配置查询成功");
+                } else {
+                    System.out.println("=====验签失败=====");
+                }
+            } else {
+                System.out.println("=====没有返回data数据=====");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return toResponsFail("商户支付配置查询失败");
+    }
+
+}

+ 289 - 0
kmall-api/src/main/java/com/kmall/api/api/wxGlobal/ApiWxGlobalPayController.java

@@ -0,0 +1,289 @@
+package com.kmall.api.api.wxGlobal;
+
+import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.api.annotation.LoginUser;
+import com.kmall.common.constant.Dict;
+import com.kmall.api.entity.*;
+import com.kmall.api.service.*;
+import com.kmall.api.service.wxGlobal.ApiWxGlobalPayService;
+import com.kmall.api.util.ApiBaseAction;
+import com.kmall.api.util.CommonUtil;
+import com.kmall.common.utils.CharUtil;
+import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.XmlUtil;
+import com.kmall.common.utils.wechat.AESUtil;
+import com.kmall.common.utils.wechat.WechatRefundApiResult;
+import com.kmall.common.utils.wechat.WechatRefundNotifyResult;
+import com.kmall.common.utils.wechat.WechatUtil;
+import com.kmall.common.utils.wechat.wxglobal.AesGcmExampleUtil;
+import com.kmall.common.utils.wechat.wxglobal.WechatGlobalUtil;
+import com.kmall.common.utils.wechat.wxglobal.dto.*;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.*;
+
+
+/**
+ * 微信境外支付
+ *
+ * @author huangyq
+ * @email
+ * @date 2018-12-11 17:01
+ */
+@RestController
+@RequestMapping("/api/global/pay")
+public class ApiWxGlobalPayController extends ApiBaseAction {
+    private Logger logger = Logger.getLogger(ApiWxGlobalPayController.class);
+    @Autowired
+    private ApiOrderService orderService;
+    @Autowired
+    private ApiOrderGoodsService orderGoodsService;
+    @Autowired
+    private ApiWxGlobalPayService apiWxGlobalPayService;
+    @Autowired
+    private ApiOrderProcessRecordService orderProcessRecordService;
+    @Autowired
+    private ApiOrderExceptionRecordService apiOrderExceptionRecordService;
+    @Autowired
+    private ApiStoreService apiStoreService;
+
+    /**
+     * 发起支付
+     * @param loginUser
+     * @param orderIds
+     * @param isMergePay
+     * @return
+     */
+    @GetMapping("pay_prepay")
+    public Object payPrepay(@LoginUser UserVo loginUser, Long[] orderIds,String isMergePay) {
+        logger.info("微信支付接口>>>>>>payPrepay start");
+        List<Long> orderIdList = new ArrayList<>();
+        String merchOrderSn = "";
+        for(int i=0;i<orderIds.length;i++){
+            orderIdList.add(orderIds[i]);
+        }
+        BigDecimal actual_price = Constant.ZERO;
+        String storeName = "";
+        List<OrderVo> orderVoList = orderService.queryObjectByIdList(orderIdList);
+        List<OrderProcessRecordEntity> processRecordEntityList = new ArrayList<>();
+
+        for (OrderVo orderInfo:orderVoList) {
+            if (orderInfo.getOrder_status() == 101) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单超时支付,已取消", "");
+            }
+            if (orderInfo.getPay_status() != 0 && orderInfo.getPay_status() != 1) {
+                return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单已支付,请不要重复操作", "");
+            }
+            OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
+            if(processRecordEntity != null){
+                OrderProcessRecordEntity entity = new OrderProcessRecordEntity();
+                entity.setOrderSn(orderInfo.getOrder_sn());
+                entity.setUserId(Integer.valueOf(loginUser.getId()+""));
+                entity.setId(processRecordEntity.getId());
+                entity.setPayStartTime(new Date());
+                processRecordEntityList.add(entity);
+            }
+            merchOrderSn = orderInfo.getMerchOrderSn();
+            //如此次是单笔支付,则判断下单时该商户订单是否是拆单订单,如果都满足,则更新商户订单号,生成新的预支付信息
+            if(Dict.isMergePay.item_0.getItem().equalsIgnoreCase(isMergePay)) {
+                if ("2".equalsIgnoreCase(orderInfo.getIsMergePay())) {//多笔订单单笔支付,则商户订单号,生成新的预支付信息
+                    merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                }
+            }
+            actual_price = actual_price.add(orderInfo.getActual_price());
+            StoreVo storeVo = apiStoreService.queryObject(orderInfo.getStore_id());
+            storeName = storeVo.getStoreName();
+        }
+        String nonceStr = CharUtil.getRandomString(32).toUpperCase();
+        Map<Object, Object> resultObj = new HashMap();
+
+        try {
+            //订单的商品
+//            List<OrderGoodsVo> orderGoods = orderGoodsService.queryListByIds(orderIdList);
+            String body = "中网国际跨境商城-"+storeName;
+            //统一下单
+            WechatGlobalQueryApiResult queryApiResult = WechatGlobalUtil.unifiedOrder(merchOrderSn,nonceStr, body, actual_price, loginUser.getWeixin_openid());
+            // 响应报文
+            String code = queryApiResult.getCode();
+            if(StringUtils.isEmpty(queryApiResult.getPrepay_id())) {
+                if (!code.equalsIgnoreCase("OK")) {
+                    String message = queryApiResult.getMessage();
+                    addOrderExceptionRecord(orderVoList, Dict.exceptionStatus.item_00.getItem(), "支付失败 ," + message);//记录订单异常信息
+                    return toResponsFail("支付失败 ," + message);
+                }
+            }else{
+                apiWxGlobalPayService.payPrepay(resultObj, queryApiResult, nonceStr, orderVoList);
+                orderProcessRecordService.updateBatch(processRecordEntityList);//更新订单流转信息
+                return toResponsObject(0, "微信统一订单下单成功", resultObj);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return toResponsFail("下单失败,error=" + e.getMessage());
+        }
+        return toResponsFail("下单失败");
+    }
+
+//    /**
+//     * 更新订单支付失败流转信息
+//     * @param processRecordEntityList
+//     * @param return_msg
+//     */
+//    public void updateFailProcessBatch(List<OrderProcessRecordEntity> processRecordEntityList,String return_msg){
+//        for (OrderProcessRecordEntity orderProcessRecordEntity : processRecordEntityList) {
+//            orderProcessRecordEntity.setIsPaymentSend(Dict.isSend.item_0.getItem());
+//            orderProcessRecordEntity.setProcessContent(return_msg);
+//        }
+//        orderProcessRecordService.updateBatch(processRecordEntityList);
+//    }
+
+    /**
+     * 记录订单异常信息
+     * @param orderVoList
+     * @param exceptionStatus
+     * @param expContent
+     */
+    public void addOrderExceptionRecord(List<OrderVo> orderVoList,String exceptionStatus,String expContent){
+        for (OrderVo orderInfo: orderVoList) {
+            MallOrderExceptionRecord mallOrderExceptionRecord = new MallOrderExceptionRecord();
+            mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUser_id()+""));
+            mallOrderExceptionRecord.setOrderSn(orderInfo.getOrder_sn());
+            mallOrderExceptionRecord.setExceptionContent(expContent);
+            mallOrderExceptionRecord.setExceptionStatus(exceptionStatus);
+            mallOrderExceptionRecord.setCreateTime(new Date());
+            apiOrderExceptionRecordService.save(mallOrderExceptionRecord);
+        }
+    }
+
+    /**
+     * 微信订单回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/notify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void notify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("微信订单回调接口>>>>>>notify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            logger.error("reponseXml:" + reponseXml);
+            JSONObject jsonObject = JSONObject.fromObject(reponseXml);
+            PayResourceDto payResourceDto = (PayResourceDto)JSONObject.toBean(jsonObject, PayResourceDto.class);
+
+            String event_type = payResourceDto.getEvent_type();
+            if (event_type.equalsIgnoreCase("TRANSACTION.SUCCESS")) {
+                ResourceDto resourceDto = payResourceDto.getResource();//加密数据对象
+                if(resourceDto != null) {
+                    String associatedData = resourceDto.getAssociated_data();
+                    String nonce = resourceDto.getNonce();
+                    String cipherText = resourceDto.getCiphertext();//数据密文
+                    String wechatpayCert = AesGcmExampleUtil.aesgcmDecrypt(associatedData, nonce, cipherText);
+                    JSONObject certJson = JSONObject.fromObject(wechatpayCert);
+                    WechatGlobalUniformNotifyResult result = (WechatGlobalUniformNotifyResult)JSONObject.toBean(certJson, WechatGlobalUniformNotifyResult.class);
+                    logger.error("订单 " + result.getOut_trade_no() + " 支付成功");
+                    // 业务处理
+                    apiWxGlobalPayService.notify(result);
+                }
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            } else {
+                logger.error("支付失败");
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+    /**
+     * 微信订单退款回调接口
+     *
+     * @return
+     */
+    @IgnoreAuth
+    @RequestMapping(value = "/refundNotify", produces = "text/html;charset=UTF-8")
+    @ResponseBody
+    public void refundNotify(HttpServletRequest request, HttpServletResponse response) {
+        logger.info("微信订单退款回调接口》》》》refundNotify start");
+        try {
+            request.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("text/html;charset=UTF-8");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            InputStream in = request.getInputStream();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buffer = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buffer)) != -1) {
+                out.write(buffer, 0, len);
+            }
+            out.close();
+            in.close();
+            String reponseXml = new String(out.toByteArray(), "utf-8");//xml数据
+            reponseXml = reponseXml.replace("\n","").replace("\r","");
+            reponseXml = reponseXml+"}}";
+            logger.error("reponseXml :" + reponseXml);
+            JSONObject jsonObject= JSONObject.fromObject(reponseXml);
+            PayResourceDto payResourceDto = (PayResourceDto)JSONObject.toBean(jsonObject, PayResourceDto.class);
+
+            String event_type = payResourceDto.getEvent_type();
+            if (event_type.equalsIgnoreCase("REFUND.SUCCESS")) {
+                ResourceDto resourceDto = payResourceDto.getResource();//加密数据对象
+                if(resourceDto != null) {
+                    String associatedData = resourceDto.getAssociated_data();
+                    String nonce = resourceDto.getNonce();
+                    String cipherText = resourceDto.getCiphertext();//数据密文
+                    String wechatpayCert = AesGcmExampleUtil.aesgcmDecrypt(associatedData, nonce, cipherText);
+                    JSONObject certJson = JSONObject.fromObject(wechatpayCert);
+                    WechatRefundAsynApiResult refundApiResult = (WechatRefundAsynApiResult)JSONObject.toBean(certJson, WechatRefundAsynApiResult.class);
+                    logger.error("订单 " + refundApiResult.getOut_trade_no() + "退款成功");
+                    // 业务处理
+                    apiWxGlobalPayService.refundNotify(refundApiResult);
+                    response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                }
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            } else {
+                logger.info("微信国际退款接口调用失败 : "+payResourceDto.getSummary());
+                response.getWriter().write(setXml(WechatGlobalUtil.WXTradeState.SUCCESS.getCode(), "OK"));
+                response.getWriter().close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return;
+        }
+    }
+
+    //返回微信服务
+    public static String setXml(String return_code, String return_msg) {
+        return "<xml><return_code><![CDATA[" + return_code + "]]></return_code><return_msg><![CDATA[" + return_msg + "]]></return_msg></xml>";
+    }
+}

+ 119 - 0
kmall-api/src/main/java/com/kmall/api/cache/UserTokenCache.java

@@ -0,0 +1,119 @@
+package com.kmall.api.cache;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
+import com.kmall.api.entity.TokenEntity;
+import com.kmall.api.entity.UserVo;
+import com.kmall.common.utils.StringUtils;
+import com.kmall.common.utils.redis.JedisUtil;
+import org.apache.log4j.Logger;
+
+/**
+ * 会员缓存
+ *
+ * @author Scott
+ */
+public class UserTokenCache {
+    private static Logger logger = Logger.getLogger(UserTokenCache.class);
+    static SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
+
+    /**
+     * 存放user和token的关联关系
+     */
+    public static final String XCX_TOKEN_USER_PREFIXX = "xcx_token_user_";
+    public static final String XCX_USER_TOKEN_PREFIXX = "xcx_user_token_";
+    public static final String XCX_USER_INFO_PREFIXX = "xcx_user_info_";
+    public static int wsTokenExpireTime = 3600 * 24 * 30;
+
+    /**
+     * 根据用户Id
+     *
+     * @param userId
+     * @return
+     */
+    public static TokenEntity getUserTokenByUserId(Long userId) {
+        String temp = JedisUtil.get(toUserTokenKey(userId));
+        if (!org.springframework.util.StringUtils.isEmpty(temp)) {
+            TokenEntity d = JSON.parseObject(temp, TokenEntity.class);
+            return d;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 根据token
+     *
+     * @param token
+     * @return
+     */
+
+    public static TokenEntity getUserInfoByToken(String token) {
+        String temp = JedisUtil.get(toTokenUserKey(token));
+        if (StringUtils.isNullOrEmpty(temp)) {
+            return null;
+        }
+        String userID = toUserTokenKey(Long.valueOf(temp));
+        String tokenEntityJson = JedisUtil.get(userID);
+        if (!org.springframework.util.StringUtils.isEmpty(tokenEntityJson)) {
+            TokenEntity d = JSON.parseObject(tokenEntityJson, TokenEntity.class);
+            return d;
+        } else {
+            return null;
+        }
+    }
+
+    public static void del(Long userId) {
+        JedisUtil.del(toUserTokenKey(userId));
+    }
+
+    /**
+     * 放置用户Id和token关系
+     *
+     * @param tokenEntity
+     */
+    public static void putUserToken(TokenEntity tokenEntity) {
+        JedisUtil.set(toUserTokenKey(tokenEntity.getUserId()), fromTokenCacheString(tokenEntity), wsTokenExpireTime);
+        JedisUtil.set(toTokenUserKey(tokenEntity.getToken()), tokenEntity.getUserId().toString(), wsTokenExpireTime);
+    }
+
+    private static String fromTokenCacheString(TokenEntity d) {
+        if (d == null)
+            return null;
+        return JSON.toJSONString(d, filter);
+    }
+
+    private static String toUserTokenKey(Long userId) {
+        return XCX_TOKEN_USER_PREFIXX + userId;
+    }
+
+    private static String toTokenUserKey(String token) {
+        return XCX_USER_TOKEN_PREFIXX + token;
+    }
+
+    private static String toUserInfoKey(Long userId) {
+        return XCX_USER_INFO_PREFIXX + userId;
+    }
+
+    public static UserVo getUserInfo(Long userId) {
+//        logger.error("getUserInfo key:" + toUserInfoKey(userId));
+        String temp = JedisUtil.get(toUserInfoKey(userId));
+//        logger.error("getUserInfo temp:" + temp);
+        if (!org.springframework.util.StringUtils.isEmpty(temp)) {
+            UserVo d = JSON.parseObject(temp, UserVo.class);
+            return d;
+        } else {
+            return null;
+        }
+    }
+
+    public static void putUserInfo(UserVo userVo) {
+        JedisUtil.set(toUserInfoKey(userVo.getId()), fromUserCacheString(userVo), wsTokenExpireTime);
+    }
+
+    private static String fromUserCacheString(UserVo d) {
+        if (d == null)
+            return null;
+        return JSON.toJSONString(d, filter);
+    }
+}

+ 44 - 0
kmall-api/src/main/java/com/kmall/api/config/SwaggerConfig.java

@@ -0,0 +1,44 @@
+package com.kmall.api.config;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableWebMvc
+@EnableSwagger2
+@ComponentScan(basePackages="com.kmall.api.api")
+public class SwaggerConfig {
+
+    @Bean
+    public Docket api(){
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(this.apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.kmall.api.api"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+
+    private ApiInfo apiInfo(){
+        @SuppressWarnings("deprecation")
+        ApiInfo info=new ApiInfo(
+                "小程序接口文档",
+                "小程序接口文档",
+                "1.0",
+                "urn:tos",
+                "pwm",
+                "",
+                "");
+        return info;
+    }
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiAdMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AdVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+public interface ApiAdMapper extends BaseDao<AdVo> {
+	
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiAdPositionMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AdPositionVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+public interface ApiAdPositionMapper extends BaseDao<AdPositionVo> {
+	
+}

+ 13 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiAddressMapper.java

@@ -0,0 +1,13 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+public interface ApiAddressMapper extends BaseDao<AddressVo> {
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiAttributeCategoryMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AttributeCategoryVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+public interface ApiAttributeCategoryMapper extends BaseDao<AttributeCategoryVo> {
+	
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiAttributeMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AttributeVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+public interface ApiAttributeMapper extends BaseDao<AttributeVo> {
+	
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiBrandMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.BrandVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+public interface ApiBrandMapper extends BaseDao<BrandVo> {
+	
+}

+ 30 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCartMapper.java

@@ -0,0 +1,30 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CartVo;
+import org.apache.ibatis.annotations.Param;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+@Component
+public interface ApiCartMapper extends BaseDao<CartVo> {
+    void updateCheck(@Param("productIds") String[] productIds,
+                     @Param("isChecked") Integer isChecked, @Param("user_id") Long userId, @Param("store_id") Long store_id);
+
+    void deleteByProductIds(@Param("productIds") String[] productIds, @Param("store_id") Long store_id);
+
+    void deleteByCart(@Param("user_id") Long user_id, @Param("store_id") Long store_id, @Param("checked") Integer checked);
+
+    List<CartVo> queryCartByGoodsBizType(@Param("goodsBizType") String goodsBizType);
+
+    List<CartVo> queryValidCartList(Map<String, Object> map);
+
+    CartVo queryObjectByGoodsIdAndUserId(@Param("goods_id")Long goods_id,@Param("user_id")Long user_id);
+}

+ 21 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCategoryMapper.java

@@ -0,0 +1,21 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CategoryVo;
+import com.kmall.common.dao.BaseDao;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:25
+ */
+public interface ApiCategoryMapper extends BaseDao<CategoryVo> {
+
+    /**
+     * 根据父节点,查询所有子节点,包括自己
+     */
+    List<CategoryVo> queryListByParentId(Map<String, Object> map);
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiChannelMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.ChannelVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+public interface ApiChannelMapper extends BaseDao<ChannelVo> {
+	
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCollectMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CollectVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+public interface ApiCollectMapper extends BaseDao<CollectVo> {
+	
+}

+ 26 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCommentMapper.java

@@ -0,0 +1,26 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CommentVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:26
+ */
+@Component
+public interface ApiCommentMapper extends BaseDao<CommentVo> {
+    int queryhasPicTotal(Map<String, Object> map);
+
+    /**
+     * 查询评价统计
+     *
+     * @param map
+     * @return
+     */
+    List<Map> queryOrderTotal(Map<String, Object> map);
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCommentPictureMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CommentPictureVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:26
+ */
+@Component
+public interface ApiCommentPictureMapper extends BaseDao<CommentPictureVo> {
+	
+}

+ 32 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiCouponMapper.java

@@ -0,0 +1,32 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.CouponVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+@Component
+public interface ApiCouponMapper extends BaseDao<CouponVo> {
+    /**
+     * 按条件查询用户优惠券
+     *
+     * @param params
+     * @return
+     */
+    List<CouponVo> queryUserCoupons(Map<String, Object> params);
+
+    /**
+     * 按类型查询
+     *
+     * @param params
+     * @return
+     */
+    CouponVo queryMaxUserEnableCoupon(Map<String, Object> params);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiFeedbackMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.FeedbackVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:26
+ */
+public interface ApiFeedbackMapper extends BaseDao<FeedbackVo> {
+	
+}

+ 18 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiFootprintMapper.java

@@ -0,0 +1,18 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.FootprintVo;
+import com.kmall.common.dao.BaseDao;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:14:26
+ */
+public interface ApiFootprintMapper extends BaseDao<FootprintVo> {
+    int deleteByParam(Map<String, Object> map);
+
+    List<FootprintVo> shareList(Map<String, Object> map);
+}

+ 19 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiFreightMapper.java

@@ -0,0 +1,19 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.FreightEntity;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+/**
+ * Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-10-22 17:20:31
+ */
+@Component
+public interface ApiFreightMapper extends BaseDao<FreightEntity> {
+    FreightEntity queryObjectByGoodsId(@Param("goodsId") Long goodsId);
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsActivityMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.dto.GoodsActivityVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-08-26 21:37:50
+ */
+public interface ApiGoodsActivityMapper extends BaseDao<GoodsActivityVo> {
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsCrashMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsCrashVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 商品搭配减Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-08-30 19:38:48
+ */
+public interface ApiGoodsCrashMapper extends BaseDao<GoodsCrashVo> {
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGalleryMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsGalleryVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiGoodsGalleryMapper extends BaseDao<GoodsGalleryVo> {
+	
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsGroupVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-08-26 21:37:50
+ */
+public interface ApiGoodsGroupMapper extends BaseDao<GoodsGroupVo> {
+
+    GoodsGroupVo queryObjectByStoreId(@Param("id") Long id, @Param("storeId") Long storeId);
+}

+ 19 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupOpenDetailMapper.java

@@ -0,0 +1,19 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsGroupOpenDetailVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-10-18 16:00:50
+ */
+@Component
+public interface ApiGoodsGroupOpenDetailMapper extends BaseDao<GoodsGroupOpenDetailVo> {
+    int updateComplete(Map<String, Object> params);
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsGroupOpenMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsGroupOpenVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-10-18 16:00:50
+ */
+@Component
+public interface ApiGoodsGroupOpenMapper extends BaseDao<GoodsGroupOpenVo> {
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsIssueMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsIssueVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiGoodsIssueMapper extends BaseDao<GoodsIssueVo> {
+	
+}

+ 24 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsMapper.java

@@ -0,0 +1,24 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:45
+ */
+@Component
+public interface ApiGoodsMapper extends BaseDao<GoodsVo> {
+
+    List<GoodsVo> queryHotGoodsList(Map<String, Object> params);
+
+    List<GoodsVo> queryCatalogProductList(Map<String, Object> params);
+
+    GoodsVo queryObjectByStoreId(@Param("id") Long id, @Param("storeId") Long storeId);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiGoodsSpecificationMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.GoodsSpecificationVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 商品对应规格表值表
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiGoodsSpecificationMapper extends BaseDao<GoodsSpecificationVo> {
+	
+}

+ 16 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiHelpIssueMapper.java

@@ -0,0 +1,16 @@
+package com.kmall.api.dao;
+
+
+import com.kmall.api.entity.HelpIssueVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-12-02 10:04:20
+ */
+public interface ApiHelpIssueMapper extends BaseDao<HelpIssueVo> {
+
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiHelpTypeMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.HelpTypeVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-12-02 10:04:20
+ */
+public interface ApiHelpTypeMapper extends BaseDao<HelpTypeVo> {
+
+}

+ 18 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiKeywordsMapper.java

@@ -0,0 +1,18 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.KeywordsVo;
+import com.kmall.common.dao.BaseDao;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 热闹关键词表
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiKeywordsMapper extends BaseDao<KeywordsVo> {
+    List<Map> hotKeywordList(Map param);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiMerchMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.MerchVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-12-05 18:06:35
+ */
+public interface ApiMerchMapper extends BaseDao<MerchVo> {
+    MerchVo queryObjectByMerchSn(String merchSn);
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiMerchUserMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+
+import com.kmall.api.entity.MerchUserVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-12-05 14:34:32
+ */
+public interface ApiMerchUserMapper extends BaseDao<MerchUserVo> {
+    MerchUserVo queryObjectByStoreId(@Param("storeId") Long storeId, @Param("userId")Long userId);
+}

+ 11 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiMngChangeMapper.java

@@ -0,0 +1,11 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.MallMngChange;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiMngChangeMapper extends BaseDao<AddressVo> {
+
+    MallMngChange selectByPrimaryKey(Integer id);
+
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderBuyerPayCheckMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.OrderBuyerPayCheckEntity;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * 订单订购人支付人核验记录Dao
+ *
+ * @author huangyaqin
+ * @email admin@qhdswl.com
+ * @date 2018-10-25 17:53:21
+ */
+@Component
+public interface ApiOrderBuyerPayCheckMapper extends BaseDao<OrderBuyerPayCheckEntity> {
+
+}

+ 11 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderExceptionRecordMapper.java

@@ -0,0 +1,11 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.MallOrderExceptionRecord;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+@Component
+public interface ApiOrderExceptionRecordMapper extends BaseDao<MallOrderExceptionRecord> {
+
+    MallOrderExceptionRecord selectByPrimaryKey(Integer id);
+}

+ 21 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderGoodsMapper.java

@@ -0,0 +1,21 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.OrderGoodsVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+@Component
+public interface ApiOrderGoodsMapper extends BaseDao<OrderGoodsVo> {
+    List<OrderGoodsVo> queryListByIds(@Param("orderIdList")List<Long> orderIdList);
+	
+}

+ 49 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderMapper.java

@@ -0,0 +1,49 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.OrderVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+@Component
+public interface ApiOrderMapper extends BaseDao<OrderVo> {
+    void riderOrderUpdate(OrderVo orderVo);
+
+    /**
+     * 根据订单编号查询订单
+     *
+     * @param order_sn
+     * @return
+     */
+    OrderVo queryObjectByOrderSn(@Param("order_sn") String order_sn);
+
+    /**
+     * 统计个人中心首页的订单数量
+     *
+     * @param map
+     * @return
+     */
+    Map queryUcenterMap(Map<String, Object> map);
+
+    List<OrderVo> queryObjectByIdList(@Param("orderIdList")List<Long> orderIdList);
+
+    List<OrderVo> queryObjectByMerchOrderSn(@Param("merchOrderSn")String merchOrderSn);
+
+    int queryCountByMerchOrderSn(@Param("merchOrderSn")String merchOrderSn);
+
+    int queryCountByPayId(@Param("payId")String payId);
+
+    int updateOrderByMerchOrderSn(OrderVo orderVo);
+
+    List<OrderVo> queryOrderByMerchOrderSnAndRefundStatus(@Param("merchOrderSn")String merchOrderSn);
+
+    int updateBatch(List<OrderVo> list);
+}

+ 23 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderProcessRecordMapper.java

@@ -0,0 +1,23 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.OrderProcessRecordEntity;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 订单流转过程记录表Dao
+ *
+ * @author huangyaqin
+ * @email admin@qhdswl.com
+ * @date 2018-10-25 17:48:30
+ */
+@Component
+public interface ApiOrderProcessRecordMapper extends BaseDao<OrderProcessRecordEntity> {
+
+    void updateBatch(List<OrderProcessRecordEntity> list);
+
+    OrderProcessRecordEntity queryObjectByOrderSn(@Param("orderSn") String orderSn);
+}

+ 13 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderRefundMapper.java

@@ -0,0 +1,13 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.MallOrderRefund;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+@Component
+public interface ApiOrderRefundMapper extends BaseDao<MallOrderRefund> {
+    MallOrderRefund selectByPrimaryKey(Integer id);
+
+    MallOrderRefund queryObjectByOrderId(@Param("orderId") String orderId);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiPayerChildOrderRealMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.PayerChildOrderRealEntity;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 支付单子订单关联记录表Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-10-11 14:38:15
+ */
+public interface ApiPayerChildOrderRealMapper extends BaseDao<PayerChildOrderRealEntity> {
+
+}

+ 20 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiPinganPayOrderMapper.java

@@ -0,0 +1,20 @@
+package com.kmall.api.dao;
+
+import com.kmall.common.dao.BaseDao;
+import com.kmall.common.utils.pingan.dto.PinganPayOrderDto;
+import org.springframework.stereotype.Component;
+
+/**
+ * Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-12-06 15:29:43
+ */
+@Component
+public interface ApiPinganPayOrderMapper extends BaseDao<PinganPayOrderDto> {
+
+    int updateByOutNo(PinganPayOrderDto pinganPayOrder);
+
+    PinganPayOrderDto queryByOutNo(String outNo);
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiPinganResponseMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.common.dao.BaseDao;
+import com.kmall.common.utils.pingan.dto.PinganResponseDto;
+import org.springframework.stereotype.Component;
+
+/**
+ * Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2018-12-06 15:29:43
+ */
+@Component
+public interface ApiPinganResponseMapper extends BaseDao<PinganResponseDto> {
+
+}

+ 42 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiProductMapper.java

@@ -0,0 +1,42 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.ProductVo;
+import org.apache.ibatis.annotations.Param;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+@Component
+public interface ApiProductMapper extends BaseDao<ProductVo> {
+    ProductVo queryObjectByStoreId(@Param("id") Long id, @Param("store_id") Long store_id);
+
+    /**
+     * 根据门店查找库存最大的产品
+     *
+     * @param goods_id
+     * @param store_id
+     * @return
+     */
+    ProductVo queryOneByGoodsId(@Param("goods_id") Long goods_id, @Param("store_id") Long store_id);
+
+    ProductVo queryByStoreId(@Param("id") Long id, @Param("store_id") Long store_id);
+
+    /**
+     * 更新库存
+     *
+     * @return
+     */
+    void updateStockNum(ProductVo productVo);
+
+    /**
+     * 更新销售量
+     *
+     * @return
+     */
+    void updateSellVolumeNum(ProductVo productVo);
+
+}

+ 18 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiProductStoreRelaMapper.java

@@ -0,0 +1,18 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.ProductStoreRelaVo;
+import com.kmall.common.dao.BaseDao;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Component;
+
+/**
+ * 门店商品表Dao
+ *
+ * @author huangyaqin
+ * @email admin@qhdswl.com
+ * @date 2018-10-30 14:15:55
+ */
+@Component
+public interface ApiProductStoreRelaMapper extends BaseDao<ProductStoreRelaVo> {
+    ProductStoreRelaVo queryByStoreIdProductId(@Param("storeId") Long storeId, @Param("productId") Long productId);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiRelatedGoodsMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.RelatedGoodsVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiRelatedGoodsMapper extends BaseDao<RelatedGoodsVo> {
+	
+}

+ 16 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiSearchHistoryMapper.java

@@ -0,0 +1,16 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.SearchHistoryVo;
+import org.apache.ibatis.annotations.Param;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiSearchHistoryMapper extends BaseDao<SearchHistoryVo> {
+    int deleteByUserId(@Param("user_id") Long userId);
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiSpecificationMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.SpecificationVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 规格表
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiSpecificationMapper extends BaseDao<SpecificationVo> {
+	
+}

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiStoreGoodsGalleryMapper.java

@@ -0,0 +1,10 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.MallStoreGoodsGallery;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiStoreGoodsGalleryMapper extends BaseDao<AddressVo> {
+
+    MallStoreGoodsGallery selectByPrimaryKey(Integer id);
+}

+ 19 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMapper.java

@@ -0,0 +1,19 @@
+package com.kmall.api.dao;
+
+
+import com.kmall.api.entity.StoreVo;
+import com.kmall.common.dao.BaseDao;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Dao
+ *
+ * @author Scott
+ * @email
+ * @date 2017-12-07 17:53:15
+ */
+public interface ApiStoreMapper extends BaseDao<StoreVo> {
+    List<StoreVo> queryNearbyList(Map param);
+}

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMngChangeMapper.java

@@ -0,0 +1,10 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.MallStoreMngChange;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiStoreMngChangeMapper extends BaseDao<AddressVo> {
+
+    MallStoreMngChange selectByPrimaryKey(Integer id);
+}

+ 9 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiStoreMngMapper.java

@@ -0,0 +1,9 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.MallStoreMng;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiStoreMngMapper extends BaseDao<AddressVo> {
+    MallStoreMng selectByPrimaryKey(Integer id);
+}

+ 9 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiSysExceptionRecordMapper.java

@@ -0,0 +1,9 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.SysExceptionRecord;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiSysExceptionRecordMapper extends BaseDao<AddressVo> {
+    SysExceptionRecord selectByPrimaryKey(Integer id);
+}

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiSysParamMapper.java

@@ -0,0 +1,10 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.SysParam;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiSysParamMapper extends BaseDao<AddressVo> {
+
+    SysParam selectByPrimaryKey(Integer paramId);
+}

+ 16 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiSysPrinterMapper.java

@@ -0,0 +1,16 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.SysPrinterVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * 打印机
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:22:06
+ */
+@Component
+public interface ApiSysPrinterMapper extends BaseDao<SysPrinterVo> {
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiTopicCategoryMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.TopicCategoryVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiTopicCategoryMapper extends BaseDao<TopicCategoryVo> {
+	
+}

+ 15 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiTopicMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.TopicVo;
+import com.kmall.common.dao.BaseDao;
+
+/**
+ * 
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:46
+ */
+public interface ApiTopicMapper extends BaseDao<TopicVo> {
+	
+}

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiUserCollectionMapper.java

@@ -0,0 +1,10 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.AddressVo;
+import com.kmall.api.entity.MallUserCollection;
+import com.kmall.common.dao.BaseDao;
+
+public interface ApiUserCollectionMapper extends BaseDao<AddressVo> {
+    MallUserCollection selectByPrimaryKey(Integer id);
+
+}

+ 22 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiUserCouponMapper.java

@@ -0,0 +1,22 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.UserCouponVo;
+import org.apache.ibatis.annotations.Param;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+@Component
+public interface ApiUserCouponMapper extends BaseDao<UserCouponVo> {
+    UserCouponVo queryByCouponNumber(@Param("coupon_number") String coupon_number);
+
+    UserCouponVo queryByOrderId(@Param("order_id") Long order_id);
+
+    Integer cancelOrder(UserCouponVo couponVo);
+
+    UserCouponVo queryObjectByIdAndUsed(Integer id);
+}

+ 17 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiUserLevelMapper.java

@@ -0,0 +1,17 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.UserLevelVo;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+/**
+ * 商城_用户级别
+ * 
+ * @author Scott
+ * @email
+ * @date 2017-08-11 09:16:47
+ */
+@Component
+public interface ApiUserLevelMapper extends BaseDao<UserLevelVo> {
+	
+}

+ 44 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiUserMapper.java

@@ -0,0 +1,44 @@
+package com.kmall.api.dao;
+
+import com.kmall.api.entity.SmsLogVo;
+import com.kmall.api.entity.UserVo;
+import org.apache.ibatis.annotations.Param;
+import com.kmall.common.dao.BaseDao;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 用户
+ *
+ * @author Scott
+ * @email
+ * @date 2017-03-23 15:22:06
+ */
+@Component
+public interface ApiUserMapper extends BaseDao<UserVo> {
+
+    List<UserVo> queryByMobile(String mobile);
+
+    UserVo queryByOpenId(@Param("openId") String openId);
+
+    /**
+     * 获取用户最后一条短信
+     *
+     * @param id
+     * @return
+     */
+    SmsLogVo querySmsCodeByUserId(@Param("id") Long id);
+
+    /**
+     * 保存短信
+     *
+     * @param smsLogVo
+     * @return
+     */
+    int saveSmsCodeLog(SmsLogVo smsLogVo);
+
+    UserVo queryObject(Integer id);
+
+    UserVo queryObjectByIdNoAndName(@Param("idNo") String idNo,@Param("userName") String userName);
+}

+ 152 - 0
kmall-api/src/main/java/com/kmall/api/dto/GeometryMarker.java

@@ -0,0 +1,152 @@
+package com.kmall.api.dto;
+
+import com.kmall.api.util.CommonUtil;
+
+import java.math.BigDecimal;
+
+/**
+ * @author zhouzhengde(CN)
+ * @date 2017/12/28.
+ */
+public class GeometryMarker {
+    //
+    private Long id;
+    //
+    private String iconPath;
+    //
+    private BigDecimal latitude;
+    //
+    private BigDecimal longitude;
+    //
+    private Integer width;
+    //
+    private Integer height;
+    //
+    private GeometryMarkerCallout callout;
+
+    class GeometryMarkerCallout {
+        //
+        private String content;
+        //
+        private String color;
+        //
+        private String display;
+        //
+        private Integer padding;
+        //
+        private Integer borderRadius;
+
+        public String getContent() {
+            return content;
+        }
+
+        public void setContent(String content) {
+            this.content = content;
+        }
+
+        public String getColor() {
+            return color;
+        }
+
+        public void setColor(String color) {
+            this.color = color;
+        }
+
+        public String getDisplay() {
+            return display;
+        }
+
+        public void setDisplay(String display) {
+            this.display = display;
+        }
+
+        public Integer getPadding() {
+            return padding;
+        }
+
+        public void setPadding(Integer padding) {
+            this.padding = padding;
+        }
+
+        public Integer getBorderRadius() {
+            return borderRadius;
+        }
+
+        public void setBorderRadius(Integer borderRadius) {
+            this.borderRadius = borderRadius;
+        }
+    }
+
+    public String getIconPath() {
+        return iconPath;
+    }
+
+    public void setIconPath(String iconPath) {
+        this.iconPath = iconPath;
+    }
+
+    public BigDecimal getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(BigDecimal latitude) {
+        this.latitude = latitude;
+    }
+
+    public BigDecimal getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(BigDecimal longitude) {
+        this.longitude = longitude;
+    }
+
+    public Integer getWidth() {
+        return width;
+    }
+
+    public void setWidth(Integer width) {
+        this.width = width;
+    }
+
+    public Integer getHeight() {
+        return height;
+    }
+
+    public void setHeight(Integer height) {
+        this.height = height;
+    }
+
+    public GeometryMarkerCallout getCallout() {
+        return callout;
+    }
+
+    public void setCallout(GeometryMarkerCallout callout) {
+        this.callout = callout;
+    }
+
+    /**
+     * 配送中的订单骑手初始化
+     *
+     * @param id
+     * @param latitude
+     * @param longitude
+     * @param targetLatitude
+     * @param targetLongitude
+     */
+    public GeometryMarker(Long id, BigDecimal latitude, BigDecimal longitude, BigDecimal targetLatitude, BigDecimal targetLongitude) {
+        this.id = id;
+        this.iconPath = "/static/images/rider.png";
+        this.width = 40;
+        this.height = 40;
+        this.latitude = latitude;
+        this.longitude = longitude;
+        double distance = CommonUtil.getDistance(latitude.doubleValue(), longitude.doubleValue(),
+                targetLatitude.doubleValue(), targetLongitude.doubleValue());
+        this.callout = new GeometryMarkerCallout();
+        callout.setContent("距离你" + distance + "km");
+        callout.setColor("#fe7200");
+        callout.setDisplay("ALWAYS");
+        callout.setBorderRadius(30);
+    }
+}

+ 125 - 0
kmall-api/src/main/java/com/kmall/api/dto/GoodsActivityVo.java

@@ -0,0 +1,125 @@
+package com.kmall.api.dto;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * 活动实体(团购)
+ */
+public class GoodsActivityVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //主键
+    private Integer id;
+    //活動大图
+    private String title;
+    //活動条例图片
+    private String item_pic_url;
+    //原价
+    private BigDecimal market_price;
+    //零售价格(现价)
+    private BigDecimal retail_price;
+    // 活动价
+    private BigDecimal retail_min_price;
+    //
+    private Integer goods_id;
+    //
+    private Date open_time;
+    //
+    private Date end_time;
+    //
+    private String subtitle;
+    // 活动类型 1 2团购
+    private Integer type;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getItem_pic_url() {
+        return item_pic_url;
+    }
+
+    public void setItem_pic_url(String item_pic_url) {
+        this.item_pic_url = item_pic_url;
+    }
+
+    public BigDecimal getMarket_price() {
+        return market_price;
+    }
+
+    public void setMarket_price(BigDecimal market_price) {
+        this.market_price = market_price;
+    }
+
+    public Integer getGoods_id() {
+        return goods_id;
+    }
+
+    public void setGoods_id(Integer goods_id) {
+        this.goods_id = goods_id;
+    }
+
+    public String getSubtitle() {
+        return subtitle;
+    }
+
+
+    public void setSubtitle(String subtitle) {
+        this.subtitle = subtitle;
+    }
+
+    public BigDecimal getRetail_price() {
+        return retail_price;
+    }
+
+    public void setRetail_price(BigDecimal retail_price) {
+        this.retail_price = retail_price;
+    }
+
+    public Date getOpen_time() {
+        return open_time;
+    }
+
+    public void setOpen_time(Date open_time) {
+        this.open_time = open_time;
+    }
+
+    public Date getEnd_time() {
+        return end_time;
+    }
+
+    public void setEnd_time(Date end_time) {
+        this.end_time = end_time;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public BigDecimal getRetail_min_price() {
+        return retail_min_price;
+    }
+
+    public void setRetail_min_price(BigDecimal retail_min_price) {
+        this.retail_min_price = retail_min_price;
+    }
+}

+ 48 - 0
kmall-api/src/main/java/com/kmall/api/dto/IdCardMsgVo.java

@@ -0,0 +1,48 @@
+package com.kmall.api.dto;
+
+/**
+ * @author huangyaqin
+ * @version 1.0
+ * 2018-10-16 14:23
+ */
+public class IdCardMsgVo {
+    private String respCode;
+
+    private String respMessage;
+
+    private String idNo;
+
+    private String name;
+
+    public String getRespCode() {
+        return respCode;
+    }
+
+    public void setRespCode(String respCode) {
+        this.respCode = respCode;
+    }
+
+    public String getRespMessage() {
+        return respMessage;
+    }
+
+    public void setRespMessage(String respMessage) {
+        this.respMessage = respMessage;
+    }
+
+    public String getIdNo() {
+        return idNo;
+    }
+
+    public void setIdNo(String idNo) {
+        this.idNo = idNo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 48 - 0
kmall-api/src/main/java/com/kmall/api/dto/SendMsgVo.java

@@ -0,0 +1,48 @@
+package com.kmall.api.dto;
+
+/**
+ * @author huangyaqin
+ * @version 1.0
+ * 2018-10-16 14:23
+ */
+public class SendMsgVo {
+    private String code;
+
+    private String msg;
+
+    private String result;
+
+    private String sid;
+
+    public String getSid() {
+        return sid;
+    }
+
+    public void setSid(String sid) {
+        this.sid = sid;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+}

+ 64 - 0
kmall-api/src/main/java/com/kmall/api/entity/AdPositionVo.java

@@ -0,0 +1,64 @@
+package com.kmall.api.entity;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-15 08:03:40
+ */
+public class AdPositionVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //主键
+    private Integer id;
+    //位置名称
+    private String name;
+    //宽度
+    private Integer width;
+    //高度
+    private Integer height;
+    //描述
+    private String desc;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getWidth() {
+        return width;
+    }
+
+    public void setWidth(Integer width) {
+        this.width = width;
+    }
+
+    public Integer getHeight() {
+        return height;
+    }
+
+    public void setHeight(Integer height) {
+        this.height = height;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+}

+ 135 - 0
kmall-api/src/main/java/com/kmall/api/entity/AdVo.java

@@ -0,0 +1,135 @@
+package com.kmall.api.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-15 08:03:40
+ */
+public class AdVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //主键
+    private Integer id;
+    //广告位置Id
+    private Integer adPositionId;
+    //形式 0 普通 1活动广告 2新用户注册
+    private Integer mediaType;
+    //广告名称
+    private String name;
+    //链接
+    private String link;
+    //图片
+    private String imageUrl;
+    //内容
+    private String content;
+    //结束时间
+    private Date endTime;
+    //状态
+    private Integer enabled;
+
+    private Integer sortOrder;
+
+    private Long storeId;
+
+    private String merchSn;
+
+    public Long getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(Long storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
+    public Integer getSortOrder() {
+        return sortOrder;
+    }
+
+    public void setSortOrder(Integer sortOrder) {
+        this.sortOrder = sortOrder;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLink() {
+        return link;
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Integer getEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(Integer enabled) {
+        this.enabled = enabled;
+    }
+
+    public Integer getAdPositionId() {
+        return adPositionId;
+    }
+
+    public void setAdPositionId(Integer adPositionId) {
+        this.adPositionId = adPositionId;
+    }
+
+    public Integer getMediaType() {
+        return mediaType;
+    }
+
+    public void setMediaType(Integer mediaType) {
+        this.mediaType = mediaType;
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+}

+ 246 - 0
kmall-api/src/main/java/com/kmall/api/entity/AddressVo.java

@@ -0,0 +1,246 @@
+package com.kmall.api.entity;
+
+import com.kmall.common.cache.RegionCacheUtil;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-15 08:03:39
+ */
+public class AddressVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //
+    private Long id;
+    //会员ID
+    private Long userId;
+    //收货人姓名
+    private String userName;
+    //手机
+    private String telNumber;
+    //邮编
+    private String postalCode;
+    //收货地址国家码
+    private String nationalCode;
+    //省
+    private String provinceName;
+    //市
+    private String cityName;
+    //区
+    private String countyName;
+    //详细收货地址信息
+    private String detailInfo;
+    // 是否默认
+    private Integer isDefault = 0;
+    //纬度
+    private BigDecimal latitude;
+    //经度
+    private BigDecimal longitude;
+
+    //冗余
+    private Integer provinceId;
+    private Integer cityId;
+    private Integer countyId;
+
+    /**
+     * 设置:
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 获取:
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 设置:会员ID
+     */
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 获取:会员ID
+     */
+    public Long getUserId() {
+        return userId;
+    }
+
+    /**
+     * 设置:收货人姓名
+     */
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    /**
+     * 获取:收货人姓名
+     */
+    public String getUserName() {
+        return userName;
+    }
+
+    /**
+     * 设置:手机
+     */
+    public void setTelNumber(String telNumber) {
+        this.telNumber = telNumber;
+    }
+
+    /**
+     * 获取:手机
+     */
+    public String getTelNumber() {
+        return telNumber;
+    }
+
+    /**
+     * 设置:邮编
+     */
+    public void setPostalCode(String postalCode) {
+        this.postalCode = postalCode;
+    }
+
+    /**
+     * 获取:邮编
+     */
+    public String getPostalCode() {
+        return postalCode;
+    }
+
+    /**
+     * 设置:收货地址国家码
+     */
+    public void setNationalCode(String nationalCode) {
+        this.nationalCode = nationalCode;
+    }
+
+    /**
+     * 获取:收货地址国家码
+     */
+    public String getNationalCode() {
+        return nationalCode;
+    }
+
+    /**
+     * 设置:省
+     */
+    public void setProvinceName(String provinceName) {
+        this.provinceName = provinceName;
+    }
+
+    /**
+     * 获取:省
+     */
+    public String getProvinceName() {
+        return provinceName;
+    }
+
+    /**
+     * 设置:市
+     */
+    public void setCityName(String cityName) {
+        this.cityName = cityName;
+    }
+
+    /**
+     * 获取:市
+     */
+    public String getCityName() {
+        return cityName;
+    }
+
+    /**
+     * 设置:区
+     */
+    public void setCountyName(String countyName) {
+        this.countyName = countyName;
+    }
+
+    /**
+     * 获取:区
+     */
+    public String getCountyName() {
+        return countyName;
+    }
+
+    /**
+     * 设置:详细收货地址信息
+     */
+    public void setDetailInfo(String detailInfo) {
+        this.detailInfo = detailInfo;
+    }
+
+    /**
+     * 获取:详细收货地址信息
+     */
+    public String getDetailInfo() {
+        return detailInfo;
+    }
+
+    public Integer getIsDefault() {
+        return isDefault;
+    }
+
+    public void setIsDefault(Integer isDefault) {
+        this.isDefault = isDefault;
+    }
+
+    public Integer getProvinceId() {
+        if (null == provinceId && !StringUtils.isEmpty(provinceName)) {
+            provinceId = RegionCacheUtil.getProvinceIdByName(provinceName);
+        }
+        return provinceId;
+    }
+
+    public void setProvinceId(Integer provinceId) {
+        this.provinceId = provinceId;
+    }
+
+    public Integer getCityId() {
+        if (null == cityId && !StringUtils.isEmpty(cityName) && null != getProvinceId()) {
+            cityId = RegionCacheUtil.getCityIdByName(getProvinceId(), cityName);
+        }
+        return cityId;
+    }
+
+    public void setCityId(Integer cityId) {
+        this.cityId = cityId;
+    }
+
+    public Integer getCountyId() {
+        if (null == countyId && !StringUtils.isEmpty(cityName) && null != getProvinceId() && null != getCityId()) {
+            countyId = RegionCacheUtil.getDistrictIdByName(getProvinceId(), getCityId(), countyName);
+        }
+        return countyId;
+    }
+
+    public void setCountyId(Integer countyId) {
+        this.countyId = countyId;
+    }
+
+    public BigDecimal getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(BigDecimal latitude) {
+        this.latitude = latitude;
+    }
+
+    public BigDecimal getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(BigDecimal longitude) {
+        this.longitude = longitude;
+    }
+}

+ 45 - 0
kmall-api/src/main/java/com/kmall/api/entity/AttributeCategoryVo.java

@@ -0,0 +1,45 @@
+package com.kmall.api.entity;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Scott
+ * @email
+ * @date 2017-08-15 08:03:41
+ */
+public class AttributeCategoryVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    //
+    private Integer id;
+    //
+    private String name;
+    //
+    private Integer enabled;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(Integer enabled) {
+        this.enabled = enabled;
+    }
+}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.