|
|
@@ -773,3 +773,81 @@ func QueryHsbyBuyMyTradeDetail(c *gin.Context) {
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, orders)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// GetHsbyMyCountReq 获取我的订单与包裹数量请求参数模型
|
|
|
+type GetHsbyMyCountReq struct {
|
|
|
+ AccountIDs string `form:"accountIDs" binding:"required"`
|
|
|
+}
|
|
|
+
|
|
|
+// GetHsbyMyCountRsp 获取我的订单与包裹数量返回模型
|
|
|
+type GetHsbyMyCountRsp struct {
|
|
|
+ MyOrderDetailPreCount int `json:"myOrderDetailPreCount"` // 我的订单抢购中数量
|
|
|
+ MyOrderDetailListingCount int `json:"myOrderDetailListingCount"` // 我的订单求购中数量
|
|
|
+ MyPackageUnSendCount int `json:"myPackageUnSendCount"` // 我的包裹待发货数量
|
|
|
+ MyPackageUnReceiveCount int `json:"myPackageUnReceiveCount"` // 我的包裹待收货数量
|
|
|
+}
|
|
|
+
|
|
|
+// GetHsbyMyCount 获取我的订单与包裹数量
|
|
|
+// @Summary 获取我的订单与包裹数量
|
|
|
+// @Description 说明: 不包括已完成的数量。
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param accountIDs query string true "资金账户列表,格式:1,2,3"
|
|
|
+// @Success 200 {object} GetHsbyMyCountRsp
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /HSBY/GetHsbyMyCount [get]
|
|
|
+// @Tags 定制【海商报业】
|
|
|
+func GetHsbyMyCount(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req GetHsbyMyCountReq
|
|
|
+ if err := appG.C.ShouldBindQuery(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取我的订单数据
|
|
|
+ myOrderDetails, err := models.GetHsbyBuyMyOrderDetails(req.AccountIDs, 0)
|
|
|
+ if err != nil {
|
|
|
+ // 查询失败
|
|
|
+ logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取数据
|
|
|
+ myPackages, err := models.GetHsbyMyPackages(req.AccountIDs, 0)
|
|
|
+ if err != nil {
|
|
|
+ // 查询失败
|
|
|
+ logger.GetLogger().Errorf("GetHsbyMyCount failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 统计数量
|
|
|
+ rsp := GetHsbyMyCountRsp{}
|
|
|
+ for _, v := range myOrderDetails {
|
|
|
+ if v.MyBuyStatus == 1 {
|
|
|
+ // 抢购中
|
|
|
+ rsp.MyOrderDetailPreCount++
|
|
|
+ } else if v.MyBuyStatus == 2 {
|
|
|
+ // 求购中
|
|
|
+ rsp.MyOrderDetailListingCount++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range myPackages {
|
|
|
+ if v.Takeorderstatus == 1 {
|
|
|
+ // 待发货
|
|
|
+ rsp.MyPackageUnSendCount++
|
|
|
+ } else if v.Takeorderstatus == 2 {
|
|
|
+ // 待收货
|
|
|
+ rsp.MyPackageUnReceiveCount++
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询成功返回
|
|
|
+ logger.GetLogger().Debugln("GetHsbyMyCount successed: %v", rsp)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, rsp)
|
|
|
+}
|