|
@@ -101,7 +101,7 @@ func StockManagerApiRegistRouters() {
|
101
|
101
|
|
102
|
102
|
//耗材调价
|
103
|
103
|
beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
|
104
|
|
-
|
|
104
|
+ beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
|
105
|
105
|
}
|
106
|
106
|
|
107
|
107
|
func (c *StockManagerApiController) CreateWarehouse() {
|
|
@@ -4713,3 +4713,162 @@ func (this *StockManagerApiController) GetSearchGoodWarehouseList() {
|
4713
|
4713
|
"dealerList": dealerList,
|
4714
|
4714
|
})
|
4715
|
4715
|
}
|
|
4716
|
+
|
|
4717
|
+func (this *StockManagerApiController) SaveAdjuestPrice() {
|
|
4718
|
+ timeLayout := "2006-01-02"
|
|
4719
|
+ loc, _ := time.LoadLocation("Local")
|
|
4720
|
+ dataBody := make(map[string]interface{}, 0)
|
|
4721
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
4722
|
+ if err != nil {
|
|
4723
|
+ utils.ErrorLog(err.Error())
|
|
4724
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4725
|
+ return
|
|
4726
|
+ }
|
|
4727
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
4728
|
+ if len(tableData) > 0 {
|
|
4729
|
+ for _, item := range tableData {
|
|
4730
|
+ items := item.(map[string]interface{})
|
|
4731
|
+
|
|
4732
|
+ if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
|
|
4733
|
+ utils.ErrorLog("good_name")
|
|
4734
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4735
|
+ return
|
|
4736
|
+ }
|
|
4737
|
+ good_name := items["good_name"].(string)
|
|
4738
|
+
|
|
4739
|
+ if items["good_name"] == nil || reflect.TypeOf(items["good_name"]).String() != "string" {
|
|
4740
|
+ utils.ErrorLog("good_name")
|
|
4741
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4742
|
+ return
|
|
4743
|
+ }
|
|
4744
|
+
|
|
4745
|
+ if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
|
|
4746
|
+ utils.ErrorLog("packing_price")
|
|
4747
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4748
|
+ return
|
|
4749
|
+ }
|
|
4750
|
+ packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
|
|
4751
|
+
|
|
4752
|
+ if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
|
|
4753
|
+ utils.ErrorLog("warehousing_order")
|
|
4754
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4755
|
+ return
|
|
4756
|
+ }
|
|
4757
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
4758
|
+
|
|
4759
|
+ if items["license_number"] == nil || reflect.TypeOf(items["license_number"]).String() != "string" {
|
|
4760
|
+ utils.ErrorLog("license_number")
|
|
4761
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4762
|
+ return
|
|
4763
|
+ }
|
|
4764
|
+ license_number := items["license_number"].(string)
|
|
4765
|
+
|
|
4766
|
+ if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
|
|
4767
|
+ utils.ErrorLog("dealer")
|
|
4768
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4769
|
+ return
|
|
4770
|
+ }
|
|
4771
|
+ dealer := items["dealer"].(string)
|
|
4772
|
+
|
|
4773
|
+ if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
|
|
4774
|
+ utils.ErrorLog("manufacturer")
|
|
4775
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4776
|
+ return
|
|
4777
|
+ }
|
|
4778
|
+ manufacturer := items["manufacturer"].(string)
|
|
4779
|
+
|
|
4780
|
+ if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
|
4781
|
+ utils.ErrorLog("specification_name")
|
|
4782
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4783
|
+ return
|
|
4784
|
+ }
|
|
4785
|
+ specification_name := items["specification_name"].(string)
|
|
4786
|
+
|
|
4787
|
+ if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
|
|
4788
|
+ utils.ErrorLog("remark")
|
|
4789
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4790
|
+ return
|
|
4791
|
+ }
|
|
4792
|
+ remark := items["remark"].(string)
|
|
4793
|
+
|
|
4794
|
+ if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
|
|
4795
|
+ utils.ErrorLog("warehousing_unit")
|
|
4796
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4797
|
+ return
|
|
4798
|
+ }
|
|
4799
|
+ warehousing_unit := items["warehousing_unit"].(string)
|
|
4800
|
+
|
|
4801
|
+ if items["buy_price"] == nil || reflect.TypeOf(items["buy_price"]).String() != "string" {
|
|
4802
|
+ utils.ErrorLog("buy_price")
|
|
4803
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4804
|
+ return
|
|
4805
|
+ }
|
|
4806
|
+ buy_price, _ := strconv.ParseFloat(items["buy_price"].(string), 64)
|
|
4807
|
+
|
|
4808
|
+ if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
|
|
4809
|
+ utils.ErrorLog("count")
|
|
4810
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4811
|
+ return
|
|
4812
|
+ }
|
|
4813
|
+ count := int64(items["count"].(float64))
|
|
4814
|
+
|
|
4815
|
+ if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
|
|
4816
|
+ utils.ErrorLog("new_price")
|
|
4817
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4818
|
+ return
|
|
4819
|
+ }
|
|
4820
|
+ new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
|
|
4821
|
+
|
|
4822
|
+ if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
|
|
4823
|
+ utils.ErrorLog("good_id")
|
|
4824
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4825
|
+ return
|
|
4826
|
+ }
|
|
4827
|
+ good_id := int64(items["good_id"].(float64))
|
|
4828
|
+
|
|
4829
|
+ if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
|
|
4830
|
+ utils.ErrorLog("start_time")
|
|
4831
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4832
|
+ return
|
|
4833
|
+ }
|
|
4834
|
+ var startTime int64
|
|
4835
|
+ start_time := items["start_time"].(string)
|
|
4836
|
+ if len(start_time) > 0 {
|
|
4837
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
4838
|
+ if err != nil {
|
|
4839
|
+ fmt.Println(err)
|
|
4840
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4841
|
+ return
|
|
4842
|
+ }
|
|
4843
|
+ startTime = theTime.Unix()
|
|
4844
|
+ }
|
|
4845
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
4846
|
+ adjustprice := models.XtStockAdjustPrice{
|
|
4847
|
+ GoodName: good_name,
|
|
4848
|
+ SpecificationName: specification_name,
|
|
4849
|
+ WarehousingUnit: warehousing_unit,
|
|
4850
|
+ Count: count,
|
|
4851
|
+ BuyPrice: buy_price,
|
|
4852
|
+ PackingPrice: packing_price,
|
|
4853
|
+ NewPrice: new_price,
|
|
4854
|
+ Manufacturer: manufacturer,
|
|
4855
|
+ Dealer: dealer,
|
|
4856
|
+ Remark: remark,
|
|
4857
|
+ GoodId: good_id,
|
|
4858
|
+ UserOrgId: orgId,
|
|
4859
|
+ Ctime: time.Now().Unix(),
|
|
4860
|
+ Mtime: 0,
|
|
4861
|
+ Status: 1,
|
|
4862
|
+ WarehousingOrder: warehousing_order,
|
|
4863
|
+ LicenseNumber: license_number,
|
|
4864
|
+ StartTime: startTime,
|
|
4865
|
+ }
|
|
4866
|
+
|
|
4867
|
+ service.CreateAdjustPrice(&adjustprice)
|
|
4868
|
+ }
|
|
4869
|
+ }
|
|
4870
|
+
|
|
4871
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
4872
|
+ "msg": "保存成功!",
|
|
4873
|
+ })
|
|
4874
|
+}
|