|
@@ -103,6 +103,10 @@ func StockManagerApiRegistRouters() {
|
103
|
103
|
beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
|
104
|
104
|
beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
|
105
|
105
|
beego.Router("/api/stock/getallstockprice", &StockManagerApiController{}, "Get:GetAllStockPrice")
|
|
106
|
+ beego.Router("/api/stock/savecheckedprice", &StockManagerApiController{}, "Get:SaveCheckPrice")
|
|
107
|
+ beego.Router("/api/stock/getadjustpriceinfo", &StockManagerApiController{}, "Get:GetAdjustPriceById")
|
|
108
|
+ beego.Router("/api/stock/savereportstock", &StockManagerApiController{}, "Post:SaveReportStock")
|
|
109
|
+ beego.Router("/api/stock/getreportstocklist", &StockManagerApiController{}, "Get:GetReportStockList")
|
106
|
110
|
}
|
107
|
111
|
|
108
|
112
|
func (c *StockManagerApiController) CreateWarehouse() {
|
|
@@ -4916,3 +4920,253 @@ func (this *StockManagerApiController) GetAllStockPrice() {
|
4916
|
4920
|
"doctor": doctor,
|
4917
|
4921
|
})
|
4918
|
4922
|
}
|
|
4923
|
+
|
|
4924
|
+func (this *StockManagerApiController) SaveCheckPrice() {
|
|
4925
|
+ timeLayout := "2006-01-02"
|
|
4926
|
+ loc, _ := time.LoadLocation("Local")
|
|
4927
|
+ dataBody := make(map[string]interface{}, 0)
|
|
4928
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
4929
|
+ fmt.Println(err)
|
|
4930
|
+ idstr := this.GetString("ids")
|
|
4931
|
+ ids := strings.Split(idstr, ",")
|
|
4932
|
+ check_time := this.GetString("check_time")
|
|
4933
|
+ var checkTime int64
|
|
4934
|
+ if len(check_time) > 0 {
|
|
4935
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
|
|
4936
|
+ if err != nil {
|
|
4937
|
+ fmt.Println(err)
|
|
4938
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4939
|
+ return
|
|
4940
|
+ }
|
|
4941
|
+ checkTime = theTime.Unix()
|
|
4942
|
+ }
|
|
4943
|
+ checker, _ := this.GetInt64("checker")
|
|
4944
|
+ adjustPrice := models.XtStockAdjustPrice{
|
|
4945
|
+ Checker: checker,
|
|
4946
|
+ CheckerStatus: 1,
|
|
4947
|
+ CheckerTime: checkTime,
|
|
4948
|
+ }
|
|
4949
|
+ err = service.UpdateAdjustPrice(ids, adjustPrice)
|
|
4950
|
+ fmt.Println(err)
|
|
4951
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4952
|
+ "adjustPrice": adjustPrice,
|
|
4953
|
+ })
|
|
4954
|
+}
|
|
4955
|
+
|
|
4956
|
+func (this *StockManagerApiController) GetAdjustPriceById() {
|
|
4957
|
+
|
|
4958
|
+ ids := this.GetString("ids")
|
|
4959
|
+ fmt.Println("ids23232233223233232", ids)
|
|
4960
|
+ splitIds := strings.Split(ids, ",")
|
|
4961
|
+ list, _ := service.GetAdjustPricebyIdOne(splitIds)
|
|
4962
|
+ fmt.Println("list2322322323", list)
|
|
4963
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4964
|
+ "list": list,
|
|
4965
|
+ })
|
|
4966
|
+}
|
|
4967
|
+
|
|
4968
|
+func (this *StockManagerApiController) SaveReportStock() {
|
|
4969
|
+ timeLayout := "2006-01-02"
|
|
4970
|
+ loc, _ := time.LoadLocation("Local")
|
|
4971
|
+ dataBody := make(map[string]interface{}, 0)
|
|
4972
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
4973
|
+ if err != nil {
|
|
4974
|
+ utils.ErrorLog(err.Error())
|
|
4975
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4976
|
+ return
|
|
4977
|
+ }
|
|
4978
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
4979
|
+ if len(tableData) > 0 {
|
|
4980
|
+ for _, item := range tableData {
|
|
4981
|
+ items := item.(map[string]interface{})
|
|
4982
|
+
|
|
4983
|
+ if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
|
|
4984
|
+ utils.ErrorLog("good_name")
|
|
4985
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4986
|
+ return
|
|
4987
|
+ }
|
|
4988
|
+ good_name := items["good_name"].(string)
|
|
4989
|
+
|
|
4990
|
+ if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
|
|
4991
|
+ utils.ErrorLog("good_name")
|
|
4992
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4993
|
+ return
|
|
4994
|
+ }
|
|
4995
|
+
|
|
4996
|
+ if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
|
|
4997
|
+ utils.ErrorLog("packing_price")
|
|
4998
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4999
|
+ return
|
|
5000
|
+ }
|
|
5001
|
+ packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
|
|
5002
|
+
|
|
5003
|
+ if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
|
|
5004
|
+ utils.ErrorLog("warehousing_order")
|
|
5005
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5006
|
+ return
|
|
5007
|
+ }
|
|
5008
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
5009
|
+
|
|
5010
|
+ if items["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
|
|
5011
|
+ utils.ErrorLog("license_number")
|
|
5012
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5013
|
+ return
|
|
5014
|
+ }
|
|
5015
|
+ license_number := items["license_number"].(string)
|
|
5016
|
+
|
|
5017
|
+ if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
|
|
5018
|
+ utils.ErrorLog("dealer")
|
|
5019
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5020
|
+ return
|
|
5021
|
+ }
|
|
5022
|
+ dealer := items["dealer"].(string)
|
|
5023
|
+
|
|
5024
|
+ if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
|
|
5025
|
+ utils.ErrorLog("manufacturer")
|
|
5026
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5027
|
+ return
|
|
5028
|
+ }
|
|
5029
|
+ manufacturer := items["manufacturer"].(string)
|
|
5030
|
+
|
|
5031
|
+ if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
|
5032
|
+ utils.ErrorLog("specification_name")
|
|
5033
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5034
|
+ return
|
|
5035
|
+ }
|
|
5036
|
+ specification_name := items["specification_name"].(string)
|
|
5037
|
+
|
|
5038
|
+ if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
|
|
5039
|
+ utils.ErrorLog("remark")
|
|
5040
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5041
|
+ return
|
|
5042
|
+ }
|
|
5043
|
+ remark := items["remark"].(string)
|
|
5044
|
+
|
|
5045
|
+ if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
|
|
5046
|
+ utils.ErrorLog("warehousing_unit")
|
|
5047
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5048
|
+ return
|
|
5049
|
+ }
|
|
5050
|
+ warehousing_unit := items["warehousing_unit"].(string)
|
|
5051
|
+
|
|
5052
|
+ if items["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
|
|
5053
|
+ utils.ErrorLog("buy_price")
|
|
5054
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5055
|
+ return
|
|
5056
|
+ }
|
|
5057
|
+ buy_price, _ := strconv.ParseFloat(items["buy_price"].(string), 64)
|
|
5058
|
+
|
|
5059
|
+ if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
|
|
5060
|
+ utils.ErrorLog("count")
|
|
5061
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5062
|
+ return
|
|
5063
|
+ }
|
|
5064
|
+ count := int64(items["count"].(float64))
|
|
5065
|
+
|
|
5066
|
+ if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
|
|
5067
|
+ utils.ErrorLog("new_price")
|
|
5068
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5069
|
+ return
|
|
5070
|
+ }
|
|
5071
|
+ new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
|
|
5072
|
+
|
|
5073
|
+ if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
|
|
5074
|
+ utils.ErrorLog("good_id")
|
|
5075
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5076
|
+ return
|
|
5077
|
+ }
|
|
5078
|
+ good_id := int64(items["good_id"].(float64))
|
|
5079
|
+
|
|
5080
|
+ if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
|
|
5081
|
+ utils.ErrorLog("start_time")
|
|
5082
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5083
|
+ return
|
|
5084
|
+ }
|
|
5085
|
+ var startTime int64
|
|
5086
|
+ start_time := items["start_time"].(string)
|
|
5087
|
+ if len(start_time) > 0 {
|
|
5088
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
5089
|
+ if err != nil {
|
|
5090
|
+ fmt.Println(err)
|
|
5091
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5092
|
+ return
|
|
5093
|
+ }
|
|
5094
|
+ startTime = theTime.Unix()
|
|
5095
|
+ }
|
|
5096
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
5097
|
+ Creater := this.GetAdminUserInfo().AdminUser.Id
|
|
5098
|
+ reportPrice := models.XtStockReportPrice{
|
|
5099
|
+ GoodName: good_name,
|
|
5100
|
+ SpecificationName: specification_name,
|
|
5101
|
+ WarehousingUnit: warehousing_unit,
|
|
5102
|
+ Count: count,
|
|
5103
|
+ BuyPrice: buy_price,
|
|
5104
|
+ PackingPrice: packing_price,
|
|
5105
|
+ NewPrice: new_price,
|
|
5106
|
+ Manufacturer: manufacturer,
|
|
5107
|
+ Dealer: dealer,
|
|
5108
|
+ Remark: remark,
|
|
5109
|
+ GoodId: good_id,
|
|
5110
|
+ UserOrgId: orgId,
|
|
5111
|
+ Ctime: time.Now().Unix(),
|
|
5112
|
+ Mtime: 0,
|
|
5113
|
+ Status: 1,
|
|
5114
|
+ WarehousingOrder: warehousing_order,
|
|
5115
|
+ LicenseNumber: license_number,
|
|
5116
|
+ StartTime: startTime,
|
|
5117
|
+ Creater: Creater,
|
|
5118
|
+ Checker: 0,
|
|
5119
|
+ CheckerStatus: 2,
|
|
5120
|
+ CheckerTime: 0,
|
|
5121
|
+ }
|
|
5122
|
+ err := service.CreateReportPrice(&reportPrice)
|
|
5123
|
+ fmt.Println(err)
|
|
5124
|
+ }
|
|
5125
|
+ }
|
|
5126
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5127
|
+ "msg": "保存成功!",
|
|
5128
|
+ })
|
|
5129
|
+}
|
|
5130
|
+
|
|
5131
|
+func (this *StockManagerApiController) GetReportStockList() {
|
|
5132
|
+ fmt.Println("2323323322332323232233232322323232323")
|
|
5133
|
+ timeLayout := "2006-01-02"
|
|
5134
|
+ loc, _ := time.LoadLocation("Local")
|
|
5135
|
+ start_time := this.GetString("start_time")
|
|
5136
|
+ end_time := this.GetString("end_time")
|
|
5137
|
+ page, _ := this.GetInt64("page")
|
|
5138
|
+ limit, _ := this.GetInt64("limit")
|
|
5139
|
+ var startTime int64
|
|
5140
|
+ if len(start_time) > 0 {
|
|
5141
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
5142
|
+ if err != nil {
|
|
5143
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5144
|
+ return
|
|
5145
|
+ }
|
|
5146
|
+ startTime = theTime.Unix()
|
|
5147
|
+ fmt.Println("开始时间", startTime)
|
|
5148
|
+ }
|
|
5149
|
+ var endTime int64
|
|
5150
|
+ if len(end_time) > 0 {
|
|
5151
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
5152
|
+ if err != nil {
|
|
5153
|
+ utils.ErrorLog(err.Error())
|
|
5154
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
5155
|
+ return
|
|
5156
|
+ }
|
|
5157
|
+ endTime = theTime.Unix()
|
|
5158
|
+ fmt.Println("endtime2322332233223", endTime)
|
|
5159
|
+ }
|
|
5160
|
+
|
|
5161
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
5162
|
+ keyword := this.GetString("keyword")
|
|
5163
|
+ fmt.Println("startTime", startTime, "endTime", endTime)
|
|
5164
|
+ list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
|
|
5165
|
+ doctorlist, _ := service.GetAllDoctorThree(orgId)
|
|
5166
|
+ fmt.Println("list232232322332232323", list)
|
|
5167
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
5168
|
+ "list": list,
|
|
5169
|
+ "total": total,
|
|
5170
|
+ "doctorlist": doctorlist,
|
|
5171
|
+ })
|
|
5172
|
+}
|