1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
|
<?php //============================================================================== // 쇼핑몰 라이브러리 모음 시작 //==============================================================================
/* 간편 사용법 : 상품유형을 1~5 사이로 지정합니다. $disp = new item_list(1); echo $disp->run();
유형+분류별로 노출하는 경우 상세 사용법 : 상품유형을 지정하는 것은 동일합니다. $disp = new item_list(1); // 사용할 스킨을 바꿉니다. $disp->set_list_skin("type_user.skin.php"); // 1단계분류를 20으로 시작되는 분류로 지정합니다. $disp->set_category("20", 1); echo $disp->run();
분류별로 노출하는 경우 상세 사용법 // type13.skin.php 스킨으로 3개씩 2줄을 폭 150 사이즈로 분류코드 30 으로 시작되는 상품을 노출합니다. $disp = new item_list(0, "type13.skin.php", 3, 2, 150, 0, "30"); echo $disp->run();
이벤트로 노출하는 경우 상세 사용법 // type13.skin.php 스킨으로 3개씩 2줄을 폭 150 사이즈로 상품을 노출합니다. // 스킨의 경로는 스킨 파일의 절대경로를 지정합니다. $disp = new item_list(0, G5_SHOP_SKIN_PATH.'/list.10.skin.php', 3, 2, 150, 0); // 이벤트번호를 설정합니다. $disp->set_event("12345678"); echo $disp->run();
참고) 영카트4의 display_type 함수와 사용방법이 비슷한 class 입니다. display_category 나 display_event 로 사용하기 위해서는 $type 값만 넘기지 않으면 됩니다. */
$g5['otms_11st_id'] = $id_11st; $g5['otms_11st_pw'] = $pw_11st; $g5['otms_11st_priority'] = $priority_11st; $g5['otms_11st_ktb_agent'] = $ktb_agent_11st;
class item_list { // 상품유형 : 기본적으로 1~5 까지 사용할수 있으며 0 으로 설정하는 경우 상품유형별로 노출하지 않습니다. // 분류나 이벤트로 노출하는 경우 상품유형을 0 으로 설정하면 됩니다. protected $type;
protected $list_skin; protected $list_mod; protected $list_row; protected $img_width; protected $img_height;
// 상품상세보기 경로 protected $href = "";
// select 에 사용되는 필드 protected $fields = "*";
// 분류코드로만 사용하는 경우 상품유형($type)을 0 으로 설정하면 됩니다. protected $ca_id = ""; protected $ca_id2 = ""; protected $ca_id3 = "";
// 노출순서 protected $order_by = "it_order, it_id desc";
// 상품의 이벤트번호를 저장합니다. protected $event = "";
// 스킨의 기본 css 를 다른것으로 사용하고자 할 경우에 사용합니다. protected $css = "";
// 상품의 사용여부를 따져 노출합니다. 0 인 경우 모든 상품을 노출합니다. protected $use = 1;
// 모바일에서 노출하고자 할 경우에 true 로 설정합니다. protected $is_mobile = false;
// 기본으로 보여지는 필드들 protected $view_it_id = false; // 상품코드 protected $view_it_img = true; // 상품이미지 protected $view_it_name = true; // 상품명 protected $view_it_basic = true; // 기본설명 protected $view_it_price = true; // 판매가격 protected $view_it_cust_price = false; // 소비자가 protected $view_it_icon = false; // 아이콘 protected $view_sns = false; // SNS
// 몇번째 class 호출인지를 저장합니다. protected $count = 0;
// true 인 경우 페이지를 구한다. protected $is_page = false;
// 페이지 표시를 위하여 총 상품수를 구합니다. public $total_count = 0;
// sql limit 의 시작 레코드 protected $from_record = 0;
// 외부에서 쿼리문을 넘겨줄 경우에 담아두는 변수 protected $query = "";
// $type : 상품유형 (기본으로 1~5까지 사용) // $list_skin : 상품리스트를 노출할 스킨을 설정합니다. 스킨위치는 skin/shop/쇼핑몰설정스킨/type??.skin.php // $list_mod : 1줄에 몇개의 상품을 노출할지를 설정합니다. // $list_row : 상품을 몇줄에 노출할지를 설정합니다. // $img_width : 상품이미지의 폭을 설정합니다. // $img_height : 상품이미지의 높이을 설정합니다. 0 으로 설정하는 경우 썸네일 이미지의 높이는 폭에 비례하여 생성합니다. //function __construct($type=0, $list_skin='', $list_mod='', $list_row='', $img_width='', $img_height=0, $ca_id='') { function __construct($list_skin='', $list_mod='', $list_row='', $img_width='', $img_height=0) { $this->list_skin = $list_skin; $this->list_mod = $list_mod; $this->list_row = $list_row; $this->img_width = $img_width; $this->img_height = $img_height; $this->set_href(G5_SHOP_URL.'/item.php?it_id='); $this->count++; }
function set_type($type) { $this->type = $type; if ($type) { $this->set_list_skin($this->list_skin); $this->set_list_mod($this->list_mod); $this->set_list_row($this->list_row); $this->set_img_size($this->img_width, $this->img_height); } }
// 분류코드로 검색을 하고자 하는 경우 아래와 같이 인수를 넘겨줍니다. // 1단계 분류는 (분류코드, 1) // 2단계 분류는 (분류코드, 2) // 3단계 분류는 (분류코드, 3) function set_category($ca_id, $level=1) { if ($level == 2) { $this->ca_id2 = $ca_id; } else if ($level == 3) { $this->ca_id3 = $ca_id; } else { $this->ca_id = $ca_id; } }
// 이벤트코드를 인수로 넘기게 되면 해당 이벤트에 속한 상품을 노출합니다. function set_event($ev_id) { $this->event = $ev_id; }
// 리스트 스킨을 바꾸고자 하는 경우에 사용합니다. // 리스트 스킨의 위치는 skin/shop/쇼핑몰설정스킨/type??.skin.php 입니다. // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다. function set_list_skin($list_skin) { global $default; if ($this->is_mobile) { $this->list_skin = $list_skin ? $list_skin : G5_MSHOP_SKIN_PATH.'/'.$default['de_mobile_type'.$this->type.'_list_skin']; } else { $this->list_skin = $list_skin ? $list_skin : G5_SHOP_SKIN_PATH.'/'.$default['de_type'.$this->type.'_list_skin']; } }
// 1줄에 몇개를 노출할지를 사용한다. // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다. function set_list_mod($list_mod) { global $default; if ($this->is_mobile) { $this->list_mod = $list_mod ? $list_mod : $default['de_mobile_type'.$this->type.'_list_mod']; } else { $this->list_mod = $list_mod ? $list_mod : $default['de_type'.$this->type.'_list_mod']; } }
// 몇줄을 노출할지를 사용한다. // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다. function set_list_row($list_row) { global $default; if ($this->is_mobile) { $this->list_row = $list_row ? $list_row : $default['de_mobile_type'.$this->type.'_list_row']; } else { $this->list_row = $list_row ? $list_row : $default['de_type'.$this->type.'_list_row']; } if (!$this->list_row) $this->list_row = 1; }
// 노출이미지(썸네일생성)의 폭, 높이를 설정합니다. 높이를 0 으로 설정하는 경우 쎰네일 비율에 따릅니다. // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다. function set_img_size($img_width, $img_height=0) { global $default; if ($this->is_mobile) { $this->img_width = $img_width ? $img_width : $default['de_mobile_type'.$this->type.'_img_width']; $this->img_height = $img_height ? $img_height : $default['de_mobile_type'.$this->type.'_img_height']; } else { $this->img_width = $img_width ? $img_width : $default['de_type'.$this->type.'_img_width']; $this->img_height = $img_height ? $img_height : $default['de_type'.$this->type.'_img_height']; } }
// 특정 필드만 select 하는 경우에는 필드명을 , 로 구분하여 "field1, field2, field3, ... fieldn" 으로 인수를 넘겨줍니다. function set_fields($str) { $this->fields = $str; }
// 특정 필드로 정렬을 하는 경우 필드와 정렬순서를 , 로 구분하여 "field1 desc, field2 asc, ... fieldn desc " 으로 인수를 넘겨줍니다. function set_order_by($str) { $this->order_by = $str; }
// 사용하는 상품외에 모든 상품을 노출하려면 0 을 인수로 넘겨줍니다. function set_use($use) { $this->use = $use; }
// 모바일로 사용하려는 경우 true 를 인수로 넘겨줍니다. function set_mobile($mobile=true) { $this->is_mobile = $mobile; }
// 스킨에서 특정 필드를 노출하거나 하지 않게 할수 있습니다. // 가령 소비자가는 처음에 노출되지 않도록 설정되어 있지만 노출을 하려면 // ("it_cust_price", true) 와 같이 인수를 넘겨줍니다. // 이때 인수로 넘겨주는 값은 스킨에 정의된 필드만 가능하다는 것입니다. function set_view($field, $view=true) { $this->{"view_".$field} = $view; }
// anchor 태그에 하이퍼링크를 다른 주소로 걸거나 아예 링크를 걸지 않을 수 있습니다. // 인수를 "" 공백으로 넘기면 링크를 걸지 않습니다. function set_href($href) { $this->href = $href; }
// ul 태그의 css 를 교체할수 있다. "sct sct_abc" 를 인수로 넘기게 되면 // 기존의 ul 태그에 걸린 css 는 무시되며 인수로 넘긴 css 가 사용됩니다. function set_css($css) { $this->css = $css; }
// 페이지를 노출하기 위해 true 로 설정할때 사용합니다. function set_is_page($is_page) { $this->is_page = $is_page; }
// select ... limit 의 시작값 function set_from_record($from_record) { $this->from_record = $from_record; }
// 외부에서 쿼리문을 넘겨줄 경우에 담아둡니다. function set_query($query) { $this->query = $query; }
// class 에 설정된 값으로 최종 실행합니다. function run() {
global $g5, $config, $member, $default;
if ($this->query) {
$sql = $this->query; $result = sql_query($sql); $this->total_count = @mysql_num_rows($result);
} else {
$where = array(); if ($this->use) { $where[] = " it_use = '1' "; }
if ($this->type) { $where[] = " it_type{$this->type} = '1' "; }
if ($this->ca_id || $this->ca_id2 || $this->ca_id3) { $where_ca_id = array(); if ($this->ca_id) { $where_ca_id[] = " ca_id like '{$this->ca_id}%' "; } if ($this->ca_id2) { $where_ca_id[] = " ca_id2 like '{$this->ca_id2}%' "; } if ($this->ca_id3) { $where_ca_id[] = " ca_id3 like '{$this->ca_id3}%' "; } $where[] = " ( " . implode(" or ", $where_ca_id) . " ) "; }
if ($this->order_by) { $sql_order = " order by {$this->order_by} "; }
if ($this->event) { $sql_select = " select {$this->fields} "; $sql_common = " from `{$g5['g5_shop_event_item_table']}` a left join `{$g5['g5_shop_item_table']}` b on (a.it_id = b.it_id) "; $where[] = " a.ev_id = '{$this->event}' "; } else { $sql_select = " select {$this->fields} "; $sql_common = " from `{$g5['g5_shop_item_table']}` "; } $sql_where = " where " . implode(" and ", $where); $sql_limit = " limit " . $this->from_record . " , " . ($this->list_mod * $this->list_row);
$sql = $sql_select . $sql_common . $sql_where . $sql_order . $sql_limit; $result = sql_query($sql);
if ($this->is_page) { $sql2 = " select count(*) as cnt " . $sql_common . $sql_where; $row2 = sql_fetch($sql2); $this->total_count = $row2['cnt']; }
}
$file = $this->list_skin;
if ($this->list_skin == "") { return $this->count."번 item_list() 의 스킨파일이 지정되지 않았습니다."; } else if (!file_exists($file)) { return $file." 파일을 찾을 수 없습니다."; } else { ob_start(); $list_mod = $this->list_mod; include($file); $content = ob_get_contents(); ob_end_clean(); return $content; } } }
// 장바구니 건수 검사 function get_cart_count($cart_id) { global $g5, $default;
$sql = " select count(ct_id) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$cart_id' "; $row = sql_fetch($sql); $cnt = (int)$row['cnt']; return $cnt; }
// 이미지를 얻는다 function get_image($img, $width=0, $height=0, $img_id='') { global $g5, $default;
$full_img = G5_DATA_PATH.'/item/'.$img;
if (file_exists($full_img) && $img) { if (!$width) { $size = getimagesize($full_img); $width = $size[0]; $height = $size[1]; } $str = '<img src="'.G5_DATA_URL.'/item/'.$img.'" alt="" width="'.$width.'" height="'.$height.'"';
if($img_id) $str .= ' id="'.$img_id.'"';
$str .= '>'; } else { $str = '<img src="'.G5_SHOP_URL.'/img/no_image.gif" alt="" '; if ($width) $str .= 'width="'.$width.'" height="'.$height.'"'; else $str .= 'width="'.$default['de_mimg_width'].'" height="'.$default['de_mimg_height'].'"';
if($img_id) $str .= ' id="'.$img_id.'"'. $str .= '>'; }
return $str; }
// 상품 이미지를 얻는다 function get_it_image($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='') { global $g5;
if(!$it_id || !$width) return '';
$sql = " select it_id, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $row = sql_fetch($sql);
if(!$row['it_id']) return '';
for($i=1;$i<=10; $i++) { $file = G5_DATA_PATH.'/item/'.$row['it_img'.$i]; if(is_file($file) && $row['it_img'.$i]) { $size = @getimagesize($file); if($size[2] < 1 || $size[2] > 3) continue;
$filename = basename($file); $filepath = dirname($file); $img_width = $size[0]; $img_height = $size[1];
break; } }
if($img_width && !$height) { $height = round(($width * $img_height) / $img_width); }
if($filename) { //thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop=false, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3') if($height==0 && 1==2){ // 사용할려다가 사용 안함 $thumb = thumbnail_new($filename, $filepath, $filepath, $width, $height, false, true, 'center', true, $um_value='80/0.5/3'); } else { $thumb = thumbnail($filename, $filepath, $filepath, $width, $height, false, true, 'center', true, $um_value='80/0.5/3'); } }
if($thumb) { $file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb); $img = '<img src="'.$file_url.'" width="'.$width.'" height="'.$height.'" alt="'.$img_alt.'"'; } else { $img = '<img src="'.G5_SHOP_URL.'/img/no_image.gif" width="'.$width.'"'; if($height) $img .= ' height="'.$height.'"'; $img .= ' alt="'.$img_alt.'"'; }
if($img_id) $img .= ' id="'.$img_id.'"'; $img .= '>';
if($anchor) $img = '<a href="'.G5_SHOP_URL.'/item.php?it_id='.$it_id.'">'.$img.'</a>';
return $img; }
// 상품이미지 썸네일 생성 function get_it_thumbnail($img, $width, $height=0, $id='') { $str = '';
$file = G5_DATA_PATH.'/item/'.$img; if(is_file($file)) $size = @getimagesize($file);
if($size[2] < 1 || $size[2] > 3) return '';
$img_width = $size[0]; $img_height = $size[1]; $filename = basename($file); $filepath = dirname($file);
if($img_width && !$height) { $height = round(($width * $img_height) / $img_width); }
//echo $filepath."/".$filename; exit;
if($height==0 && 1==2){ // 사용할려다가 사용 안함 $thumb = thumbnail_new($filename, $filepath, $filepath, $width, $height, false, false, '', true, $um_value='80/0.5/3'); } else { $thumb = thumbnail($filename, $filepath, $filepath, $width, $height, false, false, '', true, $um_value='80/0.5/3'); }
if($thumb) { $file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb); //$str = '<img src="'.$file_url.'" width="'.$width.'" height="'.$height.'"'; $str = '<img src="'.$file_url.'" '; if($id) $str .= ' id="'.$id.'"'; $str .= ' alt="">'; }
return $str; }
// 이미지 URL 을 얻는다. function get_it_imageurl($it_id) { global $g5;
$sql = " select it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $row = sql_fetch($sql); $filepath = '';
for($i=1; $i<=10; $i++) { $img = $row['it_img'.$i]; $file = G5_DATA_PATH.'/item/'.$img; if(!is_file($file)) continue;
$size = @getimagesize($file); if($size[2] < 1 || $size[2] > 3) continue;
$filepath = $file; break; }
if($filepath) $str = str_replace(G5_PATH, G5_URL, $filepath); else $str = G5_SHOP_URL.'/img/no_image.gif';
return $str; }
// 상품의 재고 (창고재고수량 - 주문대기수량) function get_it_stock_qty($it_id) { global $g5,$default;
$sql = " select it_stock_qty, it_4,it_8 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $row = sql_fetch($sql);
if($row['it_8']=='1'){ return 9999; } // 무한재고일 경우 재고 리턴
$jaego = (int)$row['it_stock_qty'];
if($default['de_cs_qty_use']=='1'){ // 천년재고 체크 일경우는 천년재고의 재고량을 우선으로 체크한다. $jaego = $row['it_4']*1; }
// 재고에서 빼지 않았고 주문인것만 $sql = " select SUM(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and io_id = '' and ct_stock_use = 0 and ct_status in ('주문', '입금', '준비') "; $row = sql_fetch($sql); $daegi = (int)$row['sum_qty'];
return $jaego - $daegi; }
// 옵션의 재고 (창고재고수량 - 주문대기수량) function get_option_stock_qty($it_id, $io_id, $type) { global $g5,$default;
$sql = "select it_8 from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' "; $it = sql_fetch($sql); if($it['it_8']=='1'){ return 9999; } // 무한재고일 경우 재고 리턴
$sql = " select io_stock_qty, io_cs_qty from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' and io_id = '$io_id' and io_type = '$type' and io_use = '1' "; $row = sql_fetch($sql); $jaego = (int)$row['io_stock_qty'];
if($default['de_cs_qty_use']=='1'){ // 천년재고 체크 일경우는 천년재고의 재고량을 우선으로 체크한다. $jaego = (int)$row['io_cs_qty']; }
// 재고에서 빼지 않았고 주문인것만 $sql = " select SUM(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and io_id = '$io_id' and io_type = '$type' and ct_stock_use = 0 and ct_status in ('주문', '입금', '준비') "; $row = sql_fetch($sql); $daegi = (int)$row['sum_qty'];
return $jaego - $daegi; }
// 큰 이미지 function get_large_image($img, $it_id, $btn_image=true) { global $g5;
if (file_exists(G5_DATA_PATH.'/item/'.$img) && $img != '') { $size = getimagesize(G5_DATA_PATH.'/item/'.$img); $width = $size[0]; $height = $size[1]; $str = '<a href="javascript:popup_large_image(\''.$it_id.'\', \''.$img.'\', '.$width.', '.$height.', \''.G5_SHOP_URL.'\')">'; if ($btn_image) $str .= '큰이미지</a>'; } else $str = ''; return $str; }
// 금액 표시 function display_price($price, $tel_inq=false) { if ($tel_inq) $price = '전화문의'; else $price = number_format($price, 0).'원';
return $price; }
// 금액 표시 function display_price_eng($price, $tel_inq=false) { if ($tel_inq) $price = 'CallMe'; else $price = number_format($price, 0).'won';
return $price; }
// 금액표시 // $it : 상품 배열 function get_price($it) { global $member,$g5, $default,$item_view;
if ($it['it_tel_inq']) return '전화문의';
$price = $it['it_price'];
// 다중 단가를 사용하면 다중단가의 가격을 가져와 뿌려준다. $price = multy_price_check($price,$it['it_id'], '');
$price = mem_group_price_check($price);
//echo $skin_file; if($price==0 && $item_view!='Y'){ $sql = "select io_id,io_price from {$g5['g5_shop_item_option_table']} where it_id = '{$it['it_id']}' and io_use = 1 and io_type = 0 and io_id <> '' order by io_no limit 1 "; //_pr($sql); $io_price = sql_fetch($sql); //_pr($io_price); if($io_price['io_price']>0){ $price = multy_price_check($io_price['io_price'],$it['it_id'], $io_price['io_id']); $price = mem_group_price_check($price); } }
return (int)$price; }
// 포인트 표시 function display_point($point) { return number_format($point, 0).'점'; }
// 포인트를 구한다 function get_point($amount, $point) { return (int)($amount * $point / 100); }
// 상품이미지 업로드 function it_img_upload($srcfile, $filename, $dir) { if($filename == '') return '';
$size = @getimagesize($srcfile); if($size[2] < 1 || $size[2] > 3) return '';
if(!is_dir($dir)) { @mkdir($dir, G5_DIR_PERMISSION); @chmod($dir, G5_DIR_PERMISSION); }
$pattern = "/[#\&\+\-%@=\/\\:;,'\"\^`~\|\!\?\*\$#<>\(\)\[\]\{\}]/";
$filename = preg_replace("/\s+/", "", $filename); $filename = preg_replace( $pattern, "", $filename);
$filename = preg_replace_callback( "/[가-힣]+/", create_function('$matches', 'return base64_encode($matches[0]);'), $filename);
$filename = preg_replace( $pattern, "", $filename);
upload_file($srcfile, $filename, $dir);
$file = str_replace(G5_DATA_PATH.'/item/', '', $dir.'/'.$filename);
return $file; }
// 파일을 업로드 함 function upload_file($srcfile, $destfile, $dir) { if ($destfile == "") return false; // 업로드 한후 , 퍼미션을 변경함 @move_uploaded_file($srcfile, $dir.'/'.$destfile); @chmod($dir.'/'.$destfile, G5_FILE_PERMISSION); return true; }
function message($subject, $content, $align="left", $width="450") { $str = " <table width=\"$width\" cellpadding=\"4\" align=\"center\"> <tr><td class=\"line\" height=\"1\"></td></tr> <tr> <td align=\"center\">$subject</td> </tr> <tr><td class=\"line\" height=\"1\"></td></tr> <tr> <td> <table width=\"100%\" cellpadding=\"8\" cellspacing=\"0\"> <tr> <td class=\"leading\" align=\"$align\">$content</td> </tr> </table> </td> </tr> <tr><td class=\"line\" height=\"1\"></td></tr> </table> <br> "; return $str; }
// 시간이 비어 있는지 검사 function is_null_time($datetime) { // 공란 0 : - 제거 //$datetime = ereg_replace("[ 0:-]", "", $datetime); // 이 함수는 PHP 5.3.0 에서 배제되고 PHP 6.0 부터 사라집니다. $datetime = preg_replace("/[ 0:-]/", "", $datetime); if ($datetime == "") return true; else return false; }
// 출력유형, 스킨파일, 1라인이미지수, 총라인수, 이미지폭, 이미지높이 // 1.02.01 $ca_id 추가 //function display_type($type, $skin_file, $list_mod, $list_row, $img_width, $img_height, $ca_id="") function display_type($type, $list_skin='', $list_mod='', $list_row='', $img_width='', $img_height='', $ca_id='') { global $member, $g5, $config, $default;
if (!$default["de_type{$type}_list_use"]) return "";
$list_skin = $list_skin ? $list_skin : $default["de_type{$type}_list_skin"]; $list_mod = $list_mod ? $list_mod : $default["de_type{$type}_list_mod"]; $list_row = $list_row ? $list_row : $default["de_type{$type}_list_row"]; $img_width = $img_width ? $img_width : $default["de_type{$type}_img_width"]; $img_height = $img_height ? $img_height : $default["de_type{$type}_img_height"];
// 상품수 $items = $list_mod * $list_row;
// 1.02.00 // it_order 추가 $sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' and it_type{$type} = '1' "; if ($ca_id) $sql .= " and ca_id like '$ca_id%' "; $sql .= " order by it_order, it_id desc limit $items "; $result = sql_query($sql); /* if (!mysql_num_rows($result)) { return false; } */
//$file = G5_SHOP_PATH.'/'.$skin_file; $file = G5_SHOP_SKIN_PATH.'/'.$list_skin; if (!file_exists($file)) { return G5_SHOP_SKIN_URL.'/'.$list_skin.' 파일을 찾을 수 없습니다.'; } else { $td_width = (int)(100 / $list_mod); ob_start(); include $file; $content = ob_get_contents(); ob_end_clean(); return $content; } }
// 모바일 유형별 상품 출력 function mobile_display_type($type, $skin_file, $list_row, $img_width, $img_height, $ca_id="") { global $member, $g5, $config;
// 상품수 $items = $list_row;
// 1.02.00 // it_order 추가 $sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1' and it_type{$type} = '1' "; if ($ca_id) $sql .= " and ca_id like '$ca_id%' "; $sql .= " order by it_order, it_id desc limit $items "; $result = sql_query($sql); /* if (!mysql_num_rows($result)) { return false; } */
$file = G5_MSHOP_PATH.'/'.$skin_file; if (!file_exists($file)) { echo $file.' 파일을 찾을 수 없습니다.'; } else { //$td_width = (int)(100 / $list_mod); include $file; } }
// 분류별 출력 // 스킨파일번호, 1라인이미지수, 총라인수, 이미지폭, 이미지높이 , 분류번호 function display_category($no, $list_mod, $list_row, $img_width, $img_height, $ca_id="") { global $member, $g5;
// 상품수 $items = $list_mod * $list_row;
$sql = " select * from {$g5['g5_shop_item_table']} where it_use = '1'"; if ($ca_id) $sql .= " and ca_id LIKE '{$ca_id}%' "; $sql .= " order by it_order, it_id desc limit $items "; $result = sql_query($sql); if (!mysql_num_rows($result)) { return false; }
$file = G5_SHOP_PATH.'/maintype'.$no.'.inc.php'; if (!file_exists($file)) { echo $file.' 파일을 찾을 수 없습니다.'; } else { $td_width = (int)(100 / $list_mod); include $file; } }
// 별 function get_star($score) { $star = round($score); if ($star > 5) $star = 5; else if ($star < 0) $star = 0;
return $star; }
// 별 이미지 function get_star_image($it_id) { global $g5;
$sql = "select (SUM(is_score) / COUNT(*)) as score from {$g5['g5_shop_item_use_table']} where it_id = '$it_id' "; $row = sql_fetch($sql);
return (int)get_star($row['score']); }
// 메일 보내는 내용을 HTML 형식으로 만든다. function email_content($str) { global $g5;
$s = ""; $s .= "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset={$g5['charset']}\"><title>메일</title>\n"; $s .= "<body>\n"; $s .= $str; $s .= "</body>\n"; $s .= "</html>";
return $s; }
// 타임스탬프 형식으로 넘어와야 한다. // 시작시간, 종료시간 function gap_time($begin_time, $end_time) { $gap = $end_time - $begin_time; $time['days'] = (int)($gap / 86400); $time['hours'] = (int)(($gap - ($time['days'] * 86400)) / 3600); $time['minutes'] = (int)(($gap - ($time['days'] * 86400 + $time['hours'] * 3600)) / 60); $time['seconds'] = (int)($gap - ($time['days'] * 86400 + $time['hours'] * 3600 + $time['minutes'] * 60)); return $time; }
// 공란없이 이어지는 문자 자르기 (wayboard 참고 (way.co.kr)) function continue_cut_str($str, $len=80) { /* $pattern = "[^ \n<>]{".$len."}"; return eregi_replace($pattern, "\\0\n", $str); */ $pattern = "/[^ \n<>]{".$len."}/"; return preg_replace($pattern, "\\0\n", $str); }
// 제목별로 컬럼 정렬하는 QUERY STRING // $type 이 1이면 반대 function title_sort($col, $type=0) { global $sort1, $sort2; global $_SERVER; global $page; global $doc;
$q1 = 'sort1='.$col; if ($type) { $q2 = 'sort2=desc'; if ($sort1 == $col) { if ($sort2 == 'desc') { $q2 = 'sort2=asc'; } } } else { $q2 = 'sort2=asc'; if ($sort1 == $col) { if ($sort2 == 'asc') { $q2 = 'sort2=desc'; } } } #return "$_SERVER[SCRIPT_NAME]?$q1&$q2&page=$page"; return "{$_SERVER['SCRIPT_NAME']}?$q1&$q2&page=$page"; }
// 세션값을 체크하여 이쪽에서 온것이 아니면 메인으로 function session_check() { global $g5;
if (!trim(get_session('ss_uniqid'))) gotourl(G5_SHOP_URL); }
// 상품 선택옵션 function get_item_options($it_id, $subject) { global $g5,$default;
$sql = "select it_price,it_8 from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' "; $it = sql_fetch($sql);
$multi_price = multy_price_check($it['it_price'],$it_id); // 다중단가 본품 가격 가져옴 $multi_price = mem_group_price_check($multi_price);
// 해당 상품코드의 다중단가를 가져옴 $multy_price_array = multy_price_array($it_id);
if(!$it_id || !$subject) return '';
$sql = " select * from {$g5['g5_shop_item_option_table']} where io_type = '0' and it_id = '$it_id' and io_use = '1' and io_id <> '' order by io_no asc "; $result = sql_query($sql); if(!mysql_num_rows($result)) return '';
$str = ''; $subj = explode(',', $subject); $subj_count = count($subj);
if($subj_count > 1) { $options = array();
// 옵션항목 배열에 저장 for($i=0; $row=sql_fetch_array($result); $i++) { $opt_id = explode(chr(30), $row['io_id']);
for($k=0; $k<$subj_count; $k++) { if(!is_array($options[$k])) $options[$k] = array();
if($opt_id[$k] && !in_array($opt_id[$k], $options[$k])) $options[$k][] = $opt_id[$k]; } }
// 옵션선택목록 만들기 for($i=0; $i<$subj_count; $i++) { $opt = $options[$i]; $opt_count = count($opt); $disabled = ''; if($opt_count) { $seq = $i + 1; if($i > 0) $disabled = ' disabled="disabled"'; $str .= '<tr>'.PHP_EOL; $str .= '<th><label for="it_option_'.$seq.'">'.$subj[$i].'</label></th>'.PHP_EOL;
$select = '<select id="it_option_'.$seq.'" class="it_option"'.$disabled.'>'.PHP_EOL; $select .= '<option value="">선택</option>'.PHP_EOL; for($k=0; $k<$opt_count; $k++) { $opt_val = $opt[$k]; if(strlen($opt_val)) { $select .= '<option value="'.$opt_val.'">'.$opt_val.'</option>'.PHP_EOL; } } $select .= '</select>'.PHP_EOL;
$str .= '<td>'.$select.'</td>'.PHP_EOL; $str .= '</tr>'.PHP_EOL; } } } else { $str .= '<tr>'.PHP_EOL; $str .= '<th><label for="it_option_1">'.$subj[0].'</label></th>'.PHP_EOL;
$select = '<select id="it_option_1" class="it_option">'.PHP_EOL; $select .= '<option value="">선택</option>'.PHP_EOL; for($i=0; $row=sql_fetch_array($result); $i++) { // 옵션가격에서 본품을빼서 옵션가격 처리 $row['io_price'] = $row['io_price'] - $it['it_price'];
if($default['de_multy_price_use']=='1'){ // 다중단가 적용시 옵션가를 계산해서 처리함 if(count($multy_price_array)>0){ foreach($multy_price_array as $key => $val){ if($val['io_id']==$row['io_id']){ $row['io_price'] = $val['price']-$multi_price; break; // 다중단가 데이터는 본품가격 계산된것이 오기때문에 본품가격을 빼고 계산해준다. } } } }
$row['io_price'] = mem_group_price_check($row['io_price'],$it['it_price']);
if($row['io_price'] >= 0) $price = ' + '.number_format($row['io_price']).'원'; else $price = ' '.number_format($row['io_price']).'원';
if($it['it_8']=='1'){ // 무한재고일 경우 재고 리턴 $row['io_stock_qty'] = '9999'; $soldout = " [재고:".number_format($row['io_stock_qty'])."]"; } else if($row['io_stock_qty'] < 1) { $soldout = ' [품절]'; } else { //$soldout = ''; $soldout = " [재고:".number_format($row['io_stock_qty'])."]"; }
$select .= '<option value="'.$row['io_id'].','.$row['io_price'].','.$row['io_stock_qty'].'">'.$row['io_id'].$price.$soldout.'</option>'.PHP_EOL; } $select .= '</select>'.PHP_EOL;
$str .= '<td>'.$select.'</td>'.PHP_EOL; $str .= '</tr>'.PHP_EOL; }
return $str; }
// 상품 추가옵션 function get_item_supply($it_id, $subject) { global $g5,$default;
// 해당 상품코드의 다중단가를 가져옴 $multy_price_array = multy_price_array($it_id);
if(!$it_id || !$subject) return '';
$sql = " select * from {$g5['g5_shop_item_option_table']} where io_type = '1' and it_id = '$it_id' and io_use = '1' order by io_no asc "; $result = sql_query($sql); if(!mysql_num_rows($result)) return '';
$str = '';
$subj = explode(',', $subject); $subj_count = count($subj); $options = array();
// 옵션항목 배열에 저장 for($i=0; $row=sql_fetch_array($result); $i++) {
$opt_id = explode(chr(30), $row['io_id']);
if($opt_id[0] && !array_key_exists($opt_id[0], $options)) $options[$opt_id[0]] = array();
if($default['de_multy_price_use']=='1'){ // 다중단가 적용시 추가옵션가를 계산해서 처리함 foreach($multy_price_array as $key => $val){ //echo "!-".$row['io_id']."-!<br>"; if($val['io_id']==$row['io_id']){ $row['io_price'] = $val['price']; break; } } }
$row['io_price'] = mem_group_price_check($row['io_price']);
if(strlen($opt_id[1])) { if($row['io_price'] >= 0) $price = ' + '.number_format($row['io_price']).'원'; else $price = ' '.number_format($row['io_price']).'원'; $io_stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);
if($io_stock_qty < 1) $soldout = ' [품절]'; else $soldout = '';
$options[$opt_id[0]][] = '<option value="'.$opt_id[1].','.$row['io_price'].','.$io_stock_qty.'">'.$opt_id[1].$price.$soldout.'</option>'; } }
// 옵션항목 만들기 for($i=0; $i<$subj_count; $i++) { $opt = $options[$subj[$i]]; $opt_count = count($opt); if($opt_count) { $seq = $i + 1; $str .= '<tr>'.PHP_EOL; $str .= '<th><label for="it_supply_'.$seq.'">'.$subj[$i].'</label></th>'.PHP_EOL;
$select = '<select id="it_supply_'.$seq.'" class="it_supply">'.PHP_EOL; $select .= '<option value="">선택</option>'.PHP_EOL; for($k=0; $k<$opt_count; $k++) { $opt_val = $opt[$k]; if($opt_val) { $select .= $opt_val.PHP_EOL; } } $select .= '</select>'.PHP_EOL;
$str .= '<td class="td_sit_sel">'.$select.'</td>'.PHP_EOL; $str .= '</tr>'.PHP_EOL; } }
return $str; }
function print_item_options($it_id, $cart_id) { global $g5;
$sql = " select ct_option, ct_qty, io_price from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$cart_id' order by io_type asc, ct_id asc "; $result = sql_query($sql);
$str = ''; for($i=0; $row=sql_fetch_array($result); $i++) { if($i == 0) $str .= '<ul>'.PHP_EOL; $price_plus = ''; if($row['io_price'] >= 0) $price_plus = '+'; $str .= '<li>'.$row['ct_option'].' '.$row['ct_qty'].'개 ('.$price_plus.display_price($row['io_price']).')</li>'.PHP_EOL; }
if($i > 0) $str .= '</ul>';
return $str; }
// 일자형식변환 function date_conv($date, $case=1) { if ($case == 1) { // 년-월-일 로 만들어줌 $date = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3", $date); } else if ($case == 2) { // 년월일 로 만들어줌 $date = preg_replace("/-/", "", $date); }
return $date; }
// 배너출력 function display_banner($position, $skin='') { global $g5;
if (!$position) $position = '왼쪽'; if (!$skin) $skin = 'boxbanner.skin.php';
$skin_path = G5_SHOP_SKIN_PATH.'/'.$skin;
if(file_exists($skin_path)) { // 배너 출력 $sql = " select * from {$g5['g5_shop_banner_table']} where '".G5_TIME_YMDHIS."' between bn_begin_time and bn_end_time and bn_position = '$position' order by bn_order, bn_id desc "; $result = sql_query($sql);
include $skin_path; } else { echo '<p>'.str_replace(G5_PATH.'/', '', $skin_path).'파일이 존재하지 않습니다.</p>'; } }
// 1.00.02 // 파일번호, 이벤트번호, 1라인이미지수, 총라인수, 이미지폭, 이미지높이 // 1.02.01 $ca_id 추가 function display_event($no, $event, $list_mod, $list_row, $img_width, $img_height, $ca_id="") { global $member, $g5;
// 상품수 $items = $list_mod * $list_row;
// 1.02.00 // b.it_order 추가 $sql = " select b.* from {$g5['g5_shop_event_item_table']} a, {$g5['g5_shop_item_table']} b where a.it_id = b.it_id and b.it_use = '1' and a.ev_id = '$event' "; if ($ca_id) $sql .= " and ca_id = '$ca_id' "; $sql .= " order by b.it_order, a.it_id desc limit $items "; $result = sql_query($sql); if (!mysql_num_rows($result)) { return false; }
$file = G5_SHOP_PATH.'/maintype'.$no.'.inc.php'; if (!file_exists($file)) { echo $file.' 파일을 찾을 수 없습니다.'; } else { $td_width = (int)(100 / $list_mod); include $file; } }
function get_yn($val, $case='') { switch ($case) { case '1' : $result = ($val > 0) ? 'Y' : 'N'; break; default : $result = ($val > 0) ? '예' : '아니오'; } return $result; }
// 상품명과 건수를 반환 function get_goods($cart_id) { global $g5;
// 상품명만들기 $row = sql_fetch(" select a.it_id, b.it_name from {$g5['g5_shop_cart_table']} a, {$g5['g5_shop_item_table']} b where a.it_id = b.it_id and a.od_id = '$cart_id' order by ct_id limit 1 "); // 상품명에 "(쌍따옴표)가 들어가면 오류 발생함 $goods['it_id'] = $row['it_id']; $goods['full_name']= $goods['name'] = addslashes($row['it_name']); // 특수문자제거 $goods['full_name'] = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>()\[\]\{\}]/i", "", $goods['full_name']);
// 상품건수 $row = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_cart_table']} where od_id = '$cart_id' "); $cnt = $row['cnt'] - 1; if ($cnt) $goods['full_name'] .= ' 외 '.$cnt.'건'; $goods['count'] = $row['cnt'];
return $goods; }
// 패턴의 내용대로 해당 디렉토리에서 정렬하여 <select> 태그에 적용할 수 있게 반환 function get_list_skin_options($pattern, $dirname='./', $sval='') { $str = '<option value="">선택</option>'.PHP_EOL;
unset($arr); $handle = opendir($dirname); while ($file = readdir($handle)) { if (preg_match("/$pattern/", $file, $matches)) { $arr[] = $matches[0]; } } closedir($handle);
sort($arr); foreach($arr as $value) { if($value == $sval) $selected = ' selected="selected"'; else $selected = '';
$str .= '<option value="'.$value.'"'.$selected.'>'.$value.'</option>'.PHP_EOL; }
return $str; }
// 일자 시간을 검사한다. function check_datetime($datetime) { if ($datetime == "0000-00-00 00:00:00") return true;
$year = substr($datetime, 0, 4); $month = substr($datetime, 5, 2); $day = substr($datetime, 8, 2); $hour = substr($datetime, 11, 2); $minute = substr($datetime, 14, 2); $second = substr($datetime, 17, 2);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
$tmp_datetime = date("Y-m-d H:i:s", $timestamp); if ($datetime == $tmp_datetime) return true; else return false; }
// 경고메세지를 경고창으로 function alert_opener($msg='', $url='') { global $g5;
if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"; echo "<script>"; echo "alert(\"$msg\");"; echo "opener.location.href=\"$url\";"; echo "self.close();"; echo "</script>"; exit; }
// option 리스트에 selected 추가 function conv_selected_option($options, $value) { if(!$options) return '';
$options = str_replace('value="'.$value.'"', 'value="'.$value.'" selected', $options);
return $options; }
// 주문서 번호를 얻는다. function get_new_od_id() { global $g5;
// 주문서 테이블 Lock 걸고 sql_query(" LOCK TABLES {$g5['g5_shop_order_table']} READ, {$g5['g5_shop_order_table']} WRITE ", FALSE); // 주문서 번호를 만든다. $date = date("ymd", time()); // 2002년 3월 7일 일경우 020307 $sql = " select max(od_id) as max_od_id from {$g5['g5_shop_order_table']} where SUBSTRING(od_id, 1, 6) = '$date' "; $row = sql_fetch($sql); $od_id = $row['max_od_id']; if ($od_id == 0) $od_id = 1; else { $od_id = (int)substr($od_id, -4); $od_id++; } $od_id = $date . substr("0000" . $od_id, -4); // 주문서 테이블 Lock 풀고 sql_query(" UNLOCK TABLES ", FALSE);
return $od_id; }
// cart id 설정 function set_cart_id($direct) { global $g5, $default, $member;
if ($direct) { $tmp_cart_id = get_session('ss_cart_direct'); if(!$tmp_cart_id) { $tmp_cart_id = get_uniqid(); set_session('ss_cart_direct', $tmp_cart_id); } } else { // 비회원장바구니 cart id 쿠키설정 if($default['de_guest_cart_use']) { $tmp_cart_id = get_cookie('ck_guest_cart_id'); if($tmp_cart_id) { set_session('ss_cart_id', $tmp_cart_id); //set_cookie('ck_guest_cart_id', $tmp_cart_id, ($default['de_cart_keep_term'] * 86400)); } else { $tmp_cart_id = get_uniqid(); set_session('ss_cart_id', $tmp_cart_id); set_cookie('ck_guest_cart_id', $tmp_cart_id, ($default['de_cart_keep_term'] * 86400)); } } else { $tmp_cart_id = get_session('ss_cart_id'); if(!$tmp_cart_id) { $tmp_cart_id = get_uniqid(); set_session('ss_cart_id', $tmp_cart_id); } }
// 보관된 회원장바구니 자료 cart id 변경 if($member['mb_id'] && $tmp_cart_id) { $sql = " update {$g5['g5_shop_cart_table']} set od_id = '$tmp_cart_id' where mb_id = '{$member['mb_id']}' and ct_direct = '0' and ct_status = '쇼핑' "; sql_query($sql); } } }
// 상품 목록 : 관련 상품 출력 function relation_item($it_id, $width, $height, $rows=3) { global $g5;
$str = '';
if(!$it_id) return $str;
$sql = " select b.it_id, b.it_name, b.it_price, b.it_tel_inq from {$g5['g5_shop_item_relation_table']} a left join {$g5['g5_shop_item_table']} b on ( a.it_id2 = b.it_id ) where a.it_id = '$it_id' order by ir_no asc limit 0, $rows "; $result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) { if($i == 0) { $str .= '<span class="sound_only">관련 상품 시작</span>'; $str .= '<ul class="sct_rel_ul">'; }
$it_name = get_text($row['it_name']); // 상품명 $it_price = get_price($row); // 상품가격 if(!$row['it_tel_inq']) $it_price = display_price($it_price);
$img = get_it_image($row['it_id'], $width, $height);
$str .= '<li class="sct_rel_li"><a href="'.G5_SHOP_URL.'/item.php?it_id='.$row['it_id'].'" class="sct_rel_a">'.$img.'</a></li>'; }
if($i > 0) $str .= '</ul><span class="sound_only">관련 상품 끝</span>';
return $str; }
// 상품이미지에 유형 아이콘 출력 function item_icon($it) { global $g5,$default;
$icon = '<span class="sit_icon">'; // 품절 if (is_soldout($it['it_id'])) $icon .= '<img src="'.G5_SHOP_URL.'/img/icon_soldout.png" alt="품절">';
if ($it['it_type1']){ $imgx = listtype_rep_icon(1,G5_SHOP_URL.'/img/icon_hit.png'); $text = listtype_rep_text(1,'히트상품'); $icon .= '<img src="'.$imgx.'" alt="'.$text.'">'; } if ($it['it_type2']){ $imgx = listtype_rep_icon(2,G5_SHOP_URL.'/img/icon_rec.png'); $text = listtype_rep_text(2,'추천상품'); $icon .= '<img src="'.$imgx.'" alt="'.$text.'">'; } if ($it['it_type3']){ $imgx = listtype_rep_icon(3,G5_SHOP_URL.'/img/icon_new.png'); $text = listtype_rep_text(3,'최신상품'); $icon .= '<img src="'.$imgx.'" alt="'.$text.'">'; //$icon .= '<img src="'.G5_SHOP_URL.'/img/icon_new.png" alt="최신상품">'; } if ($it['it_type4']){ $imgx = listtype_rep_icon(4,G5_SHOP_URL.'/img/icon_best.png'); $text = listtype_rep_text(4,'인기상품'); $icon .= '<img src="'.$imgx.'" alt="'.$text.'">'; //$icon .= '<img src="'.G5_SHOP_URL.'/img/icon_best.png" alt="인기상품">'; } if ($it['it_type5']){ $imgx = listtype_rep_icon(5,G5_SHOP_URL.'/img/icon_discount.png'); $text = listtype_rep_text(5,'할인상품'); $icon .= '<img src="'.$imgx.'" alt="'.$text.'">'; //$icon .= '<img src="'.G5_SHOP_URL.'/img/icon_discount.png" alt="할인상품">'; } // 쿠폰상품 $sql = " select count(*) as cnt from {$g5['g5_shop_coupon_table']} where cp_start <= '".G5_TIME_YMD."' and cp_end >= '".G5_TIME_YMD."' and ( ( cp_method = '0' and cp_target = '{$it['it_id']}' ) OR ( cp_method = '1' and ( cp_target IN ( '{$it['ca_id']}', '{$it['ca_id2']}', '{$it['ca_id3']}' ) ) ) ) "; $row = sql_fetch($sql); if($row['cnt']) $icon .= '<img src="'.G5_SHOP_URL.'/img/icon_cp.png" alt="쿠폰상품">';
$icon .= '</span>';
return $icon; }
// sns 공유하기 function get_sns_share_link($sns, $url, $title, $img) { global $config;
if(!$sns) return '';
switch($sns) { case 'facebook': $str = '<a href="https://www.facebook.com/sharer/sharer.php?u='.urlencode($url).'&p='.urlencode($title).'" class="share-facebook" target="_blank"><img src="'.$img.'" alt="페이스북에 공유"></a>'; break; case 'twitter': $str = '<a href="https://twitter.com/share?url='.urlencode($url).'&text='.urlencode($title).'" class="share-twitter" target="_blank"><img src="'.$img.'" alt="트위터에 공유"></a>'; break; case 'googleplus': $str = '<a href="https://plus.google.com/share?url='.urlencode($url).'" class="share-googleplus" target="_blank"><img src="'.$img.'" alt="구글플러스에 공유"></a>'; break; case 'kakaotalk': if($config['cf_kakao_js_apikey']) $str = '<a href="javascript:kakaolink_send(\''.str_replace('+', ' ', urlencode($title)).'\', \''.urlencode($url).'\');" class="share-kakaotalk"><img src="'.$img.'" alt="카카오톡 링크보내기"></a>'; break; }
return $str; }
// 상품이미지 썸네일 삭제 function delete_item_thumbnail($dir, $file) { if(!$dir || !$file) return;
$filename = preg_replace("/\.[^\.]+$/i", "", $file); // 확장자제거
$files = glob($dir.'/thumb-'.$filename.'*');
if(is_array($files)) { foreach($files as $thumb_file) { @unlink($thumb_file); } } }
// 쿠폰번호 생성함수 function get_coupon_id() { $len = 16; $chars = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789";
srand((double)microtime()*1000000);
$i = 0; $str = '';
while ($i < $len) { $num = rand() % strlen($chars); $tmp = substr($chars, $num, 1); $str .= $tmp; $i++; }
$str = preg_replace("/([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})/", "\\1-\\2-\\3-\\4", $str);
return $str; }
// 주문의 금액, 배송비 과세금액 등의 정보를 가져옴 function get_order_info($od_id) { global $g5;
// 주문정보 $sql = " select * from {$g5['g5_shop_order_table']} where od_id = '$od_id' "; $od = sql_fetch($sql);
if(!$od['od_id']) return false;
$info = array();
// 장바구니 주문금액정보 $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price, SUM(cp_price) as coupon, SUM( IF( ct_notax = 0, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as tax_mny, SUM( IF( ct_notax = 1, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as free_mny from {$g5['g5_shop_cart_table']} where od_id = '$od_id' and ct_status IN ( '주문', '입금', '준비', '배송', '완료' ) "; $sum = sql_fetch($sql);
$cart_price = $sum['price']; $cart_coupon = $sum['coupon'];
// 배송비 $send_cost = get_sendcost($od_id);
$od_coupon = $od_send_coupon = 0;
if($od['mb_id']) { // 주문할인 쿠폰 $sql = " select a.cp_id, a.cp_type, a.cp_price, a.cp_trunc, a.cp_minimum, a.cp_maximum from {$g5['g5_shop_coupon_table']} a right join {$g5['g5_shop_coupon_log_table']} b on ( a.cp_id = b.cp_id ) where b.od_id = '$od_id' and b.mb_id = '{$od['mb_id']}' and a.cp_method = '2' "; $cp = sql_fetch($sql);
$tot_od_price = $cart_price - $cart_coupon;
if($cp['cp_id']) { $dc = 0;
if($cp['cp_minimum'] <= $tot_od_price) { if($cp['cp_type']) { $dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; } else { $dc = $cp['cp_price']; }
if($cp['cp_maximum'] && $dc > $cp['cp_maximum']) $dc = $cp['cp_maximum'];
if($tot_od_price < $dc) $dc = $tot_od_price;
$tot_od_price -= $dc; $od_coupon = $dc; } }
// 배송쿠폰 할인 $sql = " select a.cp_id, a.cp_type, a.cp_price, a.cp_trunc, a.cp_minimum, a.cp_maximum from {$g5['g5_shop_coupon_table']} a right join {$g5['g5_shop_coupon_log_table']} b on ( a.cp_id = b.cp_id ) where b.od_id = '$od_id' and b.mb_id = '{$od['mb_id']}' and a.cp_method = '3' "; $cp = sql_fetch($sql);
if($cp['cp_id']) { $dc = 0; if($cp['cp_minimum'] <= $tot_od_price) { if($cp['cp_type']) { $dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc']; } else { $dc = $cp['cp_price']; }
if($cp['cp_maximum'] && $dc > $cp['cp_maximum']) $dc = $cp['cp_maximum'];
if($dc > $send_cost) $dc = $send_cost;
$od_send_coupon = $dc; } } }
if($od['od_vender_deliinfo']!=''){ // 기존의 벤더로 배송비가 책정되어 있다면. $send_cost = 0; $vd = explode(",",$od['od_vender_deliinfo']); foreach($vd as $key=>$val){ if(trim($val)!=''){ $vds = explode("^",$val); $send_cost += $vds[1]; } } }
// 과세, 비과세 금액정보 $tax_mny = $sum['tax_mny']; $free_mny = $sum['free_mny'];
if($od['od_tax_flag']) { $tot_tax_mny = ( $tax_mny + $send_cost + $od['od_send_cost2'] ) - ( $od_coupon + $od_send_coupon + $od['od_receipt_point'] ); if($tot_tax_mny < 0) { $free_mny += $tot_tax_mny; $tot_tax_mny = 0; } } else { $tot_tax_mny = ( $tax_mny + $free_mny + $send_cost + $od['od_send_cost2'] ) - ( $od_coupon + $od_send_coupon + $od['od_receipt_point'] ); $free_mny = 0; }
$od_tax_mny = round($tot_tax_mny / 1.1); $od_vat_mny = $tot_tax_mny - $od_tax_mny; $od_free_mny = $free_mny;
// 장바구니 취소금액 정보 $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price from {$g5['g5_shop_cart_table']} where od_id = '$od_id' and ct_status IN ( '취소', '반품', '품절' ) "; $sum = sql_fetch($sql); $cancel_price = $sum['price']; if(1==1){ // 취소금액에 배송비 포함함 일단 포함함 //$cancel_price = $cancel_price + $send_cost; }
// 미수금액 $od_misu = ( $cart_price + $send_cost + $od['od_send_cost2'] ) - ( $cart_coupon + $od_coupon + $od_send_coupon ) - ( $od['od_receipt_price'] + $od['od_receipt_point'] - $od['od_refund_price'] ) - $od['od_dc_price'] ;
// 장바구니상품금액 $od_cart_price = $cart_price + $cancel_price;
// 결과처리 $info['od_cart_price'] = $od_cart_price; $info['od_send_cost'] = $send_cost; $info['od_coupon'] = $od_coupon; $info['od_send_coupon'] = $od_send_coupon; $info['od_cart_coupon'] = $cart_coupon; $info['od_tax_mny'] = $od_tax_mny; $info['od_vat_mny'] = $od_vat_mny; $info['od_free_mny'] = $od_free_mny; $info['od_cancel_price'] = $cancel_price; $info['od_misu'] = $od_misu;
return $info; }
// 상품포인트 function get_item_point($it, $io_id='', $trunc=10) { global $g5;
$it_point = 0;
if($it['it_point_type'] > 0) { $it_price = $it['it_price'];
if($it['it_point_type'] == 2 && $io_id) { $sql = " select io_id, io_price from {$g5['g5_shop_item_option_table']} where it_id = '{$it['it_id']}' and io_id = '$io_id' and io_type = '0' and io_use = '1' "; $opt = sql_fetch($sql);
if($opt['io_id']) $it_price += $opt['io_price']; }
$it_point = floor(($it_price * ($it['it_point'] / 100) / $trunc)) * $trunc; } else { $it_point = $it['it_point']; }
return $it_point; }
// 배송비 구함 function get_sendcost($cart_id, $selected=1,$vm_id=0) { global $default, $g5;
$send_cost = 0; $total_price = 0; $total_send_cost = 0;
$sql = " select distinct it_id from {$g5['g5_shop_cart_table']} where od_id = '$cart_id' and ct_send_cost = '0' and ct_status IN ( '쇼핑', '주문', '입금', '준비', '배송', '완료' ) and ct_select = '$selected' ";
$result = sql_query($sql); for($i=0; $sc=sql_fetch_array($result); $i++) { // 합계 if($default['de_vender_use']=='1'){ $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price, SUM(ct_qty) as qty from {$g5['g5_shop_cart_table']} where it_id = '{$sc['it_id']}' and vm_id = '$vm_id' and od_id = '$cart_id' and ct_status IN ( '쇼핑', '주문', '입금', '준비', '배송', '완료' ) and ct_select = '$selected'"; } else { $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price, SUM(ct_qty) as qty from {$g5['g5_shop_cart_table']} where it_id = '{$sc['it_id']}' and od_id = '$cart_id' and ct_status IN ( '쇼핑', '주문', '입금', '준비', '배송', '완료' ) and ct_select = '$selected'"; } $sum = sql_fetch($sql);
$send_cost = get_item_sendcost($sc['it_id'], $sum['price'], $sum['qty'], $cart_id);
if($send_cost > 0) $total_send_cost += $send_cost;
if($default['de_send_cost_case'] == '차등' && $send_cost == -1) $total_price += $sum['price']; }
$send_cost = 0; if($default['de_send_cost_case'] == '차등' && $total_price > 0) { // 금액별차등 : 여러단계의 배송비 적용 가능 $send_cost_limit = explode(";", $default['de_send_cost_limit']); $send_cost_list = explode(";", $default['de_send_cost_list']); $send_cost = 0; for ($k=0; $k<count($send_cost_limit); $k++) { // 총판매금액이 배송비 상한가 보다 작다면 if ($total_price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) { $send_cost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]); break; } } }
return ($total_send_cost + $send_cost); }
// 상품별 배송비 function get_item_sendcost($it_id, $price, $qty, $cart_id) { global $g5, $default;
$sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$cart_id' order by ct_id limit 1 "; $ct = sql_fetch($sql); if(!$ct['it_id']) return 0;
if($ct['it_sc_type'] > 1) { if($ct['it_sc_type'] == 2) { // 조건부무료 if($price >= $ct['it_sc_minimum']) $sendcost = 0; else $sendcost = $ct['it_sc_price']; } else if($ct['it_sc_type'] == 3) { // 유료배송 $sendcost = $ct['it_sc_price']; } else { // 수량별 부과 if(!$ct['it_sc_qty']) $ct['it_sc_qty'] = 1;
$q = ceil((int)$qty / (int)$ct['it_sc_qty']); $sendcost = (int)$ct['it_sc_price'] * $q; } } else if($ct['it_sc_type'] == 1) { // 무료배송 $sendcost = 0; } else { $sendcost = -1; }
return $sendcost; }
// 가격비교 사이트 상품 배송비 function get_item_sendcost2($it_id, $price, $qty) { global $g5, $default;
$sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $it = sql_fetch($sql); if(!$it['it_id']) return 0;
$sendcost = 0;
// 쇼핑몰 기본설정을 사용할 때 if($it['it_sc_type'] == 0) { if($default['de_send_cost_case'] == '차등') { // 금액별차등 : 여러단계의 배송비 적용 가능 $send_cost_limit = explode(";", $default['de_send_cost_limit']); $send_cost_list = explode(";", $default['de_send_cost_list']);
for ($k=0; $k<count($send_cost_limit); $k++) { // 총판매금액이 배송비 상한가 보다 작다면 if ($price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) { $sendcost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]); break; } } } } else { if($it['it_sc_type'] > 1) { if($it['it_sc_type'] == 2) { // 조건부무료 if($price >= $it['it_sc_minimum']) $sendcost = 0; else $sendcost = $it['it_sc_price']; } else if($it['it_sc_type'] == 3) { // 유료배송 $sendcost = $it['it_sc_price']; } else { // 수량별 부과 if(!$it['it_sc_qty']) $it['it_sc_qty'] = 1;
$q = ceil((int)$qty / (int)$it['it_sc_qty']); $sendcost = (int)$it['it_sc_price'] * $q; } } else if($it['it_sc_type'] == 1) { // 무료배송 $sendcost = 0; } }
return $sendcost; }
// 쿠폰 사용체크 function is_used_coupon($mb_id, $cp_id) { global $g5, $default;
$used = false;
$sql = " select count(*) as cnt from {$g5['g5_shop_coupon_log_table']} where mb_id = '$mb_id' and cp_id = '$cp_id' "; $row = sql_fetch($sql);
if($row['cnt']) $used = true;
return $used; }
// 품절상품인지 체크 function is_soldout($it_id) { global $g5, $default;
// 상품정보 $sql = " select it_soldout, it_stock_qty, it_4, it_8 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $it = sql_fetch($sql);
if(trim($it['it_8'])=='1'){ return false; } // 무한 재고 사용시엔 무조건 판매됨
// 상품에 선택옵션 있으면.. $sql = " select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' and io_type = '0' "; $row = sql_fetch($sql);
if($it['it_soldout']){ return true; } else if($row['cnt']>0){ // 옵션상품이 있을경우 본품재고 0이라도 품절 안떨어지게 수정
} else if($it['it_stock_qty']<=0){ return true; }
if($default['de_cs_qty_use']=='1'){ // 품절체크에서 천년재고 사용이 체크일경우 천년재고가 품절이면 바로 품절처리함 if($row['cnt']>0){ // 옵션상품이 있을경우 CS재고 0이라도 품절 안떨어지게 수정
} else if($it['it_4']*1<=0) { return true; } }
$count = 0; $count2 = 0; $soldout = false;
if($row['cnt']) { $sql = " select io_id, io_type, io_stock_qty, io_cs_qty from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' and io_type = '0' and io_use = '1' "; $result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) { // 옵션 재고수량 $stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);
if($stock_qty <= 0) $count++;
if($default['de_cs_qty_use']=='1'){ // 천년재고 사용이 체크일경우 천년재고 옵션들의 재고를 체크해서 품절 if($row['io_cs_qty']<=0){ $count2++; } } }
// 모든 선택옵션 품절이면 상품 품절 if($i == $count){ $soldout = true; } } else { // 상품 재고수량 $stock_qty = get_it_stock_qty($it_id);
if($stock_qty <= 0) $soldout = true; }
return $soldout; }
// 상품후기 작성가능한지 체크 function check_itemuse_write($it_id, $mb_id, $close=true) { global $g5, $default, $is_admin;
if(!$is_admin && $default['de_item_use_write']) { $sql = " select count(*) as cnt from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and mb_id = '$mb_id' and ct_status = '완료' "; $row = sql_fetch($sql);
if($row['cnt'] == 0) { if($close) alert_close('사용후기는 주문이 완료된 경우에만 작성하실 수 있습니다.'); else alert('사용후기는 주문하신 상품의 상태가 완료인 경우에만 작성하실 수 있습니다.'); } } }
// 구매 본인인증 체크 function shop_member_cert_check($id, $type) { global $g5, $member;
$msg = '';
switch($type) { case 'item': $sql = " select ca_id, ca_id2, ca_id3 from {$g5['g5_shop_item_table']} where it_id = '$id' "; $it = sql_fetch($sql);
$seq = ''; for($i=0; $i<3; $i++) { $ca_id = $it['ca_id'.$seq];
if(!$ca_id) continue;
$sql = " select ca_cert_use, ca_adult_use from {$g5['g5_shop_category_table']} where ca_id = '$ca_id' "; $row = sql_fetch($sql);
// 본인확인체크 if($row['ca_cert_use'] && !$member['mb_certify']) { if($member['mb_id']) $msg = '회원정보 수정에서 본인확인 후 이용해 주십시오.'; else $msg = '본인확인된 로그인 회원만 이용할 수 있습니다.';
break; }
// 성인인증체크 if($row['ca_adult_use'] && !$member['mb_adult']) { if($member['mb_id']) $msg = '본인확인으로 성인인증된 회원만 이용할 수 있습니다.\\n회원정보 수정에서 본인확인을 해주십시오.'; else $msg = '본인확인으로 성인인증된 회원만 이용할 수 있습니다.';
break; }
if($i == 0) $seq = 1; $seq++; }
break; case 'list': $sql = " select * from {$g5['g5_shop_category_table']} where ca_id = '$id' "; $ca = sql_fetch($sql);
// 본인확인체크 if($ca['ca_cert_use'] && !$member['mb_certify']) { if($member['mb_id']) $msg = '회원정보 수정에서 본인확인 후 이용해 주십시오.'; else $msg = '본인확인된 로그인 회원만 이용할 수 있습니다.'; }
// 성인인증체크 if($ca['ca_adult_use'] && !$member['mb_adult']) { if($member['mb_id']) $msg = '본인확인으로 성인인증된 회원만 이용할 수 있습니다.\\n회원정보 수정에서 본인확인을 해주십시오.'; else $msg = '본인확인으로 성인인증된 회원만 이용할 수 있습니다.'; }
break; default: break; }
return $msg; }
// 배송조회버튼 생성 function get_delivery_inquiry($company, $invoice, $class='') { if(!$company || !$invoice) return '';
$dlcomp = explode(")", str_replace("(", "", G5_DELIVERY_COMPANY));
for($i=0; $i<count($dlcomp); $i++) { if(strstr($dlcomp[$i], $company)) { list($com, $url, $tel) = explode("^", $dlcomp[$i]); break; } }
$str = ''; if($com && $url) { $str .= '<a href="'.$url.$invoice.'" target="_blank"'; if($class) $str .= ' class="'.$class.'"'; $str .='>배송조회</a>'; if($tel) $str .= ' (문의전화: '.$tel.')'; }
return $str; }
// 사용후기의 확인된 건수를 상품테이블에 저장합니다. function update_use_cnt($it_id) { global $g5; $row = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_item_use_table']} where it_id = '{$it_id}' and is_confirm = 1 "); return sql_query(" update {$g5['g5_shop_item_table']} set it_use_cnt = '{$row['cnt']}' where it_id = '{$it_id}' "); }
// 사용후기의 선호도(별) 평균을 상품테이블에 저장합니다. function update_use_avg($it_id) { global $g5; $row = sql_fetch(" select count(*) as cnt, sum(is_score) as total from {$g5['g5_shop_item_use_table']} where it_id = '{$it_id}' "); $average = ($row['total'] && $row['cnt']) ? $row['total'] / $row['cnt'] : 0; return sql_query(" update {$g5['g5_shop_item_table']} set it_use_avg = '$average' where it_id = '{$it_id}' "); }
//------------------------------------------------------------------------------ // 주문포인트를 적립한다. // 설정일이 지난 포인트 부여되지 않은 배송완료된 장바구니 자료에 포인트 부여 // 설정일이 0 이면 주문서 완료 설정 시점에서 포인트를 바로 부여합니다. //------------------------------------------------------------------------------ function save_order_point($ct_status="완료") { global $g5, $default;
$beforedays = date("Y-m-d H:i:s", ( time() - (86400 * (int)$default['de_point_days']) ) ); // 86400초는 하루 $sql = " select * from {$g5['g5_shop_cart_table']} where ct_status = '$ct_status' and ct_point_use = '0' and ct_time <= '$beforedays' "; $result = sql_query($sql); for ($i=0; $row=sql_fetch_array($result); $i++) { // 회원 ID 를 얻는다. $od_row = sql_fetch("select od_id, mb_id from {$g5['g5_shop_order_table']} where od_id = '{$row['od_id']}' "); if ($od_row['mb_id'] && $row['ct_point'] > 0) { // 회원이면서 포인트가 0보다 크다면 $po_point = $row['ct_point'] * $row['ct_qty']; $po_content = "주문번호 {$od_row['od_id']} ({$row['ct_id']}) 배송완료"; insert_point($od_row['mb_id'], $po_point, $po_content, "@delivery", $od_row['mb_id'], "{$od_row['od_id']},{$row['ct_id']}"); } sql_query("update {$g5['g5_shop_cart_table']} set ct_point_use = '1' where ct_id = '{$row['ct_id']}' "); }
// 회원 등급 항목 체크후 등급 추가 적립이 있는 경우 추가적립함 $sql = " select * from {$g5['g5_shop_order_table']} where od_status = '$ct_status' and od_point_use = '0' and od_time <= '$beforedays' "; $result = sql_query($sql); for ($i=0; $row=sql_fetch_array($result); $i++) { $sql = "select a.mb_id, b.* from {$g5['member_table']} a left join {$g5['member_group']} b on a.mb_1 = b.mg_no where a.mb_id = '{$row['mb_id']}' "; $mb_mg_info = sql_fetch($sql); if($mb_mg_info['mg_point']=='Y'){ if($row['od_cart_price']>=$mb_mg_info['mg_point_price']){ $po_point = round($row['od_cart_price']*$mb_mg_info['mg_point_price_get']/100); $po_content = "주문번호 {$od_row['od_id']} 배송완료 -> {$mb_mg_info['mg_point_price_get']}% 등급 추가적립"; insert_point($row['mb_id'], $po_point, $po_content, "@memgroup", $row['mb_id'], "{$row['od_id']}",$mb_mg_info['mg_point_price_get']); } } $sql = "update {$g5['g5_shop_order_table']} set od_point_use = 1 where od_id = '{$row['od_id']}' "; sql_query($sql); } }
// 배송업체 리스트 얻기 function get_delivery_company($company) { $option = '<option value="">없음</option>'.PHP_EOL; $option .= '<option value="자체배송" '.get_selected($company, '자체배송').'>자체배송</option>'.PHP_EOL;
$dlcomp = explode(")", str_replace("(", "", G5_DELIVERY_COMPANY)); for ($i=0; $i<count($dlcomp); $i++) { if (trim($dlcomp[$i])=="") continue; list($value, $url, $tel) = explode("^", $dlcomp[$i]); $option .= '<option value="'.$value.'" '.get_selected($company, $value).'>'.$value.'</option>'.PHP_EOL; }
return $option; }
// 사용후기 썸네일 생성 function get_itemuselist_thumbnail($it_id, $contents, $thumb_width, $thumb_height, $is_create=false, $is_crop=true, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3') { global $g5, $config; $img = $filename = $alt = "";
if($contents) { $matches = get_editor_image($contents, false);
for($i=0; $i<count($matches[1]); $i++) { // 이미지 path 구함 $p = parse_url($matches[1][$i]); if(strpos($p['path'], '/'.G5_DATA_DIR.'/') != 0) $data_path = preg_replace('/^\/.*\/'.G5_DATA_DIR.'/', '/'.G5_DATA_DIR, $p['path']); else $data_path = $p['path'];
$srcfile = G5_PATH.$data_path;
if(preg_match("/\.({$config['cf_image_extension']})$/i", $srcfile) && is_file($srcfile)) { $size = @getimagesize($srcfile); if(empty($size)) continue;
$filename = basename($srcfile); $filepath = dirname($srcfile);
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matches[0][$i], $malt); $alt = get_text($malt[1]);
break; } }
if($filename) { $thumb = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
if($thumb) { $src = G5_URL.str_replace($filename, $thumb, $data_path); $img = '<img src="'.$src.'" width="'.$thumb_width.'" height="'.$thumb_height.'" alt="'.$alt.'">'; } } }
if(!$img) $img = get_it_image($it_id, $thumb_width, $thumb_height);
return $img; }
// 장바구니 상품삭제 function cart_item_clean() { global $g5, $default;
// 장바구니 보관일 $keep_term = $default['de_cart_keep_term']; if(!$keep_term) $keep_term = 15; // 기본값 15일
// ct_select_time이 기준시간 이상 경과된 경우 변경 if(defined('G5_CART_STOCK_LIMIT')) $cart_stock_limit = G5_CART_STOCK_LIMIT; else $cart_stock_limit = 3;
$stocktime = 0; if($cart_stock_limit > 0) { if($cart_stock_limit > $keep_term * 24) $cart_stock_limit = $keep_term * 24;
$stocktime = G5_SERVER_TIME - (3600 * $cart_stock_limit); $sql = " update {$g5['g5_shop_cart_table']} set ct_select = '0' where ct_select = '1' and ct_status = '쇼핑' and UNIX_TIMESTAMP(ct_select_time) < '$stocktime' "; sql_query($sql); }
// 설정 시간이상 경과된 상품 삭제 $statustime = G5_SERVER_TIME - (86400 * $keep_term);
$sql = " delete from {$g5['g5_shop_cart_table']} where ct_status = '쇼핑' and UNIX_TIMESTAMP(ct_time) < '$statustime' "; sql_query($sql); }
// 모바일 PG 주문 필드 생성 function make_order_field($data, $exclude) { $field = '';
foreach($data as $key=>$value) { if(in_array($key, $exclude)) continue;
if(is_array($value)) { foreach($value as $k=>$v) { $field .= '<input type="hidden" name="'.$key.'['.$k.']" value="'.$v.'">'.PHP_EOL; } } else { $field .= '<input type="hidden" name="'.$key.'" value="'.$value.'">'.PHP_EOL; } }
return $field; }
//============================================================================== // 쇼핑몰 라이브러리 모음 끝 //==============================================================================
// 다중단가 체크 처리 function multy_price_check($price,$it_id, $io_id=""){ Global $g5, $default, $member;
if($default['de_multy_price_use']=='1'){ $sql = "select it_9 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $it = sql_fetch($sql);
// 회원에 매핑된 CS거래처가 있는지 확인해며 해당 거래처의가 선택되어 있는 다중단가 번호를 가져와서 다중단가 테이블에 확인후 해당 금액을 가져온다. $sql = "select b.multypriceno from {$g5['jegocs_member_mapping']} a left join {$g5['jegocs_customer']} b on a.jego_code = b.code where a.shop_code = '{$member['mb_no']}' "; //_pr($sql); $jego_mem = sql_fetch($sql);
if($jego_mem['multypriceno']>0){ $sql = "select * from {$g5['g5_shop_item_multy_price_table']} where pseq = '{$jego_mem['multypriceno']}' and it_id = '$it_id' and io_id = '$io_id' "; $info = sql_fetch($sql); if($info['price']!=''){ return $info['price']; } else { return $price; } } else { return $price; } } else { return $price; } }
function multy_price_array($it_id){ Global $g5, $default, $member;
$sql = "select it_9 from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; $it = sql_fetch($sql);
// 회원에 매핑된 CS거래처가 있는지 확인해며 해당 거래처의가 선택되어 있는 다중단가 번호를 가져와서 다중단가 테이블에 확인후 해당 금액을 가져온다. $sql = "select b.multypriceno from {$g5['jegocs_member_mapping']} a left join {$g5['jegocs_customer']} b on a.jego_code = b.code where a.shop_code = '{$member['mb_no']}' "; $jego_mem = sql_fetch($sql);
if($jego_mem['multypriceno']>0){ //$sql = "select * from {$g5['g5_shop_item_multy_price_table']} where it_id = '$it_id' and pseq = '{$it['it_9']}' "; $sql = "select * from {$g5['g5_shop_item_multy_price_table']} where pseq = '{$jego_mem['multypriceno']}' and it_id = '$it_id' "; //echo $sql; $res = sql_query($sql); while($info=mysql_fetch_array($res)){ $mp_info[] = $info; } //_pr($mp_info); } return $mp_info; }
// 주문과 취소등에 따라서 재고를 가감하는 함수 function set_item_stock_cal($flag,$od_id){ Global $g5, $default;
$it_prod_map_array = it_prod_map(); // CS상품과 쇼핑몰 상품의 매핑 레코드를 가져온다.
$sql = "select * from {$g5['g5_shop_order_table']} where od_id = '$od_id' "; $od_info = sql_fetch($sql);
$sql = "select * from {$g5['g5_shop_cart_table']} where od_id = '{$od_id}' "; $res = sql_query($sql);
while($ct_info=mysql_fetch_array($res)){ $sql = "select it_stock_qty, it_3 from {$g5['g5_shop_item_table']} where it_id = '{$ct_info['it_id']}' "; $it_info = sql_fetch($sql);
if(($ct_info['ct_status']=='주문' || $ct_info['ct_status']=='취소' || $ct_info['ct_status']=='반품') && $ct_info['ct_stock_use']=='1'){ // 주문상품이 [주문][취소] 이며 재고가 빠져나갔으면 재고 복원 if($ct_info['io_id']){ // 옵션일경우 처리 if($ct_info['io_type']=='0'){ // 상품옵션일때만 본상품 재고 재입고 추가옵션일경우 재입고안함 if($it_info['it_3']=='2'){ // 셋트일경우 본품의 재고를 추가함 $del_stock_su = $ct_info['ct_qty']*$ct_info['io_qty_weight']; // 제외할 재고의 재고비중을 곱함 $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty + '$del_stock_su' where it_id = '{$ct_info['it_id']}' "; sql_query($sql); } else { // 일반상품이경우 옵션의 재고만 추가함 $sql = " update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty + '{$ct_info['ct_qty']}' where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' "; sql_query($sql); } } else if($ct_info['io_type']=='1'){ // 추가 옵션일 경우 처리 $sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty + '{$ct_info['ct_qty']}' where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' and io_type='1' "; sql_query($sql); // 일단 추가 옵션의 재고를 복구다.
$sql = "select * from {$g5['g5_shop_item_option_table']} where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' and io_type='1' "; $io_info = sql_fetch($sql); // 추가 옵션 정보 가져온다. if($io_info['spl_it_id']>'0' && trim($io_info['spl_io_id'])==''){ // 추가옵션 연관 상품이 본상품이다. $sql = "select * from {$g5['g5_shop_item_table']} where it_id = '{$io_info['spl_it_id']}' "; $spl_it_info = sql_fetch($sql);
$sql = "update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty + {$ct_info['ct_qty']} where it_id = '{$io_info['spl_it_id']}' "; // 본상품의 재고를 연동해서 복구한다. sql_query($sql); } else if($io_info['spl_it_id']>'0' && trim($io_info['spl_io_id'])!='') { // 추가옵션 연관상품이 옵션상품이다. $sql = "select it_3 from {$g5['g5_shop_item_table']} where it_id = '{$io_info['spl_it_id']}' "; $spl_it_info = sql_fetch($sql);
$sql = "select io_qty_weight from {$g5['g5_shop_item_option_table']} where it_id = '{$io_info['spl_it_id']}' and io_id = '{$io_info['spl_io_id']}' "; $spl_io_info = sql_fetch($sql);
$sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty + {$ct_info['ct_qty']} where it_id = '{$io_info['spl_it_id']}' and io_id = '{$io_info['spl_io_id']}' and io_type = '1' "; // 옵션상품의 재고를 연동해서 복구한다. sql_query($sql);
if($spl_it_info['it_3']=='2'){ $del_stock_su = $ct_info['ct_qty']*$spl_io_info['io_qty_weight']; // 제외할 재고의 재고비중을 곱함 $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty + '$del_stock_su' where it_id = '{$io_info['spl_it_id']}' "; sql_query($sql); // 추가옵션의 연관 상품의 본상품을 복구한다. set_item_qty_cal($io_info['spl_it_id']); } } } } else { $del_stock_su = $ct_info['ct_qty']; $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty + '$del_stock_su' where it_id = '{$ct_info['it_id']}' "; sql_query($sql); } $sql = "update {$g5['g5_shop_cart_table']} set ct_stock_use = 0 where ct_id = '{$ct_info['ct_id']}' "; sql_query($sql); // 주문상품 재고반영 체크
if($default['de_prodset_qty_use']=='1'){ // CS셋트상품 재고 처리 일경우 처리함 (재고 복구) $prod_code = ""; foreach($it_prod_map_array as $key => $val){ if($val['it_id']==$ct_info['it_id'] && $val['io_id']==''){ $prod_code = $val['code']; break; } if($val['it_id']==$ct_info['it_id'] && $val['io_id']==$ct_info['io_id']){ $prod_code = $val['code']; break; } }
if($prod_code!=''){ $sql = "select * from {$g5['jegocs_prodset']} where pcode = '{$prod_code}' "; $res_set = sql_query($sql); while($info_set=mysql_fetch_array($res_set)){ foreach($it_prod_map_array as $key => $val){ if($info_set['pscode']==$val['code']){ $v_it_id = $val['it_id']; $v_io_id = trim($val['io_id']); break; } }
$qty_val = $info_set['qnt']*$ct_info['ct_qty']; if($v_io_id==''){ $sql = "update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty + {$qty_val} where it_id = '{$v_it_id}' "; } else { $sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty + {$qty_val} where it_id = '{$v_it_id}' and io_id = '{$v_io_id}' "; } sql_query($sql); } } }
//_pr($sql); exit; } else if(($ct_info['ct_status']=='입금' || $ct_info['ct_status']=='준비' || $ct_info['ct_status']=='배송' || $ct_info['ct_status']=='완료') && $ct_info['ct_stock_use']=='0' ){ // 주문상품이 [입금][준비][배송][완료] 이며 재고가 차감이 안되었으면 재고 차감
//_pr($it_prod_map_array);
if($ct_info['io_id']){ // 옵션일경우 처리 if($ct_info['io_type']=='0'){ // 상품옵션일때만 본상품 재고 차감 추가옵션일경우 차감안함 if($it_info['it_3']=='2'){ // 셋트옵션일경우 본품의 재고를 비중을 곱해서 차감함 $del_stock_su = $ct_info['ct_qty']*$ct_info['io_qty_weight']; // 제외할 재고의 재고비중을 곱함 $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty - '$del_stock_su' where it_id = '{$ct_info['it_id']}' "; sql_query($sql); } else { // 일반상품일경우 옵션재고의 갯수만 차감함 $sql = " update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty - '{$ct_info['ct_qty']}' where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' "; sql_query($sql); } } else if($ct_info['io_type']=='1'){ // 추가 옵션일 경우 처리 $sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty - '{$ct_info['ct_qty']}' where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' and io_type='1' "; sql_query($sql); // 일단 추가 옵션의 재고를 빼준다.
$sql = "select * from {$g5['g5_shop_item_option_table']} where it_id = '{$ct_info['it_id']}' and io_id = '{$ct_info['io_id']}' and io_type='1' "; $io_info = sql_fetch($sql); // 추가 옵션 정보 가져온다. if($io_info['spl_it_id']>'0' && trim($io_info['spl_io_id'])==''){ // 추가옵션 연관 상품이 본상품이다. $sql = "select it_3 from {$g5['g5_shop_item_table']} where it_id = '{$io_info['spl_it_id']}' "; $spl_it_info = sql_fetch($sql);
$sql = "update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty - {$ct_info['ct_qty']} where it_id = '{$io_info['spl_it_id']}' "; // 본상품의 재고를 연동해서 뺀다. sql_query($sql); } else if($io_info['spl_it_id']>'0' && trim($io_info['spl_io_id'])!='') { // 추가옵션 연관상품이 옵션상품이다. $sql = "select it_3 from {$g5['g5_shop_item_table']} where it_id = '{$io_info['spl_it_id']}' "; $spl_it_info = sql_fetch($sql);
$sql = "select io_qty_weight from {$g5['g5_shop_item_option_table']} where it_id = '{$io_info['spl_it_id']}' and io_id = '{$io_info['spl_io_id']}' "; $spl_io_info = sql_fetch($sql);
$sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty - {$ct_info['ct_qty']} where it_id = '{$io_info['spl_it_id']}' and io_id = '{$io_info['spl_io_id']}' and io_type = '0' "; // 옵션상품의 재고를 연동해서 뺀다. sql_query($sql);
if($spl_it_info['it_3']=='2'){ $del_stock_su = $ct_info['ct_qty']*$spl_io_info['io_qty_weight']; // 제외할 재고의 재고비중을 곱함 $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty - '$del_stock_su' where it_id = '{$io_info['spl_it_id']}' "; sql_query($sql); set_item_qty_cal($io_info['spl_it_id']); } } } } else { $del_stock_su = $ct_info['ct_qty']; $sql = " update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty - '$del_stock_su' where it_id = '{$ct_info['it_id']}' "; sql_query($sql); } $sql = "update {$g5['g5_shop_cart_table']} set ct_stock_use = 1 where ct_id = '{$ct_info['ct_id']}' "; sql_query($sql); // 주문상품 재고반영 체크
if($default['de_prodset_qty_use']=='1'){ // CS셋트상품 재고 처리 일경우 처리함 $prod_code = ""; foreach($it_prod_map_array as $key => $val){ if($val['it_id']==$ct_info['it_id'] && $val['io_id']==''){ $prod_code = $val['code']; break; } if($val['it_id']==$ct_info['it_id'] && $val['io_id']==$ct_info['io_id']){ $prod_code = $val['code']; break; } }
if($prod_code!=''){ $sql = "select * from {$g5['jegocs_prodset']} where pcode = '{$prod_code}' "; $res_set = sql_query($sql); while($info_set=mysql_fetch_array($res_set)){ foreach($it_prod_map_array as $key => $val){ if($info_set['pscode']==$val['code']){ $v_it_id = $val['it_id']; $v_io_id = trim($val['io_id']); break; } }
$qty_val = $info_set['qnt']*$ct_info['ct_qty']; if($v_io_id==''){ $sql = "update {$g5['g5_shop_item_table']} set it_stock_qty = it_stock_qty - {$qty_val} where it_id = '{$v_it_id}' "; } else { $sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = io_stock_qty - {$qty_val} where it_id = '{$v_it_id}' and io_id = '{$v_io_id}' "; } sql_query($sql); } } } }
// 셋트옵션인지 일반옵션인지 가져와서 옵션 재고별 재고보정 set_item_qty_cal($ct_info['it_id']); } // while //exit; }
// CS상품과 쇼핑몰 상품의 매핑 레코드를 가져온다. function it_prod_map(){ Global $g5, $default;
$it_prod_map_array = array();
if($default['de_prodset_qty_use']=='1'){ // CS셋트상품 재고 처리 일경우 처리함 $sql = "select * from {$g5['jegocs_item_mapping']} where 1=1 and ocode = '1' "; $resx = sql_query($sql); while($infox=mysql_fetch_array($resx)){ $it_prod_map_array[] = $infox; } }
return $it_prod_map_array; }
// 셋트옵션일 경우 본상품의 재고를 기반으로 셋트옵션들 재고 재 산정함 function set_item_qty_cal($it_id){ Global $g5, $default; $sql = "select it_stock_qty, it_3 from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' "; $it_info = sql_fetch($sql);
if($it_info['it_3']=='2'){ $sql = "select * from {$g5['g5_shop_item_option_table']} where it_id = '{$it_id}' and io_type = '0' "; $res2 = sql_query($sql); while($opt_info=mysql_fetch_array($res2)){ $mod_qty = floor($it_info['it_stock_qty']/$opt_info['io_qty_weight']); $sql = "update {$g5['g5_shop_item_option_table']} set io_stock_qty = '{$mod_qty}' where it_id = '{$opt_info['it_id']}' and io_id = '{$opt_info['io_id']}' and io_type = '0' "; sql_query($sql); } } }
// 포인트와 주문쿠폰의 금액을 상품가격별로 나눈다. function set_point_order_coupon_divide($od_id){ Global $g5, $default;
$sql = "select * from {$g5['g5_shop_order_table']} where od_id = '{$od_id}' "; $od_info =sql_fetch($sql); $od_receipt_point = $od_info['od_receipt_point']; $od_coupon = $od_info['od_coupon'];
$sql = "select od_id, ct_id,ct_price,ct_qty from {$g5['g5_shop_cart_table']} where od_id = '{$od_id}' "; $res =sql_query($sql); $sum_ct_price = 0; while($ct_info=mysql_fetch_array($res)){ $ct_info['ct_cal_price'] = $ct_info['ct_price']*$ct_info['ct_qty']; $ct_array[] = $ct_info; $sum_ct_price = $sum_ct_price + $ct_info['ct_cal_price']; }
$ct_max = 0; // 가장 큰 판매가를 저장함 $rp_sum = 0; $oc_sum = 0; for($i=0;$i<count($ct_array);$i++){ _pr($ct_array); $ct_info = $ct_array[$i]; $v_per = $ct_info['ct_cal_price']/$sum_ct_price*100; $v_receipt_point = round($od_receipt_point*$v_per/100); // 사용 포인트 분배 $v_od_coupon = round($od_coupon*$v_per/100); // 주문쿠폰 분배
$ct_array[$i]['div_receipt_point'] = $v_receipt_point; // 해당 카트에 포인트 분배값 저장 $ct_array[$i]['div_od_coupon'] = $v_od_coupon; // 해당 카트에 쿠폰 분배값 저장 $rp_sum = $rp_sum + $v_receipt_point; $oc_sum = $oc_sum + $v_od_coupon; if($ct_max<$ct_info['ct_cal_price']){ // 가장 큰판매가 저장 (차후 보정용) $ct_max = $ct_info['ct_cal_price']; } }
$rp_ch = $od_receipt_point - $rp_sum; // 기존의 포인트와 분배된 합계의 포인트의 차이를 계산함 $oc_ch = $od_coupon - $oc_sum; // 기존의 포인트와 분배된 합계의 포인트의 차이를 계산함 for($i=0;$i<count($ct_array);$i++){ if($ct_array[$i]['ct_cal_price']==$ct_max){ // 가장 크게 분배된 장바구니에서 분배된 차이를 보정해줌 $ct_array[$i]['ct_cal_price'] = $ct_array[$i]['ct_cal_price'] + $rp_ch; } } for($i=0;$i<count($ct_array);$i++){ // 상품별로 분배된 값을 저장함 $sql = "update {$g5['g5_shop_cart_table']} set ct_od_coupon_div = '{$ct_array[$i]['div_od_coupon']}', ct_od_point_div = '{$ct_array[$i]['div_receipt_point']}' where ct_id = '{$ct_array[$i]['ct_id']}' "; sql_query($sql); //_pr($sql); }
}
// 추가옵션 가격 연동일 경우 해당 상품 및 옵션들 체크해서 해당상품이 추가상품으로 있을 경우 가격을 연동처리함 function add_option_price_ch($it_id){ Global $g5, $default;
if($default['de_spl_price_ch']=='1'){ // 설정에서 사용시만 처리됨 $sql = "select * from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' "; $it = sql_fetch($sql);
// 단일 상품의 경우 상품 가격 업데이트 $sql = "update {$g5['g5_shop_item_option_table']} set io_price = '{$it['it_price']}', io_buyprice = '{$it['it_buyprice']}' where spl_it_id = '{$it_id}' and spl_io_id = '' "; //_pr($sql); sql_query($sql);
$sql = "select * from {$g5['g5_shop_item_option_table']} where it_id = '{$it_id}' and io_type = '0' "; $resx = sql_query($sql); while($infox=mysql_fetch_array($resx)){ $io_price = $it['it_price']+$infox['io_price']; $io_buyprice = $it['it_buyprice']+$infox['io_buyprice']; $sql = "update {$g5['g5_shop_item_option_table']} set io_price = '{$io_price}', io_buyprice = '{$io_buyprice}' where spl_it_id = '{$it_id}' and spl_io_id = '{$infox['io_id']}' "; //_pr($sql); sql_query($sql); } } }
// 오픈마켓 주문상태 변경 function otms_order_status_ch($od_id){ Global $g5, $default;
$sql = "select * from {$g5['g5_shop_order_table']} where od_id = '{$od_id}' "; $od_info = sql_fetch($sql); if(!$od_info){ return; }
$sql = "select otms_OrderNo from {$g5['g5_shop_cart_table']} where od_id = '{$od_id}' "; $ct_info = sql_fetch($sql); if(!$ct_info){ return; }
$sql = "select * from {$g5['otms_ordergoods']} where OrderNo = '{$ct_info['otms_OrderNo']}' "; $oo_info =sql_fetch($sql); if(!$oo_info){ return; }
if($od_info['od_status']=='준비'){ if($oo_info['SiteID']=='au' || $oo_info['SiteID']=='gm'){ otms_order_ready_ch_esm($oo_info); } else if($oo_info['SiteID']=='11'){ otms_order_ready_ch_11st($oo_info); } } else if($od_info['od_status']=='배송'){ if($oo_info['SiteID']=='au' || $oo_info['SiteID']=='gm'){ otms_order_deli_ch_esm($oo_info, $od_info, $ct_info); } else if($oo_info['SiteID']=='11'){ otms_order_deli_ch_11st($oo_info, $od_info, $ct_info); } }
} // 오픈마켓 주문상태 변경 옥션/지마켓 (입금->준비) function otms_order_ready_ch_esm($oo_info){ Global $g5, $default;
$id = trim($default['de_otms_id_esm']); $pw = trim($default['de_otms_pw_esm']);
// 로그인 처리 $loginUrl = "https://www.esmplus.com/Member/SignIn/Authenticate"; $login_data = "Type=E&ReturnUrl=&Id={$id}&Password={$pw}&RememberMe=false"; $cookie_nm = G5_DATA_PATH."/session/esm_cookie.txt";
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_SSLVERSION,1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_nm); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_nm); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch);
//echo "<textarea cols=80 rows=20>"; print_r($result); echo "</textarea>";
$url = "https://www.esmplus.com/Escrow/Order/OrderCheck";
if($oo_info['SiteID']=='au'){ $orderInfo = "{$oo_info['OrderNo']},1,{$oo_info['SellerCustNo']}"; } else { $orderInfo = "{$oo_info['OrderNo']},2,{$oo_info['SellerCustNo']}"; } $login_data = "mID={$oo_info['MasterId']}&orderInfo=".urlencode($orderInfo);
curl_setopt ($ch, CURLOPT_URL,$url); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
$res = json_decode($result);
return $res; //_pr($res);
} // 오픈마켓 주문상태 변경 11번가 (입금->준비) function otms_order_ready_ch_11st($oo_info){ Global $g5, $default;
$id = trim($g5['otms_11st_id']); $pw = trim($g5['otms_11st_pw']); $priority = trim($g5['otms_11st_priority']); $ktb_agent = trim($g5['otms_11st_ktb_agent']);
// 로그인 처리 $loginUrl = "https://login.soffice.11st.co.kr/login/Login.page?returnURL=http%3A%2F%2Fsoffice.11st.co.kr%2FIndex.tmall"; $login_data = ""; $cookie_nm = G5_DATA_PATH."/session/st11_cookie.txt";
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_SSLVERSION,1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_nm); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_nm); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch);
// 로그인 정보이용 로그인함 RSA 암호화된 id/pw 필요함 암호화는 이 페이지 콜하기전 JS로 암호화함 $loginUrl = "https://login.soffice.11st.co.kr/login/LoginOk.tmall"; $login_data = "encryptedLoginName={$id}&encryptedPassWord={$pw}&priority={$priority}&ktb_agent={$ktb_agent}&authMethod=login&returnURL=http%3A%2F%2Fsoffice.11st.co.kr%2FIndex.tmall&loginName=&passWord="; //_pr($login_data);
curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
$sdate = date("Y/m/d",time()-(60*60*24*30)); $edate = date("Y/m/d",time()); $od_no = substr($oo_info['OrderNo'],0,15); $od_no_seq = substr($oo_info['OrderNo'],15,1);
$RcverInfoPacking = explode("^",$oo_info['RcverInfoPacking']);
$url = "https://soffice.11st.co.kr/escrow/OrderCancelManage.tmall?method=setOrderConfirmProcesss"; $data_11st = "[{\"ordNo\":\"{$od_no}\",\"ordPrdSeq\":\"{$od_no_seq}\",\"addPrdYn\":\"{$RcverInfoPacking[1]}\",\"addPrdNo\":\"{$RcverInfoPacking[0]}\",\"isAbrdSellerYn\":\"\",\"dlvNo\":\"{$oo_info['TransNo']}\"}]"; //_pr($data_11st); //$login_data = "data=%5B%7B%22ordNo%22%3A%22201511061940570%22%2C%22ordPrdSeq%22%3A%221%22%2C%22addPrdYn%22%3A%22N%22%2C%22addPrdNo%22%3A%220%22%2C%22isAbrdSellerYn%22%3A%22%22%2C%22dlvNo%22%3A%22512116890%22%7D%5D&chkPrdNoList="; $login_data = "data=".urlencode($data_11st)."&chkPrdNoList=";
//_pr($login_data);
curl_setopt ($ch, CURLOPT_URL,$url); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
$result = iconv("EUCKR","UTF-8",$result); $res = json_decode($result);
//_pr($res);
//echo "<textarea cols=80 rows=20>"; print_r($result); echo "</textarea>"; } // 오픈마켓 주문상태 변경 옥션/지마켓 (준비->배송) function otms_order_deli_ch_esm($oo_info, $od_info, $ct_info){ Global $g5, $default, $deli_au_code, $deli_gm_code, $deli_11_code;
$deli_comp = $od_info['od_delivery_company']; $deli_no = $od_info['od_invoice'];
$deli_code = ""; if($oo_info['SiteID']=='au'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ GLS택배'; } foreach($deli_au_code as $key => $val){ if($deli_comp==$val){ $deli_code = $key; } }
} else if($oo_info['SiteID']=='gm'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ택배'; } foreach($deli_gm_code as $key => $val){ if($deli_comp==$val){ $deli_code = $key; } } } else if($oo_info['SiteID']=='11'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ대한통운'; } $flag = 0; foreach($deli_11_code as $key => $val){ if($deli_comp==$val){ $deli_code = $val; $flag = 1; } } if($flag==0){ $deli_code = "기타"; } }
if($oo_info['SiteID']=='au' || $oo_info['SiteID']=='gm'){ // 옥션 지마켓일경우 처리 if($deli_code!=''){ // 여러개송장 업데이트시엔 ^ 구분자로 여러개 처리 $deliveryInfo = "{$oo_info['OrderNo']},{$deli_code},{$deli_comp},{$deli_no}"; $deli_param = "mID={$oo_info['MasterId']}&deliveryInfo=".urlencode($deliveryInfo); } else { echo "택배업체 코드 없음"; exit; }
$id = trim($default['de_otms_id_esm']); $pw = trim($default['de_otms_pw_esm']);
// 로그인 처리 $loginUrl = "https://www.esmplus.com/Member/SignIn/Authenticate"; $login_data = "Type=E&ReturnUrl=&Id={$id}&Password={$pw}&RememberMe=false"; $cookie_nm = G5_DATA_PATH."/session/esm_cookie.txt";
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_SSLVERSION,1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_nm); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_nm); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch);
$url = "http://www.esmplus.com/Escrow/Order/ReceiptCheck?menuCode=TDM104";
curl_setopt ($ch, CURLOPT_URL,$url); //접속할 URL 주소 $result = curl_exec ($ch);
$MasterId = get_esm_MasterId($result); // 옥션/지마켓 MasterId 가져오기
$url = "https://www.esmplus.com/Escrow/Delivery/SetDoShippingGeneral"; $login_data = $deli_param; _pr($deli_param);
curl_setopt ($ch, CURLOPT_URL,$url); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch); $res = json_decode($result);
if($res->success=='1'){ echo $res->message; } else { echo "이미 배송중처리되었거나 아직 발송처리준비 상태의 주문이 아닙니다."; }
} } // 오픈마켓 주문상태 변경 11번가 (준비->배송) function otms_order_deli_ch_11st($oo_info, $od_info, $ct_info){ //_pr($oo_info); exit; Global $g5, $default, $deli_au_code, $deli_gm_code, $deli_11_code;
$deli_comp = $od_info['od_delivery_company']; $deli_no = $od_info['od_invoice'];
$deli_code = ""; if($oo_info['SiteID']=='au'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ GLS택배'; } foreach($deli_au_code as $key => $val){ if($deli_comp==$val){ $deli_code = $key; } }
} else if($oo_info['SiteID']=='gm'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ택배'; } foreach($deli_gm_code as $key => $val){ if($deli_comp==$val){ $deli_code = $key; } } } else if($oo_info['SiteID']=='11'){ if(substr($deli_comp,0,2)=='CJ'){ $deli_comp = 'CJ대한통운'; } $flag = 0; foreach($deli_11_code as $key => $val){ if($deli_comp==$val){ $deli_code = $val; $flag = 1; } } if($flag==0){ $deli_code = "기타"; } }
$id = trim($g5['otms_11st_id']); $pw = trim($g5['otms_11st_pw']); $priority = trim($g5['otms_11st_priority']); $ktb_agent = trim($g5['otms_11st_ktb_agent']);
if($oo_info['SiteID']=='11'){ // 11번가 일경우 처리 // 로그인 처리 $loginUrl = "https://login.soffice.11st.co.kr/login/Login.page?returnURL=http%3A%2F%2Fsoffice.11st.co.kr%2FIndex.tmall"; $login_data = ""; $cookie_nm = G5_DATA_PATH."/session/st11_cookie.txt";
$ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_SSLVERSION,1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_nm); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_nm); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); curl_setopt ($ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch);
// 로그인 정보이용 로그인함 RSA 암호화된 id/pw 필요함 암호화는 이 페이지 콜하기전 JS로 암호화함 $loginUrl = "https://login.soffice.11st.co.kr/login/LoginOk.tmall"; $login_data = "encryptedLoginName={$id}&encryptedPassWord={$pw}&priority={$priority}&ktb_agent={$ktb_agent}&authMethod=login&returnURL=http%3A%2F%2Fsoffice.11st.co.kr%2FIndex.tmall&loginName=&passWord="; //_pr($login_data);
curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
$loginUrl = "http://soffice.11st.co.kr/Index.tmall"; $login_data = "";
curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
//echo "<textarea cols=80 rows=20>"; print_r($result); echo "</textarea>"; exit;
$ord_prd_seq = substr($oo_info['OrderNo'],strlen($oo_info['OrderNo'])-1,strlen($oo_info['OrderNo'])); $DeliveryTypeCode = explode("^",$oo_info['DeliveryTypeCode']); //_pr($DeliveryTypeCode);
// 한글관련 내용은 urlencoding을 2번 해야한다. $DLV_MTHD_CD = urlencode("택배"); $deli_code = urlencode($deli_code);
$data_list = '[{"DLV_NO":"'.$oo_info['TransNo'].'","DLV_MTHD_CD":"'.$DLV_MTHD_CD.'","DLV_ETPRS_NM":"'.$deli_code.'","ORD_NO":"'.$oo_info['SiteOrderNo'].'","ORD_PRD_SEQ":"'.$ord_prd_seq.'","INVC_NO":"'.$deli_no.'","ORD_QTY":"'.$oo_info['OrderQty'].'","PRD_NO":"'.$oo_info['GoodsNo'].'","ADD_PRD_NO":"'.$DeliveryTypeCode[0].'","BSN_DEAL_CLF":"'.$DeliveryTypeCode[1].'","GBL_ITG_MEM_NO":"'.$DeliveryTypeCode[2].'","PART_DLV_YN":"'.$DeliveryTypeCode[3].'"}]';
//_pr($data_list);
$loginUrl = "http://soffice.11st.co.kr/escrow/shipping/getInvoiceList.tmall?method=insertSendFinishProcess"; $login_data = "data=".urlencode($data_list)."&chkPrdNoList=";
//_pr($login_data); exit;
curl_setopt ($ch, CURLOPT_URL,$loginUrl); //접속할 URL 주소 curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec ($ch);
$result = iconv("EUCKR","UTF-8",$result);
$res = json_decode($result);
$msg = $res->msg; $success = $res->success;
echo $msg; } //exit; }
// 11번가 RSA용 마이크로 타임 가져오기용 function microtime_13(){ $v = microtime(); $v1 = explode(" ",$v); $r1 = trim($v1[1]); $r2 = substr($v1[0],2,3); return $r1.$r2; }
$bank_name_list = Array('산업은행','기업은행','국민은행','외환은행','수협','농협','우리은행','제일은행','신한은행','한미(시티)은행','대구은행','부산은행','광주은행','제주은행','전북은행','경남은행','새마을','신협','우체국','하나은행');
function bank_select_function($id_name, $cur_val){ Global $bank_name_list;
$rtn_select = "<select name='$id_name' id='$id_name'>"; foreach($bank_name_list as $key => $val){ if($cur_val==$val) { $selected = "selected"; } else { $selected = ""; } $rtn_select .= "<option value='$val' $selected>$val</option>"; } $rtn_select .= "</select>";
return $rtn_select; }
function is_options($it_id){ global $g5, $default;
$sql = "select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '{$it_id}' "; $info = sql_fetch($sql); if($info['cnt']>0){ return true; } else { return false; } }
// 회원 등급별 단가변동 함수 function mem_group_price_check($price, $ori_it_price=0){ global $g5, $default,$member;
if($member['mg_danga_use']=='1' && trim($member['mg_danga_per'])!='0' ){ if($ori_it_price>0){ // 만약 상품 본가격이 토스되면 본가격+옵션가격에서 등급 처리한다음 본가격의 등급처리된 금액을 빼서 옵션가격을 계산한다. $ori_sum_price = $ori_it_price + $price; $ori_danga_price = round($ori_sum_price * $member['mg_danga_per'] / 100); $danga_it_price = round($ori_it_price * $member['mg_danga_per'] / 100); $price = $ori_danga_price - $danga_it_price; } else { $price = round($price * $member['mg_danga_per'] / 100); } } return $price; }
// 상품유형 대체 텍스트 처리 function listtype_rep_text($type,$text){ global $g5, $default;
if(trim($type)=='') { return $text; }
if(trim($default['de_type'.$type.'_rep_text'])!=''){ $text = $default['de_type'.$type.'_rep_text']; } return $text;
}
// 상품유형 대체 아이콘 처리 function listtype_rep_icon($type,$url){ global $g5, $default;
if(trim($type)=='') { return $url; }
if(file_exists(G5_DATA_PATH."/common/listtype_".$type)){ $url = G5_DATA_URL."/common/listtype_".$type; } return $url;
}
?>
|