Browse Source

no message

FengChaoYu 7 months ago
parent
commit
5cafd8b595

+ 16 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/material/parts/WebsitExtends.java

@@ -0,0 +1,16 @@
+package com.gree.mall.miniapp.bean.material.parts;
+
+import com.gree.mall.miniapp.plus.entity.AdminWebsit;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class WebsitExtends extends AdminWebsit {
+
+    @ApiModelProperty("距离(单位:km)")
+    private Double distance;
+}

+ 8 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/MaterialMapper.java

@@ -215,6 +215,7 @@ public interface MaterialMapper {
                                                    @Param("identity") String identity,
                                                    @Param("websitId") String websitId);
 
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     IPage<OldRefundManageBean> appOldRefundList(Page page,
                                                 @Param("companyWechatId") String companyWechatId,
                                                 @Param("applyNo") String applyNo,
@@ -222,4 +223,11 @@ public interface MaterialMapper {
                                                 @Param("flag") String flag,
                                                 @Param("identity") String identity,
                                                 @Param("partsNumber") String partsNumber);
+
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
+    IPage<WebsitExtends> queryWebsitList(Page page,
+                                         @Param("companyWechatId") String companyWechatId,
+                                         @Param("websitId") String websitId,
+                                         @Param("longitude") String longitude,
+                                         @Param("latitude") String latitude);
 }

+ 52 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/material/parts/BuyController.java

@@ -0,0 +1,52 @@
+package com.gree.mall.miniapp.controller.material.parts;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.miniapp.bean.material.parts.WebsitExtends;
+import com.gree.mall.miniapp.exception.RemoteServiceException;
+import com.gree.mall.miniapp.helper.ResponseHelper;
+import com.gree.mall.miniapp.logic.material.parts.BuyLogic;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+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 javax.annotation.Resource;
+
+@Slf4j
+@RestController
+@Api(value = "配件购买", tags ={"配件购买"} )
+@RequestMapping(value = "/app/buy", produces = "application/json; charset=utf-8")
+public class BuyController {
+
+    @Resource
+    BuyLogic buyLogic;
+
+    @ApiOperation(value = "当前默认销售网点")
+    @GetMapping("/websit/default")
+    public ResponseHelper<WebsitExtends> websitDefault(
+            @ApiParam(value = "所属网点编码",required = false) @RequestParam(required = false)  String websitId,
+            @ApiParam(value = "经度",required = true) @RequestParam(required = true) String longitude,
+            @ApiParam(value = "纬度",required = true) @RequestParam(required = true) String latitude
+    ) throws RemoteServiceException {
+        WebsitExtends shop = buyLogic.defaultWebsit(websitId, longitude, latitude);
+        return ResponseHelper.success(shop);
+    }
+
+
+    @ApiOperation(value = "附近的销售网点列表")
+    @GetMapping("/websit/list")
+    public ResponseHelper<IPage<WebsitExtends>> websitDefault(
+            @ApiParam(value = "所属网点编码") @RequestParam(required = false) String websitId,
+            @ApiParam(value = "经度",required = true) @RequestParam String longitude,
+            @ApiParam(value = "纬度",required = true) @RequestParam String latitude,
+            @ApiParam(value = "页号",required = true) @RequestParam Integer pageNo,
+            @ApiParam(value = "页大小",required = true) @RequestParam Integer pageSize
+    ) throws RemoteServiceException {
+        IPage<WebsitExtends> fcShopExtendsIPage = buyLogic.queryWebsitList(websitId, longitude, latitude, pageNo, pageSize);
+        return ResponseHelper.success(fcShopExtendsIPage);
+    }
+}

+ 36 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/parts/BuyLogic.java

@@ -0,0 +1,36 @@
+package com.gree.mall.miniapp.logic.material.parts;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.miniapp.bean.material.parts.WebsitExtends;
+import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
+import com.gree.mall.miniapp.commonmapper.MaterialMapper;
+import com.gree.mall.miniapp.logic.common.CommonLogic;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Service
+public class BuyLogic {
+
+    @Resource
+    MaterialMapper materialMapper;
+    @Resource
+    CommonLogic commonLogic;
+
+    public WebsitExtends defaultWebsit(String websitId, String longitude, String latitude) {
+        final CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat();
+        IPage<WebsitExtends> shopExtendsIPage = materialMapper.queryWebsitList(new Page(1, 1,false), wechat.getCompanyWechatId(), websitId, longitude, latitude);
+        if(shopExtendsIPage.getRecords().size() > 0){
+            return shopExtendsIPage.getRecords().get(0);
+        }
+        return null;
+    }
+
+    public IPage<WebsitExtends> queryWebsitList(String websitId, String longitude, String latitude, Integer pageNo, Integer pageSize) {
+        final CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat();
+        return materialMapper.queryWebsitList(new Page(pageNo, pageSize), wechat.getCompanyWechatId(), websitId, longitude, latitude);
+    }
+}

+ 18 - 0
mall-miniapp-service/src/main/resources/mapper/MaterialMapper.xml

@@ -677,5 +677,23 @@
         ORDER BY a.createTime DESC
     </select>
 
+    <select id="queryWebsitList" resultType="com.gree.mall.miniapp.bean.material.parts.WebsitExtends">
+        SELECT
+        a.*,
+        <!-- 按距离排序计算 -->
+        TRUNCATE(ACOS(
+        SIN((PI() / 180) * lat) * SIN((PI() / 180) * #{latitude})
+        + COS((PI() / 180) * lat) * COS((PI() / 180) * #{latitude}) * COS((PI() / 180) * #{longitude} - (PI() / 180) * lng)
+        ) * 6371,0) as distance
+
+        from admin_websit a
+        <where>
+            <if test="websitId == null">
+                AND a.status = 1
+            </if>
+        </where>
+        order by distance asc, websit_id
+    </select>
+
 
 </mapper>